babylon.module.d.ts 5.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module "babylonjs/Misc/logger" {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module "babylonjs/Misc/typeStore" {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module "babylonjs/Misc/deepCopier" {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module "babylonjs/Misc/precisionDate" {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module "babylonjs/Misc/devTools" {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module "babylonjs/Misc/webRequest" {
  409. /**
  410. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module "babylonjs/Misc/fileRequest" {
  480. import { Observable } from "babylonjs/Misc/observable";
  481. /**
  482. * File request interface
  483. */
  484. export interface IFileRequest {
  485. /**
  486. * Raised when the request is complete (success or error).
  487. */
  488. onCompleteObservable: Observable<IFileRequest>;
  489. /**
  490. * Aborts the request for a file.
  491. */
  492. abort: () => void;
  493. }
  494. }
  495. declare module "babylonjs/Misc/performanceMonitor" {
  496. /**
  497. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  498. */
  499. export class PerformanceMonitor {
  500. private _enabled;
  501. private _rollingFrameTime;
  502. private _lastFrameTimeMs;
  503. /**
  504. * constructor
  505. * @param frameSampleSize The number of samples required to saturate the sliding window
  506. */
  507. constructor(frameSampleSize?: number);
  508. /**
  509. * Samples current frame
  510. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  511. */
  512. sampleFrame(timeMs?: number): void;
  513. /**
  514. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  515. */
  516. readonly averageFrameTime: number;
  517. /**
  518. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  519. */
  520. readonly averageFrameTimeVariance: number;
  521. /**
  522. * Returns the frame time of the most recent frame
  523. */
  524. readonly instantaneousFrameTime: number;
  525. /**
  526. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  527. */
  528. readonly averageFPS: number;
  529. /**
  530. * Returns the average framerate in frames per second using the most recent frame time
  531. */
  532. readonly instantaneousFPS: number;
  533. /**
  534. * Returns true if enough samples have been taken to completely fill the sliding window
  535. */
  536. readonly isSaturated: boolean;
  537. /**
  538. * Enables contributions to the sliding window sample set
  539. */
  540. enable(): void;
  541. /**
  542. * Disables contributions to the sliding window sample set
  543. * Samples will not be interpolated over the disabled period
  544. */
  545. disable(): void;
  546. /**
  547. * Returns true if sampling is enabled
  548. */
  549. readonly isEnabled: boolean;
  550. /**
  551. * Resets performance monitor
  552. */
  553. reset(): void;
  554. }
  555. /**
  556. * RollingAverage
  557. *
  558. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  559. */
  560. export class RollingAverage {
  561. /**
  562. * Current average
  563. */
  564. average: number;
  565. /**
  566. * Current variance
  567. */
  568. variance: number;
  569. protected _samples: Array<number>;
  570. protected _sampleCount: number;
  571. protected _pos: number;
  572. protected _m2: number;
  573. /**
  574. * constructor
  575. * @param length The number of samples required to saturate the sliding window
  576. */
  577. constructor(length: number);
  578. /**
  579. * Adds a sample to the sample set
  580. * @param v The sample value
  581. */
  582. add(v: number): void;
  583. /**
  584. * Returns previously added values or null if outside of history or outside the sliding window domain
  585. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  586. * @return Value previously recorded with add() or null if outside of range
  587. */
  588. history(i: number): number;
  589. /**
  590. * Returns true if enough samples have been taken to completely fill the sliding window
  591. * @return true if sample-set saturated
  592. */
  593. isSaturated(): boolean;
  594. /**
  595. * Resets the rolling average (equivalent to 0 samples taken so far)
  596. */
  597. reset(): void;
  598. /**
  599. * Wraps a value around the sample range boundaries
  600. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  601. * @return Wrapped position in sample range
  602. */
  603. protected _wrapPosition(i: number): number;
  604. }
  605. }
  606. declare module "babylonjs/Misc/stringDictionary" {
  607. import { Nullable } from "babylonjs/types";
  608. /**
  609. * This class implement a typical dictionary using a string as key and the generic type T as value.
  610. * The underlying implementation relies on an associative array to ensure the best performances.
  611. * The value can be anything including 'null' but except 'undefined'
  612. */
  613. export class StringDictionary<T> {
  614. /**
  615. * This will clear this dictionary and copy the content from the 'source' one.
  616. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  617. * @param source the dictionary to take the content from and copy to this dictionary
  618. */
  619. copyFrom(source: StringDictionary<T>): void;
  620. /**
  621. * Get a value based from its key
  622. * @param key the given key to get the matching value from
  623. * @return the value if found, otherwise undefined is returned
  624. */
  625. get(key: string): T | undefined;
  626. /**
  627. * Get a value from its key or add it if it doesn't exist.
  628. * This method will ensure you that a given key/data will be present in the dictionary.
  629. * @param key the given key to get the matching value from
  630. * @param factory the factory that will create the value if the key is not present in the dictionary.
  631. * The factory will only be invoked if there's no data for the given key.
  632. * @return the value corresponding to the key.
  633. */
  634. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  635. /**
  636. * Get a value from its key if present in the dictionary otherwise add it
  637. * @param key the key to get the value from
  638. * @param val if there's no such key/value pair in the dictionary add it with this value
  639. * @return the value corresponding to the key
  640. */
  641. getOrAdd(key: string, val: T): T;
  642. /**
  643. * Check if there's a given key in the dictionary
  644. * @param key the key to check for
  645. * @return true if the key is present, false otherwise
  646. */
  647. contains(key: string): boolean;
  648. /**
  649. * Add a new key and its corresponding value
  650. * @param key the key to add
  651. * @param value the value corresponding to the key
  652. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  653. */
  654. add(key: string, value: T): boolean;
  655. /**
  656. * Update a specific value associated to a key
  657. * @param key defines the key to use
  658. * @param value defines the value to store
  659. * @returns true if the value was updated (or false if the key was not found)
  660. */
  661. set(key: string, value: T): boolean;
  662. /**
  663. * Get the element of the given key and remove it from the dictionary
  664. * @param key defines the key to search
  665. * @returns the value associated with the key or null if not found
  666. */
  667. getAndRemove(key: string): Nullable<T>;
  668. /**
  669. * Remove a key/value from the dictionary.
  670. * @param key the key to remove
  671. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  672. */
  673. remove(key: string): boolean;
  674. /**
  675. * Clear the whole content of the dictionary
  676. */
  677. clear(): void;
  678. /**
  679. * Gets the current count
  680. */
  681. readonly count: number;
  682. /**
  683. * Execute a callback on each key/val of the dictionary.
  684. * Note that you can remove any element in this dictionary in the callback implementation
  685. * @param callback the callback to execute on a given key/value pair
  686. */
  687. forEach(callback: (key: string, val: T) => void): void;
  688. /**
  689. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  690. * If the callback returns null or undefined the method will iterate to the next key/value pair
  691. * Note that you can remove any element in this dictionary in the callback implementation
  692. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  693. * @returns the first item
  694. */
  695. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  696. private _count;
  697. private _data;
  698. }
  699. }
  700. declare module "babylonjs/Meshes/dataBuffer" {
  701. /**
  702. * Class used to store gfx data (like WebGLBuffer)
  703. */
  704. export class DataBuffer {
  705. /**
  706. * Gets or sets the number of objects referencing this buffer
  707. */
  708. references: number;
  709. /** Gets or sets the size of the underlying buffer */
  710. capacity: number;
  711. /**
  712. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  713. */
  714. is32Bits: boolean;
  715. /**
  716. * Gets the underlying buffer
  717. */
  718. readonly underlyingResource: any;
  719. }
  720. }
  721. declare module "babylonjs/Meshes/buffer" {
  722. import { Nullable, DataArray } from "babylonjs/types";
  723. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  724. /**
  725. * Class used to store data that will be store in GPU memory
  726. */
  727. export class Buffer {
  728. private _engine;
  729. private _buffer;
  730. /** @hidden */
  731. _data: Nullable<DataArray>;
  732. private _updatable;
  733. private _instanced;
  734. /**
  735. * Gets the byte stride.
  736. */
  737. readonly byteStride: number;
  738. /**
  739. * Constructor
  740. * @param engine the engine
  741. * @param data the data to use for this buffer
  742. * @param updatable whether the data is updatable
  743. * @param stride the stride (optional)
  744. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  745. * @param instanced whether the buffer is instanced (optional)
  746. * @param useBytes set to true if the stride in in bytes (optional)
  747. */
  748. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  749. /**
  750. * Create a new VertexBuffer based on the current buffer
  751. * @param kind defines the vertex buffer kind (position, normal, etc.)
  752. * @param offset defines offset in the buffer (0 by default)
  753. * @param size defines the size in floats of attributes (position is 3 for instance)
  754. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  755. * @param instanced defines if the vertex buffer contains indexed data
  756. * @param useBytes defines if the offset and stride are in bytes
  757. * @returns the new vertex buffer
  758. */
  759. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  760. /**
  761. * Gets a boolean indicating if the Buffer is updatable?
  762. * @returns true if the buffer is updatable
  763. */
  764. isUpdatable(): boolean;
  765. /**
  766. * Gets current buffer's data
  767. * @returns a DataArray or null
  768. */
  769. getData(): Nullable<DataArray>;
  770. /**
  771. * Gets underlying native buffer
  772. * @returns underlying native buffer
  773. */
  774. getBuffer(): Nullable<DataBuffer>;
  775. /**
  776. * Gets the stride in float32 units (i.e. byte stride / 4).
  777. * May not be an integer if the byte stride is not divisible by 4.
  778. * DEPRECATED. Use byteStride instead.
  779. * @returns the stride in float32 units
  780. */
  781. getStrideSize(): number;
  782. /**
  783. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  784. * @param data defines the data to store
  785. */
  786. create(data?: Nullable<DataArray>): void;
  787. /** @hidden */
  788. _rebuild(): void;
  789. /**
  790. * Update current buffer data
  791. * @param data defines the data to store
  792. */
  793. update(data: DataArray): void;
  794. /**
  795. * Updates the data directly.
  796. * @param data the new data
  797. * @param offset the new offset
  798. * @param vertexCount the vertex count (optional)
  799. * @param useBytes set to true if the offset is in bytes
  800. */
  801. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  802. /**
  803. * Release all resources
  804. */
  805. dispose(): void;
  806. }
  807. /**
  808. * Specialized buffer used to store vertex data
  809. */
  810. export class VertexBuffer {
  811. /** @hidden */
  812. _buffer: Buffer;
  813. private _kind;
  814. private _size;
  815. private _ownsBuffer;
  816. private _instanced;
  817. private _instanceDivisor;
  818. /**
  819. * The byte type.
  820. */
  821. static readonly BYTE: number;
  822. /**
  823. * The unsigned byte type.
  824. */
  825. static readonly UNSIGNED_BYTE: number;
  826. /**
  827. * The short type.
  828. */
  829. static readonly SHORT: number;
  830. /**
  831. * The unsigned short type.
  832. */
  833. static readonly UNSIGNED_SHORT: number;
  834. /**
  835. * The integer type.
  836. */
  837. static readonly INT: number;
  838. /**
  839. * The unsigned integer type.
  840. */
  841. static readonly UNSIGNED_INT: number;
  842. /**
  843. * The float type.
  844. */
  845. static readonly FLOAT: number;
  846. /**
  847. * Gets or sets the instance divisor when in instanced mode
  848. */
  849. instanceDivisor: number;
  850. /**
  851. * Gets the byte stride.
  852. */
  853. readonly byteStride: number;
  854. /**
  855. * Gets the byte offset.
  856. */
  857. readonly byteOffset: number;
  858. /**
  859. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  860. */
  861. readonly normalized: boolean;
  862. /**
  863. * Gets the data type of each component in the array.
  864. */
  865. readonly type: number;
  866. /**
  867. * Constructor
  868. * @param engine the engine
  869. * @param data the data to use for this vertex buffer
  870. * @param kind the vertex buffer kind
  871. * @param updatable whether the data is updatable
  872. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  873. * @param stride the stride (optional)
  874. * @param instanced whether the buffer is instanced (optional)
  875. * @param offset the offset of the data (optional)
  876. * @param size the number of components (optional)
  877. * @param type the type of the component (optional)
  878. * @param normalized whether the data contains normalized data (optional)
  879. * @param useBytes set to true if stride and offset are in bytes (optional)
  880. */
  881. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  882. /** @hidden */
  883. _rebuild(): void;
  884. /**
  885. * Returns the kind of the VertexBuffer (string)
  886. * @returns a string
  887. */
  888. getKind(): string;
  889. /**
  890. * Gets a boolean indicating if the VertexBuffer is updatable?
  891. * @returns true if the buffer is updatable
  892. */
  893. isUpdatable(): boolean;
  894. /**
  895. * Gets current buffer's data
  896. * @returns a DataArray or null
  897. */
  898. getData(): Nullable<DataArray>;
  899. /**
  900. * Gets underlying native buffer
  901. * @returns underlying native buffer
  902. */
  903. getBuffer(): Nullable<DataBuffer>;
  904. /**
  905. * Gets the stride in float32 units (i.e. byte stride / 4).
  906. * May not be an integer if the byte stride is not divisible by 4.
  907. * DEPRECATED. Use byteStride instead.
  908. * @returns the stride in float32 units
  909. */
  910. getStrideSize(): number;
  911. /**
  912. * Returns the offset as a multiple of the type byte length.
  913. * DEPRECATED. Use byteOffset instead.
  914. * @returns the offset in bytes
  915. */
  916. getOffset(): number;
  917. /**
  918. * Returns the number of components per vertex attribute (integer)
  919. * @returns the size in float
  920. */
  921. getSize(): number;
  922. /**
  923. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  924. * @returns true if this buffer is instanced
  925. */
  926. getIsInstanced(): boolean;
  927. /**
  928. * Returns the instancing divisor, zero for non-instanced (integer).
  929. * @returns a number
  930. */
  931. getInstanceDivisor(): number;
  932. /**
  933. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  934. * @param data defines the data to store
  935. */
  936. create(data?: DataArray): void;
  937. /**
  938. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  939. * This function will create a new buffer if the current one is not updatable
  940. * @param data defines the data to store
  941. */
  942. update(data: DataArray): void;
  943. /**
  944. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  945. * Returns the directly updated WebGLBuffer.
  946. * @param data the new data
  947. * @param offset the new offset
  948. * @param useBytes set to true if the offset is in bytes
  949. */
  950. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  951. /**
  952. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  953. */
  954. dispose(): void;
  955. /**
  956. * Enumerates each value of this vertex buffer as numbers.
  957. * @param count the number of values to enumerate
  958. * @param callback the callback function called for each value
  959. */
  960. forEach(count: number, callback: (value: number, index: number) => void): void;
  961. /**
  962. * Positions
  963. */
  964. static readonly PositionKind: string;
  965. /**
  966. * Normals
  967. */
  968. static readonly NormalKind: string;
  969. /**
  970. * Tangents
  971. */
  972. static readonly TangentKind: string;
  973. /**
  974. * Texture coordinates
  975. */
  976. static readonly UVKind: string;
  977. /**
  978. * Texture coordinates 2
  979. */
  980. static readonly UV2Kind: string;
  981. /**
  982. * Texture coordinates 3
  983. */
  984. static readonly UV3Kind: string;
  985. /**
  986. * Texture coordinates 4
  987. */
  988. static readonly UV4Kind: string;
  989. /**
  990. * Texture coordinates 5
  991. */
  992. static readonly UV5Kind: string;
  993. /**
  994. * Texture coordinates 6
  995. */
  996. static readonly UV6Kind: string;
  997. /**
  998. * Colors
  999. */
  1000. static readonly ColorKind: string;
  1001. /**
  1002. * Matrix indices (for bones)
  1003. */
  1004. static readonly MatricesIndicesKind: string;
  1005. /**
  1006. * Matrix weights (for bones)
  1007. */
  1008. static readonly MatricesWeightsKind: string;
  1009. /**
  1010. * Additional matrix indices (for bones)
  1011. */
  1012. static readonly MatricesIndicesExtraKind: string;
  1013. /**
  1014. * Additional matrix weights (for bones)
  1015. */
  1016. static readonly MatricesWeightsExtraKind: string;
  1017. /**
  1018. * Deduces the stride given a kind.
  1019. * @param kind The kind string to deduce
  1020. * @returns The deduced stride
  1021. */
  1022. static DeduceStride(kind: string): number;
  1023. /**
  1024. * Gets the byte length of the given type.
  1025. * @param type the type
  1026. * @returns the number of bytes
  1027. */
  1028. static GetTypeByteLength(type: number): number;
  1029. /**
  1030. * Enumerates each value of the given parameters as numbers.
  1031. * @param data the data to enumerate
  1032. * @param byteOffset the byte offset of the data
  1033. * @param byteStride the byte stride of the data
  1034. * @param componentCount the number of components per element
  1035. * @param componentType the type of the component
  1036. * @param count the number of values to enumerate
  1037. * @param normalized whether the data is normalized
  1038. * @param callback the callback function called for each value
  1039. */
  1040. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1041. private static _GetFloatValue;
  1042. }
  1043. }
  1044. declare module "babylonjs/Maths/math.scalar" {
  1045. /**
  1046. * Scalar computation library
  1047. */
  1048. export class Scalar {
  1049. /**
  1050. * Two pi constants convenient for computation.
  1051. */
  1052. static TwoPi: number;
  1053. /**
  1054. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1055. * @param a number
  1056. * @param b number
  1057. * @param epsilon (default = 1.401298E-45)
  1058. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1059. */
  1060. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1061. /**
  1062. * Returns a string : the upper case translation of the number i to hexadecimal.
  1063. * @param i number
  1064. * @returns the upper case translation of the number i to hexadecimal.
  1065. */
  1066. static ToHex(i: number): string;
  1067. /**
  1068. * Returns -1 if value is negative and +1 is value is positive.
  1069. * @param value the value
  1070. * @returns the value itself if it's equal to zero.
  1071. */
  1072. static Sign(value: number): number;
  1073. /**
  1074. * Returns the value itself if it's between min and max.
  1075. * Returns min if the value is lower than min.
  1076. * Returns max if the value is greater than max.
  1077. * @param value the value to clmap
  1078. * @param min the min value to clamp to (default: 0)
  1079. * @param max the max value to clamp to (default: 1)
  1080. * @returns the clamped value
  1081. */
  1082. static Clamp(value: number, min?: number, max?: number): number;
  1083. /**
  1084. * the log2 of value.
  1085. * @param value the value to compute log2 of
  1086. * @returns the log2 of value.
  1087. */
  1088. static Log2(value: number): number;
  1089. /**
  1090. * Loops the value, so that it is never larger than length and never smaller than 0.
  1091. *
  1092. * This is similar to the modulo operator but it works with floating point numbers.
  1093. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1094. * With t = 5 and length = 2.5, the result would be 0.0.
  1095. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1096. * @param value the value
  1097. * @param length the length
  1098. * @returns the looped value
  1099. */
  1100. static Repeat(value: number, length: number): number;
  1101. /**
  1102. * Normalize the value between 0.0 and 1.0 using min and max values
  1103. * @param value value to normalize
  1104. * @param min max to normalize between
  1105. * @param max min to normalize between
  1106. * @returns the normalized value
  1107. */
  1108. static Normalize(value: number, min: number, max: number): number;
  1109. /**
  1110. * Denormalize the value from 0.0 and 1.0 using min and max values
  1111. * @param normalized value to denormalize
  1112. * @param min max to denormalize between
  1113. * @param max min to denormalize between
  1114. * @returns the denormalized value
  1115. */
  1116. static Denormalize(normalized: number, min: number, max: number): number;
  1117. /**
  1118. * Calculates the shortest difference between two given angles given in degrees.
  1119. * @param current current angle in degrees
  1120. * @param target target angle in degrees
  1121. * @returns the delta
  1122. */
  1123. static DeltaAngle(current: number, target: number): number;
  1124. /**
  1125. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1126. * @param tx value
  1127. * @param length length
  1128. * @returns The returned value will move back and forth between 0 and length
  1129. */
  1130. static PingPong(tx: number, length: number): number;
  1131. /**
  1132. * Interpolates between min and max with smoothing at the limits.
  1133. *
  1134. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1135. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1136. * @param from from
  1137. * @param to to
  1138. * @param tx value
  1139. * @returns the smooth stepped value
  1140. */
  1141. static SmoothStep(from: number, to: number, tx: number): number;
  1142. /**
  1143. * Moves a value current towards target.
  1144. *
  1145. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1146. * Negative values of maxDelta pushes the value away from target.
  1147. * @param current current value
  1148. * @param target target value
  1149. * @param maxDelta max distance to move
  1150. * @returns resulting value
  1151. */
  1152. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1153. /**
  1154. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1155. *
  1156. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1157. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1158. * @param current current value
  1159. * @param target target value
  1160. * @param maxDelta max distance to move
  1161. * @returns resulting angle
  1162. */
  1163. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1164. /**
  1165. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1166. * @param start start value
  1167. * @param end target value
  1168. * @param amount amount to lerp between
  1169. * @returns the lerped value
  1170. */
  1171. static Lerp(start: number, end: number, amount: number): number;
  1172. /**
  1173. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1174. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1175. * @param start start value
  1176. * @param end target value
  1177. * @param amount amount to lerp between
  1178. * @returns the lerped value
  1179. */
  1180. static LerpAngle(start: number, end: number, amount: number): number;
  1181. /**
  1182. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1183. * @param a start value
  1184. * @param b target value
  1185. * @param value value between a and b
  1186. * @returns the inverseLerp value
  1187. */
  1188. static InverseLerp(a: number, b: number, value: number): number;
  1189. /**
  1190. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1191. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1192. * @param value1 spline value
  1193. * @param tangent1 spline value
  1194. * @param value2 spline value
  1195. * @param tangent2 spline value
  1196. * @param amount input value
  1197. * @returns hermite result
  1198. */
  1199. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1200. /**
  1201. * Returns a random float number between and min and max values
  1202. * @param min min value of random
  1203. * @param max max value of random
  1204. * @returns random value
  1205. */
  1206. static RandomRange(min: number, max: number): number;
  1207. /**
  1208. * This function returns percentage of a number in a given range.
  1209. *
  1210. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1211. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1212. * @param number to convert to percentage
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the percentage
  1216. */
  1217. static RangeToPercent(number: number, min: number, max: number): number;
  1218. /**
  1219. * This function returns number that corresponds to the percentage in a given range.
  1220. *
  1221. * PercentToRange(0.34,0,100) will return 34.
  1222. * @param percent to convert to number
  1223. * @param min min range
  1224. * @param max max range
  1225. * @returns the number
  1226. */
  1227. static PercentToRange(percent: number, min: number, max: number): number;
  1228. /**
  1229. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1230. * @param angle The angle to normalize in radian.
  1231. * @return The converted angle.
  1232. */
  1233. static NormalizeRadians(angle: number): number;
  1234. }
  1235. }
  1236. declare module "babylonjs/Maths/math.constants" {
  1237. /**
  1238. * Constant used to convert a value to gamma space
  1239. * @ignorenaming
  1240. */
  1241. export const ToGammaSpace: number;
  1242. /**
  1243. * Constant used to convert a value to linear space
  1244. * @ignorenaming
  1245. */
  1246. export const ToLinearSpace = 2.2;
  1247. /**
  1248. * Constant used to define the minimal number value in Babylon.js
  1249. * @ignorenaming
  1250. */
  1251. let Epsilon: number;
  1252. export { Epsilon };
  1253. }
  1254. declare module "babylonjs/Maths/math.viewport" {
  1255. /**
  1256. * Class used to represent a viewport on screen
  1257. */
  1258. export class Viewport {
  1259. /** viewport left coordinate */
  1260. x: number;
  1261. /** viewport top coordinate */
  1262. y: number;
  1263. /**viewport width */
  1264. width: number;
  1265. /** viewport height */
  1266. height: number;
  1267. /**
  1268. * Creates a Viewport object located at (x, y) and sized (width, height)
  1269. * @param x defines viewport left coordinate
  1270. * @param y defines viewport top coordinate
  1271. * @param width defines the viewport width
  1272. * @param height defines the viewport height
  1273. */
  1274. constructor(
  1275. /** viewport left coordinate */
  1276. x: number,
  1277. /** viewport top coordinate */
  1278. y: number,
  1279. /**viewport width */
  1280. width: number,
  1281. /** viewport height */
  1282. height: number);
  1283. /**
  1284. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1285. * @param renderWidth defines the rendering width
  1286. * @param renderHeight defines the rendering height
  1287. * @returns a new Viewport
  1288. */
  1289. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1290. /**
  1291. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1292. * @param renderWidth defines the rendering width
  1293. * @param renderHeight defines the rendering height
  1294. * @param ref defines the target viewport
  1295. * @returns the current viewport
  1296. */
  1297. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1298. /**
  1299. * Returns a new Viewport copied from the current one
  1300. * @returns a new Viewport
  1301. */
  1302. clone(): Viewport;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/arrayTools" {
  1306. /**
  1307. * Class containing a set of static utilities functions for arrays.
  1308. */
  1309. export class ArrayTools {
  1310. /**
  1311. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1312. * @param size the number of element to construct and put in the array
  1313. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1314. * @returns a new array filled with new objects
  1315. */
  1316. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1317. }
  1318. }
  1319. declare module "babylonjs/Maths/math.like" {
  1320. import { float, int, DeepImmutable } from "babylonjs/types";
  1321. /**
  1322. * @hidden
  1323. */
  1324. export interface IColor4Like {
  1325. r: float;
  1326. g: float;
  1327. b: float;
  1328. a: float;
  1329. }
  1330. /**
  1331. * @hidden
  1332. */
  1333. export interface IColor3Like {
  1334. r: float;
  1335. g: float;
  1336. b: float;
  1337. }
  1338. /**
  1339. * @hidden
  1340. */
  1341. export interface IVector4Like {
  1342. x: float;
  1343. y: float;
  1344. z: float;
  1345. w: float;
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export interface IVector3Like {
  1351. x: float;
  1352. y: float;
  1353. z: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IVector2Like {
  1359. x: float;
  1360. y: float;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IMatrixLike {
  1366. toArray(): DeepImmutable<Float32Array>;
  1367. updateFlag: int;
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export interface IViewportLike {
  1373. x: float;
  1374. y: float;
  1375. width: float;
  1376. height: float;
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export interface IPlaneLike {
  1382. normal: IVector3Like;
  1383. d: float;
  1384. normalize(): void;
  1385. }
  1386. }
  1387. declare module "babylonjs/Maths/math.vector" {
  1388. import { Viewport } from "babylonjs/Maths/math.viewport";
  1389. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1390. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1391. /**
  1392. * Class representing a vector containing 2 coordinates
  1393. */
  1394. export class Vector2 {
  1395. /** defines the first coordinate */
  1396. x: number;
  1397. /** defines the second coordinate */
  1398. y: number;
  1399. /**
  1400. * Creates a new Vector2 from the given x and y coordinates
  1401. * @param x defines the first coordinate
  1402. * @param y defines the second coordinate
  1403. */
  1404. constructor(
  1405. /** defines the first coordinate */
  1406. x?: number,
  1407. /** defines the second coordinate */
  1408. y?: number);
  1409. /**
  1410. * Gets a string with the Vector2 coordinates
  1411. * @returns a string with the Vector2 coordinates
  1412. */
  1413. toString(): string;
  1414. /**
  1415. * Gets class name
  1416. * @returns the string "Vector2"
  1417. */
  1418. getClassName(): string;
  1419. /**
  1420. * Gets current vector hash code
  1421. * @returns the Vector2 hash code as a number
  1422. */
  1423. getHashCode(): number;
  1424. /**
  1425. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1426. * @param array defines the source array
  1427. * @param index defines the offset in source array
  1428. * @returns the current Vector2
  1429. */
  1430. toArray(array: FloatArray, index?: number): Vector2;
  1431. /**
  1432. * Copy the current vector to an array
  1433. * @returns a new array with 2 elements: the Vector2 coordinates.
  1434. */
  1435. asArray(): number[];
  1436. /**
  1437. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1438. * @param source defines the source Vector2
  1439. * @returns the current updated Vector2
  1440. */
  1441. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1442. /**
  1443. * Sets the Vector2 coordinates with the given floats
  1444. * @param x defines the first coordinate
  1445. * @param y defines the second coordinate
  1446. * @returns the current updated Vector2
  1447. */
  1448. copyFromFloats(x: number, y: number): Vector2;
  1449. /**
  1450. * Sets the Vector2 coordinates with the given floats
  1451. * @param x defines the first coordinate
  1452. * @param y defines the second coordinate
  1453. * @returns the current updated Vector2
  1454. */
  1455. set(x: number, y: number): Vector2;
  1456. /**
  1457. * Add another vector with the current one
  1458. * @param otherVector defines the other vector
  1459. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1460. */
  1461. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1462. /**
  1463. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1464. * @param otherVector defines the other vector
  1465. * @param result defines the target vector
  1466. * @returns the unmodified current Vector2
  1467. */
  1468. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1469. /**
  1470. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1471. * @param otherVector defines the other vector
  1472. * @returns the current updated Vector2
  1473. */
  1474. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1475. /**
  1476. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1477. * @param otherVector defines the other vector
  1478. * @returns a new Vector2
  1479. */
  1480. addVector3(otherVector: Vector3): Vector2;
  1481. /**
  1482. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1483. * @param otherVector defines the other vector
  1484. * @returns a new Vector2
  1485. */
  1486. subtract(otherVector: Vector2): Vector2;
  1487. /**
  1488. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1489. * @param otherVector defines the other vector
  1490. * @param result defines the target vector
  1491. * @returns the unmodified current Vector2
  1492. */
  1493. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1494. /**
  1495. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1496. * @param otherVector defines the other vector
  1497. * @returns the current updated Vector2
  1498. */
  1499. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1500. /**
  1501. * Multiplies in place the current Vector2 coordinates by the given ones
  1502. * @param otherVector defines the other vector
  1503. * @returns the current updated Vector2
  1504. */
  1505. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1506. /**
  1507. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1508. * @param otherVector defines the other vector
  1509. * @returns a new Vector2
  1510. */
  1511. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1512. /**
  1513. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1514. * @param otherVector defines the other vector
  1515. * @param result defines the target vector
  1516. * @returns the unmodified current Vector2
  1517. */
  1518. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1519. /**
  1520. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1521. * @param x defines the first coordinate
  1522. * @param y defines the second coordinate
  1523. * @returns a new Vector2
  1524. */
  1525. multiplyByFloats(x: number, y: number): Vector2;
  1526. /**
  1527. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1528. * @param otherVector defines the other vector
  1529. * @returns a new Vector2
  1530. */
  1531. divide(otherVector: Vector2): Vector2;
  1532. /**
  1533. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1534. * @param otherVector defines the other vector
  1535. * @param result defines the target vector
  1536. * @returns the unmodified current Vector2
  1537. */
  1538. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1539. /**
  1540. * Divides the current Vector2 coordinates by the given ones
  1541. * @param otherVector defines the other vector
  1542. * @returns the current updated Vector2
  1543. */
  1544. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1545. /**
  1546. * Gets a new Vector2 with current Vector2 negated coordinates
  1547. * @returns a new Vector2
  1548. */
  1549. negate(): Vector2;
  1550. /**
  1551. * Multiply the Vector2 coordinates by scale
  1552. * @param scale defines the scaling factor
  1553. * @returns the current updated Vector2
  1554. */
  1555. scaleInPlace(scale: number): Vector2;
  1556. /**
  1557. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1558. * @param scale defines the scaling factor
  1559. * @returns a new Vector2
  1560. */
  1561. scale(scale: number): Vector2;
  1562. /**
  1563. * Scale the current Vector2 values by a factor to a given Vector2
  1564. * @param scale defines the scale factor
  1565. * @param result defines the Vector2 object where to store the result
  1566. * @returns the unmodified current Vector2
  1567. */
  1568. scaleToRef(scale: number, result: Vector2): Vector2;
  1569. /**
  1570. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1571. * @param scale defines the scale factor
  1572. * @param result defines the Vector2 object where to store the result
  1573. * @returns the unmodified current Vector2
  1574. */
  1575. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1576. /**
  1577. * Gets a boolean if two vectors are equals
  1578. * @param otherVector defines the other vector
  1579. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1580. */
  1581. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1582. /**
  1583. * Gets a boolean if two vectors are equals (using an epsilon value)
  1584. * @param otherVector defines the other vector
  1585. * @param epsilon defines the minimal distance to consider equality
  1586. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1587. */
  1588. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. floor(): Vector2;
  1594. /**
  1595. * Gets a new Vector2 from current Vector2 floored values
  1596. * @returns a new Vector2
  1597. */
  1598. fract(): Vector2;
  1599. /**
  1600. * Gets the length of the vector
  1601. * @returns the vector length (float)
  1602. */
  1603. length(): number;
  1604. /**
  1605. * Gets the vector squared length
  1606. * @returns the vector squared length (float)
  1607. */
  1608. lengthSquared(): number;
  1609. /**
  1610. * Normalize the vector
  1611. * @returns the current updated Vector2
  1612. */
  1613. normalize(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 copied from the Vector2
  1616. * @returns a new Vector2
  1617. */
  1618. clone(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(0, 0)
  1621. * @returns a new Vector2
  1622. */
  1623. static Zero(): Vector2;
  1624. /**
  1625. * Gets a new Vector2(1, 1)
  1626. * @returns a new Vector2
  1627. */
  1628. static One(): Vector2;
  1629. /**
  1630. * Gets a new Vector2 set from the given index element of the given array
  1631. * @param array defines the data source
  1632. * @param offset defines the offset in the data source
  1633. * @returns a new Vector2
  1634. */
  1635. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1636. /**
  1637. * Sets "result" from the given index element of the given array
  1638. * @param array defines the data source
  1639. * @param offset defines the offset in the data source
  1640. * @param result defines the target vector
  1641. */
  1642. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1643. /**
  1644. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1645. * @param value1 defines 1st point of control
  1646. * @param value2 defines 2nd point of control
  1647. * @param value3 defines 3rd point of control
  1648. * @param value4 defines 4th point of control
  1649. * @param amount defines the interpolation factor
  1650. * @returns a new Vector2
  1651. */
  1652. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1653. /**
  1654. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1655. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1656. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1657. * @param value defines the value to clamp
  1658. * @param min defines the lower limit
  1659. * @param max defines the upper limit
  1660. * @returns a new Vector2
  1661. */
  1662. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1665. * @param value1 defines the 1st control point
  1666. * @param tangent1 defines the outgoing tangent
  1667. * @param value2 defines the 2nd control point
  1668. * @param tangent2 defines the incoming tangent
  1669. * @param amount defines the interpolation factor
  1670. * @returns a new Vector2
  1671. */
  1672. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1673. /**
  1674. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1675. * @param start defines the start vector
  1676. * @param end defines the end vector
  1677. * @param amount defines the interpolation factor
  1678. * @returns a new Vector2
  1679. */
  1680. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1681. /**
  1682. * Gets the dot product of the vector "left" and the vector "right"
  1683. * @param left defines first vector
  1684. * @param right defines second vector
  1685. * @returns the dot product (float)
  1686. */
  1687. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1688. /**
  1689. * Returns a new Vector2 equal to the normalized given vector
  1690. * @param vector defines the vector to normalize
  1691. * @returns a new Vector2
  1692. */
  1693. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1694. /**
  1695. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1696. * @param left defines 1st vector
  1697. * @param right defines 2nd vector
  1698. * @returns a new Vector2
  1699. */
  1700. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1701. /**
  1702. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1703. * @param left defines 1st vector
  1704. * @param right defines 2nd vector
  1705. * @returns a new Vector2
  1706. */
  1707. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1708. /**
  1709. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1710. * @param vector defines the vector to transform
  1711. * @param transformation defines the matrix to apply
  1712. * @returns a new Vector2
  1713. */
  1714. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1715. /**
  1716. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1717. * @param vector defines the vector to transform
  1718. * @param transformation defines the matrix to apply
  1719. * @param result defines the target vector
  1720. */
  1721. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1722. /**
  1723. * Determines if a given vector is included in a triangle
  1724. * @param p defines the vector to test
  1725. * @param p0 defines 1st triangle point
  1726. * @param p1 defines 2nd triangle point
  1727. * @param p2 defines 3rd triangle point
  1728. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1729. */
  1730. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1731. /**
  1732. * Gets the distance between the vectors "value1" and "value2"
  1733. * @param value1 defines first vector
  1734. * @param value2 defines second vector
  1735. * @returns the distance between vectors
  1736. */
  1737. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1738. /**
  1739. * Returns the squared distance between the vectors "value1" and "value2"
  1740. * @param value1 defines first vector
  1741. * @param value2 defines second vector
  1742. * @returns the squared distance between vectors
  1743. */
  1744. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1745. /**
  1746. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1747. * @param value1 defines first vector
  1748. * @param value2 defines second vector
  1749. * @returns a new Vector2
  1750. */
  1751. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1752. /**
  1753. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1754. * @param p defines the middle point
  1755. * @param segA defines one point of the segment
  1756. * @param segB defines the other point of the segment
  1757. * @returns the shortest distance
  1758. */
  1759. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1760. }
  1761. /**
  1762. * Classed used to store (x,y,z) vector representation
  1763. * A Vector3 is the main object used in 3D geometry
  1764. * It can represent etiher the coordinates of a point the space, either a direction
  1765. * Reminder: js uses a left handed forward facing system
  1766. */
  1767. export class Vector3 {
  1768. /**
  1769. * Defines the first coordinates (on X axis)
  1770. */
  1771. x: number;
  1772. /**
  1773. * Defines the second coordinates (on Y axis)
  1774. */
  1775. y: number;
  1776. /**
  1777. * Defines the third coordinates (on Z axis)
  1778. */
  1779. z: number;
  1780. private static _UpReadOnly;
  1781. private static _ZeroReadOnly;
  1782. /**
  1783. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1784. * @param x defines the first coordinates (on X axis)
  1785. * @param y defines the second coordinates (on Y axis)
  1786. * @param z defines the third coordinates (on Z axis)
  1787. */
  1788. constructor(
  1789. /**
  1790. * Defines the first coordinates (on X axis)
  1791. */
  1792. x?: number,
  1793. /**
  1794. * Defines the second coordinates (on Y axis)
  1795. */
  1796. y?: number,
  1797. /**
  1798. * Defines the third coordinates (on Z axis)
  1799. */
  1800. z?: number);
  1801. /**
  1802. * Creates a string representation of the Vector3
  1803. * @returns a string with the Vector3 coordinates.
  1804. */
  1805. toString(): string;
  1806. /**
  1807. * Gets the class name
  1808. * @returns the string "Vector3"
  1809. */
  1810. getClassName(): string;
  1811. /**
  1812. * Creates the Vector3 hash code
  1813. * @returns a number which tends to be unique between Vector3 instances
  1814. */
  1815. getHashCode(): number;
  1816. /**
  1817. * Creates an array containing three elements : the coordinates of the Vector3
  1818. * @returns a new array of numbers
  1819. */
  1820. asArray(): number[];
  1821. /**
  1822. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1823. * @param array defines the destination array
  1824. * @param index defines the offset in the destination array
  1825. * @returns the current Vector3
  1826. */
  1827. toArray(array: FloatArray, index?: number): Vector3;
  1828. /**
  1829. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1830. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1831. */
  1832. toQuaternion(): Quaternion;
  1833. /**
  1834. * Adds the given vector to the current Vector3
  1835. * @param otherVector defines the second operand
  1836. * @returns the current updated Vector3
  1837. */
  1838. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1839. /**
  1840. * Adds the given coordinates to the current Vector3
  1841. * @param x defines the x coordinate of the operand
  1842. * @param y defines the y coordinate of the operand
  1843. * @param z defines the z coordinate of the operand
  1844. * @returns the current updated Vector3
  1845. */
  1846. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1847. /**
  1848. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1849. * @param otherVector defines the second operand
  1850. * @returns the resulting Vector3
  1851. */
  1852. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1853. /**
  1854. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1855. * @param otherVector defines the second operand
  1856. * @param result defines the Vector3 object where to store the result
  1857. * @returns the current Vector3
  1858. */
  1859. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1860. /**
  1861. * Subtract the given vector from the current Vector3
  1862. * @param otherVector defines the second operand
  1863. * @returns the current updated Vector3
  1864. */
  1865. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1866. /**
  1867. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1868. * @param otherVector defines the second operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1872. /**
  1873. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1874. * @param otherVector defines the second operand
  1875. * @param result defines the Vector3 object where to store the result
  1876. * @returns the current Vector3
  1877. */
  1878. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1879. /**
  1880. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1881. * @param x defines the x coordinate of the operand
  1882. * @param y defines the y coordinate of the operand
  1883. * @param z defines the z coordinate of the operand
  1884. * @returns the resulting Vector3
  1885. */
  1886. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1887. /**
  1888. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1889. * @param x defines the x coordinate of the operand
  1890. * @param y defines the y coordinate of the operand
  1891. * @param z defines the z coordinate of the operand
  1892. * @param result defines the Vector3 object where to store the result
  1893. * @returns the current Vector3
  1894. */
  1895. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1896. /**
  1897. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1898. * @returns a new Vector3
  1899. */
  1900. negate(): Vector3;
  1901. /**
  1902. * Multiplies the Vector3 coordinates by the float "scale"
  1903. * @param scale defines the multiplier factor
  1904. * @returns the current updated Vector3
  1905. */
  1906. scaleInPlace(scale: number): Vector3;
  1907. /**
  1908. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1909. * @param scale defines the multiplier factor
  1910. * @returns a new Vector3
  1911. */
  1912. scale(scale: number): Vector3;
  1913. /**
  1914. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1915. * @param scale defines the multiplier factor
  1916. * @param result defines the Vector3 object where to store the result
  1917. * @returns the current Vector3
  1918. */
  1919. scaleToRef(scale: number, result: Vector3): Vector3;
  1920. /**
  1921. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1922. * @param scale defines the scale factor
  1923. * @param result defines the Vector3 object where to store the result
  1924. * @returns the unmodified current Vector3
  1925. */
  1926. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1927. /**
  1928. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1929. * @param otherVector defines the second operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1933. /**
  1934. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1935. * @param otherVector defines the second operand
  1936. * @param epsilon defines the minimal distance to define values as equals
  1937. * @returns true if both vectors are distant less than epsilon
  1938. */
  1939. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1940. /**
  1941. * Returns true if the current Vector3 coordinates equals the given floats
  1942. * @param x defines the x coordinate of the operand
  1943. * @param y defines the y coordinate of the operand
  1944. * @param z defines the z coordinate of the operand
  1945. * @returns true if both vectors are equals
  1946. */
  1947. equalsToFloats(x: number, y: number, z: number): boolean;
  1948. /**
  1949. * Multiplies the current Vector3 coordinates by the given ones
  1950. * @param otherVector defines the second operand
  1951. * @returns the current updated Vector3
  1952. */
  1953. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1954. /**
  1955. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1956. * @param otherVector defines the second operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1960. /**
  1961. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1962. * @param otherVector defines the second operand
  1963. * @param result defines the Vector3 object where to store the result
  1964. * @returns the current Vector3
  1965. */
  1966. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1967. /**
  1968. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1969. * @param x defines the x coordinate of the operand
  1970. * @param y defines the y coordinate of the operand
  1971. * @param z defines the z coordinate of the operand
  1972. * @returns the new Vector3
  1973. */
  1974. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1975. /**
  1976. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1977. * @param otherVector defines the second operand
  1978. * @returns the new Vector3
  1979. */
  1980. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1981. /**
  1982. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1983. * @param otherVector defines the second operand
  1984. * @param result defines the Vector3 object where to store the result
  1985. * @returns the current Vector3
  1986. */
  1987. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1988. /**
  1989. * Divides the current Vector3 coordinates by the given ones.
  1990. * @param otherVector defines the second operand
  1991. * @returns the current updated Vector3
  1992. */
  1993. divideInPlace(otherVector: Vector3): Vector3;
  1994. /**
  1995. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1996. * @param other defines the second operand
  1997. * @returns the current updated Vector3
  1998. */
  1999. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2000. /**
  2001. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2002. * @param other defines the second operand
  2003. * @returns the current updated Vector3
  2004. */
  2005. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2006. /**
  2007. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2008. * @param x defines the x coordinate of the operand
  2009. * @param y defines the y coordinate of the operand
  2010. * @param z defines the z coordinate of the operand
  2011. * @returns the current updated Vector3
  2012. */
  2013. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2014. /**
  2015. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2016. * @param x defines the x coordinate of the operand
  2017. * @param y defines the y coordinate of the operand
  2018. * @param z defines the z coordinate of the operand
  2019. * @returns the current updated Vector3
  2020. */
  2021. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2022. /**
  2023. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2024. * Check if is non uniform within a certain amount of decimal places to account for this
  2025. * @param epsilon the amount the values can differ
  2026. * @returns if the the vector is non uniform to a certain number of decimal places
  2027. */
  2028. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2029. /**
  2030. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2031. */
  2032. readonly isNonUniform: boolean;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. floor(): Vector3;
  2038. /**
  2039. * Gets a new Vector3 from current Vector3 floored values
  2040. * @returns a new Vector3
  2041. */
  2042. fract(): Vector3;
  2043. /**
  2044. * Gets the length of the Vector3
  2045. * @returns the length of the Vector3
  2046. */
  2047. length(): number;
  2048. /**
  2049. * Gets the squared length of the Vector3
  2050. * @returns squared length of the Vector3
  2051. */
  2052. lengthSquared(): number;
  2053. /**
  2054. * Normalize the current Vector3.
  2055. * Please note that this is an in place operation.
  2056. * @returns the current updated Vector3
  2057. */
  2058. normalize(): Vector3;
  2059. /**
  2060. * Reorders the x y z properties of the vector in place
  2061. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2062. * @returns the current updated vector
  2063. */
  2064. reorderInPlace(order: string): this;
  2065. /**
  2066. * Rotates the vector around 0,0,0 by a quaternion
  2067. * @param quaternion the rotation quaternion
  2068. * @param result vector to store the result
  2069. * @returns the resulting vector
  2070. */
  2071. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2072. /**
  2073. * Rotates a vector around a given point
  2074. * @param quaternion the rotation quaternion
  2075. * @param point the point to rotate around
  2076. * @param result vector to store the result
  2077. * @returns the resulting vector
  2078. */
  2079. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2080. /**
  2081. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2082. * The cross product is then orthogonal to both current and "other"
  2083. * @param other defines the right operand
  2084. * @returns the cross product
  2085. */
  2086. cross(other: Vector3): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 with the given input length.
  2089. * Please note that this is an in place operation.
  2090. * @param len the length of the vector
  2091. * @returns the current updated Vector3
  2092. */
  2093. normalizeFromLength(len: number): Vector3;
  2094. /**
  2095. * Normalize the current Vector3 to a new vector
  2096. * @returns the new Vector3
  2097. */
  2098. normalizeToNew(): Vector3;
  2099. /**
  2100. * Normalize the current Vector3 to the reference
  2101. * @param reference define the Vector3 to update
  2102. * @returns the updated Vector3
  2103. */
  2104. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2105. /**
  2106. * Creates a new Vector3 copied from the current Vector3
  2107. * @returns the new Vector3
  2108. */
  2109. clone(): Vector3;
  2110. /**
  2111. * Copies the given vector coordinates to the current Vector3 ones
  2112. * @param source defines the source Vector3
  2113. * @returns the current updated Vector3
  2114. */
  2115. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2116. /**
  2117. * Copies the given floats to the current Vector3 coordinates
  2118. * @param x defines the x coordinate of the operand
  2119. * @param y defines the y coordinate of the operand
  2120. * @param z defines the z coordinate of the operand
  2121. * @returns the current updated Vector3
  2122. */
  2123. copyFromFloats(x: number, y: number, z: number): Vector3;
  2124. /**
  2125. * Copies the given floats to the current Vector3 coordinates
  2126. * @param x defines the x coordinate of the operand
  2127. * @param y defines the y coordinate of the operand
  2128. * @param z defines the z coordinate of the operand
  2129. * @returns the current updated Vector3
  2130. */
  2131. set(x: number, y: number, z: number): Vector3;
  2132. /**
  2133. * Copies the given float to the current Vector3 coordinates
  2134. * @param v defines the x, y and z coordinates of the operand
  2135. * @returns the current updated Vector3
  2136. */
  2137. setAll(v: number): Vector3;
  2138. /**
  2139. * Get the clip factor between two vectors
  2140. * @param vector0 defines the first operand
  2141. * @param vector1 defines the second operand
  2142. * @param axis defines the axis to use
  2143. * @param size defines the size along the axis
  2144. * @returns the clip factor
  2145. */
  2146. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2147. /**
  2148. * Get angle between two vectors
  2149. * @param vector0 angle between vector0 and vector1
  2150. * @param vector1 angle between vector0 and vector1
  2151. * @param normal direction of the normal
  2152. * @return the angle between vector0 and vector1
  2153. */
  2154. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2155. /**
  2156. * Returns a new Vector3 set from the index "offset" of the given array
  2157. * @param array defines the source array
  2158. * @param offset defines the offset in the source array
  2159. * @returns the new Vector3
  2160. */
  2161. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2162. /**
  2163. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2164. * This function is deprecated. Use FromArray instead
  2165. * @param array defines the source array
  2166. * @param offset defines the offset in the source array
  2167. * @returns the new Vector3
  2168. */
  2169. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2170. /**
  2171. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2172. * @param array defines the source array
  2173. * @param offset defines the offset in the source array
  2174. * @param result defines the Vector3 where to store the result
  2175. */
  2176. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2177. /**
  2178. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2179. * This function is deprecated. Use FromArrayToRef instead.
  2180. * @param array defines the source array
  2181. * @param offset defines the offset in the source array
  2182. * @param result defines the Vector3 where to store the result
  2183. */
  2184. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2185. /**
  2186. * Sets the given vector "result" with the given floats.
  2187. * @param x defines the x coordinate of the source
  2188. * @param y defines the y coordinate of the source
  2189. * @param z defines the z coordinate of the source
  2190. * @param result defines the Vector3 where to store the result
  2191. */
  2192. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2193. /**
  2194. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2195. * @returns a new empty Vector3
  2196. */
  2197. static Zero(): Vector3;
  2198. /**
  2199. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2200. * @returns a new unit Vector3
  2201. */
  2202. static One(): Vector3;
  2203. /**
  2204. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2205. * @returns a new up Vector3
  2206. */
  2207. static Up(): Vector3;
  2208. /**
  2209. * Gets a up Vector3 that must not be updated
  2210. */
  2211. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2212. /**
  2213. * Gets a zero Vector3 that must not be updated
  2214. */
  2215. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2216. /**
  2217. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2218. * @returns a new down Vector3
  2219. */
  2220. static Down(): Vector3;
  2221. /**
  2222. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2223. * @returns a new forward Vector3
  2224. */
  2225. static Forward(): Vector3;
  2226. /**
  2227. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2228. * @returns a new forward Vector3
  2229. */
  2230. static Backward(): Vector3;
  2231. /**
  2232. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2233. * @returns a new right Vector3
  2234. */
  2235. static Right(): Vector3;
  2236. /**
  2237. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2238. * @returns a new left Vector3
  2239. */
  2240. static Left(): Vector3;
  2241. /**
  2242. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2243. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2244. * @param vector defines the Vector3 to transform
  2245. * @param transformation defines the transformation matrix
  2246. * @returns the transformed Vector3
  2247. */
  2248. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2249. /**
  2250. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2251. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2252. * @param vector defines the Vector3 to transform
  2253. * @param transformation defines the transformation matrix
  2254. * @param result defines the Vector3 where to store the result
  2255. */
  2256. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2257. /**
  2258. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2259. * This method computes tranformed coordinates only, not transformed direction vectors
  2260. * @param x define the x coordinate of the source vector
  2261. * @param y define the y coordinate of the source vector
  2262. * @param z define the z coordinate of the source vector
  2263. * @param transformation defines the transformation matrix
  2264. * @param result defines the Vector3 where to store the result
  2265. */
  2266. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2267. /**
  2268. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2269. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2270. * @param vector defines the Vector3 to transform
  2271. * @param transformation defines the transformation matrix
  2272. * @returns the new Vector3
  2273. */
  2274. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2275. /**
  2276. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2277. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2278. * @param vector defines the Vector3 to transform
  2279. * @param transformation defines the transformation matrix
  2280. * @param result defines the Vector3 where to store the result
  2281. */
  2282. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2283. /**
  2284. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2285. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2286. * @param x define the x coordinate of the source vector
  2287. * @param y define the y coordinate of the source vector
  2288. * @param z define the z coordinate of the source vector
  2289. * @param transformation defines the transformation matrix
  2290. * @param result defines the Vector3 where to store the result
  2291. */
  2292. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2293. /**
  2294. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2295. * @param value1 defines the first control point
  2296. * @param value2 defines the second control point
  2297. * @param value3 defines the third control point
  2298. * @param value4 defines the fourth control point
  2299. * @param amount defines the amount on the spline to use
  2300. * @returns the new Vector3
  2301. */
  2302. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2303. /**
  2304. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2305. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2306. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2307. * @param value defines the current value
  2308. * @param min defines the lower range value
  2309. * @param max defines the upper range value
  2310. * @returns the new Vector3
  2311. */
  2312. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2313. /**
  2314. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2315. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2316. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2317. * @param value defines the current value
  2318. * @param min defines the lower range value
  2319. * @param max defines the upper range value
  2320. * @param result defines the Vector3 where to store the result
  2321. */
  2322. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2323. /**
  2324. * Checks if a given vector is inside a specific range
  2325. * @param v defines the vector to test
  2326. * @param min defines the minimum range
  2327. * @param max defines the maximum range
  2328. */
  2329. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2330. /**
  2331. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2332. * @param value1 defines the first control point
  2333. * @param tangent1 defines the first tangent vector
  2334. * @param value2 defines the second control point
  2335. * @param tangent2 defines the second tangent vector
  2336. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2337. * @returns the new Vector3
  2338. */
  2339. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2340. /**
  2341. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2342. * @param start defines the start value
  2343. * @param end defines the end value
  2344. * @param amount max defines amount between both (between 0 and 1)
  2345. * @returns the new Vector3
  2346. */
  2347. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2348. /**
  2349. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2350. * @param start defines the start value
  2351. * @param end defines the end value
  2352. * @param amount max defines amount between both (between 0 and 1)
  2353. * @param result defines the Vector3 where to store the result
  2354. */
  2355. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2356. /**
  2357. * Returns the dot product (float) between the vectors "left" and "right"
  2358. * @param left defines the left operand
  2359. * @param right defines the right operand
  2360. * @returns the dot product
  2361. */
  2362. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2363. /**
  2364. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2365. * The cross product is then orthogonal to both "left" and "right"
  2366. * @param left defines the left operand
  2367. * @param right defines the right operand
  2368. * @returns the cross product
  2369. */
  2370. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Sets the given vector "result" with the cross product of "left" and "right"
  2373. * The cross product is then orthogonal to both "left" and "right"
  2374. * @param left defines the left operand
  2375. * @param right defines the right operand
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2379. /**
  2380. * Returns a new Vector3 as the normalization of the given vector
  2381. * @param vector defines the Vector3 to normalize
  2382. * @returns the new Vector3
  2383. */
  2384. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2385. /**
  2386. * Sets the given vector "result" with the normalization of the given first vector
  2387. * @param vector defines the Vector3 to normalize
  2388. * @param result defines the Vector3 where to store the result
  2389. */
  2390. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2391. /**
  2392. * Project a Vector3 onto screen space
  2393. * @param vector defines the Vector3 to project
  2394. * @param world defines the world matrix to use
  2395. * @param transform defines the transform (view x projection) matrix to use
  2396. * @param viewport defines the screen viewport to use
  2397. * @returns the new Vector3
  2398. */
  2399. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2400. /** @hidden */
  2401. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2402. /**
  2403. * Unproject from screen space to object space
  2404. * @param source defines the screen space Vector3 to use
  2405. * @param viewportWidth defines the current width of the viewport
  2406. * @param viewportHeight defines the current height of the viewport
  2407. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2408. * @param transform defines the transform (view x projection) matrix to use
  2409. * @returns the new Vector3
  2410. */
  2411. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2412. /**
  2413. * Unproject from screen space to object space
  2414. * @param source defines the screen space Vector3 to use
  2415. * @param viewportWidth defines the current width of the viewport
  2416. * @param viewportHeight defines the current height of the viewport
  2417. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2418. * @param view defines the view matrix to use
  2419. * @param projection defines the projection matrix to use
  2420. * @returns the new Vector3
  2421. */
  2422. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2423. /**
  2424. * Unproject from screen space to object space
  2425. * @param source defines the screen space Vector3 to use
  2426. * @param viewportWidth defines the current width of the viewport
  2427. * @param viewportHeight defines the current height of the viewport
  2428. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2429. * @param view defines the view matrix to use
  2430. * @param projection defines the projection matrix to use
  2431. * @param result defines the Vector3 where to store the result
  2432. */
  2433. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2434. /**
  2435. * Unproject from screen space to object space
  2436. * @param sourceX defines the screen space x coordinate to use
  2437. * @param sourceY defines the screen space y coordinate to use
  2438. * @param sourceZ defines the screen space z coordinate to use
  2439. * @param viewportWidth defines the current width of the viewport
  2440. * @param viewportHeight defines the current height of the viewport
  2441. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2442. * @param view defines the view matrix to use
  2443. * @param projection defines the projection matrix to use
  2444. * @param result defines the Vector3 where to store the result
  2445. */
  2446. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2447. /**
  2448. * Gets the minimal coordinate values between two Vector3
  2449. * @param left defines the first operand
  2450. * @param right defines the second operand
  2451. * @returns the new Vector3
  2452. */
  2453. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2454. /**
  2455. * Gets the maximal coordinate values between two Vector3
  2456. * @param left defines the first operand
  2457. * @param right defines the second operand
  2458. * @returns the new Vector3
  2459. */
  2460. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2461. /**
  2462. * Returns the distance between the vectors "value1" and "value2"
  2463. * @param value1 defines the first operand
  2464. * @param value2 defines the second operand
  2465. * @returns the distance
  2466. */
  2467. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2468. /**
  2469. * Returns the squared distance between the vectors "value1" and "value2"
  2470. * @param value1 defines the first operand
  2471. * @param value2 defines the second operand
  2472. * @returns the squared distance
  2473. */
  2474. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2475. /**
  2476. * Returns a new Vector3 located at the center between "value1" and "value2"
  2477. * @param value1 defines the first operand
  2478. * @param value2 defines the second operand
  2479. * @returns the new Vector3
  2480. */
  2481. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2484. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2485. * to something in order to rotate it from its local system to the given target system
  2486. * Note: axis1, axis2 and axis3 are normalized during this operation
  2487. * @param axis1 defines the first axis
  2488. * @param axis2 defines the second axis
  2489. * @param axis3 defines the third axis
  2490. * @returns a new Vector3
  2491. */
  2492. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2493. /**
  2494. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2495. * @param axis1 defines the first axis
  2496. * @param axis2 defines the second axis
  2497. * @param axis3 defines the third axis
  2498. * @param ref defines the Vector3 where to store the result
  2499. */
  2500. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2501. }
  2502. /**
  2503. * Vector4 class created for EulerAngle class conversion to Quaternion
  2504. */
  2505. export class Vector4 {
  2506. /** x value of the vector */
  2507. x: number;
  2508. /** y value of the vector */
  2509. y: number;
  2510. /** z value of the vector */
  2511. z: number;
  2512. /** w value of the vector */
  2513. w: number;
  2514. /**
  2515. * Creates a Vector4 object from the given floats.
  2516. * @param x x value of the vector
  2517. * @param y y value of the vector
  2518. * @param z z value of the vector
  2519. * @param w w value of the vector
  2520. */
  2521. constructor(
  2522. /** x value of the vector */
  2523. x: number,
  2524. /** y value of the vector */
  2525. y: number,
  2526. /** z value of the vector */
  2527. z: number,
  2528. /** w value of the vector */
  2529. w: number);
  2530. /**
  2531. * Returns the string with the Vector4 coordinates.
  2532. * @returns a string containing all the vector values
  2533. */
  2534. toString(): string;
  2535. /**
  2536. * Returns the string "Vector4".
  2537. * @returns "Vector4"
  2538. */
  2539. getClassName(): string;
  2540. /**
  2541. * Returns the Vector4 hash code.
  2542. * @returns a unique hash code
  2543. */
  2544. getHashCode(): number;
  2545. /**
  2546. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2547. * @returns the resulting array
  2548. */
  2549. asArray(): number[];
  2550. /**
  2551. * Populates the given array from the given index with the Vector4 coordinates.
  2552. * @param array array to populate
  2553. * @param index index of the array to start at (default: 0)
  2554. * @returns the Vector4.
  2555. */
  2556. toArray(array: FloatArray, index?: number): Vector4;
  2557. /**
  2558. * Adds the given vector to the current Vector4.
  2559. * @param otherVector the vector to add
  2560. * @returns the updated Vector4.
  2561. */
  2562. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2563. /**
  2564. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2565. * @param otherVector the vector to add
  2566. * @returns the resulting vector
  2567. */
  2568. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2569. /**
  2570. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2571. * @param otherVector the vector to add
  2572. * @param result the vector to store the result
  2573. * @returns the current Vector4.
  2574. */
  2575. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2576. /**
  2577. * Subtract in place the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @returns the updated Vector4.
  2580. */
  2581. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2582. /**
  2583. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2584. * @param otherVector the vector to add
  2585. * @returns the new vector with the result
  2586. */
  2587. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2588. /**
  2589. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2590. * @param otherVector the vector to subtract
  2591. * @param result the vector to store the result
  2592. * @returns the current Vector4.
  2593. */
  2594. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2595. /**
  2596. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. */
  2598. /**
  2599. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2600. * @param x value to subtract
  2601. * @param y value to subtract
  2602. * @param z value to subtract
  2603. * @param w value to subtract
  2604. * @returns new vector containing the result
  2605. */
  2606. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2607. /**
  2608. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2609. * @param x value to subtract
  2610. * @param y value to subtract
  2611. * @param z value to subtract
  2612. * @param w value to subtract
  2613. * @param result the vector to store the result in
  2614. * @returns the current Vector4.
  2615. */
  2616. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2617. /**
  2618. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2619. * @returns a new vector with the negated values
  2620. */
  2621. negate(): Vector4;
  2622. /**
  2623. * Multiplies the current Vector4 coordinates by scale (float).
  2624. * @param scale the number to scale with
  2625. * @returns the updated Vector4.
  2626. */
  2627. scaleInPlace(scale: number): Vector4;
  2628. /**
  2629. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2630. * @param scale the number to scale with
  2631. * @returns a new vector with the result
  2632. */
  2633. scale(scale: number): Vector4;
  2634. /**
  2635. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2636. * @param scale the number to scale with
  2637. * @param result a vector to store the result in
  2638. * @returns the current Vector4.
  2639. */
  2640. scaleToRef(scale: number, result: Vector4): Vector4;
  2641. /**
  2642. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2643. * @param scale defines the scale factor
  2644. * @param result defines the Vector4 object where to store the result
  2645. * @returns the unmodified current Vector4
  2646. */
  2647. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2648. /**
  2649. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2650. * @param otherVector the vector to compare against
  2651. * @returns true if they are equal
  2652. */
  2653. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2654. /**
  2655. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2656. * @param otherVector vector to compare against
  2657. * @param epsilon (Default: very small number)
  2658. * @returns true if they are equal
  2659. */
  2660. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2661. /**
  2662. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2663. * @param x x value to compare against
  2664. * @param y y value to compare against
  2665. * @param z z value to compare against
  2666. * @param w w value to compare against
  2667. * @returns true if equal
  2668. */
  2669. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2670. /**
  2671. * Multiplies in place the current Vector4 by the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @returns the updated Vector4.
  2674. */
  2675. multiplyInPlace(otherVector: Vector4): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2678. * @param otherVector vector to multiple with
  2679. * @returns resulting new vector
  2680. */
  2681. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2682. /**
  2683. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2684. * @param otherVector vector to multiple with
  2685. * @param result vector to store the result
  2686. * @returns the current Vector4.
  2687. */
  2688. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2689. /**
  2690. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2691. * @param x x value multiply with
  2692. * @param y y value multiply with
  2693. * @param z z value multiply with
  2694. * @param w w value multiply with
  2695. * @returns resulting new vector
  2696. */
  2697. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2698. /**
  2699. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2700. * @param otherVector vector to devide with
  2701. * @returns resulting new vector
  2702. */
  2703. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2704. /**
  2705. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2706. * @param otherVector vector to devide with
  2707. * @param result vector to store the result
  2708. * @returns the current Vector4.
  2709. */
  2710. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2711. /**
  2712. * Divides the current Vector3 coordinates by the given ones.
  2713. * @param otherVector vector to devide with
  2714. * @returns the updated Vector3.
  2715. */
  2716. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2719. * @param other defines the second operand
  2720. * @returns the current updated Vector4
  2721. */
  2722. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2723. /**
  2724. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2725. * @param other defines the second operand
  2726. * @returns the current updated Vector4
  2727. */
  2728. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2729. /**
  2730. * Gets a new Vector4 from current Vector4 floored values
  2731. * @returns a new Vector4
  2732. */
  2733. floor(): Vector4;
  2734. /**
  2735. * Gets a new Vector4 from current Vector3 floored values
  2736. * @returns a new Vector4
  2737. */
  2738. fract(): Vector4;
  2739. /**
  2740. * Returns the Vector4 length (float).
  2741. * @returns the length
  2742. */
  2743. length(): number;
  2744. /**
  2745. * Returns the Vector4 squared length (float).
  2746. * @returns the length squared
  2747. */
  2748. lengthSquared(): number;
  2749. /**
  2750. * Normalizes in place the Vector4.
  2751. * @returns the updated Vector4.
  2752. */
  2753. normalize(): Vector4;
  2754. /**
  2755. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2756. * @returns this converted to a new vector3
  2757. */
  2758. toVector3(): Vector3;
  2759. /**
  2760. * Returns a new Vector4 copied from the current one.
  2761. * @returns the new cloned vector
  2762. */
  2763. clone(): Vector4;
  2764. /**
  2765. * Updates the current Vector4 with the given one coordinates.
  2766. * @param source the source vector to copy from
  2767. * @returns the updated Vector4.
  2768. */
  2769. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2770. /**
  2771. * Updates the current Vector4 coordinates with the given floats.
  2772. * @param x float to copy from
  2773. * @param y float to copy from
  2774. * @param z float to copy from
  2775. * @param w float to copy from
  2776. * @returns the updated Vector4.
  2777. */
  2778. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2779. /**
  2780. * Updates the current Vector4 coordinates with the given floats.
  2781. * @param x float to set from
  2782. * @param y float to set from
  2783. * @param z float to set from
  2784. * @param w float to set from
  2785. * @returns the updated Vector4.
  2786. */
  2787. set(x: number, y: number, z: number, w: number): Vector4;
  2788. /**
  2789. * Copies the given float to the current Vector3 coordinates
  2790. * @param v defines the x, y, z and w coordinates of the operand
  2791. * @returns the current updated Vector3
  2792. */
  2793. setAll(v: number): Vector4;
  2794. /**
  2795. * Returns a new Vector4 set from the starting index of the given array.
  2796. * @param array the array to pull values from
  2797. * @param offset the offset into the array to start at
  2798. * @returns the new vector
  2799. */
  2800. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2801. /**
  2802. * Updates the given vector "result" from the starting index of the given array.
  2803. * @param array the array to pull values from
  2804. * @param offset the offset into the array to start at
  2805. * @param result the vector to store the result in
  2806. */
  2807. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2808. /**
  2809. * Updates the given vector "result" from the starting index of the given Float32Array.
  2810. * @param array the array to pull values from
  2811. * @param offset the offset into the array to start at
  2812. * @param result the vector to store the result in
  2813. */
  2814. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2815. /**
  2816. * Updates the given vector "result" coordinates from the given floats.
  2817. * @param x float to set from
  2818. * @param y float to set from
  2819. * @param z float to set from
  2820. * @param w float to set from
  2821. * @param result the vector to the floats in
  2822. */
  2823. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2824. /**
  2825. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2826. * @returns the new vector
  2827. */
  2828. static Zero(): Vector4;
  2829. /**
  2830. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2831. * @returns the new vector
  2832. */
  2833. static One(): Vector4;
  2834. /**
  2835. * Returns a new normalized Vector4 from the given one.
  2836. * @param vector the vector to normalize
  2837. * @returns the vector
  2838. */
  2839. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2840. /**
  2841. * Updates the given vector "result" from the normalization of the given one.
  2842. * @param vector the vector to normalize
  2843. * @param result the vector to store the result in
  2844. */
  2845. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2846. /**
  2847. * Returns a vector with the minimum values from the left and right vectors
  2848. * @param left left vector to minimize
  2849. * @param right right vector to minimize
  2850. * @returns a new vector with the minimum of the left and right vector values
  2851. */
  2852. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2853. /**
  2854. * Returns a vector with the maximum values from the left and right vectors
  2855. * @param left left vector to maximize
  2856. * @param right right vector to maximize
  2857. * @returns a new vector with the maximum of the left and right vector values
  2858. */
  2859. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2860. /**
  2861. * Returns the distance (float) between the vectors "value1" and "value2".
  2862. * @param value1 value to calulate the distance between
  2863. * @param value2 value to calulate the distance between
  2864. * @return the distance between the two vectors
  2865. */
  2866. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2867. /**
  2868. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2869. * @param value1 value to calulate the distance between
  2870. * @param value2 value to calulate the distance between
  2871. * @return the distance between the two vectors squared
  2872. */
  2873. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2874. /**
  2875. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2876. * @param value1 value to calulate the center between
  2877. * @param value2 value to calulate the center between
  2878. * @return the center between the two vectors
  2879. */
  2880. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2881. /**
  2882. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2883. * This methods computes transformed normalized direction vectors only.
  2884. * @param vector the vector to transform
  2885. * @param transformation the transformation matrix to apply
  2886. * @returns the new vector
  2887. */
  2888. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2889. /**
  2890. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2891. * This methods computes transformed normalized direction vectors only.
  2892. * @param vector the vector to transform
  2893. * @param transformation the transformation matrix to apply
  2894. * @param result the vector to store the result in
  2895. */
  2896. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2897. /**
  2898. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2899. * This methods computes transformed normalized direction vectors only.
  2900. * @param x value to transform
  2901. * @param y value to transform
  2902. * @param z value to transform
  2903. * @param w value to transform
  2904. * @param transformation the transformation matrix to apply
  2905. * @param result the vector to store the results in
  2906. */
  2907. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2908. /**
  2909. * Creates a new Vector4 from a Vector3
  2910. * @param source defines the source data
  2911. * @param w defines the 4th component (default is 0)
  2912. * @returns a new Vector4
  2913. */
  2914. static FromVector3(source: Vector3, w?: number): Vector4;
  2915. }
  2916. /**
  2917. * Class used to store quaternion data
  2918. * @see https://en.wikipedia.org/wiki/Quaternion
  2919. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2920. */
  2921. export class Quaternion {
  2922. /** defines the first component (0 by default) */
  2923. x: number;
  2924. /** defines the second component (0 by default) */
  2925. y: number;
  2926. /** defines the third component (0 by default) */
  2927. z: number;
  2928. /** defines the fourth component (1.0 by default) */
  2929. w: number;
  2930. /**
  2931. * Creates a new Quaternion from the given floats
  2932. * @param x defines the first component (0 by default)
  2933. * @param y defines the second component (0 by default)
  2934. * @param z defines the third component (0 by default)
  2935. * @param w defines the fourth component (1.0 by default)
  2936. */
  2937. constructor(
  2938. /** defines the first component (0 by default) */
  2939. x?: number,
  2940. /** defines the second component (0 by default) */
  2941. y?: number,
  2942. /** defines the third component (0 by default) */
  2943. z?: number,
  2944. /** defines the fourth component (1.0 by default) */
  2945. w?: number);
  2946. /**
  2947. * Gets a string representation for the current quaternion
  2948. * @returns a string with the Quaternion coordinates
  2949. */
  2950. toString(): string;
  2951. /**
  2952. * Gets the class name of the quaternion
  2953. * @returns the string "Quaternion"
  2954. */
  2955. getClassName(): string;
  2956. /**
  2957. * Gets a hash code for this quaternion
  2958. * @returns the quaternion hash code
  2959. */
  2960. getHashCode(): number;
  2961. /**
  2962. * Copy the quaternion to an array
  2963. * @returns a new array populated with 4 elements from the quaternion coordinates
  2964. */
  2965. asArray(): number[];
  2966. /**
  2967. * Check if two quaternions are equals
  2968. * @param otherQuaternion defines the second operand
  2969. * @return true if the current quaternion and the given one coordinates are strictly equals
  2970. */
  2971. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2972. /**
  2973. * Clone the current quaternion
  2974. * @returns a new quaternion copied from the current one
  2975. */
  2976. clone(): Quaternion;
  2977. /**
  2978. * Copy a quaternion to the current one
  2979. * @param other defines the other quaternion
  2980. * @returns the updated current quaternion
  2981. */
  2982. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2983. /**
  2984. * Updates the current quaternion with the given float coordinates
  2985. * @param x defines the x coordinate
  2986. * @param y defines the y coordinate
  2987. * @param z defines the z coordinate
  2988. * @param w defines the w coordinate
  2989. * @returns the updated current quaternion
  2990. */
  2991. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2992. /**
  2993. * Updates the current quaternion from the given float coordinates
  2994. * @param x defines the x coordinate
  2995. * @param y defines the y coordinate
  2996. * @param z defines the z coordinate
  2997. * @param w defines the w coordinate
  2998. * @returns the updated current quaternion
  2999. */
  3000. set(x: number, y: number, z: number, w: number): Quaternion;
  3001. /**
  3002. * Adds two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3005. */
  3006. add(other: DeepImmutable<Quaternion>): Quaternion;
  3007. /**
  3008. * Add a quaternion to the current one
  3009. * @param other defines the quaternion to add
  3010. * @returns the current quaternion
  3011. */
  3012. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3013. /**
  3014. * Subtract two quaternions
  3015. * @param other defines the second operand
  3016. * @returns a new quaternion as the subtraction result of the given one from the current one
  3017. */
  3018. subtract(other: Quaternion): Quaternion;
  3019. /**
  3020. * Multiplies the current quaternion by a scale factor
  3021. * @param value defines the scale factor
  3022. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3023. */
  3024. scale(value: number): Quaternion;
  3025. /**
  3026. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3027. * @param scale defines the scale factor
  3028. * @param result defines the Quaternion object where to store the result
  3029. * @returns the unmodified current quaternion
  3030. */
  3031. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3032. /**
  3033. * Multiplies in place the current quaternion by a scale factor
  3034. * @param value defines the scale factor
  3035. * @returns the current modified quaternion
  3036. */
  3037. scaleInPlace(value: number): Quaternion;
  3038. /**
  3039. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3040. * @param scale defines the scale factor
  3041. * @param result defines the Quaternion object where to store the result
  3042. * @returns the unmodified current quaternion
  3043. */
  3044. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3045. /**
  3046. * Multiplies two quaternions
  3047. * @param q1 defines the second operand
  3048. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3049. */
  3050. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3051. /**
  3052. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3053. * @param q1 defines the second operand
  3054. * @param result defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3058. /**
  3059. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3060. * @param q1 defines the second operand
  3061. * @returns the currentupdated quaternion
  3062. */
  3063. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3064. /**
  3065. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3066. * @param ref defines the target quaternion
  3067. * @returns the current quaternion
  3068. */
  3069. conjugateToRef(ref: Quaternion): Quaternion;
  3070. /**
  3071. * Conjugates in place (1-q) the current quaternion
  3072. * @returns the current updated quaternion
  3073. */
  3074. conjugateInPlace(): Quaternion;
  3075. /**
  3076. * Conjugates in place (1-q) the current quaternion
  3077. * @returns a new quaternion
  3078. */
  3079. conjugate(): Quaternion;
  3080. /**
  3081. * Gets length of current quaternion
  3082. * @returns the quaternion length (float)
  3083. */
  3084. length(): number;
  3085. /**
  3086. * Normalize in place the current quaternion
  3087. * @returns the current updated quaternion
  3088. */
  3089. normalize(): Quaternion;
  3090. /**
  3091. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3092. * @param order is a reserved parameter and is ignore for now
  3093. * @returns a new Vector3 containing the Euler angles
  3094. */
  3095. toEulerAngles(order?: string): Vector3;
  3096. /**
  3097. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3098. * @param result defines the vector which will be filled with the Euler angles
  3099. * @param order is a reserved parameter and is ignore for now
  3100. * @returns the current unchanged quaternion
  3101. */
  3102. toEulerAnglesToRef(result: Vector3): Quaternion;
  3103. /**
  3104. * Updates the given rotation matrix with the current quaternion values
  3105. * @param result defines the target matrix
  3106. * @returns the current unchanged quaternion
  3107. */
  3108. toRotationMatrix(result: Matrix): Quaternion;
  3109. /**
  3110. * Updates the current quaternion from the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @returns the current updated quaternion
  3113. */
  3114. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3115. /**
  3116. * Creates a new quaternion from a rotation matrix
  3117. * @param matrix defines the source matrix
  3118. * @returns a new quaternion created from the given rotation matrix values
  3119. */
  3120. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3121. /**
  3122. * Updates the given quaternion with the given rotation matrix values
  3123. * @param matrix defines the source matrix
  3124. * @param result defines the target quaternion
  3125. */
  3126. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3127. /**
  3128. * Returns the dot product (float) between the quaternions "left" and "right"
  3129. * @param left defines the left operand
  3130. * @param right defines the right operand
  3131. * @returns the dot product
  3132. */
  3133. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3134. /**
  3135. * Checks if the two quaternions are close to each other
  3136. * @param quat0 defines the first quaternion to check
  3137. * @param quat1 defines the second quaternion to check
  3138. * @returns true if the two quaternions are close to each other
  3139. */
  3140. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3141. /**
  3142. * Creates an empty quaternion
  3143. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3144. */
  3145. static Zero(): Quaternion;
  3146. /**
  3147. * Inverse a given quaternion
  3148. * @param q defines the source quaternion
  3149. * @returns a new quaternion as the inverted current quaternion
  3150. */
  3151. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3152. /**
  3153. * Inverse a given quaternion
  3154. * @param q defines the source quaternion
  3155. * @param result the quaternion the result will be stored in
  3156. * @returns the result quaternion
  3157. */
  3158. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3159. /**
  3160. * Creates an identity quaternion
  3161. * @returns the identity quaternion
  3162. */
  3163. static Identity(): Quaternion;
  3164. /**
  3165. * Gets a boolean indicating if the given quaternion is identity
  3166. * @param quaternion defines the quaternion to check
  3167. * @returns true if the quaternion is identity
  3168. */
  3169. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3170. /**
  3171. * Creates a quaternion from a rotation around an axis
  3172. * @param axis defines the axis to use
  3173. * @param angle defines the angle to use
  3174. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3175. */
  3176. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3177. /**
  3178. * Creates a rotation around an axis and stores it into the given quaternion
  3179. * @param axis defines the axis to use
  3180. * @param angle defines the angle to use
  3181. * @param result defines the target quaternion
  3182. * @returns the target quaternion
  3183. */
  3184. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3185. /**
  3186. * Creates a new quaternion from data stored into an array
  3187. * @param array defines the data source
  3188. * @param offset defines the offset in the source array where the data starts
  3189. * @returns a new quaternion
  3190. */
  3191. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3192. /**
  3193. * Create a quaternion from Euler rotation angles
  3194. * @param x Pitch
  3195. * @param y Yaw
  3196. * @param z Roll
  3197. * @returns the new Quaternion
  3198. */
  3199. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3200. /**
  3201. * Updates a quaternion from Euler rotation angles
  3202. * @param x Pitch
  3203. * @param y Yaw
  3204. * @param z Roll
  3205. * @param result the quaternion to store the result
  3206. * @returns the updated quaternion
  3207. */
  3208. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3209. /**
  3210. * Create a quaternion from Euler rotation vector
  3211. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3212. * @returns the new Quaternion
  3213. */
  3214. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3215. /**
  3216. * Updates a quaternion from Euler rotation vector
  3217. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3218. * @param result the quaternion to store the result
  3219. * @returns the updated quaternion
  3220. */
  3221. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3222. /**
  3223. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3224. * @param yaw defines the rotation around Y axis
  3225. * @param pitch defines the rotation around X axis
  3226. * @param roll defines the rotation around Z axis
  3227. * @returns the new quaternion
  3228. */
  3229. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3230. /**
  3231. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3232. * @param yaw defines the rotation around Y axis
  3233. * @param pitch defines the rotation around X axis
  3234. * @param roll defines the rotation around Z axis
  3235. * @param result defines the target quaternion
  3236. */
  3237. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3238. /**
  3239. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3240. * @param alpha defines the rotation around first axis
  3241. * @param beta defines the rotation around second axis
  3242. * @param gamma defines the rotation around third axis
  3243. * @returns the new quaternion
  3244. */
  3245. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3246. /**
  3247. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3248. * @param alpha defines the rotation around first axis
  3249. * @param beta defines the rotation around second axis
  3250. * @param gamma defines the rotation around third axis
  3251. * @param result defines the target quaternion
  3252. */
  3253. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3254. /**
  3255. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3256. * @param axis1 defines the first axis
  3257. * @param axis2 defines the second axis
  3258. * @param axis3 defines the third axis
  3259. * @returns the new quaternion
  3260. */
  3261. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3262. /**
  3263. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3264. * @param axis1 defines the first axis
  3265. * @param axis2 defines the second axis
  3266. * @param axis3 defines the third axis
  3267. * @param ref defines the target quaternion
  3268. */
  3269. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3270. /**
  3271. * Interpolates between two quaternions
  3272. * @param left defines first quaternion
  3273. * @param right defines second quaternion
  3274. * @param amount defines the gradient to use
  3275. * @returns the new interpolated quaternion
  3276. */
  3277. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3278. /**
  3279. * Interpolates between two quaternions and stores it into a target quaternion
  3280. * @param left defines first quaternion
  3281. * @param right defines second quaternion
  3282. * @param amount defines the gradient to use
  3283. * @param result defines the target quaternion
  3284. */
  3285. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3286. /**
  3287. * Interpolate between two quaternions using Hermite interpolation
  3288. * @param value1 defines first quaternion
  3289. * @param tangent1 defines the incoming tangent
  3290. * @param value2 defines second quaternion
  3291. * @param tangent2 defines the outgoing tangent
  3292. * @param amount defines the target quaternion
  3293. * @returns the new interpolated quaternion
  3294. */
  3295. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3296. }
  3297. /**
  3298. * Class used to store matrix data (4x4)
  3299. */
  3300. export class Matrix {
  3301. private static _updateFlagSeed;
  3302. private static _identityReadOnly;
  3303. private _isIdentity;
  3304. private _isIdentityDirty;
  3305. private _isIdentity3x2;
  3306. private _isIdentity3x2Dirty;
  3307. /**
  3308. * Gets the update flag of the matrix which is an unique number for the matrix.
  3309. * It will be incremented every time the matrix data change.
  3310. * You can use it to speed the comparison between two versions of the same matrix.
  3311. */
  3312. updateFlag: number;
  3313. private readonly _m;
  3314. /**
  3315. * Gets the internal data of the matrix
  3316. */
  3317. readonly m: DeepImmutable<Float32Array>;
  3318. /** @hidden */
  3319. _markAsUpdated(): void;
  3320. /** @hidden */
  3321. private _updateIdentityStatus;
  3322. /**
  3323. * Creates an empty matrix (filled with zeros)
  3324. */
  3325. constructor();
  3326. /**
  3327. * Check if the current matrix is identity
  3328. * @returns true is the matrix is the identity matrix
  3329. */
  3330. isIdentity(): boolean;
  3331. /**
  3332. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3333. * @returns true is the matrix is the identity matrix
  3334. */
  3335. isIdentityAs3x2(): boolean;
  3336. /**
  3337. * Gets the determinant of the matrix
  3338. * @returns the matrix determinant
  3339. */
  3340. determinant(): number;
  3341. /**
  3342. * Returns the matrix as a Float32Array
  3343. * @returns the matrix underlying array
  3344. */
  3345. toArray(): DeepImmutable<Float32Array>;
  3346. /**
  3347. * Returns the matrix as a Float32Array
  3348. * @returns the matrix underlying array.
  3349. */
  3350. asArray(): DeepImmutable<Float32Array>;
  3351. /**
  3352. * Inverts the current matrix in place
  3353. * @returns the current inverted matrix
  3354. */
  3355. invert(): Matrix;
  3356. /**
  3357. * Sets all the matrix elements to zero
  3358. * @returns the current matrix
  3359. */
  3360. reset(): Matrix;
  3361. /**
  3362. * Adds the current matrix with a second one
  3363. * @param other defines the matrix to add
  3364. * @returns a new matrix as the addition of the current matrix and the given one
  3365. */
  3366. add(other: DeepImmutable<Matrix>): Matrix;
  3367. /**
  3368. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3369. * @param other defines the matrix to add
  3370. * @param result defines the target matrix
  3371. * @returns the current matrix
  3372. */
  3373. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3374. /**
  3375. * Adds in place the given matrix to the current matrix
  3376. * @param other defines the second operand
  3377. * @returns the current updated matrix
  3378. */
  3379. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3380. /**
  3381. * Sets the given matrix to the current inverted Matrix
  3382. * @param other defines the target matrix
  3383. * @returns the unmodified current matrix
  3384. */
  3385. invertToRef(other: Matrix): Matrix;
  3386. /**
  3387. * add a value at the specified position in the current Matrix
  3388. * @param index the index of the value within the matrix. between 0 and 15.
  3389. * @param value the value to be added
  3390. * @returns the current updated matrix
  3391. */
  3392. addAtIndex(index: number, value: number): Matrix;
  3393. /**
  3394. * mutiply the specified position in the current Matrix by a value
  3395. * @param index the index of the value within the matrix. between 0 and 15.
  3396. * @param value the value to be added
  3397. * @returns the current updated matrix
  3398. */
  3399. multiplyAtIndex(index: number, value: number): Matrix;
  3400. /**
  3401. * Inserts the translation vector (using 3 floats) in the current matrix
  3402. * @param x defines the 1st component of the translation
  3403. * @param y defines the 2nd component of the translation
  3404. * @param z defines the 3rd component of the translation
  3405. * @returns the current updated matrix
  3406. */
  3407. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3408. /**
  3409. * Adds the translation vector (using 3 floats) in the current matrix
  3410. * @param x defines the 1st component of the translation
  3411. * @param y defines the 2nd component of the translation
  3412. * @param z defines the 3rd component of the translation
  3413. * @returns the current updated matrix
  3414. */
  3415. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3416. /**
  3417. * Inserts the translation vector in the current matrix
  3418. * @param vector3 defines the translation to insert
  3419. * @returns the current updated matrix
  3420. */
  3421. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3422. /**
  3423. * Gets the translation value of the current matrix
  3424. * @returns a new Vector3 as the extracted translation from the matrix
  3425. */
  3426. getTranslation(): Vector3;
  3427. /**
  3428. * Fill a Vector3 with the extracted translation from the matrix
  3429. * @param result defines the Vector3 where to store the translation
  3430. * @returns the current matrix
  3431. */
  3432. getTranslationToRef(result: Vector3): Matrix;
  3433. /**
  3434. * Remove rotation and scaling part from the matrix
  3435. * @returns the updated matrix
  3436. */
  3437. removeRotationAndScaling(): Matrix;
  3438. /**
  3439. * Multiply two matrices
  3440. * @param other defines the second operand
  3441. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3442. */
  3443. multiply(other: DeepImmutable<Matrix>): Matrix;
  3444. /**
  3445. * Copy the current matrix from the given one
  3446. * @param other defines the source matrix
  3447. * @returns the current updated matrix
  3448. */
  3449. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3450. /**
  3451. * Populates the given array from the starting index with the current matrix values
  3452. * @param array defines the target array
  3453. * @param offset defines the offset in the target array where to start storing values
  3454. * @returns the current matrix
  3455. */
  3456. copyToArray(array: Float32Array, offset?: number): Matrix;
  3457. /**
  3458. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3459. * @param other defines the second operand
  3460. * @param result defines the matrix where to store the multiplication
  3461. * @returns the current matrix
  3462. */
  3463. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3464. /**
  3465. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3466. * @param other defines the second operand
  3467. * @param result defines the array where to store the multiplication
  3468. * @param offset defines the offset in the target array where to start storing values
  3469. * @returns the current matrix
  3470. */
  3471. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3472. /**
  3473. * Check equality between this matrix and a second one
  3474. * @param value defines the second matrix to compare
  3475. * @returns true is the current matrix and the given one values are strictly equal
  3476. */
  3477. equals(value: DeepImmutable<Matrix>): boolean;
  3478. /**
  3479. * Clone the current matrix
  3480. * @returns a new matrix from the current matrix
  3481. */
  3482. clone(): Matrix;
  3483. /**
  3484. * Returns the name of the current matrix class
  3485. * @returns the string "Matrix"
  3486. */
  3487. getClassName(): string;
  3488. /**
  3489. * Gets the hash code of the current matrix
  3490. * @returns the hash code
  3491. */
  3492. getHashCode(): number;
  3493. /**
  3494. * Decomposes the current Matrix into a translation, rotation and scaling components
  3495. * @param scale defines the scale vector3 given as a reference to update
  3496. * @param rotation defines the rotation quaternion given as a reference to update
  3497. * @param translation defines the translation vector3 given as a reference to update
  3498. * @returns true if operation was successful
  3499. */
  3500. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3501. /**
  3502. * Gets specific row of the matrix
  3503. * @param index defines the number of the row to get
  3504. * @returns the index-th row of the current matrix as a new Vector4
  3505. */
  3506. getRow(index: number): Nullable<Vector4>;
  3507. /**
  3508. * Sets the index-th row of the current matrix to the vector4 values
  3509. * @param index defines the number of the row to set
  3510. * @param row defines the target vector4
  3511. * @returns the updated current matrix
  3512. */
  3513. setRow(index: number, row: Vector4): Matrix;
  3514. /**
  3515. * Compute the transpose of the matrix
  3516. * @returns the new transposed matrix
  3517. */
  3518. transpose(): Matrix;
  3519. /**
  3520. * Compute the transpose of the matrix and store it in a given matrix
  3521. * @param result defines the target matrix
  3522. * @returns the current matrix
  3523. */
  3524. transposeToRef(result: Matrix): Matrix;
  3525. /**
  3526. * Sets the index-th row of the current matrix with the given 4 x float values
  3527. * @param index defines the row index
  3528. * @param x defines the x component to set
  3529. * @param y defines the y component to set
  3530. * @param z defines the z component to set
  3531. * @param w defines the w component to set
  3532. * @returns the updated current matrix
  3533. */
  3534. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3535. /**
  3536. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3537. * @param scale defines the scale factor
  3538. * @returns a new matrix
  3539. */
  3540. scale(scale: number): Matrix;
  3541. /**
  3542. * Scale the current matrix values by a factor to a given result matrix
  3543. * @param scale defines the scale factor
  3544. * @param result defines the matrix to store the result
  3545. * @returns the current matrix
  3546. */
  3547. scaleToRef(scale: number, result: Matrix): Matrix;
  3548. /**
  3549. * Scale the current matrix values by a factor and add the result to a given matrix
  3550. * @param scale defines the scale factor
  3551. * @param result defines the Matrix to store the result
  3552. * @returns the current matrix
  3553. */
  3554. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3555. /**
  3556. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3557. * @param ref matrix to store the result
  3558. */
  3559. toNormalMatrix(ref: Matrix): void;
  3560. /**
  3561. * Gets only rotation part of the current matrix
  3562. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3563. */
  3564. getRotationMatrix(): Matrix;
  3565. /**
  3566. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3567. * @param result defines the target matrix to store data to
  3568. * @returns the current matrix
  3569. */
  3570. getRotationMatrixToRef(result: Matrix): Matrix;
  3571. /**
  3572. * Toggles model matrix from being right handed to left handed in place and vice versa
  3573. */
  3574. toggleModelMatrixHandInPlace(): void;
  3575. /**
  3576. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3577. */
  3578. toggleProjectionMatrixHandInPlace(): void;
  3579. /**
  3580. * Creates a matrix from an array
  3581. * @param array defines the source array
  3582. * @param offset defines an offset in the source array
  3583. * @returns a new Matrix set from the starting index of the given array
  3584. */
  3585. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3586. /**
  3587. * Copy the content of an array into a given matrix
  3588. * @param array defines the source array
  3589. * @param offset defines an offset in the source array
  3590. * @param result defines the target matrix
  3591. */
  3592. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3593. /**
  3594. * Stores an array into a matrix after having multiplied each component by a given factor
  3595. * @param array defines the source array
  3596. * @param offset defines the offset in the source array
  3597. * @param scale defines the scaling factor
  3598. * @param result defines the target matrix
  3599. */
  3600. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3601. /**
  3602. * Gets an identity matrix that must not be updated
  3603. */
  3604. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3605. /**
  3606. * Stores a list of values (16) inside a given matrix
  3607. * @param initialM11 defines 1st value of 1st row
  3608. * @param initialM12 defines 2nd value of 1st row
  3609. * @param initialM13 defines 3rd value of 1st row
  3610. * @param initialM14 defines 4th value of 1st row
  3611. * @param initialM21 defines 1st value of 2nd row
  3612. * @param initialM22 defines 2nd value of 2nd row
  3613. * @param initialM23 defines 3rd value of 2nd row
  3614. * @param initialM24 defines 4th value of 2nd row
  3615. * @param initialM31 defines 1st value of 3rd row
  3616. * @param initialM32 defines 2nd value of 3rd row
  3617. * @param initialM33 defines 3rd value of 3rd row
  3618. * @param initialM34 defines 4th value of 3rd row
  3619. * @param initialM41 defines 1st value of 4th row
  3620. * @param initialM42 defines 2nd value of 4th row
  3621. * @param initialM43 defines 3rd value of 4th row
  3622. * @param initialM44 defines 4th value of 4th row
  3623. * @param result defines the target matrix
  3624. */
  3625. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3626. /**
  3627. * Creates new matrix from a list of values (16)
  3628. * @param initialM11 defines 1st value of 1st row
  3629. * @param initialM12 defines 2nd value of 1st row
  3630. * @param initialM13 defines 3rd value of 1st row
  3631. * @param initialM14 defines 4th value of 1st row
  3632. * @param initialM21 defines 1st value of 2nd row
  3633. * @param initialM22 defines 2nd value of 2nd row
  3634. * @param initialM23 defines 3rd value of 2nd row
  3635. * @param initialM24 defines 4th value of 2nd row
  3636. * @param initialM31 defines 1st value of 3rd row
  3637. * @param initialM32 defines 2nd value of 3rd row
  3638. * @param initialM33 defines 3rd value of 3rd row
  3639. * @param initialM34 defines 4th value of 3rd row
  3640. * @param initialM41 defines 1st value of 4th row
  3641. * @param initialM42 defines 2nd value of 4th row
  3642. * @param initialM43 defines 3rd value of 4th row
  3643. * @param initialM44 defines 4th value of 4th row
  3644. * @returns the new matrix
  3645. */
  3646. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3647. /**
  3648. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3649. * @param scale defines the scale vector3
  3650. * @param rotation defines the rotation quaternion
  3651. * @param translation defines the translation vector3
  3652. * @returns a new matrix
  3653. */
  3654. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3655. /**
  3656. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3657. * @param scale defines the scale vector3
  3658. * @param rotation defines the rotation quaternion
  3659. * @param translation defines the translation vector3
  3660. * @param result defines the target matrix
  3661. */
  3662. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3663. /**
  3664. * Creates a new identity matrix
  3665. * @returns a new identity matrix
  3666. */
  3667. static Identity(): Matrix;
  3668. /**
  3669. * Creates a new identity matrix and stores the result in a given matrix
  3670. * @param result defines the target matrix
  3671. */
  3672. static IdentityToRef(result: Matrix): void;
  3673. /**
  3674. * Creates a new zero matrix
  3675. * @returns a new zero matrix
  3676. */
  3677. static Zero(): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis
  3680. * @param angle defines the angle (in radians) to use
  3681. * @return the new matrix
  3682. */
  3683. static RotationX(angle: number): Matrix;
  3684. /**
  3685. * Creates a new matrix as the invert of a given matrix
  3686. * @param source defines the source matrix
  3687. * @returns the new matrix
  3688. */
  3689. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationXToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Y axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationY(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationYToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the Z axis
  3710. * @param angle defines the angle (in radians) to use
  3711. * @return the new matrix
  3712. */
  3713. static RotationZ(angle: number): Matrix;
  3714. /**
  3715. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3716. * @param angle defines the angle (in radians) to use
  3717. * @param result defines the target matrix
  3718. */
  3719. static RotationZToRef(angle: number, result: Matrix): void;
  3720. /**
  3721. * Creates a new rotation matrix for "angle" radians around the given axis
  3722. * @param axis defines the axis to use
  3723. * @param angle defines the angle (in radians) to use
  3724. * @return the new matrix
  3725. */
  3726. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3727. /**
  3728. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3729. * @param axis defines the axis to use
  3730. * @param angle defines the angle (in radians) to use
  3731. * @param result defines the target matrix
  3732. */
  3733. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3734. /**
  3735. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3736. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3737. * @param from defines the vector to align
  3738. * @param to defines the vector to align to
  3739. * @param result defines the target matrix
  3740. */
  3741. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3742. /**
  3743. * Creates a rotation matrix
  3744. * @param yaw defines the yaw angle in radians (Y axis)
  3745. * @param pitch defines the pitch angle in radians (X axis)
  3746. * @param roll defines the roll angle in radians (X axis)
  3747. * @returns the new rotation matrix
  3748. */
  3749. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3750. /**
  3751. * Creates a rotation matrix and stores it in a given matrix
  3752. * @param yaw defines the yaw angle in radians (Y axis)
  3753. * @param pitch defines the pitch angle in radians (X axis)
  3754. * @param roll defines the roll angle in radians (X axis)
  3755. * @param result defines the target matrix
  3756. */
  3757. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3758. /**
  3759. * Creates a scaling matrix
  3760. * @param x defines the scale factor on X axis
  3761. * @param y defines the scale factor on Y axis
  3762. * @param z defines the scale factor on Z axis
  3763. * @returns the new matrix
  3764. */
  3765. static Scaling(x: number, y: number, z: number): Matrix;
  3766. /**
  3767. * Creates a scaling matrix and stores it in a given matrix
  3768. * @param x defines the scale factor on X axis
  3769. * @param y defines the scale factor on Y axis
  3770. * @param z defines the scale factor on Z axis
  3771. * @param result defines the target matrix
  3772. */
  3773. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3774. /**
  3775. * Creates a translation matrix
  3776. * @param x defines the translation on X axis
  3777. * @param y defines the translation on Y axis
  3778. * @param z defines the translationon Z axis
  3779. * @returns the new matrix
  3780. */
  3781. static Translation(x: number, y: number, z: number): Matrix;
  3782. /**
  3783. * Creates a translation matrix and stores it in a given matrix
  3784. * @param x defines the translation on X axis
  3785. * @param y defines the translation on Y axis
  3786. * @param z defines the translationon Z axis
  3787. * @param result defines the target matrix
  3788. */
  3789. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3790. /**
  3791. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3792. * @param startValue defines the start value
  3793. * @param endValue defines the end value
  3794. * @param gradient defines the gradient factor
  3795. * @returns the new matrix
  3796. */
  3797. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3798. /**
  3799. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3800. * @param startValue defines the start value
  3801. * @param endValue defines the end value
  3802. * @param gradient defines the gradient factor
  3803. * @param result defines the Matrix object where to store data
  3804. */
  3805. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3806. /**
  3807. * Builds a new matrix whose values are computed by:
  3808. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3809. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3810. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3811. * @param startValue defines the first matrix
  3812. * @param endValue defines the second matrix
  3813. * @param gradient defines the gradient between the two matrices
  3814. * @returns the new matrix
  3815. */
  3816. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3817. /**
  3818. * Update a matrix to values which are computed by:
  3819. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3820. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3821. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3822. * @param startValue defines the first matrix
  3823. * @param endValue defines the second matrix
  3824. * @param gradient defines the gradient between the two matrices
  3825. * @param result defines the target matrix
  3826. */
  3827. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3828. /**
  3829. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3830. * This function works in left handed mode
  3831. * @param eye defines the final position of the entity
  3832. * @param target defines where the entity should look at
  3833. * @param up defines the up vector for the entity
  3834. * @returns the new matrix
  3835. */
  3836. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3837. /**
  3838. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3839. * This function works in left handed mode
  3840. * @param eye defines the final position of the entity
  3841. * @param target defines where the entity should look at
  3842. * @param up defines the up vector for the entity
  3843. * @param result defines the target matrix
  3844. */
  3845. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3846. /**
  3847. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3848. * This function works in right handed mode
  3849. * @param eye defines the final position of the entity
  3850. * @param target defines where the entity should look at
  3851. * @param up defines the up vector for the entity
  3852. * @returns the new matrix
  3853. */
  3854. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3855. /**
  3856. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3857. * This function works in right handed mode
  3858. * @param eye defines the final position of the entity
  3859. * @param target defines where the entity should look at
  3860. * @param up defines the up vector for the entity
  3861. * @param result defines the target matrix
  3862. */
  3863. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3864. /**
  3865. * Create a left-handed orthographic projection matrix
  3866. * @param width defines the viewport width
  3867. * @param height defines the viewport height
  3868. * @param znear defines the near clip plane
  3869. * @param zfar defines the far clip plane
  3870. * @returns a new matrix as a left-handed orthographic projection matrix
  3871. */
  3872. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3873. /**
  3874. * Store a left-handed orthographic projection to a given matrix
  3875. * @param width defines the viewport width
  3876. * @param height defines the viewport height
  3877. * @param znear defines the near clip plane
  3878. * @param zfar defines the far clip plane
  3879. * @param result defines the target matrix
  3880. */
  3881. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3882. /**
  3883. * Create a left-handed orthographic projection matrix
  3884. * @param left defines the viewport left coordinate
  3885. * @param right defines the viewport right coordinate
  3886. * @param bottom defines the viewport bottom coordinate
  3887. * @param top defines the viewport top coordinate
  3888. * @param znear defines the near clip plane
  3889. * @param zfar defines the far clip plane
  3890. * @returns a new matrix as a left-handed orthographic projection matrix
  3891. */
  3892. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3893. /**
  3894. * Stores a left-handed orthographic projection into a given matrix
  3895. * @param left defines the viewport left coordinate
  3896. * @param right defines the viewport right coordinate
  3897. * @param bottom defines the viewport bottom coordinate
  3898. * @param top defines the viewport top coordinate
  3899. * @param znear defines the near clip plane
  3900. * @param zfar defines the far clip plane
  3901. * @param result defines the target matrix
  3902. */
  3903. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3904. /**
  3905. * Creates a right-handed orthographic projection matrix
  3906. * @param left defines the viewport left coordinate
  3907. * @param right defines the viewport right coordinate
  3908. * @param bottom defines the viewport bottom coordinate
  3909. * @param top defines the viewport top coordinate
  3910. * @param znear defines the near clip plane
  3911. * @param zfar defines the far clip plane
  3912. * @returns a new matrix as a right-handed orthographic projection matrix
  3913. */
  3914. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3915. /**
  3916. * Stores a right-handed orthographic projection into a given matrix
  3917. * @param left defines the viewport left coordinate
  3918. * @param right defines the viewport right coordinate
  3919. * @param bottom defines the viewport bottom coordinate
  3920. * @param top defines the viewport top coordinate
  3921. * @param znear defines the near clip plane
  3922. * @param zfar defines the far clip plane
  3923. * @param result defines the target matrix
  3924. */
  3925. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3926. /**
  3927. * Creates a left-handed perspective projection matrix
  3928. * @param width defines the viewport width
  3929. * @param height defines the viewport height
  3930. * @param znear defines the near clip plane
  3931. * @param zfar defines the far clip plane
  3932. * @returns a new matrix as a left-handed perspective projection matrix
  3933. */
  3934. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3935. /**
  3936. * Creates a left-handed perspective projection matrix
  3937. * @param fov defines the horizontal field of view
  3938. * @param aspect defines the aspect ratio
  3939. * @param znear defines the near clip plane
  3940. * @param zfar defines the far clip plane
  3941. * @returns a new matrix as a left-handed perspective projection matrix
  3942. */
  3943. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3944. /**
  3945. * Stores a left-handed perspective projection into a given matrix
  3946. * @param fov defines the horizontal field of view
  3947. * @param aspect defines the aspect ratio
  3948. * @param znear defines the near clip plane
  3949. * @param zfar defines the far clip plane
  3950. * @param result defines the target matrix
  3951. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3952. */
  3953. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3954. /**
  3955. * Creates a right-handed perspective projection matrix
  3956. * @param fov defines the horizontal field of view
  3957. * @param aspect defines the aspect ratio
  3958. * @param znear defines the near clip plane
  3959. * @param zfar defines the far clip plane
  3960. * @returns a new matrix as a right-handed perspective projection matrix
  3961. */
  3962. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3963. /**
  3964. * Stores a right-handed perspective projection into a given matrix
  3965. * @param fov defines the horizontal field of view
  3966. * @param aspect defines the aspect ratio
  3967. * @param znear defines the near clip plane
  3968. * @param zfar defines the far clip plane
  3969. * @param result defines the target matrix
  3970. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3971. */
  3972. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3973. /**
  3974. * Stores a perspective projection for WebVR info a given matrix
  3975. * @param fov defines the field of view
  3976. * @param znear defines the near clip plane
  3977. * @param zfar defines the far clip plane
  3978. * @param result defines the target matrix
  3979. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3980. */
  3981. static PerspectiveFovWebVRToRef(fov: {
  3982. upDegrees: number;
  3983. downDegrees: number;
  3984. leftDegrees: number;
  3985. rightDegrees: number;
  3986. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3987. /**
  3988. * Computes a complete transformation matrix
  3989. * @param viewport defines the viewport to use
  3990. * @param world defines the world matrix
  3991. * @param view defines the view matrix
  3992. * @param projection defines the projection matrix
  3993. * @param zmin defines the near clip plane
  3994. * @param zmax defines the far clip plane
  3995. * @returns the transformation matrix
  3996. */
  3997. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3998. /**
  3999. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4000. * @param matrix defines the matrix to use
  4001. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4002. */
  4003. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4004. /**
  4005. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4006. * @param matrix defines the matrix to use
  4007. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4008. */
  4009. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4010. /**
  4011. * Compute the transpose of a given matrix
  4012. * @param matrix defines the matrix to transpose
  4013. * @returns the new matrix
  4014. */
  4015. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4016. /**
  4017. * Compute the transpose of a matrix and store it in a target matrix
  4018. * @param matrix defines the matrix to transpose
  4019. * @param result defines the target matrix
  4020. */
  4021. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4022. /**
  4023. * Computes a reflection matrix from a plane
  4024. * @param plane defines the reflection plane
  4025. * @returns a new matrix
  4026. */
  4027. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4028. /**
  4029. * Computes a reflection matrix from a plane
  4030. * @param plane defines the reflection plane
  4031. * @param result defines the target matrix
  4032. */
  4033. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4034. /**
  4035. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4036. * @param xaxis defines the value of the 1st axis
  4037. * @param yaxis defines the value of the 2nd axis
  4038. * @param zaxis defines the value of the 3rd axis
  4039. * @param result defines the target matrix
  4040. */
  4041. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4042. /**
  4043. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4044. * @param quat defines the quaternion to use
  4045. * @param result defines the target matrix
  4046. */
  4047. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4048. }
  4049. /**
  4050. * @hidden
  4051. */
  4052. export class TmpVectors {
  4053. static Vector2: Vector2[];
  4054. static Vector3: Vector3[];
  4055. static Vector4: Vector4[];
  4056. static Quaternion: Quaternion[];
  4057. static Matrix: Matrix[];
  4058. }
  4059. }
  4060. declare module "babylonjs/Engines/constants" {
  4061. /** Defines the cross module used constants to avoid circular dependncies */
  4062. export class Constants {
  4063. /** Defines that alpha blending is disabled */
  4064. static readonly ALPHA_DISABLE: number;
  4065. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4066. static readonly ALPHA_ADD: number;
  4067. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4068. static readonly ALPHA_COMBINE: number;
  4069. /** Defines that alpha blending to DEST - SRC * DEST */
  4070. static readonly ALPHA_SUBTRACT: number;
  4071. /** Defines that alpha blending to SRC * DEST */
  4072. static readonly ALPHA_MULTIPLY: number;
  4073. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4074. static readonly ALPHA_MAXIMIZED: number;
  4075. /** Defines that alpha blending to SRC + DEST */
  4076. static readonly ALPHA_ONEONE: number;
  4077. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4078. static readonly ALPHA_PREMULTIPLIED: number;
  4079. /**
  4080. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4081. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4082. */
  4083. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4084. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4085. static readonly ALPHA_INTERPOLATE: number;
  4086. /**
  4087. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4088. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4089. */
  4090. static readonly ALPHA_SCREENMODE: number;
  4091. /** Defines that the ressource is not delayed*/
  4092. static readonly DELAYLOADSTATE_NONE: number;
  4093. /** Defines that the ressource was successfully delay loaded */
  4094. static readonly DELAYLOADSTATE_LOADED: number;
  4095. /** Defines that the ressource is currently delay loading */
  4096. static readonly DELAYLOADSTATE_LOADING: number;
  4097. /** Defines that the ressource is delayed and has not started loading */
  4098. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4100. static readonly NEVER: number;
  4101. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4102. static readonly ALWAYS: number;
  4103. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4104. static readonly LESS: number;
  4105. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4106. static readonly EQUAL: number;
  4107. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4108. static readonly LEQUAL: number;
  4109. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4110. static readonly GREATER: number;
  4111. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4112. static readonly GEQUAL: number;
  4113. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4114. static readonly NOTEQUAL: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be kept */
  4116. static readonly KEEP: number;
  4117. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4118. static readonly REPLACE: number;
  4119. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4120. static readonly INCR: number;
  4121. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4122. static readonly DECR: number;
  4123. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4124. static readonly INVERT: number;
  4125. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4126. static readonly INCR_WRAP: number;
  4127. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4128. static readonly DECR_WRAP: number;
  4129. /** Texture is not repeating outside of 0..1 UVs */
  4130. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4131. /** Texture is repeating outside of 0..1 UVs */
  4132. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4133. /** Texture is repeating and mirrored */
  4134. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4135. /** ALPHA */
  4136. static readonly TEXTUREFORMAT_ALPHA: number;
  4137. /** LUMINANCE */
  4138. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4139. /** LUMINANCE_ALPHA */
  4140. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4141. /** RGB */
  4142. static readonly TEXTUREFORMAT_RGB: number;
  4143. /** RGBA */
  4144. static readonly TEXTUREFORMAT_RGBA: number;
  4145. /** RED */
  4146. static readonly TEXTUREFORMAT_RED: number;
  4147. /** RED (2nd reference) */
  4148. static readonly TEXTUREFORMAT_R: number;
  4149. /** RG */
  4150. static readonly TEXTUREFORMAT_RG: number;
  4151. /** RED_INTEGER */
  4152. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4153. /** RED_INTEGER (2nd reference) */
  4154. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4155. /** RG_INTEGER */
  4156. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4157. /** RGB_INTEGER */
  4158. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4159. /** RGBA_INTEGER */
  4160. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4161. /** UNSIGNED_BYTE */
  4162. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4163. /** UNSIGNED_BYTE (2nd reference) */
  4164. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4165. /** FLOAT */
  4166. static readonly TEXTURETYPE_FLOAT: number;
  4167. /** HALF_FLOAT */
  4168. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4169. /** BYTE */
  4170. static readonly TEXTURETYPE_BYTE: number;
  4171. /** SHORT */
  4172. static readonly TEXTURETYPE_SHORT: number;
  4173. /** UNSIGNED_SHORT */
  4174. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4175. /** INT */
  4176. static readonly TEXTURETYPE_INT: number;
  4177. /** UNSIGNED_INT */
  4178. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4179. /** UNSIGNED_SHORT_4_4_4_4 */
  4180. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4181. /** UNSIGNED_SHORT_5_5_5_1 */
  4182. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4183. /** UNSIGNED_SHORT_5_6_5 */
  4184. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4185. /** UNSIGNED_INT_2_10_10_10_REV */
  4186. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4187. /** UNSIGNED_INT_24_8 */
  4188. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4189. /** UNSIGNED_INT_10F_11F_11F_REV */
  4190. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4191. /** UNSIGNED_INT_5_9_9_9_REV */
  4192. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4193. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4194. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4195. /** nearest is mag = nearest and min = nearest and mip = linear */
  4196. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4197. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4198. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4199. /** Trilinear is mag = linear and min = linear and mip = linear */
  4200. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4201. /** nearest is mag = nearest and min = nearest and mip = linear */
  4202. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4203. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4204. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4205. /** Trilinear is mag = linear and min = linear and mip = linear */
  4206. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4207. /** mag = nearest and min = nearest and mip = nearest */
  4208. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4209. /** mag = nearest and min = linear and mip = nearest */
  4210. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4211. /** mag = nearest and min = linear and mip = linear */
  4212. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4213. /** mag = nearest and min = linear and mip = none */
  4214. static readonly TEXTURE_NEAREST_LINEAR: number;
  4215. /** mag = nearest and min = nearest and mip = none */
  4216. static readonly TEXTURE_NEAREST_NEAREST: number;
  4217. /** mag = linear and min = nearest and mip = nearest */
  4218. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4219. /** mag = linear and min = nearest and mip = linear */
  4220. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4221. /** mag = linear and min = linear and mip = none */
  4222. static readonly TEXTURE_LINEAR_LINEAR: number;
  4223. /** mag = linear and min = nearest and mip = none */
  4224. static readonly TEXTURE_LINEAR_NEAREST: number;
  4225. /** Explicit coordinates mode */
  4226. static readonly TEXTURE_EXPLICIT_MODE: number;
  4227. /** Spherical coordinates mode */
  4228. static readonly TEXTURE_SPHERICAL_MODE: number;
  4229. /** Planar coordinates mode */
  4230. static readonly TEXTURE_PLANAR_MODE: number;
  4231. /** Cubic coordinates mode */
  4232. static readonly TEXTURE_CUBIC_MODE: number;
  4233. /** Projection coordinates mode */
  4234. static readonly TEXTURE_PROJECTION_MODE: number;
  4235. /** Skybox coordinates mode */
  4236. static readonly TEXTURE_SKYBOX_MODE: number;
  4237. /** Inverse Cubic coordinates mode */
  4238. static readonly TEXTURE_INVCUBIC_MODE: number;
  4239. /** Equirectangular coordinates mode */
  4240. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4241. /** Equirectangular Fixed coordinates mode */
  4242. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4243. /** Equirectangular Fixed Mirrored coordinates mode */
  4244. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4245. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4246. static readonly SCALEMODE_FLOOR: number;
  4247. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4248. static readonly SCALEMODE_NEAREST: number;
  4249. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4250. static readonly SCALEMODE_CEILING: number;
  4251. /**
  4252. * The dirty texture flag value
  4253. */
  4254. static readonly MATERIAL_TextureDirtyFlag: number;
  4255. /**
  4256. * The dirty light flag value
  4257. */
  4258. static readonly MATERIAL_LightDirtyFlag: number;
  4259. /**
  4260. * The dirty fresnel flag value
  4261. */
  4262. static readonly MATERIAL_FresnelDirtyFlag: number;
  4263. /**
  4264. * The dirty attribute flag value
  4265. */
  4266. static readonly MATERIAL_AttributesDirtyFlag: number;
  4267. /**
  4268. * The dirty misc flag value
  4269. */
  4270. static readonly MATERIAL_MiscDirtyFlag: number;
  4271. /**
  4272. * The all dirty flag value
  4273. */
  4274. static readonly MATERIAL_AllDirtyFlag: number;
  4275. /**
  4276. * Returns the triangle fill mode
  4277. */
  4278. static readonly MATERIAL_TriangleFillMode: number;
  4279. /**
  4280. * Returns the wireframe mode
  4281. */
  4282. static readonly MATERIAL_WireFrameFillMode: number;
  4283. /**
  4284. * Returns the point fill mode
  4285. */
  4286. static readonly MATERIAL_PointFillMode: number;
  4287. /**
  4288. * Returns the point list draw mode
  4289. */
  4290. static readonly MATERIAL_PointListDrawMode: number;
  4291. /**
  4292. * Returns the line list draw mode
  4293. */
  4294. static readonly MATERIAL_LineListDrawMode: number;
  4295. /**
  4296. * Returns the line loop draw mode
  4297. */
  4298. static readonly MATERIAL_LineLoopDrawMode: number;
  4299. /**
  4300. * Returns the line strip draw mode
  4301. */
  4302. static readonly MATERIAL_LineStripDrawMode: number;
  4303. /**
  4304. * Returns the triangle strip draw mode
  4305. */
  4306. static readonly MATERIAL_TriangleStripDrawMode: number;
  4307. /**
  4308. * Returns the triangle fan draw mode
  4309. */
  4310. static readonly MATERIAL_TriangleFanDrawMode: number;
  4311. /**
  4312. * Stores the clock-wise side orientation
  4313. */
  4314. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4315. /**
  4316. * Stores the counter clock-wise side orientation
  4317. */
  4318. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4319. /**
  4320. * Nothing
  4321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4322. */
  4323. static readonly ACTION_NothingTrigger: number;
  4324. /**
  4325. * On pick
  4326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4327. */
  4328. static readonly ACTION_OnPickTrigger: number;
  4329. /**
  4330. * On left pick
  4331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4332. */
  4333. static readonly ACTION_OnLeftPickTrigger: number;
  4334. /**
  4335. * On right pick
  4336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4337. */
  4338. static readonly ACTION_OnRightPickTrigger: number;
  4339. /**
  4340. * On center pick
  4341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4342. */
  4343. static readonly ACTION_OnCenterPickTrigger: number;
  4344. /**
  4345. * On pick down
  4346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4347. */
  4348. static readonly ACTION_OnPickDownTrigger: number;
  4349. /**
  4350. * On double pick
  4351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4352. */
  4353. static readonly ACTION_OnDoublePickTrigger: number;
  4354. /**
  4355. * On pick up
  4356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4357. */
  4358. static readonly ACTION_OnPickUpTrigger: number;
  4359. /**
  4360. * On pick out.
  4361. * This trigger will only be raised if you also declared a OnPickDown
  4362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4363. */
  4364. static readonly ACTION_OnPickOutTrigger: number;
  4365. /**
  4366. * On long press
  4367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4368. */
  4369. static readonly ACTION_OnLongPressTrigger: number;
  4370. /**
  4371. * On pointer over
  4372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4373. */
  4374. static readonly ACTION_OnPointerOverTrigger: number;
  4375. /**
  4376. * On pointer out
  4377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4378. */
  4379. static readonly ACTION_OnPointerOutTrigger: number;
  4380. /**
  4381. * On every frame
  4382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4383. */
  4384. static readonly ACTION_OnEveryFrameTrigger: number;
  4385. /**
  4386. * On intersection enter
  4387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4388. */
  4389. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4390. /**
  4391. * On intersection exit
  4392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4393. */
  4394. static readonly ACTION_OnIntersectionExitTrigger: number;
  4395. /**
  4396. * On key down
  4397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4398. */
  4399. static readonly ACTION_OnKeyDownTrigger: number;
  4400. /**
  4401. * On key up
  4402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4403. */
  4404. static readonly ACTION_OnKeyUpTrigger: number;
  4405. /**
  4406. * Billboard mode will only apply to Y axis
  4407. */
  4408. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4409. /**
  4410. * Billboard mode will apply to all axes
  4411. */
  4412. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4413. /**
  4414. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4415. */
  4416. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4417. /**
  4418. * Gets or sets base Assets URL
  4419. */
  4420. static PARTICLES_BaseAssetsUrl: string;
  4421. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4422. * Test order :
  4423. * Is the bounding sphere outside the frustum ?
  4424. * If not, are the bounding box vertices outside the frustum ?
  4425. * It not, then the cullable object is in the frustum.
  4426. */
  4427. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4428. /** Culling strategy : Bounding Sphere Only.
  4429. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4430. * It's also less accurate than the standard because some not visible objects can still be selected.
  4431. * Test : is the bounding sphere outside the frustum ?
  4432. * If not, then the cullable object is in the frustum.
  4433. */
  4434. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4435. /** Culling strategy : Optimistic Inclusion.
  4436. * This in an inclusion test first, then the standard exclusion test.
  4437. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4438. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4439. * Anyway, it's as accurate as the standard strategy.
  4440. * Test :
  4441. * Is the cullable object bounding sphere center in the frustum ?
  4442. * If not, apply the default culling strategy.
  4443. */
  4444. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4445. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4446. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4447. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4448. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4449. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4450. * Test :
  4451. * Is the cullable object bounding sphere center in the frustum ?
  4452. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4453. */
  4454. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4455. /**
  4456. * No logging while loading
  4457. */
  4458. static readonly SCENELOADER_NO_LOGGING: number;
  4459. /**
  4460. * Minimal logging while loading
  4461. */
  4462. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4463. /**
  4464. * Summary logging while loading
  4465. */
  4466. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4467. /**
  4468. * Detailled logging while loading
  4469. */
  4470. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4471. }
  4472. }
  4473. declare module "babylonjs/Engines/IPipelineContext" {
  4474. /**
  4475. * Class used to store and describe the pipeline context associated with an effect
  4476. */
  4477. export interface IPipelineContext {
  4478. /**
  4479. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4480. */
  4481. isAsync: boolean;
  4482. /**
  4483. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4484. */
  4485. isReady: boolean;
  4486. /** @hidden */
  4487. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4488. }
  4489. }
  4490. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4491. /** @hidden */
  4492. export interface IShaderProcessor {
  4493. attributeProcessor?: (attribute: string) => string;
  4494. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4495. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4496. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4497. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4498. lineProcessor?: (line: string, isFragment: boolean) => string;
  4499. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4500. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4501. }
  4502. }
  4503. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4504. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4505. /** @hidden */
  4506. export interface ProcessingOptions {
  4507. defines: string[];
  4508. indexParameters: any;
  4509. isFragment: boolean;
  4510. shouldUseHighPrecisionShader: boolean;
  4511. supportsUniformBuffers: boolean;
  4512. shadersRepository: string;
  4513. includesShadersStore: {
  4514. [key: string]: string;
  4515. };
  4516. processor?: IShaderProcessor;
  4517. version: string;
  4518. platformName: string;
  4519. lookForClosingBracketForUniformBuffer?: boolean;
  4520. }
  4521. }
  4522. declare module "babylonjs/Misc/stringTools" {
  4523. /**
  4524. * Helper to manipulate strings
  4525. */
  4526. export class StringTools {
  4527. /**
  4528. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4529. * @param str Source string
  4530. * @param suffix Suffix to search for in the source string
  4531. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4532. */
  4533. static EndsWith(str: string, suffix: string): boolean;
  4534. /**
  4535. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4536. * @param str Source string
  4537. * @param suffix Suffix to search for in the source string
  4538. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4539. */
  4540. static StartsWith(str: string, suffix: string): boolean;
  4541. }
  4542. }
  4543. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4544. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4545. /** @hidden */
  4546. export class ShaderCodeNode {
  4547. line: string;
  4548. children: ShaderCodeNode[];
  4549. additionalDefineKey?: string;
  4550. additionalDefineValue?: string;
  4551. isValid(preprocessors: {
  4552. [key: string]: string;
  4553. }): boolean;
  4554. process(preprocessors: {
  4555. [key: string]: string;
  4556. }, options: ProcessingOptions): string;
  4557. }
  4558. }
  4559. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4560. /** @hidden */
  4561. export class ShaderCodeCursor {
  4562. private _lines;
  4563. lineIndex: number;
  4564. readonly currentLine: string;
  4565. readonly canRead: boolean;
  4566. lines: string[];
  4567. }
  4568. }
  4569. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4570. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4571. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4572. /** @hidden */
  4573. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4574. process(preprocessors: {
  4575. [key: string]: string;
  4576. }, options: ProcessingOptions): string;
  4577. }
  4578. }
  4579. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4580. /** @hidden */
  4581. export class ShaderDefineExpression {
  4582. isTrue(preprocessors: {
  4583. [key: string]: string;
  4584. }): boolean;
  4585. }
  4586. }
  4587. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4588. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4589. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4590. /** @hidden */
  4591. export class ShaderCodeTestNode extends ShaderCodeNode {
  4592. testExpression: ShaderDefineExpression;
  4593. isValid(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4602. define: string;
  4603. not: boolean;
  4604. constructor(define: string, not?: boolean);
  4605. isTrue(preprocessors: {
  4606. [key: string]: string;
  4607. }): boolean;
  4608. }
  4609. }
  4610. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4611. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4612. /** @hidden */
  4613. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4614. leftOperand: ShaderDefineExpression;
  4615. rightOperand: ShaderDefineExpression;
  4616. isTrue(preprocessors: {
  4617. [key: string]: string;
  4618. }): boolean;
  4619. }
  4620. }
  4621. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4622. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4623. /** @hidden */
  4624. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4625. leftOperand: ShaderDefineExpression;
  4626. rightOperand: ShaderDefineExpression;
  4627. isTrue(preprocessors: {
  4628. [key: string]: string;
  4629. }): boolean;
  4630. }
  4631. }
  4632. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4633. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4634. /** @hidden */
  4635. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4636. define: string;
  4637. operand: string;
  4638. testValue: string;
  4639. constructor(define: string, operand: string, testValue: string);
  4640. isTrue(preprocessors: {
  4641. [key: string]: string;
  4642. }): boolean;
  4643. }
  4644. }
  4645. declare module "babylonjs/Misc/loadFileError" {
  4646. import { WebRequest } from "babylonjs/Misc/webRequest";
  4647. /**
  4648. * @ignore
  4649. * Application error to support additional information when loading a file
  4650. */
  4651. export class LoadFileError extends Error {
  4652. /** defines the optional web request */
  4653. request?: WebRequest | undefined;
  4654. private static _setPrototypeOf;
  4655. /**
  4656. * Creates a new LoadFileError
  4657. * @param message defines the message of the error
  4658. * @param request defines the optional web request
  4659. */
  4660. constructor(message: string,
  4661. /** defines the optional web request */
  4662. request?: WebRequest | undefined);
  4663. }
  4664. }
  4665. declare module "babylonjs/Offline/IOfflineProvider" {
  4666. /**
  4667. * Class used to enable access to offline support
  4668. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4669. */
  4670. export interface IOfflineProvider {
  4671. /**
  4672. * Gets a boolean indicating if scene must be saved in the database
  4673. */
  4674. enableSceneOffline: boolean;
  4675. /**
  4676. * Gets a boolean indicating if textures must be saved in the database
  4677. */
  4678. enableTexturesOffline: boolean;
  4679. /**
  4680. * Open the offline support and make it available
  4681. * @param successCallback defines the callback to call on success
  4682. * @param errorCallback defines the callback to call on error
  4683. */
  4684. open(successCallback: () => void, errorCallback: () => void): void;
  4685. /**
  4686. * Loads an image from the offline support
  4687. * @param url defines the url to load from
  4688. * @param image defines the target DOM image
  4689. */
  4690. loadImage(url: string, image: HTMLImageElement): void;
  4691. /**
  4692. * Loads a file from offline support
  4693. * @param url defines the URL to load from
  4694. * @param sceneLoaded defines a callback to call on success
  4695. * @param progressCallBack defines a callback to call when progress changed
  4696. * @param errorCallback defines a callback to call on error
  4697. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4698. */
  4699. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4700. }
  4701. }
  4702. declare module "babylonjs/Misc/filesInputStore" {
  4703. /**
  4704. * Class used to help managing file picking and drag'n'drop
  4705. * File Storage
  4706. */
  4707. export class FilesInputStore {
  4708. /**
  4709. * List of files ready to be loaded
  4710. */
  4711. static FilesToLoad: {
  4712. [key: string]: File;
  4713. };
  4714. }
  4715. }
  4716. declare module "babylonjs/Misc/retryStrategy" {
  4717. import { WebRequest } from "babylonjs/Misc/webRequest";
  4718. /**
  4719. * Class used to define a retry strategy when error happens while loading assets
  4720. */
  4721. export class RetryStrategy {
  4722. /**
  4723. * Function used to defines an exponential back off strategy
  4724. * @param maxRetries defines the maximum number of retries (3 by default)
  4725. * @param baseInterval defines the interval between retries
  4726. * @returns the strategy function to use
  4727. */
  4728. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4729. }
  4730. }
  4731. declare module "babylonjs/Misc/fileTools" {
  4732. import { WebRequest } from "babylonjs/Misc/webRequest";
  4733. import { Nullable } from "babylonjs/types";
  4734. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4735. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4736. /**
  4737. * @hidden
  4738. */
  4739. export class FileTools {
  4740. /**
  4741. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4742. */
  4743. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4744. /**
  4745. * Gets or sets the base URL to use to load assets
  4746. */
  4747. static BaseUrl: string;
  4748. /**
  4749. * Default behaviour for cors in the application.
  4750. * It can be a string if the expected behavior is identical in the entire app.
  4751. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4752. */
  4753. static CorsBehavior: string | ((url: string | string[]) => string);
  4754. /**
  4755. * Gets or sets a function used to pre-process url before using them to load assets
  4756. */
  4757. static PreprocessUrl: (url: string) => string;
  4758. /**
  4759. * Removes unwanted characters from an url
  4760. * @param url defines the url to clean
  4761. * @returns the cleaned url
  4762. */
  4763. private static _CleanUrl;
  4764. /**
  4765. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4766. * @param url define the url we are trying
  4767. * @param element define the dom element where to configure the cors policy
  4768. */
  4769. static SetCorsBehavior(url: string | string[], element: {
  4770. crossOrigin: string | null;
  4771. }): void;
  4772. /**
  4773. * Loads an image as an HTMLImageElement.
  4774. * @param input url string, ArrayBuffer, or Blob to load
  4775. * @param onLoad callback called when the image successfully loads
  4776. * @param onError callback called when the image fails to load
  4777. * @param offlineProvider offline provider for caching
  4778. * @returns the HTMLImageElement of the loaded image
  4779. */
  4780. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4781. /**
  4782. * Loads a file
  4783. * @param fileToLoad defines the file to load
  4784. * @param callback defines the callback to call when data is loaded
  4785. * @param progressCallBack defines the callback to call during loading process
  4786. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4787. * @returns a file request object
  4788. */
  4789. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4790. /**
  4791. * Loads a file
  4792. * @param url url string, ArrayBuffer, or Blob to load
  4793. * @param onSuccess callback called when the file successfully loads
  4794. * @param onProgress callback called while file is loading (if the server supports this mode)
  4795. * @param offlineProvider defines the offline provider for caching
  4796. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4797. * @param onError callback called when the file fails to load
  4798. * @returns a file request object
  4799. */
  4800. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  4801. /**
  4802. * Checks if the loaded document was accessed via `file:`-Protocol.
  4803. * @returns boolean
  4804. */
  4805. static IsFileURL(): boolean;
  4806. }
  4807. }
  4808. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4809. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4810. /** @hidden */
  4811. export class ShaderProcessor {
  4812. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4813. private static _ProcessPrecision;
  4814. private static _ExtractOperation;
  4815. private static _BuildSubExpression;
  4816. private static _BuildExpression;
  4817. private static _MoveCursorWithinIf;
  4818. private static _MoveCursor;
  4819. private static _EvaluatePreProcessors;
  4820. private static _PreparePreProcessors;
  4821. private static _ProcessShaderConversion;
  4822. private static _ProcessIncludes;
  4823. }
  4824. }
  4825. declare module "babylonjs/Maths/math.color" {
  4826. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4827. /**
  4828. * Class used to hold a RBG color
  4829. */
  4830. export class Color3 {
  4831. /**
  4832. * Defines the red component (between 0 and 1, default is 0)
  4833. */
  4834. r: number;
  4835. /**
  4836. * Defines the green component (between 0 and 1, default is 0)
  4837. */
  4838. g: number;
  4839. /**
  4840. * Defines the blue component (between 0 and 1, default is 0)
  4841. */
  4842. b: number;
  4843. /**
  4844. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4845. * @param r defines the red component (between 0 and 1, default is 0)
  4846. * @param g defines the green component (between 0 and 1, default is 0)
  4847. * @param b defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. constructor(
  4850. /**
  4851. * Defines the red component (between 0 and 1, default is 0)
  4852. */
  4853. r?: number,
  4854. /**
  4855. * Defines the green component (between 0 and 1, default is 0)
  4856. */
  4857. g?: number,
  4858. /**
  4859. * Defines the blue component (between 0 and 1, default is 0)
  4860. */
  4861. b?: number);
  4862. /**
  4863. * Creates a string with the Color3 current values
  4864. * @returns the string representation of the Color3 object
  4865. */
  4866. toString(): string;
  4867. /**
  4868. * Returns the string "Color3"
  4869. * @returns "Color3"
  4870. */
  4871. getClassName(): string;
  4872. /**
  4873. * Compute the Color3 hash code
  4874. * @returns an unique number that can be used to hash Color3 objects
  4875. */
  4876. getHashCode(): number;
  4877. /**
  4878. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4879. * @param array defines the array where to store the r,g,b components
  4880. * @param index defines an optional index in the target array to define where to start storing values
  4881. * @returns the current Color3 object
  4882. */
  4883. toArray(array: FloatArray, index?: number): Color3;
  4884. /**
  4885. * Returns a new Color4 object from the current Color3 and the given alpha
  4886. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4887. * @returns a new Color4 object
  4888. */
  4889. toColor4(alpha?: number): Color4;
  4890. /**
  4891. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4892. * @returns the new array
  4893. */
  4894. asArray(): number[];
  4895. /**
  4896. * Returns the luminance value
  4897. * @returns a float value
  4898. */
  4899. toLuminance(): number;
  4900. /**
  4901. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4902. * @param otherColor defines the second operand
  4903. * @returns the new Color3 object
  4904. */
  4905. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4906. /**
  4907. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4908. * @param otherColor defines the second operand
  4909. * @param result defines the Color3 object where to store the result
  4910. * @returns the current Color3
  4911. */
  4912. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4913. /**
  4914. * Determines equality between Color3 objects
  4915. * @param otherColor defines the second operand
  4916. * @returns true if the rgb values are equal to the given ones
  4917. */
  4918. equals(otherColor: DeepImmutable<Color3>): boolean;
  4919. /**
  4920. * Determines equality between the current Color3 object and a set of r,b,g values
  4921. * @param r defines the red component to check
  4922. * @param g defines the green component to check
  4923. * @param b defines the blue component to check
  4924. * @returns true if the rgb values are equal to the given ones
  4925. */
  4926. equalsFloats(r: number, g: number, b: number): boolean;
  4927. /**
  4928. * Multiplies in place each rgb value by scale
  4929. * @param scale defines the scaling factor
  4930. * @returns the updated Color3
  4931. */
  4932. scale(scale: number): Color3;
  4933. /**
  4934. * Multiplies the rgb values by scale and stores the result into "result"
  4935. * @param scale defines the scaling factor
  4936. * @param result defines the Color3 object where to store the result
  4937. * @returns the unmodified current Color3
  4938. */
  4939. scaleToRef(scale: number, result: Color3): Color3;
  4940. /**
  4941. * Scale the current Color3 values by a factor and add the result to a given Color3
  4942. * @param scale defines the scale factor
  4943. * @param result defines color to store the result into
  4944. * @returns the unmodified current Color3
  4945. */
  4946. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4947. /**
  4948. * Clamps the rgb values by the min and max values and stores the result into "result"
  4949. * @param min defines minimum clamping value (default is 0)
  4950. * @param max defines maximum clamping value (default is 1)
  4951. * @param result defines color to store the result into
  4952. * @returns the original Color3
  4953. */
  4954. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4955. /**
  4956. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4957. * @param otherColor defines the second operand
  4958. * @returns the new Color3
  4959. */
  4960. add(otherColor: DeepImmutable<Color3>): Color3;
  4961. /**
  4962. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4963. * @param otherColor defines the second operand
  4964. * @param result defines Color3 object to store the result into
  4965. * @returns the unmodified current Color3
  4966. */
  4967. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4968. /**
  4969. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4970. * @param otherColor defines the second operand
  4971. * @returns the new Color3
  4972. */
  4973. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4974. /**
  4975. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4976. * @param otherColor defines the second operand
  4977. * @param result defines Color3 object to store the result into
  4978. * @returns the unmodified current Color3
  4979. */
  4980. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4981. /**
  4982. * Copy the current object
  4983. * @returns a new Color3 copied the current one
  4984. */
  4985. clone(): Color3;
  4986. /**
  4987. * Copies the rgb values from the source in the current Color3
  4988. * @param source defines the source Color3 object
  4989. * @returns the updated Color3 object
  4990. */
  4991. copyFrom(source: DeepImmutable<Color3>): Color3;
  4992. /**
  4993. * Updates the Color3 rgb values from the given floats
  4994. * @param r defines the red component to read from
  4995. * @param g defines the green component to read from
  4996. * @param b defines the blue component to read from
  4997. * @returns the current Color3 object
  4998. */
  4999. copyFromFloats(r: number, g: number, b: number): Color3;
  5000. /**
  5001. * Updates the Color3 rgb values from the given floats
  5002. * @param r defines the red component to read from
  5003. * @param g defines the green component to read from
  5004. * @param b defines the blue component to read from
  5005. * @returns the current Color3 object
  5006. */
  5007. set(r: number, g: number, b: number): Color3;
  5008. /**
  5009. * Compute the Color3 hexadecimal code as a string
  5010. * @returns a string containing the hexadecimal representation of the Color3 object
  5011. */
  5012. toHexString(): string;
  5013. /**
  5014. * Computes a new Color3 converted from the current one to linear space
  5015. * @returns a new Color3 object
  5016. */
  5017. toLinearSpace(): Color3;
  5018. /**
  5019. * Converts current color in rgb space to HSV values
  5020. * @returns a new color3 representing the HSV values
  5021. */
  5022. toHSV(): Color3;
  5023. /**
  5024. * Converts current color in rgb space to HSV values
  5025. * @param result defines the Color3 where to store the HSV values
  5026. */
  5027. toHSVToRef(result: Color3): void;
  5028. /**
  5029. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5030. * @param convertedColor defines the Color3 object where to store the linear space version
  5031. * @returns the unmodified Color3
  5032. */
  5033. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5034. /**
  5035. * Computes a new Color3 converted from the current one to gamma space
  5036. * @returns a new Color3 object
  5037. */
  5038. toGammaSpace(): Color3;
  5039. /**
  5040. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5041. * @param convertedColor defines the Color3 object where to store the gamma space version
  5042. * @returns the unmodified Color3
  5043. */
  5044. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5045. private static _BlackReadOnly;
  5046. /**
  5047. * Convert Hue, saturation and value to a Color3 (RGB)
  5048. * @param hue defines the hue
  5049. * @param saturation defines the saturation
  5050. * @param value defines the value
  5051. * @param result defines the Color3 where to store the RGB values
  5052. */
  5053. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5054. /**
  5055. * Creates a new Color3 from the string containing valid hexadecimal values
  5056. * @param hex defines a string containing valid hexadecimal values
  5057. * @returns a new Color3 object
  5058. */
  5059. static FromHexString(hex: string): Color3;
  5060. /**
  5061. * Creates a new Color3 from the starting index of the given array
  5062. * @param array defines the source array
  5063. * @param offset defines an offset in the source array
  5064. * @returns a new Color3 object
  5065. */
  5066. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5067. /**
  5068. * Creates a new Color3 from integer values (< 256)
  5069. * @param r defines the red component to read from (value between 0 and 255)
  5070. * @param g defines the green component to read from (value between 0 and 255)
  5071. * @param b defines the blue component to read from (value between 0 and 255)
  5072. * @returns a new Color3 object
  5073. */
  5074. static FromInts(r: number, g: number, b: number): Color3;
  5075. /**
  5076. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5077. * @param start defines the start Color3 value
  5078. * @param end defines the end Color3 value
  5079. * @param amount defines the gradient value between start and end
  5080. * @returns a new Color3 object
  5081. */
  5082. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5083. /**
  5084. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5085. * @param left defines the start value
  5086. * @param right defines the end value
  5087. * @param amount defines the gradient factor
  5088. * @param result defines the Color3 object where to store the result
  5089. */
  5090. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5091. /**
  5092. * Returns a Color3 value containing a red color
  5093. * @returns a new Color3 object
  5094. */
  5095. static Red(): Color3;
  5096. /**
  5097. * Returns a Color3 value containing a green color
  5098. * @returns a new Color3 object
  5099. */
  5100. static Green(): Color3;
  5101. /**
  5102. * Returns a Color3 value containing a blue color
  5103. * @returns a new Color3 object
  5104. */
  5105. static Blue(): Color3;
  5106. /**
  5107. * Returns a Color3 value containing a black color
  5108. * @returns a new Color3 object
  5109. */
  5110. static Black(): Color3;
  5111. /**
  5112. * Gets a Color3 value containing a black color that must not be updated
  5113. */
  5114. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5115. /**
  5116. * Returns a Color3 value containing a white color
  5117. * @returns a new Color3 object
  5118. */
  5119. static White(): Color3;
  5120. /**
  5121. * Returns a Color3 value containing a purple color
  5122. * @returns a new Color3 object
  5123. */
  5124. static Purple(): Color3;
  5125. /**
  5126. * Returns a Color3 value containing a magenta color
  5127. * @returns a new Color3 object
  5128. */
  5129. static Magenta(): Color3;
  5130. /**
  5131. * Returns a Color3 value containing a yellow color
  5132. * @returns a new Color3 object
  5133. */
  5134. static Yellow(): Color3;
  5135. /**
  5136. * Returns a Color3 value containing a gray color
  5137. * @returns a new Color3 object
  5138. */
  5139. static Gray(): Color3;
  5140. /**
  5141. * Returns a Color3 value containing a teal color
  5142. * @returns a new Color3 object
  5143. */
  5144. static Teal(): Color3;
  5145. /**
  5146. * Returns a Color3 value containing a random color
  5147. * @returns a new Color3 object
  5148. */
  5149. static Random(): Color3;
  5150. }
  5151. /**
  5152. * Class used to hold a RBGA color
  5153. */
  5154. export class Color4 {
  5155. /**
  5156. * Defines the red component (between 0 and 1, default is 0)
  5157. */
  5158. r: number;
  5159. /**
  5160. * Defines the green component (between 0 and 1, default is 0)
  5161. */
  5162. g: number;
  5163. /**
  5164. * Defines the blue component (between 0 and 1, default is 0)
  5165. */
  5166. b: number;
  5167. /**
  5168. * Defines the alpha component (between 0 and 1, default is 1)
  5169. */
  5170. a: number;
  5171. /**
  5172. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5173. * @param r defines the red component (between 0 and 1, default is 0)
  5174. * @param g defines the green component (between 0 and 1, default is 0)
  5175. * @param b defines the blue component (between 0 and 1, default is 0)
  5176. * @param a defines the alpha component (between 0 and 1, default is 1)
  5177. */
  5178. constructor(
  5179. /**
  5180. * Defines the red component (between 0 and 1, default is 0)
  5181. */
  5182. r?: number,
  5183. /**
  5184. * Defines the green component (between 0 and 1, default is 0)
  5185. */
  5186. g?: number,
  5187. /**
  5188. * Defines the blue component (between 0 and 1, default is 0)
  5189. */
  5190. b?: number,
  5191. /**
  5192. * Defines the alpha component (between 0 and 1, default is 1)
  5193. */
  5194. a?: number);
  5195. /**
  5196. * Adds in place the given Color4 values to the current Color4 object
  5197. * @param right defines the second operand
  5198. * @returns the current updated Color4 object
  5199. */
  5200. addInPlace(right: DeepImmutable<Color4>): Color4;
  5201. /**
  5202. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5203. * @returns the new array
  5204. */
  5205. asArray(): number[];
  5206. /**
  5207. * Stores from the starting index in the given array the Color4 successive values
  5208. * @param array defines the array where to store the r,g,b components
  5209. * @param index defines an optional index in the target array to define where to start storing values
  5210. * @returns the current Color4 object
  5211. */
  5212. toArray(array: number[], index?: number): Color4;
  5213. /**
  5214. * Determines equality between Color4 objects
  5215. * @param otherColor defines the second operand
  5216. * @returns true if the rgba values are equal to the given ones
  5217. */
  5218. equals(otherColor: DeepImmutable<Color4>): boolean;
  5219. /**
  5220. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5221. * @param right defines the second operand
  5222. * @returns a new Color4 object
  5223. */
  5224. add(right: DeepImmutable<Color4>): Color4;
  5225. /**
  5226. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5227. * @param right defines the second operand
  5228. * @returns a new Color4 object
  5229. */
  5230. subtract(right: DeepImmutable<Color4>): Color4;
  5231. /**
  5232. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5233. * @param right defines the second operand
  5234. * @param result defines the Color4 object where to store the result
  5235. * @returns the current Color4 object
  5236. */
  5237. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5238. /**
  5239. * Creates a new Color4 with the current Color4 values multiplied by scale
  5240. * @param scale defines the scaling factor to apply
  5241. * @returns a new Color4 object
  5242. */
  5243. scale(scale: number): Color4;
  5244. /**
  5245. * Multiplies the current Color4 values by scale and stores the result in "result"
  5246. * @param scale defines the scaling factor to apply
  5247. * @param result defines the Color4 object where to store the result
  5248. * @returns the current unmodified Color4
  5249. */
  5250. scaleToRef(scale: number, result: Color4): Color4;
  5251. /**
  5252. * Scale the current Color4 values by a factor and add the result to a given Color4
  5253. * @param scale defines the scale factor
  5254. * @param result defines the Color4 object where to store the result
  5255. * @returns the unmodified current Color4
  5256. */
  5257. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5258. /**
  5259. * Clamps the rgb values by the min and max values and stores the result into "result"
  5260. * @param min defines minimum clamping value (default is 0)
  5261. * @param max defines maximum clamping value (default is 1)
  5262. * @param result defines color to store the result into.
  5263. * @returns the cuurent Color4
  5264. */
  5265. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5266. /**
  5267. * Multipy an Color4 value by another and return a new Color4 object
  5268. * @param color defines the Color4 value to multiply by
  5269. * @returns a new Color4 object
  5270. */
  5271. multiply(color: Color4): Color4;
  5272. /**
  5273. * Multipy a Color4 value by another and push the result in a reference value
  5274. * @param color defines the Color4 value to multiply by
  5275. * @param result defines the Color4 to fill the result in
  5276. * @returns the result Color4
  5277. */
  5278. multiplyToRef(color: Color4, result: Color4): Color4;
  5279. /**
  5280. * Creates a string with the Color4 current values
  5281. * @returns the string representation of the Color4 object
  5282. */
  5283. toString(): string;
  5284. /**
  5285. * Returns the string "Color4"
  5286. * @returns "Color4"
  5287. */
  5288. getClassName(): string;
  5289. /**
  5290. * Compute the Color4 hash code
  5291. * @returns an unique number that can be used to hash Color4 objects
  5292. */
  5293. getHashCode(): number;
  5294. /**
  5295. * Creates a new Color4 copied from the current one
  5296. * @returns a new Color4 object
  5297. */
  5298. clone(): Color4;
  5299. /**
  5300. * Copies the given Color4 values into the current one
  5301. * @param source defines the source Color4 object
  5302. * @returns the current updated Color4 object
  5303. */
  5304. copyFrom(source: Color4): Color4;
  5305. /**
  5306. * Copies the given float values into the current one
  5307. * @param r defines the red component to read from
  5308. * @param g defines the green component to read from
  5309. * @param b defines the blue component to read from
  5310. * @param a defines the alpha component to read from
  5311. * @returns the current updated Color4 object
  5312. */
  5313. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5314. /**
  5315. * Copies the given float values into the current one
  5316. * @param r defines the red component to read from
  5317. * @param g defines the green component to read from
  5318. * @param b defines the blue component to read from
  5319. * @param a defines the alpha component to read from
  5320. * @returns the current updated Color4 object
  5321. */
  5322. set(r: number, g: number, b: number, a: number): Color4;
  5323. /**
  5324. * Compute the Color4 hexadecimal code as a string
  5325. * @returns a string containing the hexadecimal representation of the Color4 object
  5326. */
  5327. toHexString(): string;
  5328. /**
  5329. * Computes a new Color4 converted from the current one to linear space
  5330. * @returns a new Color4 object
  5331. */
  5332. toLinearSpace(): Color4;
  5333. /**
  5334. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5335. * @param convertedColor defines the Color4 object where to store the linear space version
  5336. * @returns the unmodified Color4
  5337. */
  5338. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5339. /**
  5340. * Computes a new Color4 converted from the current one to gamma space
  5341. * @returns a new Color4 object
  5342. */
  5343. toGammaSpace(): Color4;
  5344. /**
  5345. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5346. * @param convertedColor defines the Color4 object where to store the gamma space version
  5347. * @returns the unmodified Color4
  5348. */
  5349. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5350. /**
  5351. * Creates a new Color4 from the string containing valid hexadecimal values
  5352. * @param hex defines a string containing valid hexadecimal values
  5353. * @returns a new Color4 object
  5354. */
  5355. static FromHexString(hex: string): Color4;
  5356. /**
  5357. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5358. * @param left defines the start value
  5359. * @param right defines the end value
  5360. * @param amount defines the gradient factor
  5361. * @returns a new Color4 object
  5362. */
  5363. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5364. /**
  5365. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5366. * @param left defines the start value
  5367. * @param right defines the end value
  5368. * @param amount defines the gradient factor
  5369. * @param result defines the Color4 object where to store data
  5370. */
  5371. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5372. /**
  5373. * Creates a new Color4 from a Color3 and an alpha value
  5374. * @param color3 defines the source Color3 to read from
  5375. * @param alpha defines the alpha component (1.0 by default)
  5376. * @returns a new Color4 object
  5377. */
  5378. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5379. /**
  5380. * Creates a new Color4 from the starting index element of the given array
  5381. * @param array defines the source array to read from
  5382. * @param offset defines the offset in the source array
  5383. * @returns a new Color4 object
  5384. */
  5385. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5386. /**
  5387. * Creates a new Color3 from integer values (< 256)
  5388. * @param r defines the red component to read from (value between 0 and 255)
  5389. * @param g defines the green component to read from (value between 0 and 255)
  5390. * @param b defines the blue component to read from (value between 0 and 255)
  5391. * @param a defines the alpha component to read from (value between 0 and 255)
  5392. * @returns a new Color3 object
  5393. */
  5394. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5395. /**
  5396. * Check the content of a given array and convert it to an array containing RGBA data
  5397. * If the original array was already containing count * 4 values then it is returned directly
  5398. * @param colors defines the array to check
  5399. * @param count defines the number of RGBA data to expect
  5400. * @returns an array containing count * 4 values (RGBA)
  5401. */
  5402. static CheckColors4(colors: number[], count: number): number[];
  5403. }
  5404. /**
  5405. * @hidden
  5406. */
  5407. export class TmpColors {
  5408. static Color3: Color3[];
  5409. static Color4: Color4[];
  5410. }
  5411. }
  5412. declare module "babylonjs/Maths/sphericalPolynomial" {
  5413. import { Vector3 } from "babylonjs/Maths/math.vector";
  5414. import { Color3 } from "babylonjs/Maths/math.color";
  5415. /**
  5416. * Class representing spherical harmonics coefficients to the 3rd degree
  5417. */
  5418. export class SphericalHarmonics {
  5419. /**
  5420. * Defines whether or not the harmonics have been prescaled for rendering.
  5421. */
  5422. preScaled: boolean;
  5423. /**
  5424. * The l0,0 coefficients of the spherical harmonics
  5425. */
  5426. l00: Vector3;
  5427. /**
  5428. * The l1,-1 coefficients of the spherical harmonics
  5429. */
  5430. l1_1: Vector3;
  5431. /**
  5432. * The l1,0 coefficients of the spherical harmonics
  5433. */
  5434. l10: Vector3;
  5435. /**
  5436. * The l1,1 coefficients of the spherical harmonics
  5437. */
  5438. l11: Vector3;
  5439. /**
  5440. * The l2,-2 coefficients of the spherical harmonics
  5441. */
  5442. l2_2: Vector3;
  5443. /**
  5444. * The l2,-1 coefficients of the spherical harmonics
  5445. */
  5446. l2_1: Vector3;
  5447. /**
  5448. * The l2,0 coefficients of the spherical harmonics
  5449. */
  5450. l20: Vector3;
  5451. /**
  5452. * The l2,1 coefficients of the spherical harmonics
  5453. */
  5454. l21: Vector3;
  5455. /**
  5456. * The l2,2 coefficients of the spherical harmonics
  5457. */
  5458. l22: Vector3;
  5459. /**
  5460. * Adds a light to the spherical harmonics
  5461. * @param direction the direction of the light
  5462. * @param color the color of the light
  5463. * @param deltaSolidAngle the delta solid angle of the light
  5464. */
  5465. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5466. /**
  5467. * Scales the spherical harmonics by the given amount
  5468. * @param scale the amount to scale
  5469. */
  5470. scaleInPlace(scale: number): void;
  5471. /**
  5472. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5473. *
  5474. * ```
  5475. * E_lm = A_l * L_lm
  5476. * ```
  5477. *
  5478. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5479. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5480. * the scaling factors are given in equation 9.
  5481. */
  5482. convertIncidentRadianceToIrradiance(): void;
  5483. /**
  5484. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5485. *
  5486. * ```
  5487. * L = (1/pi) * E * rho
  5488. * ```
  5489. *
  5490. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5491. */
  5492. convertIrradianceToLambertianRadiance(): void;
  5493. /**
  5494. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5495. * required operations at run time.
  5496. *
  5497. * This is simply done by scaling back the SH with Ylm constants parameter.
  5498. * The trigonometric part being applied by the shader at run time.
  5499. */
  5500. preScaleForRendering(): void;
  5501. /**
  5502. * Constructs a spherical harmonics from an array.
  5503. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5504. * @returns the spherical harmonics
  5505. */
  5506. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5507. /**
  5508. * Gets the spherical harmonics from polynomial
  5509. * @param polynomial the spherical polynomial
  5510. * @returns the spherical harmonics
  5511. */
  5512. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5513. }
  5514. /**
  5515. * Class representing spherical polynomial coefficients to the 3rd degree
  5516. */
  5517. export class SphericalPolynomial {
  5518. private _harmonics;
  5519. /**
  5520. * The spherical harmonics used to create the polynomials.
  5521. */
  5522. readonly preScaledHarmonics: SphericalHarmonics;
  5523. /**
  5524. * The x coefficients of the spherical polynomial
  5525. */
  5526. x: Vector3;
  5527. /**
  5528. * The y coefficients of the spherical polynomial
  5529. */
  5530. y: Vector3;
  5531. /**
  5532. * The z coefficients of the spherical polynomial
  5533. */
  5534. z: Vector3;
  5535. /**
  5536. * The xx coefficients of the spherical polynomial
  5537. */
  5538. xx: Vector3;
  5539. /**
  5540. * The yy coefficients of the spherical polynomial
  5541. */
  5542. yy: Vector3;
  5543. /**
  5544. * The zz coefficients of the spherical polynomial
  5545. */
  5546. zz: Vector3;
  5547. /**
  5548. * The xy coefficients of the spherical polynomial
  5549. */
  5550. xy: Vector3;
  5551. /**
  5552. * The yz coefficients of the spherical polynomial
  5553. */
  5554. yz: Vector3;
  5555. /**
  5556. * The zx coefficients of the spherical polynomial
  5557. */
  5558. zx: Vector3;
  5559. /**
  5560. * Adds an ambient color to the spherical polynomial
  5561. * @param color the color to add
  5562. */
  5563. addAmbient(color: Color3): void;
  5564. /**
  5565. * Scales the spherical polynomial by the given amount
  5566. * @param scale the amount to scale
  5567. */
  5568. scaleInPlace(scale: number): void;
  5569. /**
  5570. * Gets the spherical polynomial from harmonics
  5571. * @param harmonics the spherical harmonics
  5572. * @returns the spherical polynomial
  5573. */
  5574. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5575. /**
  5576. * Constructs a spherical polynomial from an array.
  5577. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5578. * @returns the spherical polynomial
  5579. */
  5580. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5581. }
  5582. }
  5583. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5584. /**
  5585. * Define options used to create a render target texture
  5586. */
  5587. export class RenderTargetCreationOptions {
  5588. /**
  5589. * Specifies is mipmaps must be generated
  5590. */
  5591. generateMipMaps?: boolean;
  5592. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5593. generateDepthBuffer?: boolean;
  5594. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5595. generateStencilBuffer?: boolean;
  5596. /** Defines texture type (int by default) */
  5597. type?: number;
  5598. /** Defines sampling mode (trilinear by default) */
  5599. samplingMode?: number;
  5600. /** Defines format (RGBA by default) */
  5601. format?: number;
  5602. }
  5603. }
  5604. declare module "babylonjs/States/alphaCullingState" {
  5605. /**
  5606. * @hidden
  5607. **/
  5608. export class _AlphaState {
  5609. private _isAlphaBlendDirty;
  5610. private _isBlendFunctionParametersDirty;
  5611. private _isBlendEquationParametersDirty;
  5612. private _isBlendConstantsDirty;
  5613. private _alphaBlend;
  5614. private _blendFunctionParameters;
  5615. private _blendEquationParameters;
  5616. private _blendConstants;
  5617. /**
  5618. * Initializes the state.
  5619. */
  5620. constructor();
  5621. readonly isDirty: boolean;
  5622. alphaBlend: boolean;
  5623. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5624. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5625. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5626. reset(): void;
  5627. apply(gl: WebGLRenderingContext): void;
  5628. }
  5629. }
  5630. declare module "babylonjs/States/depthCullingState" {
  5631. import { Nullable } from "babylonjs/types";
  5632. /**
  5633. * @hidden
  5634. **/
  5635. export class _DepthCullingState {
  5636. private _isDepthTestDirty;
  5637. private _isDepthMaskDirty;
  5638. private _isDepthFuncDirty;
  5639. private _isCullFaceDirty;
  5640. private _isCullDirty;
  5641. private _isZOffsetDirty;
  5642. private _isFrontFaceDirty;
  5643. private _depthTest;
  5644. private _depthMask;
  5645. private _depthFunc;
  5646. private _cull;
  5647. private _cullFace;
  5648. private _zOffset;
  5649. private _frontFace;
  5650. /**
  5651. * Initializes the state.
  5652. */
  5653. constructor();
  5654. readonly isDirty: boolean;
  5655. zOffset: number;
  5656. cullFace: Nullable<number>;
  5657. cull: Nullable<boolean>;
  5658. depthFunc: Nullable<number>;
  5659. depthMask: boolean;
  5660. depthTest: boolean;
  5661. frontFace: Nullable<number>;
  5662. reset(): void;
  5663. apply(gl: WebGLRenderingContext): void;
  5664. }
  5665. }
  5666. declare module "babylonjs/States/stencilState" {
  5667. /**
  5668. * @hidden
  5669. **/
  5670. export class _StencilState {
  5671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  5672. static readonly ALWAYS: number;
  5673. /** Passed to stencilOperation to specify that stencil value must be kept */
  5674. static readonly KEEP: number;
  5675. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5676. static readonly REPLACE: number;
  5677. private _isStencilTestDirty;
  5678. private _isStencilMaskDirty;
  5679. private _isStencilFuncDirty;
  5680. private _isStencilOpDirty;
  5681. private _stencilTest;
  5682. private _stencilMask;
  5683. private _stencilFunc;
  5684. private _stencilFuncRef;
  5685. private _stencilFuncMask;
  5686. private _stencilOpStencilFail;
  5687. private _stencilOpDepthFail;
  5688. private _stencilOpStencilDepthPass;
  5689. readonly isDirty: boolean;
  5690. stencilFunc: number;
  5691. stencilFuncRef: number;
  5692. stencilFuncMask: number;
  5693. stencilOpStencilFail: number;
  5694. stencilOpDepthFail: number;
  5695. stencilOpStencilDepthPass: number;
  5696. stencilMask: number;
  5697. stencilTest: boolean;
  5698. constructor();
  5699. reset(): void;
  5700. apply(gl: WebGLRenderingContext): void;
  5701. }
  5702. }
  5703. declare module "babylonjs/States/index" {
  5704. export * from "babylonjs/States/alphaCullingState";
  5705. export * from "babylonjs/States/depthCullingState";
  5706. export * from "babylonjs/States/stencilState";
  5707. }
  5708. declare module "babylonjs/Instrumentation/timeToken" {
  5709. import { Nullable } from "babylonjs/types";
  5710. /**
  5711. * @hidden
  5712. **/
  5713. export class _TimeToken {
  5714. _startTimeQuery: Nullable<WebGLQuery>;
  5715. _endTimeQuery: Nullable<WebGLQuery>;
  5716. _timeElapsedQuery: Nullable<WebGLQuery>;
  5717. _timeElapsedQueryEnded: boolean;
  5718. }
  5719. }
  5720. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5721. /**
  5722. * Class used to evalaute queries containing `and` and `or` operators
  5723. */
  5724. export class AndOrNotEvaluator {
  5725. /**
  5726. * Evaluate a query
  5727. * @param query defines the query to evaluate
  5728. * @param evaluateCallback defines the callback used to filter result
  5729. * @returns true if the query matches
  5730. */
  5731. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5732. private static _HandleParenthesisContent;
  5733. private static _SimplifyNegation;
  5734. }
  5735. }
  5736. declare module "babylonjs/Misc/tags" {
  5737. /**
  5738. * Class used to store custom tags
  5739. */
  5740. export class Tags {
  5741. /**
  5742. * Adds support for tags on the given object
  5743. * @param obj defines the object to use
  5744. */
  5745. static EnableFor(obj: any): void;
  5746. /**
  5747. * Removes tags support
  5748. * @param obj defines the object to use
  5749. */
  5750. static DisableFor(obj: any): void;
  5751. /**
  5752. * Gets a boolean indicating if the given object has tags
  5753. * @param obj defines the object to use
  5754. * @returns a boolean
  5755. */
  5756. static HasTags(obj: any): boolean;
  5757. /**
  5758. * Gets the tags available on a given object
  5759. * @param obj defines the object to use
  5760. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5761. * @returns the tags
  5762. */
  5763. static GetTags(obj: any, asString?: boolean): any;
  5764. /**
  5765. * Adds tags to an object
  5766. * @param obj defines the object to use
  5767. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5768. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5769. */
  5770. static AddTagsTo(obj: any, tagsString: string): void;
  5771. /**
  5772. * @hidden
  5773. */
  5774. static _AddTagTo(obj: any, tag: string): void;
  5775. /**
  5776. * Removes specific tags from a specific object
  5777. * @param obj defines the object to use
  5778. * @param tagsString defines the tags to remove
  5779. */
  5780. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5781. /**
  5782. * @hidden
  5783. */
  5784. static _RemoveTagFrom(obj: any, tag: string): void;
  5785. /**
  5786. * Defines if tags hosted on an object match a given query
  5787. * @param obj defines the object to use
  5788. * @param tagsQuery defines the tag query
  5789. * @returns a boolean
  5790. */
  5791. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5792. }
  5793. }
  5794. declare module "babylonjs/Maths/math.path" {
  5795. import { DeepImmutable, Nullable } from "babylonjs/types";
  5796. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5797. /**
  5798. * Defines potential orientation for back face culling
  5799. */
  5800. export enum Orientation {
  5801. /**
  5802. * Clockwise
  5803. */
  5804. CW = 0,
  5805. /** Counter clockwise */
  5806. CCW = 1
  5807. }
  5808. /** Class used to represent a Bezier curve */
  5809. export class BezierCurve {
  5810. /**
  5811. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5812. * @param t defines the time
  5813. * @param x1 defines the left coordinate on X axis
  5814. * @param y1 defines the left coordinate on Y axis
  5815. * @param x2 defines the right coordinate on X axis
  5816. * @param y2 defines the right coordinate on Y axis
  5817. * @returns the interpolated value
  5818. */
  5819. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5820. }
  5821. /**
  5822. * Defines angle representation
  5823. */
  5824. export class Angle {
  5825. private _radians;
  5826. /**
  5827. * Creates an Angle object of "radians" radians (float).
  5828. * @param radians the angle in radians
  5829. */
  5830. constructor(radians: number);
  5831. /**
  5832. * Get value in degrees
  5833. * @returns the Angle value in degrees (float)
  5834. */
  5835. degrees(): number;
  5836. /**
  5837. * Get value in radians
  5838. * @returns the Angle value in radians (float)
  5839. */
  5840. radians(): number;
  5841. /**
  5842. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5843. * @param a defines first vector
  5844. * @param b defines second vector
  5845. * @returns a new Angle
  5846. */
  5847. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5848. /**
  5849. * Gets a new Angle object from the given float in radians
  5850. * @param radians defines the angle value in radians
  5851. * @returns a new Angle
  5852. */
  5853. static FromRadians(radians: number): Angle;
  5854. /**
  5855. * Gets a new Angle object from the given float in degrees
  5856. * @param degrees defines the angle value in degrees
  5857. * @returns a new Angle
  5858. */
  5859. static FromDegrees(degrees: number): Angle;
  5860. }
  5861. /**
  5862. * This represents an arc in a 2d space.
  5863. */
  5864. export class Arc2 {
  5865. /** Defines the start point of the arc */
  5866. startPoint: Vector2;
  5867. /** Defines the mid point of the arc */
  5868. midPoint: Vector2;
  5869. /** Defines the end point of the arc */
  5870. endPoint: Vector2;
  5871. /**
  5872. * Defines the center point of the arc.
  5873. */
  5874. centerPoint: Vector2;
  5875. /**
  5876. * Defines the radius of the arc.
  5877. */
  5878. radius: number;
  5879. /**
  5880. * Defines the angle of the arc (from mid point to end point).
  5881. */
  5882. angle: Angle;
  5883. /**
  5884. * Defines the start angle of the arc (from start point to middle point).
  5885. */
  5886. startAngle: Angle;
  5887. /**
  5888. * Defines the orientation of the arc (clock wise/counter clock wise).
  5889. */
  5890. orientation: Orientation;
  5891. /**
  5892. * Creates an Arc object from the three given points : start, middle and end.
  5893. * @param startPoint Defines the start point of the arc
  5894. * @param midPoint Defines the midlle point of the arc
  5895. * @param endPoint Defines the end point of the arc
  5896. */
  5897. constructor(
  5898. /** Defines the start point of the arc */
  5899. startPoint: Vector2,
  5900. /** Defines the mid point of the arc */
  5901. midPoint: Vector2,
  5902. /** Defines the end point of the arc */
  5903. endPoint: Vector2);
  5904. }
  5905. /**
  5906. * Represents a 2D path made up of multiple 2D points
  5907. */
  5908. export class Path2 {
  5909. private _points;
  5910. private _length;
  5911. /**
  5912. * If the path start and end point are the same
  5913. */
  5914. closed: boolean;
  5915. /**
  5916. * Creates a Path2 object from the starting 2D coordinates x and y.
  5917. * @param x the starting points x value
  5918. * @param y the starting points y value
  5919. */
  5920. constructor(x: number, y: number);
  5921. /**
  5922. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5923. * @param x the added points x value
  5924. * @param y the added points y value
  5925. * @returns the updated Path2.
  5926. */
  5927. addLineTo(x: number, y: number): Path2;
  5928. /**
  5929. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5930. * @param midX middle point x value
  5931. * @param midY middle point y value
  5932. * @param endX end point x value
  5933. * @param endY end point y value
  5934. * @param numberOfSegments (default: 36)
  5935. * @returns the updated Path2.
  5936. */
  5937. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5938. /**
  5939. * Closes the Path2.
  5940. * @returns the Path2.
  5941. */
  5942. close(): Path2;
  5943. /**
  5944. * Gets the sum of the distance between each sequential point in the path
  5945. * @returns the Path2 total length (float).
  5946. */
  5947. length(): number;
  5948. /**
  5949. * Gets the points which construct the path
  5950. * @returns the Path2 internal array of points.
  5951. */
  5952. getPoints(): Vector2[];
  5953. /**
  5954. * Retreives the point at the distance aways from the starting point
  5955. * @param normalizedLengthPosition the length along the path to retreive the point from
  5956. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5957. */
  5958. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5959. /**
  5960. * Creates a new path starting from an x and y position
  5961. * @param x starting x value
  5962. * @param y starting y value
  5963. * @returns a new Path2 starting at the coordinates (x, y).
  5964. */
  5965. static StartingAt(x: number, y: number): Path2;
  5966. }
  5967. /**
  5968. * Represents a 3D path made up of multiple 3D points
  5969. */
  5970. export class Path3D {
  5971. /**
  5972. * an array of Vector3, the curve axis of the Path3D
  5973. */
  5974. path: Vector3[];
  5975. private _curve;
  5976. private _distances;
  5977. private _tangents;
  5978. private _normals;
  5979. private _binormals;
  5980. private _raw;
  5981. /**
  5982. * new Path3D(path, normal, raw)
  5983. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5984. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5985. * @param path an array of Vector3, the curve axis of the Path3D
  5986. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5987. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5988. */
  5989. constructor(
  5990. /**
  5991. * an array of Vector3, the curve axis of the Path3D
  5992. */
  5993. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5994. /**
  5995. * Returns the Path3D array of successive Vector3 designing its curve.
  5996. * @returns the Path3D array of successive Vector3 designing its curve.
  5997. */
  5998. getCurve(): Vector3[];
  5999. /**
  6000. * Returns an array populated with tangent vectors on each Path3D curve point.
  6001. * @returns an array populated with tangent vectors on each Path3D curve point.
  6002. */
  6003. getTangents(): Vector3[];
  6004. /**
  6005. * Returns an array populated with normal vectors on each Path3D curve point.
  6006. * @returns an array populated with normal vectors on each Path3D curve point.
  6007. */
  6008. getNormals(): Vector3[];
  6009. /**
  6010. * Returns an array populated with binormal vectors on each Path3D curve point.
  6011. * @returns an array populated with binormal vectors on each Path3D curve point.
  6012. */
  6013. getBinormals(): Vector3[];
  6014. /**
  6015. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6016. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6017. */
  6018. getDistances(): number[];
  6019. /**
  6020. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6021. * @param path path which all values are copied into the curves points
  6022. * @param firstNormal which should be projected onto the curve
  6023. * @returns the same object updated.
  6024. */
  6025. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6026. private _compute;
  6027. private _getFirstNonNullVector;
  6028. private _getLastNonNullVector;
  6029. private _normalVector;
  6030. }
  6031. /**
  6032. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6033. * A Curve3 is designed from a series of successive Vector3.
  6034. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6035. */
  6036. export class Curve3 {
  6037. private _points;
  6038. private _length;
  6039. /**
  6040. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6041. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6042. * @param v1 (Vector3) the control point
  6043. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6044. * @param nbPoints (integer) the wanted number of points in the curve
  6045. * @returns the created Curve3
  6046. */
  6047. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6048. /**
  6049. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6050. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6051. * @param v1 (Vector3) the first control point
  6052. * @param v2 (Vector3) the second control point
  6053. * @param v3 (Vector3) the end point of the Cubic Bezier
  6054. * @param nbPoints (integer) the wanted number of points in the curve
  6055. * @returns the created Curve3
  6056. */
  6057. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6058. /**
  6059. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6060. * @param p1 (Vector3) the origin point of the Hermite Spline
  6061. * @param t1 (Vector3) the tangent vector at the origin point
  6062. * @param p2 (Vector3) the end point of the Hermite Spline
  6063. * @param t2 (Vector3) the tangent vector at the end point
  6064. * @param nbPoints (integer) the wanted number of points in the curve
  6065. * @returns the created Curve3
  6066. */
  6067. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6068. /**
  6069. * Returns a Curve3 object along a CatmullRom Spline curve :
  6070. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6071. * @param nbPoints (integer) the wanted number of points between each curve control points
  6072. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6073. * @returns the created Curve3
  6074. */
  6075. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6076. /**
  6077. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6078. * A Curve3 is designed from a series of successive Vector3.
  6079. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6080. * @param points points which make up the curve
  6081. */
  6082. constructor(points: Vector3[]);
  6083. /**
  6084. * @returns the Curve3 stored array of successive Vector3
  6085. */
  6086. getPoints(): Vector3[];
  6087. /**
  6088. * @returns the computed length (float) of the curve.
  6089. */
  6090. length(): number;
  6091. /**
  6092. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6093. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6094. * curveA and curveB keep unchanged.
  6095. * @param curve the curve to continue from this curve
  6096. * @returns the newly constructed curve
  6097. */
  6098. continue(curve: DeepImmutable<Curve3>): Curve3;
  6099. private _computeLength;
  6100. }
  6101. }
  6102. declare module "babylonjs/Animations/easing" {
  6103. /**
  6104. * This represents the main contract an easing function should follow.
  6105. * Easing functions are used throughout the animation system.
  6106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6107. */
  6108. export interface IEasingFunction {
  6109. /**
  6110. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6111. * of the easing function.
  6112. * The link below provides some of the most common examples of easing functions.
  6113. * @see https://easings.net/
  6114. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6115. * @returns the corresponding value on the curve defined by the easing function
  6116. */
  6117. ease(gradient: number): number;
  6118. }
  6119. /**
  6120. * Base class used for every default easing function.
  6121. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6122. */
  6123. export class EasingFunction implements IEasingFunction {
  6124. /**
  6125. * Interpolation follows the mathematical formula associated with the easing function.
  6126. */
  6127. static readonly EASINGMODE_EASEIN: number;
  6128. /**
  6129. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6130. */
  6131. static readonly EASINGMODE_EASEOUT: number;
  6132. /**
  6133. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6134. */
  6135. static readonly EASINGMODE_EASEINOUT: number;
  6136. private _easingMode;
  6137. /**
  6138. * Sets the easing mode of the current function.
  6139. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6140. */
  6141. setEasingMode(easingMode: number): void;
  6142. /**
  6143. * Gets the current easing mode.
  6144. * @returns the easing mode
  6145. */
  6146. getEasingMode(): number;
  6147. /**
  6148. * @hidden
  6149. */
  6150. easeInCore(gradient: number): number;
  6151. /**
  6152. * Given an input gradient between 0 and 1, this returns the corresponding value
  6153. * of the easing function.
  6154. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6155. * @returns the corresponding value on the curve defined by the easing function
  6156. */
  6157. ease(gradient: number): number;
  6158. }
  6159. /**
  6160. * Easing function with a circle shape (see link below).
  6161. * @see https://easings.net/#easeInCirc
  6162. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6163. */
  6164. export class CircleEase extends EasingFunction implements IEasingFunction {
  6165. /** @hidden */
  6166. easeInCore(gradient: number): number;
  6167. }
  6168. /**
  6169. * Easing function with a ease back shape (see link below).
  6170. * @see https://easings.net/#easeInBack
  6171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6172. */
  6173. export class BackEase extends EasingFunction implements IEasingFunction {
  6174. /** Defines the amplitude of the function */
  6175. amplitude: number;
  6176. /**
  6177. * Instantiates a back ease easing
  6178. * @see https://easings.net/#easeInBack
  6179. * @param amplitude Defines the amplitude of the function
  6180. */
  6181. constructor(
  6182. /** Defines the amplitude of the function */
  6183. amplitude?: number);
  6184. /** @hidden */
  6185. easeInCore(gradient: number): number;
  6186. }
  6187. /**
  6188. * Easing function with a bouncing shape (see link below).
  6189. * @see https://easings.net/#easeInBounce
  6190. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6191. */
  6192. export class BounceEase extends EasingFunction implements IEasingFunction {
  6193. /** Defines the number of bounces */
  6194. bounces: number;
  6195. /** Defines the amplitude of the bounce */
  6196. bounciness: number;
  6197. /**
  6198. * Instantiates a bounce easing
  6199. * @see https://easings.net/#easeInBounce
  6200. * @param bounces Defines the number of bounces
  6201. * @param bounciness Defines the amplitude of the bounce
  6202. */
  6203. constructor(
  6204. /** Defines the number of bounces */
  6205. bounces?: number,
  6206. /** Defines the amplitude of the bounce */
  6207. bounciness?: number);
  6208. /** @hidden */
  6209. easeInCore(gradient: number): number;
  6210. }
  6211. /**
  6212. * Easing function with a power of 3 shape (see link below).
  6213. * @see https://easings.net/#easeInCubic
  6214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6215. */
  6216. export class CubicEase extends EasingFunction implements IEasingFunction {
  6217. /** @hidden */
  6218. easeInCore(gradient: number): number;
  6219. }
  6220. /**
  6221. * Easing function with an elastic shape (see link below).
  6222. * @see https://easings.net/#easeInElastic
  6223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6224. */
  6225. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6226. /** Defines the number of oscillations*/
  6227. oscillations: number;
  6228. /** Defines the amplitude of the oscillations*/
  6229. springiness: number;
  6230. /**
  6231. * Instantiates an elastic easing function
  6232. * @see https://easings.net/#easeInElastic
  6233. * @param oscillations Defines the number of oscillations
  6234. * @param springiness Defines the amplitude of the oscillations
  6235. */
  6236. constructor(
  6237. /** Defines the number of oscillations*/
  6238. oscillations?: number,
  6239. /** Defines the amplitude of the oscillations*/
  6240. springiness?: number);
  6241. /** @hidden */
  6242. easeInCore(gradient: number): number;
  6243. }
  6244. /**
  6245. * Easing function with an exponential shape (see link below).
  6246. * @see https://easings.net/#easeInExpo
  6247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6248. */
  6249. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6250. /** Defines the exponent of the function */
  6251. exponent: number;
  6252. /**
  6253. * Instantiates an exponential easing function
  6254. * @see https://easings.net/#easeInExpo
  6255. * @param exponent Defines the exponent of the function
  6256. */
  6257. constructor(
  6258. /** Defines the exponent of the function */
  6259. exponent?: number);
  6260. /** @hidden */
  6261. easeInCore(gradient: number): number;
  6262. }
  6263. /**
  6264. * Easing function with a power shape (see link below).
  6265. * @see https://easings.net/#easeInQuad
  6266. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6267. */
  6268. export class PowerEase extends EasingFunction implements IEasingFunction {
  6269. /** Defines the power of the function */
  6270. power: number;
  6271. /**
  6272. * Instantiates an power base easing function
  6273. * @see https://easings.net/#easeInQuad
  6274. * @param power Defines the power of the function
  6275. */
  6276. constructor(
  6277. /** Defines the power of the function */
  6278. power?: number);
  6279. /** @hidden */
  6280. easeInCore(gradient: number): number;
  6281. }
  6282. /**
  6283. * Easing function with a power of 2 shape (see link below).
  6284. * @see https://easings.net/#easeInQuad
  6285. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6286. */
  6287. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6288. /** @hidden */
  6289. easeInCore(gradient: number): number;
  6290. }
  6291. /**
  6292. * Easing function with a power of 4 shape (see link below).
  6293. * @see https://easings.net/#easeInQuart
  6294. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6295. */
  6296. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6297. /** @hidden */
  6298. easeInCore(gradient: number): number;
  6299. }
  6300. /**
  6301. * Easing function with a power of 5 shape (see link below).
  6302. * @see https://easings.net/#easeInQuint
  6303. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6304. */
  6305. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6306. /** @hidden */
  6307. easeInCore(gradient: number): number;
  6308. }
  6309. /**
  6310. * Easing function with a sin shape (see link below).
  6311. * @see https://easings.net/#easeInSine
  6312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6313. */
  6314. export class SineEase extends EasingFunction implements IEasingFunction {
  6315. /** @hidden */
  6316. easeInCore(gradient: number): number;
  6317. }
  6318. /**
  6319. * Easing function with a bezier shape (see link below).
  6320. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6321. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6322. */
  6323. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6324. /** Defines the x component of the start tangent in the bezier curve */
  6325. x1: number;
  6326. /** Defines the y component of the start tangent in the bezier curve */
  6327. y1: number;
  6328. /** Defines the x component of the end tangent in the bezier curve */
  6329. x2: number;
  6330. /** Defines the y component of the end tangent in the bezier curve */
  6331. y2: number;
  6332. /**
  6333. * Instantiates a bezier function
  6334. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6335. * @param x1 Defines the x component of the start tangent in the bezier curve
  6336. * @param y1 Defines the y component of the start tangent in the bezier curve
  6337. * @param x2 Defines the x component of the end tangent in the bezier curve
  6338. * @param y2 Defines the y component of the end tangent in the bezier curve
  6339. */
  6340. constructor(
  6341. /** Defines the x component of the start tangent in the bezier curve */
  6342. x1?: number,
  6343. /** Defines the y component of the start tangent in the bezier curve */
  6344. y1?: number,
  6345. /** Defines the x component of the end tangent in the bezier curve */
  6346. x2?: number,
  6347. /** Defines the y component of the end tangent in the bezier curve */
  6348. y2?: number);
  6349. /** @hidden */
  6350. easeInCore(gradient: number): number;
  6351. }
  6352. }
  6353. declare module "babylonjs/Animations/animationKey" {
  6354. /**
  6355. * Defines an interface which represents an animation key frame
  6356. */
  6357. export interface IAnimationKey {
  6358. /**
  6359. * Frame of the key frame
  6360. */
  6361. frame: number;
  6362. /**
  6363. * Value at the specifies key frame
  6364. */
  6365. value: any;
  6366. /**
  6367. * The input tangent for the cubic hermite spline
  6368. */
  6369. inTangent?: any;
  6370. /**
  6371. * The output tangent for the cubic hermite spline
  6372. */
  6373. outTangent?: any;
  6374. /**
  6375. * The animation interpolation type
  6376. */
  6377. interpolation?: AnimationKeyInterpolation;
  6378. }
  6379. /**
  6380. * Enum for the animation key frame interpolation type
  6381. */
  6382. export enum AnimationKeyInterpolation {
  6383. /**
  6384. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6385. */
  6386. STEP = 1
  6387. }
  6388. }
  6389. declare module "babylonjs/Animations/animationRange" {
  6390. /**
  6391. * Represents the range of an animation
  6392. */
  6393. export class AnimationRange {
  6394. /**The name of the animation range**/
  6395. name: string;
  6396. /**The starting frame of the animation */
  6397. from: number;
  6398. /**The ending frame of the animation*/
  6399. to: number;
  6400. /**
  6401. * Initializes the range of an animation
  6402. * @param name The name of the animation range
  6403. * @param from The starting frame of the animation
  6404. * @param to The ending frame of the animation
  6405. */
  6406. constructor(
  6407. /**The name of the animation range**/
  6408. name: string,
  6409. /**The starting frame of the animation */
  6410. from: number,
  6411. /**The ending frame of the animation*/
  6412. to: number);
  6413. /**
  6414. * Makes a copy of the animation range
  6415. * @returns A copy of the animation range
  6416. */
  6417. clone(): AnimationRange;
  6418. }
  6419. }
  6420. declare module "babylonjs/Animations/animationEvent" {
  6421. /**
  6422. * Composed of a frame, and an action function
  6423. */
  6424. export class AnimationEvent {
  6425. /** The frame for which the event is triggered **/
  6426. frame: number;
  6427. /** The event to perform when triggered **/
  6428. action: (currentFrame: number) => void;
  6429. /** Specifies if the event should be triggered only once**/
  6430. onlyOnce?: boolean | undefined;
  6431. /**
  6432. * Specifies if the animation event is done
  6433. */
  6434. isDone: boolean;
  6435. /**
  6436. * Initializes the animation event
  6437. * @param frame The frame for which the event is triggered
  6438. * @param action The event to perform when triggered
  6439. * @param onlyOnce Specifies if the event should be triggered only once
  6440. */
  6441. constructor(
  6442. /** The frame for which the event is triggered **/
  6443. frame: number,
  6444. /** The event to perform when triggered **/
  6445. action: (currentFrame: number) => void,
  6446. /** Specifies if the event should be triggered only once**/
  6447. onlyOnce?: boolean | undefined);
  6448. /** @hidden */
  6449. _clone(): AnimationEvent;
  6450. }
  6451. }
  6452. declare module "babylonjs/Behaviors/behavior" {
  6453. import { Nullable } from "babylonjs/types";
  6454. /**
  6455. * Interface used to define a behavior
  6456. */
  6457. export interface Behavior<T> {
  6458. /** gets or sets behavior's name */
  6459. name: string;
  6460. /**
  6461. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6462. */
  6463. init(): void;
  6464. /**
  6465. * Called when the behavior is attached to a target
  6466. * @param target defines the target where the behavior is attached to
  6467. */
  6468. attach(target: T): void;
  6469. /**
  6470. * Called when the behavior is detached from its target
  6471. */
  6472. detach(): void;
  6473. }
  6474. /**
  6475. * Interface implemented by classes supporting behaviors
  6476. */
  6477. export interface IBehaviorAware<T> {
  6478. /**
  6479. * Attach a behavior
  6480. * @param behavior defines the behavior to attach
  6481. * @returns the current host
  6482. */
  6483. addBehavior(behavior: Behavior<T>): T;
  6484. /**
  6485. * Remove a behavior from the current object
  6486. * @param behavior defines the behavior to detach
  6487. * @returns the current host
  6488. */
  6489. removeBehavior(behavior: Behavior<T>): T;
  6490. /**
  6491. * Gets a behavior using its name to search
  6492. * @param name defines the name to search
  6493. * @returns the behavior or null if not found
  6494. */
  6495. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6496. }
  6497. }
  6498. declare module "babylonjs/Misc/smartArray" {
  6499. /**
  6500. * Defines an array and its length.
  6501. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6502. */
  6503. export interface ISmartArrayLike<T> {
  6504. /**
  6505. * The data of the array.
  6506. */
  6507. data: Array<T>;
  6508. /**
  6509. * The active length of the array.
  6510. */
  6511. length: number;
  6512. }
  6513. /**
  6514. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6515. */
  6516. export class SmartArray<T> implements ISmartArrayLike<T> {
  6517. /**
  6518. * The full set of data from the array.
  6519. */
  6520. data: Array<T>;
  6521. /**
  6522. * The active length of the array.
  6523. */
  6524. length: number;
  6525. protected _id: number;
  6526. /**
  6527. * Instantiates a Smart Array.
  6528. * @param capacity defines the default capacity of the array.
  6529. */
  6530. constructor(capacity: number);
  6531. /**
  6532. * Pushes a value at the end of the active data.
  6533. * @param value defines the object to push in the array.
  6534. */
  6535. push(value: T): void;
  6536. /**
  6537. * Iterates over the active data and apply the lambda to them.
  6538. * @param func defines the action to apply on each value.
  6539. */
  6540. forEach(func: (content: T) => void): void;
  6541. /**
  6542. * Sorts the full sets of data.
  6543. * @param compareFn defines the comparison function to apply.
  6544. */
  6545. sort(compareFn: (a: T, b: T) => number): void;
  6546. /**
  6547. * Resets the active data to an empty array.
  6548. */
  6549. reset(): void;
  6550. /**
  6551. * Releases all the data from the array as well as the array.
  6552. */
  6553. dispose(): void;
  6554. /**
  6555. * Concats the active data with a given array.
  6556. * @param array defines the data to concatenate with.
  6557. */
  6558. concat(array: any): void;
  6559. /**
  6560. * Returns the position of a value in the active data.
  6561. * @param value defines the value to find the index for
  6562. * @returns the index if found in the active data otherwise -1
  6563. */
  6564. indexOf(value: T): number;
  6565. /**
  6566. * Returns whether an element is part of the active data.
  6567. * @param value defines the value to look for
  6568. * @returns true if found in the active data otherwise false
  6569. */
  6570. contains(value: T): boolean;
  6571. private static _GlobalId;
  6572. }
  6573. /**
  6574. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6575. * The data in this array can only be present once
  6576. */
  6577. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6578. private _duplicateId;
  6579. /**
  6580. * Pushes a value at the end of the active data.
  6581. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6582. * @param value defines the object to push in the array.
  6583. */
  6584. push(value: T): void;
  6585. /**
  6586. * Pushes a value at the end of the active data.
  6587. * If the data is already present, it won t be added again
  6588. * @param value defines the object to push in the array.
  6589. * @returns true if added false if it was already present
  6590. */
  6591. pushNoDuplicate(value: T): boolean;
  6592. /**
  6593. * Resets the active data to an empty array.
  6594. */
  6595. reset(): void;
  6596. /**
  6597. * Concats the active data with a given array.
  6598. * This ensures no dupplicate will be present in the result.
  6599. * @param array defines the data to concatenate with.
  6600. */
  6601. concatWithNoDuplicate(array: any): void;
  6602. }
  6603. }
  6604. declare module "babylonjs/Cameras/cameraInputsManager" {
  6605. import { Nullable } from "babylonjs/types";
  6606. import { Camera } from "babylonjs/Cameras/camera";
  6607. /**
  6608. * @ignore
  6609. * This is a list of all the different input types that are available in the application.
  6610. * Fo instance: ArcRotateCameraGamepadInput...
  6611. */
  6612. export var CameraInputTypes: {};
  6613. /**
  6614. * This is the contract to implement in order to create a new input class.
  6615. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6616. */
  6617. export interface ICameraInput<TCamera extends Camera> {
  6618. /**
  6619. * Defines the camera the input is attached to.
  6620. */
  6621. camera: Nullable<TCamera>;
  6622. /**
  6623. * Gets the class name of the current intput.
  6624. * @returns the class name
  6625. */
  6626. getClassName(): string;
  6627. /**
  6628. * Get the friendly name associated with the input class.
  6629. * @returns the input friendly name
  6630. */
  6631. getSimpleName(): string;
  6632. /**
  6633. * Attach the input controls to a specific dom element to get the input from.
  6634. * @param element Defines the element the controls should be listened from
  6635. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6636. */
  6637. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6638. /**
  6639. * Detach the current controls from the specified dom element.
  6640. * @param element Defines the element to stop listening the inputs from
  6641. */
  6642. detachControl(element: Nullable<HTMLElement>): void;
  6643. /**
  6644. * Update the current camera state depending on the inputs that have been used this frame.
  6645. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6646. */
  6647. checkInputs?: () => void;
  6648. }
  6649. /**
  6650. * Represents a map of input types to input instance or input index to input instance.
  6651. */
  6652. export interface CameraInputsMap<TCamera extends Camera> {
  6653. /**
  6654. * Accessor to the input by input type.
  6655. */
  6656. [name: string]: ICameraInput<TCamera>;
  6657. /**
  6658. * Accessor to the input by input index.
  6659. */
  6660. [idx: number]: ICameraInput<TCamera>;
  6661. }
  6662. /**
  6663. * This represents the input manager used within a camera.
  6664. * It helps dealing with all the different kind of input attached to a camera.
  6665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6666. */
  6667. export class CameraInputsManager<TCamera extends Camera> {
  6668. /**
  6669. * Defines the list of inputs attahed to the camera.
  6670. */
  6671. attached: CameraInputsMap<TCamera>;
  6672. /**
  6673. * Defines the dom element the camera is collecting inputs from.
  6674. * This is null if the controls have not been attached.
  6675. */
  6676. attachedElement: Nullable<HTMLElement>;
  6677. /**
  6678. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6679. */
  6680. noPreventDefault: boolean;
  6681. /**
  6682. * Defined the camera the input manager belongs to.
  6683. */
  6684. camera: TCamera;
  6685. /**
  6686. * Update the current camera state depending on the inputs that have been used this frame.
  6687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6688. */
  6689. checkInputs: () => void;
  6690. /**
  6691. * Instantiate a new Camera Input Manager.
  6692. * @param camera Defines the camera the input manager blongs to
  6693. */
  6694. constructor(camera: TCamera);
  6695. /**
  6696. * Add an input method to a camera
  6697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6698. * @param input camera input method
  6699. */
  6700. add(input: ICameraInput<TCamera>): void;
  6701. /**
  6702. * Remove a specific input method from a camera
  6703. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6704. * @param inputToRemove camera input method
  6705. */
  6706. remove(inputToRemove: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Remove a specific input type from a camera
  6709. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6710. * @param inputType the type of the input to remove
  6711. */
  6712. removeByType(inputType: string): void;
  6713. private _addCheckInputs;
  6714. /**
  6715. * Attach the input controls to the currently attached dom element to listen the events from.
  6716. * @param input Defines the input to attach
  6717. */
  6718. attachInput(input: ICameraInput<TCamera>): void;
  6719. /**
  6720. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6721. * @param element Defines the dom element to collect the events from
  6722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6723. */
  6724. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6725. /**
  6726. * Detach the current manager inputs controls from a specific dom element.
  6727. * @param element Defines the dom element to collect the events from
  6728. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6729. */
  6730. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6731. /**
  6732. * Rebuild the dynamic inputCheck function from the current list of
  6733. * defined inputs in the manager.
  6734. */
  6735. rebuildInputCheck(): void;
  6736. /**
  6737. * Remove all attached input methods from a camera
  6738. */
  6739. clear(): void;
  6740. /**
  6741. * Serialize the current input manager attached to a camera.
  6742. * This ensures than once parsed,
  6743. * the input associated to the camera will be identical to the current ones
  6744. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6745. */
  6746. serialize(serializedCamera: any): void;
  6747. /**
  6748. * Parses an input manager serialized JSON to restore the previous list of inputs
  6749. * and states associated to a camera.
  6750. * @param parsedCamera Defines the JSON to parse
  6751. */
  6752. parse(parsedCamera: any): void;
  6753. }
  6754. }
  6755. declare module "babylonjs/Collisions/intersectionInfo" {
  6756. import { Nullable } from "babylonjs/types";
  6757. /**
  6758. * @hidden
  6759. */
  6760. export class IntersectionInfo {
  6761. bu: Nullable<number>;
  6762. bv: Nullable<number>;
  6763. distance: number;
  6764. faceId: number;
  6765. subMeshId: number;
  6766. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6767. }
  6768. }
  6769. declare module "babylonjs/Maths/math.plane" {
  6770. import { DeepImmutable } from "babylonjs/types";
  6771. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6772. /**
  6773. * Represens a plane by the equation ax + by + cz + d = 0
  6774. */
  6775. export class Plane {
  6776. private static _TmpMatrix;
  6777. /**
  6778. * Normal of the plane (a,b,c)
  6779. */
  6780. normal: Vector3;
  6781. /**
  6782. * d component of the plane
  6783. */
  6784. d: number;
  6785. /**
  6786. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6787. * @param a a component of the plane
  6788. * @param b b component of the plane
  6789. * @param c c component of the plane
  6790. * @param d d component of the plane
  6791. */
  6792. constructor(a: number, b: number, c: number, d: number);
  6793. /**
  6794. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6795. */
  6796. asArray(): number[];
  6797. /**
  6798. * @returns a new plane copied from the current Plane.
  6799. */
  6800. clone(): Plane;
  6801. /**
  6802. * @returns the string "Plane".
  6803. */
  6804. getClassName(): string;
  6805. /**
  6806. * @returns the Plane hash code.
  6807. */
  6808. getHashCode(): number;
  6809. /**
  6810. * Normalize the current Plane in place.
  6811. * @returns the updated Plane.
  6812. */
  6813. normalize(): Plane;
  6814. /**
  6815. * Applies a transformation the plane and returns the result
  6816. * @param transformation the transformation matrix to be applied to the plane
  6817. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6818. */
  6819. transform(transformation: DeepImmutable<Matrix>): Plane;
  6820. /**
  6821. * Calcualtte the dot product between the point and the plane normal
  6822. * @param point point to calculate the dot product with
  6823. * @returns the dot product (float) of the point coordinates and the plane normal.
  6824. */
  6825. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6826. /**
  6827. * Updates the current Plane from the plane defined by the three given points.
  6828. * @param point1 one of the points used to contruct the plane
  6829. * @param point2 one of the points used to contruct the plane
  6830. * @param point3 one of the points used to contruct the plane
  6831. * @returns the updated Plane.
  6832. */
  6833. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6834. /**
  6835. * Checks if the plane is facing a given direction
  6836. * @param direction the direction to check if the plane is facing
  6837. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6838. * @returns True is the vector "direction" is the same side than the plane normal.
  6839. */
  6840. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6841. /**
  6842. * Calculates the distance to a point
  6843. * @param point point to calculate distance to
  6844. * @returns the signed distance (float) from the given point to the Plane.
  6845. */
  6846. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6847. /**
  6848. * Creates a plane from an array
  6849. * @param array the array to create a plane from
  6850. * @returns a new Plane from the given array.
  6851. */
  6852. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6853. /**
  6854. * Creates a plane from three points
  6855. * @param point1 point used to create the plane
  6856. * @param point2 point used to create the plane
  6857. * @param point3 point used to create the plane
  6858. * @returns a new Plane defined by the three given points.
  6859. */
  6860. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6861. /**
  6862. * Creates a plane from an origin point and a normal
  6863. * @param origin origin of the plane to be constructed
  6864. * @param normal normal of the plane to be constructed
  6865. * @returns a new Plane the normal vector to this plane at the given origin point.
  6866. * Note : the vector "normal" is updated because normalized.
  6867. */
  6868. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6869. /**
  6870. * Calculates the distance from a plane and a point
  6871. * @param origin origin of the plane to be constructed
  6872. * @param normal normal of the plane to be constructed
  6873. * @param point point to calculate distance to
  6874. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6875. */
  6876. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6877. }
  6878. }
  6879. declare module "babylonjs/Culling/boundingSphere" {
  6880. import { DeepImmutable } from "babylonjs/types";
  6881. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6882. import { Plane } from "babylonjs/Maths/math.plane";
  6883. /**
  6884. * Class used to store bounding sphere information
  6885. */
  6886. export class BoundingSphere {
  6887. /**
  6888. * Gets the center of the bounding sphere in local space
  6889. */
  6890. readonly center: Vector3;
  6891. /**
  6892. * Radius of the bounding sphere in local space
  6893. */
  6894. radius: number;
  6895. /**
  6896. * Gets the center of the bounding sphere in world space
  6897. */
  6898. readonly centerWorld: Vector3;
  6899. /**
  6900. * Radius of the bounding sphere in world space
  6901. */
  6902. radiusWorld: number;
  6903. /**
  6904. * Gets the minimum vector in local space
  6905. */
  6906. readonly minimum: Vector3;
  6907. /**
  6908. * Gets the maximum vector in local space
  6909. */
  6910. readonly maximum: Vector3;
  6911. private _worldMatrix;
  6912. private static readonly TmpVector3;
  6913. /**
  6914. * Creates a new bounding sphere
  6915. * @param min defines the minimum vector (in local space)
  6916. * @param max defines the maximum vector (in local space)
  6917. * @param worldMatrix defines the new world matrix
  6918. */
  6919. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6920. /**
  6921. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6922. * @param min defines the new minimum vector (in local space)
  6923. * @param max defines the new maximum vector (in local space)
  6924. * @param worldMatrix defines the new world matrix
  6925. */
  6926. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6927. /**
  6928. * Scale the current bounding sphere by applying a scale factor
  6929. * @param factor defines the scale factor to apply
  6930. * @returns the current bounding box
  6931. */
  6932. scale(factor: number): BoundingSphere;
  6933. /**
  6934. * Gets the world matrix of the bounding box
  6935. * @returns a matrix
  6936. */
  6937. getWorldMatrix(): DeepImmutable<Matrix>;
  6938. /** @hidden */
  6939. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6940. /**
  6941. * Tests if the bounding sphere is intersecting the frustum planes
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @returns true if there is an intersection
  6944. */
  6945. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. /**
  6947. * Tests if the bounding sphere center is in between the frustum planes.
  6948. * Used for optimistic fast inclusion.
  6949. * @param frustumPlanes defines the frustum planes to test
  6950. * @returns true if the sphere center is in between the frustum planes
  6951. */
  6952. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6953. /**
  6954. * Tests if a point is inside the bounding sphere
  6955. * @param point defines the point to test
  6956. * @returns true if the point is inside the bounding sphere
  6957. */
  6958. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6959. /**
  6960. * Checks if two sphere intersct
  6961. * @param sphere0 sphere 0
  6962. * @param sphere1 sphere 1
  6963. * @returns true if the speres intersect
  6964. */
  6965. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6966. }
  6967. }
  6968. declare module "babylonjs/Culling/boundingBox" {
  6969. import { DeepImmutable } from "babylonjs/types";
  6970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6971. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6972. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6973. import { Plane } from "babylonjs/Maths/math.plane";
  6974. /**
  6975. * Class used to store bounding box information
  6976. */
  6977. export class BoundingBox implements ICullable {
  6978. /**
  6979. * Gets the 8 vectors representing the bounding box in local space
  6980. */
  6981. readonly vectors: Vector3[];
  6982. /**
  6983. * Gets the center of the bounding box in local space
  6984. */
  6985. readonly center: Vector3;
  6986. /**
  6987. * Gets the center of the bounding box in world space
  6988. */
  6989. readonly centerWorld: Vector3;
  6990. /**
  6991. * Gets the extend size in local space
  6992. */
  6993. readonly extendSize: Vector3;
  6994. /**
  6995. * Gets the extend size in world space
  6996. */
  6997. readonly extendSizeWorld: Vector3;
  6998. /**
  6999. * Gets the OBB (object bounding box) directions
  7000. */
  7001. readonly directions: Vector3[];
  7002. /**
  7003. * Gets the 8 vectors representing the bounding box in world space
  7004. */
  7005. readonly vectorsWorld: Vector3[];
  7006. /**
  7007. * Gets the minimum vector in world space
  7008. */
  7009. readonly minimumWorld: Vector3;
  7010. /**
  7011. * Gets the maximum vector in world space
  7012. */
  7013. readonly maximumWorld: Vector3;
  7014. /**
  7015. * Gets the minimum vector in local space
  7016. */
  7017. readonly minimum: Vector3;
  7018. /**
  7019. * Gets the maximum vector in local space
  7020. */
  7021. readonly maximum: Vector3;
  7022. private _worldMatrix;
  7023. private static readonly TmpVector3;
  7024. /**
  7025. * @hidden
  7026. */
  7027. _tag: number;
  7028. /**
  7029. * Creates a new bounding box
  7030. * @param min defines the minimum vector (in local space)
  7031. * @param max defines the maximum vector (in local space)
  7032. * @param worldMatrix defines the new world matrix
  7033. */
  7034. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7035. /**
  7036. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7037. * @param min defines the new minimum vector (in local space)
  7038. * @param max defines the new maximum vector (in local space)
  7039. * @param worldMatrix defines the new world matrix
  7040. */
  7041. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7042. /**
  7043. * Scale the current bounding box by applying a scale factor
  7044. * @param factor defines the scale factor to apply
  7045. * @returns the current bounding box
  7046. */
  7047. scale(factor: number): BoundingBox;
  7048. /**
  7049. * Gets the world matrix of the bounding box
  7050. * @returns a matrix
  7051. */
  7052. getWorldMatrix(): DeepImmutable<Matrix>;
  7053. /** @hidden */
  7054. _update(world: DeepImmutable<Matrix>): void;
  7055. /**
  7056. * Tests if the bounding box is intersecting the frustum planes
  7057. * @param frustumPlanes defines the frustum planes to test
  7058. * @returns true if there is an intersection
  7059. */
  7060. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7061. /**
  7062. * Tests if the bounding box is entirely inside the frustum planes
  7063. * @param frustumPlanes defines the frustum planes to test
  7064. * @returns true if there is an inclusion
  7065. */
  7066. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7067. /**
  7068. * Tests if a point is inside the bounding box
  7069. * @param point defines the point to test
  7070. * @returns true if the point is inside the bounding box
  7071. */
  7072. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7073. /**
  7074. * Tests if the bounding box intersects with a bounding sphere
  7075. * @param sphere defines the sphere to test
  7076. * @returns true if there is an intersection
  7077. */
  7078. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7079. /**
  7080. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7081. * @param min defines the min vector to use
  7082. * @param max defines the max vector to use
  7083. * @returns true if there is an intersection
  7084. */
  7085. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7086. /**
  7087. * Tests if two bounding boxes are intersections
  7088. * @param box0 defines the first box to test
  7089. * @param box1 defines the second box to test
  7090. * @returns true if there is an intersection
  7091. */
  7092. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7093. /**
  7094. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7095. * @param minPoint defines the minimum vector of the bounding box
  7096. * @param maxPoint defines the maximum vector of the bounding box
  7097. * @param sphereCenter defines the sphere center
  7098. * @param sphereRadius defines the sphere radius
  7099. * @returns true if there is an intersection
  7100. */
  7101. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7102. /**
  7103. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7104. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7105. * @param frustumPlanes defines the frustum planes to test
  7106. * @return true if there is an inclusion
  7107. */
  7108. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7109. /**
  7110. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7111. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7112. * @param frustumPlanes defines the frustum planes to test
  7113. * @return true if there is an intersection
  7114. */
  7115. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7116. }
  7117. }
  7118. declare module "babylonjs/Collisions/collider" {
  7119. import { Nullable, IndicesArray } from "babylonjs/types";
  7120. import { Vector3 } from "babylonjs/Maths/math.vector";
  7121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7122. import { Plane } from "babylonjs/Maths/math.plane";
  7123. /** @hidden */
  7124. export class Collider {
  7125. /** Define if a collision was found */
  7126. collisionFound: boolean;
  7127. /**
  7128. * Define last intersection point in local space
  7129. */
  7130. intersectionPoint: Vector3;
  7131. /**
  7132. * Define last collided mesh
  7133. */
  7134. collidedMesh: Nullable<AbstractMesh>;
  7135. private _collisionPoint;
  7136. private _planeIntersectionPoint;
  7137. private _tempVector;
  7138. private _tempVector2;
  7139. private _tempVector3;
  7140. private _tempVector4;
  7141. private _edge;
  7142. private _baseToVertex;
  7143. private _destinationPoint;
  7144. private _slidePlaneNormal;
  7145. private _displacementVector;
  7146. /** @hidden */
  7147. _radius: Vector3;
  7148. /** @hidden */
  7149. _retry: number;
  7150. private _velocity;
  7151. private _basePoint;
  7152. private _epsilon;
  7153. /** @hidden */
  7154. _velocityWorldLength: number;
  7155. /** @hidden */
  7156. _basePointWorld: Vector3;
  7157. private _velocityWorld;
  7158. private _normalizedVelocity;
  7159. /** @hidden */
  7160. _initialVelocity: Vector3;
  7161. /** @hidden */
  7162. _initialPosition: Vector3;
  7163. private _nearestDistance;
  7164. private _collisionMask;
  7165. collisionMask: number;
  7166. /**
  7167. * Gets the plane normal used to compute the sliding response (in local space)
  7168. */
  7169. readonly slidePlaneNormal: Vector3;
  7170. /** @hidden */
  7171. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7172. /** @hidden */
  7173. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7174. /** @hidden */
  7175. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7176. /** @hidden */
  7177. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7178. /** @hidden */
  7179. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7180. /** @hidden */
  7181. _getResponse(pos: Vector3, vel: Vector3): void;
  7182. }
  7183. }
  7184. declare module "babylonjs/Culling/boundingInfo" {
  7185. import { DeepImmutable } from "babylonjs/types";
  7186. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7187. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7188. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7189. import { Plane } from "babylonjs/Maths/math.plane";
  7190. import { Collider } from "babylonjs/Collisions/collider";
  7191. /**
  7192. * Interface for cullable objects
  7193. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7194. */
  7195. export interface ICullable {
  7196. /**
  7197. * Checks if the object or part of the object is in the frustum
  7198. * @param frustumPlanes Camera near/planes
  7199. * @returns true if the object is in frustum otherwise false
  7200. */
  7201. isInFrustum(frustumPlanes: Plane[]): boolean;
  7202. /**
  7203. * Checks if a cullable object (mesh...) is in the camera frustum
  7204. * Unlike isInFrustum this cheks the full bounding box
  7205. * @param frustumPlanes Camera near/planes
  7206. * @returns true if the object is in frustum otherwise false
  7207. */
  7208. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7209. }
  7210. /**
  7211. * Info for a bounding data of a mesh
  7212. */
  7213. export class BoundingInfo implements ICullable {
  7214. /**
  7215. * Bounding box for the mesh
  7216. */
  7217. readonly boundingBox: BoundingBox;
  7218. /**
  7219. * Bounding sphere for the mesh
  7220. */
  7221. readonly boundingSphere: BoundingSphere;
  7222. private _isLocked;
  7223. private static readonly TmpVector3;
  7224. /**
  7225. * Constructs bounding info
  7226. * @param minimum min vector of the bounding box/sphere
  7227. * @param maximum max vector of the bounding box/sphere
  7228. * @param worldMatrix defines the new world matrix
  7229. */
  7230. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7231. /**
  7232. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7233. * @param min defines the new minimum vector (in local space)
  7234. * @param max defines the new maximum vector (in local space)
  7235. * @param worldMatrix defines the new world matrix
  7236. */
  7237. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7238. /**
  7239. * min vector of the bounding box/sphere
  7240. */
  7241. readonly minimum: Vector3;
  7242. /**
  7243. * max vector of the bounding box/sphere
  7244. */
  7245. readonly maximum: Vector3;
  7246. /**
  7247. * If the info is locked and won't be updated to avoid perf overhead
  7248. */
  7249. isLocked: boolean;
  7250. /**
  7251. * Updates the bounding sphere and box
  7252. * @param world world matrix to be used to update
  7253. */
  7254. update(world: DeepImmutable<Matrix>): void;
  7255. /**
  7256. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7257. * @param center New center of the bounding info
  7258. * @param extend New extend of the bounding info
  7259. * @returns the current bounding info
  7260. */
  7261. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7262. /**
  7263. * Scale the current bounding info by applying a scale factor
  7264. * @param factor defines the scale factor to apply
  7265. * @returns the current bounding info
  7266. */
  7267. scale(factor: number): BoundingInfo;
  7268. /**
  7269. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7270. * @param frustumPlanes defines the frustum to test
  7271. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7272. * @returns true if the bounding info is in the frustum planes
  7273. */
  7274. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7275. /**
  7276. * Gets the world distance between the min and max points of the bounding box
  7277. */
  7278. readonly diagonalLength: number;
  7279. /**
  7280. * Checks if a cullable object (mesh...) is in the camera frustum
  7281. * Unlike isInFrustum this cheks the full bounding box
  7282. * @param frustumPlanes Camera near/planes
  7283. * @returns true if the object is in frustum otherwise false
  7284. */
  7285. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7286. /** @hidden */
  7287. _checkCollision(collider: Collider): boolean;
  7288. /**
  7289. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7290. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7291. * @param point the point to check intersection with
  7292. * @returns if the point intersects
  7293. */
  7294. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7295. /**
  7296. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7297. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7298. * @param boundingInfo the bounding info to check intersection with
  7299. * @param precise if the intersection should be done using OBB
  7300. * @returns if the bounding info intersects
  7301. */
  7302. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7303. }
  7304. }
  7305. declare module "babylonjs/Maths/math.functions" {
  7306. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7307. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7308. /**
  7309. * Extracts minimum and maximum values from a list of indexed positions
  7310. * @param positions defines the positions to use
  7311. * @param indices defines the indices to the positions
  7312. * @param indexStart defines the start index
  7313. * @param indexCount defines the end index
  7314. * @param bias defines bias value to add to the result
  7315. * @return minimum and maximum values
  7316. */
  7317. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7318. minimum: Vector3;
  7319. maximum: Vector3;
  7320. };
  7321. /**
  7322. * Extracts minimum and maximum values from a list of positions
  7323. * @param positions defines the positions to use
  7324. * @param start defines the start index in the positions array
  7325. * @param count defines the number of positions to handle
  7326. * @param bias defines bias value to add to the result
  7327. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7328. * @return minimum and maximum values
  7329. */
  7330. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7331. minimum: Vector3;
  7332. maximum: Vector3;
  7333. };
  7334. }
  7335. declare module "babylonjs/Misc/iInspectable" {
  7336. /**
  7337. * Enum that determines the text-wrapping mode to use.
  7338. */
  7339. export enum InspectableType {
  7340. /**
  7341. * Checkbox for booleans
  7342. */
  7343. Checkbox = 0,
  7344. /**
  7345. * Sliders for numbers
  7346. */
  7347. Slider = 1,
  7348. /**
  7349. * Vector3
  7350. */
  7351. Vector3 = 2,
  7352. /**
  7353. * Quaternions
  7354. */
  7355. Quaternion = 3,
  7356. /**
  7357. * Color3
  7358. */
  7359. Color3 = 4,
  7360. /**
  7361. * String
  7362. */
  7363. String = 5
  7364. }
  7365. /**
  7366. * Interface used to define custom inspectable properties.
  7367. * This interface is used by the inspector to display custom property grids
  7368. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7369. */
  7370. export interface IInspectable {
  7371. /**
  7372. * Gets the label to display
  7373. */
  7374. label: string;
  7375. /**
  7376. * Gets the name of the property to edit
  7377. */
  7378. propertyName: string;
  7379. /**
  7380. * Gets the type of the editor to use
  7381. */
  7382. type: InspectableType;
  7383. /**
  7384. * Gets the minimum value of the property when using in "slider" mode
  7385. */
  7386. min?: number;
  7387. /**
  7388. * Gets the maximum value of the property when using in "slider" mode
  7389. */
  7390. max?: number;
  7391. /**
  7392. * Gets the setp to use when using in "slider" mode
  7393. */
  7394. step?: number;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/timingTools" {
  7398. /**
  7399. * Class used to provide helper for timing
  7400. */
  7401. export class TimingTools {
  7402. /**
  7403. * Polyfill for setImmediate
  7404. * @param action defines the action to execute after the current execution block
  7405. */
  7406. static SetImmediate(action: () => void): void;
  7407. }
  7408. }
  7409. declare module "babylonjs/Misc/instantiationTools" {
  7410. /**
  7411. * Class used to enable instatition of objects by class name
  7412. */
  7413. export class InstantiationTools {
  7414. /**
  7415. * Use this object to register external classes like custom textures or material
  7416. * to allow the laoders to instantiate them
  7417. */
  7418. static RegisteredExternalClasses: {
  7419. [key: string]: Object;
  7420. };
  7421. /**
  7422. * Tries to instantiate a new object from a given class name
  7423. * @param className defines the class name to instantiate
  7424. * @returns the new object or null if the system was not able to do the instantiation
  7425. */
  7426. static Instantiate(className: string): any;
  7427. }
  7428. }
  7429. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7430. import { Nullable } from "babylonjs/types";
  7431. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7432. /**
  7433. * This represents the required contract to create a new type of texture loader.
  7434. */
  7435. export interface IInternalTextureLoader {
  7436. /**
  7437. * Defines wether the loader supports cascade loading the different faces.
  7438. */
  7439. supportCascades: boolean;
  7440. /**
  7441. * This returns if the loader support the current file information.
  7442. * @param extension defines the file extension of the file being loaded
  7443. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7444. * @param fallback defines the fallback internal texture if any
  7445. * @param isBase64 defines whether the texture is encoded as a base64
  7446. * @param isBuffer defines whether the texture data are stored as a buffer
  7447. * @returns true if the loader can load the specified file
  7448. */
  7449. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7450. /**
  7451. * Transform the url before loading if required.
  7452. * @param rootUrl the url of the texture
  7453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7454. * @returns the transformed texture
  7455. */
  7456. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7457. /**
  7458. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7459. * @param rootUrl the url of the texture
  7460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7461. * @returns the fallback texture
  7462. */
  7463. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7464. /**
  7465. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7466. * @param data contains the texture data
  7467. * @param texture defines the BabylonJS internal texture
  7468. * @param createPolynomials will be true if polynomials have been requested
  7469. * @param onLoad defines the callback to trigger once the texture is ready
  7470. * @param onError defines the callback to trigger in case of error
  7471. */
  7472. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7473. /**
  7474. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7475. * @param data contains the texture data
  7476. * @param texture defines the BabylonJS internal texture
  7477. * @param callback defines the method to call once ready to upload
  7478. */
  7479. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7480. }
  7481. }
  7482. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7483. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7484. import { Nullable } from "babylonjs/types";
  7485. import { Scene } from "babylonjs/scene";
  7486. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7487. module "babylonjs/Engines/engine" {
  7488. interface Engine {
  7489. /**
  7490. * Creates a depth stencil cube texture.
  7491. * This is only available in WebGL 2.
  7492. * @param size The size of face edge in the cube texture.
  7493. * @param options The options defining the cube texture.
  7494. * @returns The cube texture
  7495. */
  7496. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7497. /**
  7498. * Creates a cube texture
  7499. * @param rootUrl defines the url where the files to load is located
  7500. * @param scene defines the current scene
  7501. * @param files defines the list of files to load (1 per face)
  7502. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7503. * @param onLoad defines an optional callback raised when the texture is loaded
  7504. * @param onError defines an optional callback raised if there is an issue to load the texture
  7505. * @param format defines the format of the data
  7506. * @param forcedExtension defines the extension to use to pick the right loader
  7507. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7508. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7509. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7510. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7511. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7512. * @returns the cube texture as an InternalTexture
  7513. */
  7514. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7515. /**
  7516. * Creates a cube texture
  7517. * @param rootUrl defines the url where the files to load is located
  7518. * @param scene defines the current scene
  7519. * @param files defines the list of files to load (1 per face)
  7520. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7521. * @param onLoad defines an optional callback raised when the texture is loaded
  7522. * @param onError defines an optional callback raised if there is an issue to load the texture
  7523. * @param format defines the format of the data
  7524. * @param forcedExtension defines the extension to use to pick the right loader
  7525. * @returns the cube texture as an InternalTexture
  7526. */
  7527. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7528. /**
  7529. * Creates a cube texture
  7530. * @param rootUrl defines the url where the files to load is located
  7531. * @param scene defines the current scene
  7532. * @param files defines the list of files to load (1 per face)
  7533. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7534. * @param onLoad defines an optional callback raised when the texture is loaded
  7535. * @param onError defines an optional callback raised if there is an issue to load the texture
  7536. * @param format defines the format of the data
  7537. * @param forcedExtension defines the extension to use to pick the right loader
  7538. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7539. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7540. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7541. * @returns the cube texture as an InternalTexture
  7542. */
  7543. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7544. /** @hidden */
  7545. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7546. /** @hidden */
  7547. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7548. /** @hidden */
  7549. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7550. /** @hidden */
  7551. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7552. }
  7553. }
  7554. }
  7555. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7556. import { Nullable } from "babylonjs/types";
  7557. import { Scene } from "babylonjs/scene";
  7558. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7559. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7560. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7561. /**
  7562. * Class for creating a cube texture
  7563. */
  7564. export class CubeTexture extends BaseTexture {
  7565. private _delayedOnLoad;
  7566. /**
  7567. * The url of the texture
  7568. */
  7569. url: string;
  7570. /**
  7571. * Gets or sets the center of the bounding box associated with the cube texture.
  7572. * It must define where the camera used to render the texture was set
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxPosition: Vector3;
  7576. private _boundingBoxSize;
  7577. /**
  7578. * Gets or sets the size of the bounding box associated with the cube texture
  7579. * When defined, the cubemap will switch to local mode
  7580. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7581. * @example https://www.babylonjs-playground.com/#RNASML
  7582. */
  7583. /**
  7584. * Returns the bounding box size
  7585. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7586. */
  7587. boundingBoxSize: Vector3;
  7588. protected _rotationY: number;
  7589. /**
  7590. * Sets texture matrix rotation angle around Y axis in radians.
  7591. */
  7592. /**
  7593. * Gets texture matrix rotation angle around Y axis radians.
  7594. */
  7595. rotationY: number;
  7596. /**
  7597. * Are mip maps generated for this texture or not.
  7598. */
  7599. readonly noMipmap: boolean;
  7600. private _noMipmap;
  7601. private _files;
  7602. private _extensions;
  7603. private _textureMatrix;
  7604. private _format;
  7605. private _createPolynomials;
  7606. /** @hidden */
  7607. _prefiltered: boolean;
  7608. /**
  7609. * Creates a cube texture from an array of image urls
  7610. * @param files defines an array of image urls
  7611. * @param scene defines the hosting scene
  7612. * @param noMipmap specifies if mip maps are not used
  7613. * @returns a cube texture
  7614. */
  7615. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7616. /**
  7617. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7618. * @param url defines the url of the prefiltered texture
  7619. * @param scene defines the scene the texture is attached to
  7620. * @param forcedExtension defines the extension of the file if different from the url
  7621. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7622. * @return the prefiltered texture
  7623. */
  7624. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7625. /**
  7626. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7627. * as prefiltered data.
  7628. * @param rootUrl defines the url of the texture or the root name of the six images
  7629. * @param scene defines the scene the texture is attached to
  7630. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7631. * @param noMipmap defines if mipmaps should be created or not
  7632. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7633. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7634. * @param onError defines a callback triggered in case of error during load
  7635. * @param format defines the internal format to use for the texture once loaded
  7636. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7637. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7638. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7639. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7640. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7641. * @return the cube texture
  7642. */
  7643. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7644. /**
  7645. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7646. */
  7647. readonly isPrefiltered: boolean;
  7648. /**
  7649. * Get the current class name of the texture useful for serialization or dynamic coding.
  7650. * @returns "CubeTexture"
  7651. */
  7652. getClassName(): string;
  7653. /**
  7654. * Update the url (and optional buffer) of this texture if url was null during construction.
  7655. * @param url the url of the texture
  7656. * @param forcedExtension defines the extension to use
  7657. * @param onLoad callback called when the texture is loaded (defaults to null)
  7658. */
  7659. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7660. /**
  7661. * Delays loading of the cube texture
  7662. * @param forcedExtension defines the extension to use
  7663. */
  7664. delayLoad(forcedExtension?: string): void;
  7665. /**
  7666. * Returns the reflection texture matrix
  7667. * @returns the reflection texture matrix
  7668. */
  7669. getReflectionTextureMatrix(): Matrix;
  7670. /**
  7671. * Sets the reflection texture matrix
  7672. * @param value Reflection texture matrix
  7673. */
  7674. setReflectionTextureMatrix(value: Matrix): void;
  7675. /**
  7676. * Parses text to create a cube texture
  7677. * @param parsedTexture define the serialized text to read from
  7678. * @param scene defines the hosting scene
  7679. * @param rootUrl defines the root url of the cube texture
  7680. * @returns a cube texture
  7681. */
  7682. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7683. /**
  7684. * Makes a clone, or deep copy, of the cube texture
  7685. * @returns a new cube texture
  7686. */
  7687. clone(): CubeTexture;
  7688. }
  7689. }
  7690. declare module "babylonjs/Materials/materialDefines" {
  7691. /**
  7692. * Manages the defines for the Material
  7693. */
  7694. export class MaterialDefines {
  7695. /** @hidden */
  7696. protected _keys: string[];
  7697. private _isDirty;
  7698. /** @hidden */
  7699. _renderId: number;
  7700. /** @hidden */
  7701. _areLightsDirty: boolean;
  7702. /** @hidden */
  7703. _areLightsDisposed: boolean;
  7704. /** @hidden */
  7705. _areAttributesDirty: boolean;
  7706. /** @hidden */
  7707. _areTexturesDirty: boolean;
  7708. /** @hidden */
  7709. _areFresnelDirty: boolean;
  7710. /** @hidden */
  7711. _areMiscDirty: boolean;
  7712. /** @hidden */
  7713. _areImageProcessingDirty: boolean;
  7714. /** @hidden */
  7715. _normals: boolean;
  7716. /** @hidden */
  7717. _uvs: boolean;
  7718. /** @hidden */
  7719. _needNormals: boolean;
  7720. /** @hidden */
  7721. _needUVs: boolean;
  7722. [id: string]: any;
  7723. /**
  7724. * Specifies if the material needs to be re-calculated
  7725. */
  7726. readonly isDirty: boolean;
  7727. /**
  7728. * Marks the material to indicate that it has been re-calculated
  7729. */
  7730. markAsProcessed(): void;
  7731. /**
  7732. * Marks the material to indicate that it needs to be re-calculated
  7733. */
  7734. markAsUnprocessed(): void;
  7735. /**
  7736. * Marks the material to indicate all of its defines need to be re-calculated
  7737. */
  7738. markAllAsDirty(): void;
  7739. /**
  7740. * Marks the material to indicate that image processing needs to be re-calculated
  7741. */
  7742. markAsImageProcessingDirty(): void;
  7743. /**
  7744. * Marks the material to indicate the lights need to be re-calculated
  7745. * @param disposed Defines whether the light is dirty due to dispose or not
  7746. */
  7747. markAsLightDirty(disposed?: boolean): void;
  7748. /**
  7749. * Marks the attribute state as changed
  7750. */
  7751. markAsAttributesDirty(): void;
  7752. /**
  7753. * Marks the texture state as changed
  7754. */
  7755. markAsTexturesDirty(): void;
  7756. /**
  7757. * Marks the fresnel state as changed
  7758. */
  7759. markAsFresnelDirty(): void;
  7760. /**
  7761. * Marks the misc state as changed
  7762. */
  7763. markAsMiscDirty(): void;
  7764. /**
  7765. * Rebuilds the material defines
  7766. */
  7767. rebuild(): void;
  7768. /**
  7769. * Specifies if two material defines are equal
  7770. * @param other - A material define instance to compare to
  7771. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7772. */
  7773. isEqual(other: MaterialDefines): boolean;
  7774. /**
  7775. * Clones this instance's defines to another instance
  7776. * @param other - material defines to clone values to
  7777. */
  7778. cloneTo(other: MaterialDefines): void;
  7779. /**
  7780. * Resets the material define values
  7781. */
  7782. reset(): void;
  7783. /**
  7784. * Converts the material define values to a string
  7785. * @returns - String of material define information
  7786. */
  7787. toString(): string;
  7788. }
  7789. }
  7790. declare module "babylonjs/Materials/colorCurves" {
  7791. import { Effect } from "babylonjs/Materials/effect";
  7792. /**
  7793. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7794. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7795. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7796. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7797. */
  7798. export class ColorCurves {
  7799. private _dirty;
  7800. private _tempColor;
  7801. private _globalCurve;
  7802. private _highlightsCurve;
  7803. private _midtonesCurve;
  7804. private _shadowsCurve;
  7805. private _positiveCurve;
  7806. private _negativeCurve;
  7807. private _globalHue;
  7808. private _globalDensity;
  7809. private _globalSaturation;
  7810. private _globalExposure;
  7811. /**
  7812. * Gets the global Hue value.
  7813. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7814. */
  7815. /**
  7816. * Sets the global Hue value.
  7817. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7818. */
  7819. globalHue: number;
  7820. /**
  7821. * Gets the global Density value.
  7822. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7823. * Values less than zero provide a filter of opposite hue.
  7824. */
  7825. /**
  7826. * Sets the global Density value.
  7827. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7828. * Values less than zero provide a filter of opposite hue.
  7829. */
  7830. globalDensity: number;
  7831. /**
  7832. * Gets the global Saturation value.
  7833. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7834. */
  7835. /**
  7836. * Sets the global Saturation value.
  7837. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7838. */
  7839. globalSaturation: number;
  7840. /**
  7841. * Gets the global Exposure value.
  7842. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7843. */
  7844. /**
  7845. * Sets the global Exposure value.
  7846. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7847. */
  7848. globalExposure: number;
  7849. private _highlightsHue;
  7850. private _highlightsDensity;
  7851. private _highlightsSaturation;
  7852. private _highlightsExposure;
  7853. /**
  7854. * Gets the highlights Hue value.
  7855. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7856. */
  7857. /**
  7858. * Sets the highlights Hue value.
  7859. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7860. */
  7861. highlightsHue: number;
  7862. /**
  7863. * Gets the highlights Density value.
  7864. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7865. * Values less than zero provide a filter of opposite hue.
  7866. */
  7867. /**
  7868. * Sets the highlights Density value.
  7869. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7870. * Values less than zero provide a filter of opposite hue.
  7871. */
  7872. highlightsDensity: number;
  7873. /**
  7874. * Gets the highlights Saturation value.
  7875. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7876. */
  7877. /**
  7878. * Sets the highlights Saturation value.
  7879. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7880. */
  7881. highlightsSaturation: number;
  7882. /**
  7883. * Gets the highlights Exposure value.
  7884. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7885. */
  7886. /**
  7887. * Sets the highlights Exposure value.
  7888. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7889. */
  7890. highlightsExposure: number;
  7891. private _midtonesHue;
  7892. private _midtonesDensity;
  7893. private _midtonesSaturation;
  7894. private _midtonesExposure;
  7895. /**
  7896. * Gets the midtones Hue value.
  7897. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7898. */
  7899. /**
  7900. * Sets the midtones Hue value.
  7901. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7902. */
  7903. midtonesHue: number;
  7904. /**
  7905. * Gets the midtones Density value.
  7906. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7907. * Values less than zero provide a filter of opposite hue.
  7908. */
  7909. /**
  7910. * Sets the midtones Density value.
  7911. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7912. * Values less than zero provide a filter of opposite hue.
  7913. */
  7914. midtonesDensity: number;
  7915. /**
  7916. * Gets the midtones Saturation value.
  7917. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7918. */
  7919. /**
  7920. * Sets the midtones Saturation value.
  7921. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7922. */
  7923. midtonesSaturation: number;
  7924. /**
  7925. * Gets the midtones Exposure value.
  7926. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7927. */
  7928. /**
  7929. * Sets the midtones Exposure value.
  7930. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7931. */
  7932. midtonesExposure: number;
  7933. private _shadowsHue;
  7934. private _shadowsDensity;
  7935. private _shadowsSaturation;
  7936. private _shadowsExposure;
  7937. /**
  7938. * Gets the shadows Hue value.
  7939. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7940. */
  7941. /**
  7942. * Sets the shadows Hue value.
  7943. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7944. */
  7945. shadowsHue: number;
  7946. /**
  7947. * Gets the shadows Density value.
  7948. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7949. * Values less than zero provide a filter of opposite hue.
  7950. */
  7951. /**
  7952. * Sets the shadows Density value.
  7953. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7954. * Values less than zero provide a filter of opposite hue.
  7955. */
  7956. shadowsDensity: number;
  7957. /**
  7958. * Gets the shadows Saturation value.
  7959. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7960. */
  7961. /**
  7962. * Sets the shadows Saturation value.
  7963. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7964. */
  7965. shadowsSaturation: number;
  7966. /**
  7967. * Gets the shadows Exposure value.
  7968. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7969. */
  7970. /**
  7971. * Sets the shadows Exposure value.
  7972. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7973. */
  7974. shadowsExposure: number;
  7975. /**
  7976. * Returns the class name
  7977. * @returns The class name
  7978. */
  7979. getClassName(): string;
  7980. /**
  7981. * Binds the color curves to the shader.
  7982. * @param colorCurves The color curve to bind
  7983. * @param effect The effect to bind to
  7984. * @param positiveUniform The positive uniform shader parameter
  7985. * @param neutralUniform The neutral uniform shader parameter
  7986. * @param negativeUniform The negative uniform shader parameter
  7987. */
  7988. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7989. /**
  7990. * Prepare the list of uniforms associated with the ColorCurves effects.
  7991. * @param uniformsList The list of uniforms used in the effect
  7992. */
  7993. static PrepareUniforms(uniformsList: string[]): void;
  7994. /**
  7995. * Returns color grading data based on a hue, density, saturation and exposure value.
  7996. * @param filterHue The hue of the color filter.
  7997. * @param filterDensity The density of the color filter.
  7998. * @param saturation The saturation.
  7999. * @param exposure The exposure.
  8000. * @param result The result data container.
  8001. */
  8002. private getColorGradingDataToRef;
  8003. /**
  8004. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8005. * @param value The input slider value in range [-100,100].
  8006. * @returns Adjusted value.
  8007. */
  8008. private static applyColorGradingSliderNonlinear;
  8009. /**
  8010. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8011. * @param hue The hue (H) input.
  8012. * @param saturation The saturation (S) input.
  8013. * @param brightness The brightness (B) input.
  8014. * @result An RGBA color represented as Vector4.
  8015. */
  8016. private static fromHSBToRef;
  8017. /**
  8018. * Returns a value clamped between min and max
  8019. * @param value The value to clamp
  8020. * @param min The minimum of value
  8021. * @param max The maximum of value
  8022. * @returns The clamped value.
  8023. */
  8024. private static clamp;
  8025. /**
  8026. * Clones the current color curve instance.
  8027. * @return The cloned curves
  8028. */
  8029. clone(): ColorCurves;
  8030. /**
  8031. * Serializes the current color curve instance to a json representation.
  8032. * @return a JSON representation
  8033. */
  8034. serialize(): any;
  8035. /**
  8036. * Parses the color curve from a json representation.
  8037. * @param source the JSON source to parse
  8038. * @return The parsed curves
  8039. */
  8040. static Parse(source: any): ColorCurves;
  8041. }
  8042. }
  8043. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8044. import { Observable } from "babylonjs/Misc/observable";
  8045. import { Nullable } from "babylonjs/types";
  8046. import { Color4 } from "babylonjs/Maths/math.color";
  8047. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8048. import { Effect } from "babylonjs/Materials/effect";
  8049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8050. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8051. /**
  8052. * Interface to follow in your material defines to integrate easily the
  8053. * Image proccessing functions.
  8054. * @hidden
  8055. */
  8056. export interface IImageProcessingConfigurationDefines {
  8057. IMAGEPROCESSING: boolean;
  8058. VIGNETTE: boolean;
  8059. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8060. VIGNETTEBLENDMODEOPAQUE: boolean;
  8061. TONEMAPPING: boolean;
  8062. TONEMAPPING_ACES: boolean;
  8063. CONTRAST: boolean;
  8064. EXPOSURE: boolean;
  8065. COLORCURVES: boolean;
  8066. COLORGRADING: boolean;
  8067. COLORGRADING3D: boolean;
  8068. SAMPLER3DGREENDEPTH: boolean;
  8069. SAMPLER3DBGRMAP: boolean;
  8070. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8071. }
  8072. /**
  8073. * @hidden
  8074. */
  8075. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8076. IMAGEPROCESSING: boolean;
  8077. VIGNETTE: boolean;
  8078. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8079. VIGNETTEBLENDMODEOPAQUE: boolean;
  8080. TONEMAPPING: boolean;
  8081. TONEMAPPING_ACES: boolean;
  8082. CONTRAST: boolean;
  8083. COLORCURVES: boolean;
  8084. COLORGRADING: boolean;
  8085. COLORGRADING3D: boolean;
  8086. SAMPLER3DGREENDEPTH: boolean;
  8087. SAMPLER3DBGRMAP: boolean;
  8088. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8089. EXPOSURE: boolean;
  8090. constructor();
  8091. }
  8092. /**
  8093. * This groups together the common properties used for image processing either in direct forward pass
  8094. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8095. * or not.
  8096. */
  8097. export class ImageProcessingConfiguration {
  8098. /**
  8099. * Default tone mapping applied in BabylonJS.
  8100. */
  8101. static readonly TONEMAPPING_STANDARD: number;
  8102. /**
  8103. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8104. * to other engines rendering to increase portability.
  8105. */
  8106. static readonly TONEMAPPING_ACES: number;
  8107. /**
  8108. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8109. */
  8110. colorCurves: Nullable<ColorCurves>;
  8111. private _colorCurvesEnabled;
  8112. /**
  8113. * Gets wether the color curves effect is enabled.
  8114. */
  8115. /**
  8116. * Sets wether the color curves effect is enabled.
  8117. */
  8118. colorCurvesEnabled: boolean;
  8119. private _colorGradingTexture;
  8120. /**
  8121. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8122. */
  8123. /**
  8124. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8125. */
  8126. colorGradingTexture: Nullable<BaseTexture>;
  8127. private _colorGradingEnabled;
  8128. /**
  8129. * Gets wether the color grading effect is enabled.
  8130. */
  8131. /**
  8132. * Sets wether the color grading effect is enabled.
  8133. */
  8134. colorGradingEnabled: boolean;
  8135. private _colorGradingWithGreenDepth;
  8136. /**
  8137. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8138. */
  8139. /**
  8140. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8141. */
  8142. colorGradingWithGreenDepth: boolean;
  8143. private _colorGradingBGR;
  8144. /**
  8145. * Gets wether the color grading texture contains BGR values.
  8146. */
  8147. /**
  8148. * Sets wether the color grading texture contains BGR values.
  8149. */
  8150. colorGradingBGR: boolean;
  8151. /** @hidden */
  8152. _exposure: number;
  8153. /**
  8154. * Gets the Exposure used in the effect.
  8155. */
  8156. /**
  8157. * Sets the Exposure used in the effect.
  8158. */
  8159. exposure: number;
  8160. private _toneMappingEnabled;
  8161. /**
  8162. * Gets wether the tone mapping effect is enabled.
  8163. */
  8164. /**
  8165. * Sets wether the tone mapping effect is enabled.
  8166. */
  8167. toneMappingEnabled: boolean;
  8168. private _toneMappingType;
  8169. /**
  8170. * Gets the type of tone mapping effect.
  8171. */
  8172. /**
  8173. * Sets the type of tone mapping effect used in BabylonJS.
  8174. */
  8175. toneMappingType: number;
  8176. protected _contrast: number;
  8177. /**
  8178. * Gets the contrast used in the effect.
  8179. */
  8180. /**
  8181. * Sets the contrast used in the effect.
  8182. */
  8183. contrast: number;
  8184. /**
  8185. * Vignette stretch size.
  8186. */
  8187. vignetteStretch: number;
  8188. /**
  8189. * Vignette centre X Offset.
  8190. */
  8191. vignetteCentreX: number;
  8192. /**
  8193. * Vignette centre Y Offset.
  8194. */
  8195. vignetteCentreY: number;
  8196. /**
  8197. * Vignette weight or intensity of the vignette effect.
  8198. */
  8199. vignetteWeight: number;
  8200. /**
  8201. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8202. * if vignetteEnabled is set to true.
  8203. */
  8204. vignetteColor: Color4;
  8205. /**
  8206. * Camera field of view used by the Vignette effect.
  8207. */
  8208. vignetteCameraFov: number;
  8209. private _vignetteBlendMode;
  8210. /**
  8211. * Gets the vignette blend mode allowing different kind of effect.
  8212. */
  8213. /**
  8214. * Sets the vignette blend mode allowing different kind of effect.
  8215. */
  8216. vignetteBlendMode: number;
  8217. private _vignetteEnabled;
  8218. /**
  8219. * Gets wether the vignette effect is enabled.
  8220. */
  8221. /**
  8222. * Sets wether the vignette effect is enabled.
  8223. */
  8224. vignetteEnabled: boolean;
  8225. private _applyByPostProcess;
  8226. /**
  8227. * Gets wether the image processing is applied through a post process or not.
  8228. */
  8229. /**
  8230. * Sets wether the image processing is applied through a post process or not.
  8231. */
  8232. applyByPostProcess: boolean;
  8233. private _isEnabled;
  8234. /**
  8235. * Gets wether the image processing is enabled or not.
  8236. */
  8237. /**
  8238. * Sets wether the image processing is enabled or not.
  8239. */
  8240. isEnabled: boolean;
  8241. /**
  8242. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8243. */
  8244. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8245. /**
  8246. * Method called each time the image processing information changes requires to recompile the effect.
  8247. */
  8248. protected _updateParameters(): void;
  8249. /**
  8250. * Gets the current class name.
  8251. * @return "ImageProcessingConfiguration"
  8252. */
  8253. getClassName(): string;
  8254. /**
  8255. * Prepare the list of uniforms associated with the Image Processing effects.
  8256. * @param uniforms The list of uniforms used in the effect
  8257. * @param defines the list of defines currently in use
  8258. */
  8259. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8260. /**
  8261. * Prepare the list of samplers associated with the Image Processing effects.
  8262. * @param samplersList The list of uniforms used in the effect
  8263. * @param defines the list of defines currently in use
  8264. */
  8265. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8266. /**
  8267. * Prepare the list of defines associated to the shader.
  8268. * @param defines the list of defines to complete
  8269. * @param forPostProcess Define if we are currently in post process mode or not
  8270. */
  8271. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8272. /**
  8273. * Returns true if all the image processing information are ready.
  8274. * @returns True if ready, otherwise, false
  8275. */
  8276. isReady(): boolean;
  8277. /**
  8278. * Binds the image processing to the shader.
  8279. * @param effect The effect to bind to
  8280. * @param aspectRatio Define the current aspect ratio of the effect
  8281. */
  8282. bind(effect: Effect, aspectRatio?: number): void;
  8283. /**
  8284. * Clones the current image processing instance.
  8285. * @return The cloned image processing
  8286. */
  8287. clone(): ImageProcessingConfiguration;
  8288. /**
  8289. * Serializes the current image processing instance to a json representation.
  8290. * @return a JSON representation
  8291. */
  8292. serialize(): any;
  8293. /**
  8294. * Parses the image processing from a json representation.
  8295. * @param source the JSON source to parse
  8296. * @return The parsed image processing
  8297. */
  8298. static Parse(source: any): ImageProcessingConfiguration;
  8299. private static _VIGNETTEMODE_MULTIPLY;
  8300. private static _VIGNETTEMODE_OPAQUE;
  8301. /**
  8302. * Used to apply the vignette as a mix with the pixel color.
  8303. */
  8304. static readonly VIGNETTEMODE_MULTIPLY: number;
  8305. /**
  8306. * Used to apply the vignette as a replacement of the pixel color.
  8307. */
  8308. static readonly VIGNETTEMODE_OPAQUE: number;
  8309. }
  8310. }
  8311. declare module "babylonjs/Shaders/postprocess.vertex" {
  8312. /** @hidden */
  8313. export var postprocessVertexShader: {
  8314. name: string;
  8315. shader: string;
  8316. };
  8317. }
  8318. declare module "babylonjs/Maths/math.axis" {
  8319. import { Vector3 } from "babylonjs/Maths/math.vector";
  8320. /** Defines supported spaces */
  8321. export enum Space {
  8322. /** Local (object) space */
  8323. LOCAL = 0,
  8324. /** World space */
  8325. WORLD = 1,
  8326. /** Bone space */
  8327. BONE = 2
  8328. }
  8329. /** Defines the 3 main axes */
  8330. export class Axis {
  8331. /** X axis */
  8332. static X: Vector3;
  8333. /** Y axis */
  8334. static Y: Vector3;
  8335. /** Z axis */
  8336. static Z: Vector3;
  8337. }
  8338. }
  8339. declare module "babylonjs/Cameras/targetCamera" {
  8340. import { Nullable } from "babylonjs/types";
  8341. import { Camera } from "babylonjs/Cameras/camera";
  8342. import { Scene } from "babylonjs/scene";
  8343. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8344. /**
  8345. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8346. * This is the base of the follow, arc rotate cameras and Free camera
  8347. * @see http://doc.babylonjs.com/features/cameras
  8348. */
  8349. export class TargetCamera extends Camera {
  8350. private static _RigCamTransformMatrix;
  8351. private static _TargetTransformMatrix;
  8352. private static _TargetFocalPoint;
  8353. /**
  8354. * Define the current direction the camera is moving to
  8355. */
  8356. cameraDirection: Vector3;
  8357. /**
  8358. * Define the current rotation the camera is rotating to
  8359. */
  8360. cameraRotation: Vector2;
  8361. /**
  8362. * When set, the up vector of the camera will be updated by the rotation of the camera
  8363. */
  8364. updateUpVectorFromRotation: boolean;
  8365. private _tmpQuaternion;
  8366. /**
  8367. * Define the current rotation of the camera
  8368. */
  8369. rotation: Vector3;
  8370. /**
  8371. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8372. */
  8373. rotationQuaternion: Quaternion;
  8374. /**
  8375. * Define the current speed of the camera
  8376. */
  8377. speed: number;
  8378. /**
  8379. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8380. * around all axis.
  8381. */
  8382. noRotationConstraint: boolean;
  8383. /**
  8384. * Define the current target of the camera as an object or a position.
  8385. */
  8386. lockedTarget: any;
  8387. /** @hidden */
  8388. _currentTarget: Vector3;
  8389. /** @hidden */
  8390. _initialFocalDistance: number;
  8391. /** @hidden */
  8392. _viewMatrix: Matrix;
  8393. /** @hidden */
  8394. _camMatrix: Matrix;
  8395. /** @hidden */
  8396. _cameraTransformMatrix: Matrix;
  8397. /** @hidden */
  8398. _cameraRotationMatrix: Matrix;
  8399. /** @hidden */
  8400. _referencePoint: Vector3;
  8401. /** @hidden */
  8402. _transformedReferencePoint: Vector3;
  8403. protected _globalCurrentTarget: Vector3;
  8404. protected _globalCurrentUpVector: Vector3;
  8405. /** @hidden */
  8406. _reset: () => void;
  8407. private _defaultUp;
  8408. /**
  8409. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8410. * This is the base of the follow, arc rotate cameras and Free camera
  8411. * @see http://doc.babylonjs.com/features/cameras
  8412. * @param name Defines the name of the camera in the scene
  8413. * @param position Defines the start position of the camera in the scene
  8414. * @param scene Defines the scene the camera belongs to
  8415. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8416. */
  8417. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8418. /**
  8419. * Gets the position in front of the camera at a given distance.
  8420. * @param distance The distance from the camera we want the position to be
  8421. * @returns the position
  8422. */
  8423. getFrontPosition(distance: number): Vector3;
  8424. /** @hidden */
  8425. _getLockedTargetPosition(): Nullable<Vector3>;
  8426. private _storedPosition;
  8427. private _storedRotation;
  8428. private _storedRotationQuaternion;
  8429. /**
  8430. * Store current camera state of the camera (fov, position, rotation, etc..)
  8431. * @returns the camera
  8432. */
  8433. storeState(): Camera;
  8434. /**
  8435. * Restored camera state. You must call storeState() first
  8436. * @returns whether it was successful or not
  8437. * @hidden
  8438. */
  8439. _restoreStateValues(): boolean;
  8440. /** @hidden */
  8441. _initCache(): void;
  8442. /** @hidden */
  8443. _updateCache(ignoreParentClass?: boolean): void;
  8444. /** @hidden */
  8445. _isSynchronizedViewMatrix(): boolean;
  8446. /** @hidden */
  8447. _computeLocalCameraSpeed(): number;
  8448. /**
  8449. * Defines the target the camera should look at.
  8450. * @param target Defines the new target as a Vector or a mesh
  8451. */
  8452. setTarget(target: Vector3): void;
  8453. /**
  8454. * Return the current target position of the camera. This value is expressed in local space.
  8455. * @returns the target position
  8456. */
  8457. getTarget(): Vector3;
  8458. /** @hidden */
  8459. _decideIfNeedsToMove(): boolean;
  8460. /** @hidden */
  8461. _updatePosition(): void;
  8462. /** @hidden */
  8463. _checkInputs(): void;
  8464. protected _updateCameraRotationMatrix(): void;
  8465. /**
  8466. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8467. * @returns the current camera
  8468. */
  8469. private _rotateUpVectorWithCameraRotationMatrix;
  8470. private _cachedRotationZ;
  8471. private _cachedQuaternionRotationZ;
  8472. /** @hidden */
  8473. _getViewMatrix(): Matrix;
  8474. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8475. /**
  8476. * @hidden
  8477. */
  8478. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8479. /**
  8480. * @hidden
  8481. */
  8482. _updateRigCameras(): void;
  8483. private _getRigCamPositionAndTarget;
  8484. /**
  8485. * Gets the current object class name.
  8486. * @return the class name
  8487. */
  8488. getClassName(): string;
  8489. }
  8490. }
  8491. declare module "babylonjs/Events/keyboardEvents" {
  8492. /**
  8493. * Gather the list of keyboard event types as constants.
  8494. */
  8495. export class KeyboardEventTypes {
  8496. /**
  8497. * The keydown event is fired when a key becomes active (pressed).
  8498. */
  8499. static readonly KEYDOWN: number;
  8500. /**
  8501. * The keyup event is fired when a key has been released.
  8502. */
  8503. static readonly KEYUP: number;
  8504. }
  8505. /**
  8506. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8507. */
  8508. export class KeyboardInfo {
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number;
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent;
  8517. /**
  8518. * Instantiates a new keyboard info.
  8519. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8520. * @param type Defines the type of event (KeyboardEventTypes)
  8521. * @param event Defines the related dom event
  8522. */
  8523. constructor(
  8524. /**
  8525. * Defines the type of event (KeyboardEventTypes)
  8526. */
  8527. type: number,
  8528. /**
  8529. * Defines the related dom event
  8530. */
  8531. event: KeyboardEvent);
  8532. }
  8533. /**
  8534. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8535. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8536. */
  8537. export class KeyboardInfoPre extends KeyboardInfo {
  8538. /**
  8539. * Defines the type of event (KeyboardEventTypes)
  8540. */
  8541. type: number;
  8542. /**
  8543. * Defines the related dom event
  8544. */
  8545. event: KeyboardEvent;
  8546. /**
  8547. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8548. */
  8549. skipOnPointerObservable: boolean;
  8550. /**
  8551. * Instantiates a new keyboard pre info.
  8552. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8553. * @param type Defines the type of event (KeyboardEventTypes)
  8554. * @param event Defines the related dom event
  8555. */
  8556. constructor(
  8557. /**
  8558. * Defines the type of event (KeyboardEventTypes)
  8559. */
  8560. type: number,
  8561. /**
  8562. * Defines the related dom event
  8563. */
  8564. event: KeyboardEvent);
  8565. }
  8566. }
  8567. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8568. import { Nullable } from "babylonjs/types";
  8569. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8570. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8571. /**
  8572. * Manage the keyboard inputs to control the movement of a free camera.
  8573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8574. */
  8575. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8576. /**
  8577. * Defines the camera the input is attached to.
  8578. */
  8579. camera: FreeCamera;
  8580. /**
  8581. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8582. */
  8583. keysUp: number[];
  8584. /**
  8585. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8586. */
  8587. keysDown: number[];
  8588. /**
  8589. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8590. */
  8591. keysLeft: number[];
  8592. /**
  8593. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8594. */
  8595. keysRight: number[];
  8596. private _keys;
  8597. private _onCanvasBlurObserver;
  8598. private _onKeyboardObserver;
  8599. private _engine;
  8600. private _scene;
  8601. /**
  8602. * Attach the input controls to a specific dom element to get the input from.
  8603. * @param element Defines the element the controls should be listened from
  8604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8605. */
  8606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8607. /**
  8608. * Detach the current controls from the specified dom element.
  8609. * @param element Defines the element to stop listening the inputs from
  8610. */
  8611. detachControl(element: Nullable<HTMLElement>): void;
  8612. /**
  8613. * Update the current camera state depending on the inputs that have been used this frame.
  8614. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8615. */
  8616. checkInputs(): void;
  8617. /**
  8618. * Gets the class name of the current intput.
  8619. * @returns the class name
  8620. */
  8621. getClassName(): string;
  8622. /** @hidden */
  8623. _onLostFocus(): void;
  8624. /**
  8625. * Get the friendly name associated with the input class.
  8626. * @returns the input friendly name
  8627. */
  8628. getSimpleName(): string;
  8629. }
  8630. }
  8631. declare module "babylonjs/Lights/shadowLight" {
  8632. import { Camera } from "babylonjs/Cameras/camera";
  8633. import { Scene } from "babylonjs/scene";
  8634. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8636. import { Light } from "babylonjs/Lights/light";
  8637. /**
  8638. * Interface describing all the common properties and methods a shadow light needs to implement.
  8639. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8640. * as well as binding the different shadow properties to the effects.
  8641. */
  8642. export interface IShadowLight extends Light {
  8643. /**
  8644. * The light id in the scene (used in scene.findLighById for instance)
  8645. */
  8646. id: string;
  8647. /**
  8648. * The position the shdow will be casted from.
  8649. */
  8650. position: Vector3;
  8651. /**
  8652. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8653. */
  8654. direction: Vector3;
  8655. /**
  8656. * The transformed position. Position of the light in world space taking parenting in account.
  8657. */
  8658. transformedPosition: Vector3;
  8659. /**
  8660. * The transformed direction. Direction of the light in world space taking parenting in account.
  8661. */
  8662. transformedDirection: Vector3;
  8663. /**
  8664. * The friendly name of the light in the scene.
  8665. */
  8666. name: string;
  8667. /**
  8668. * Defines the shadow projection clipping minimum z value.
  8669. */
  8670. shadowMinZ: number;
  8671. /**
  8672. * Defines the shadow projection clipping maximum z value.
  8673. */
  8674. shadowMaxZ: number;
  8675. /**
  8676. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8677. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8678. */
  8679. computeTransformedInformation(): boolean;
  8680. /**
  8681. * Gets the scene the light belongs to.
  8682. * @returns The scene
  8683. */
  8684. getScene(): Scene;
  8685. /**
  8686. * Callback defining a custom Projection Matrix Builder.
  8687. * This can be used to override the default projection matrix computation.
  8688. */
  8689. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8690. /**
  8691. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8692. * @param matrix The materix to updated with the projection information
  8693. * @param viewMatrix The transform matrix of the light
  8694. * @param renderList The list of mesh to render in the map
  8695. * @returns The current light
  8696. */
  8697. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8698. /**
  8699. * Gets the current depth scale used in ESM.
  8700. * @returns The scale
  8701. */
  8702. getDepthScale(): number;
  8703. /**
  8704. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8705. * @returns true if a cube texture needs to be use
  8706. */
  8707. needCube(): boolean;
  8708. /**
  8709. * Detects if the projection matrix requires to be recomputed this frame.
  8710. * @returns true if it requires to be recomputed otherwise, false.
  8711. */
  8712. needProjectionMatrixCompute(): boolean;
  8713. /**
  8714. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8715. */
  8716. forceProjectionMatrixCompute(): void;
  8717. /**
  8718. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8719. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8720. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8721. */
  8722. getShadowDirection(faceIndex?: number): Vector3;
  8723. /**
  8724. * Gets the minZ used for shadow according to both the scene and the light.
  8725. * @param activeCamera The camera we are returning the min for
  8726. * @returns the depth min z
  8727. */
  8728. getDepthMinZ(activeCamera: Camera): number;
  8729. /**
  8730. * Gets the maxZ used for shadow according to both the scene and the light.
  8731. * @param activeCamera The camera we are returning the max for
  8732. * @returns the depth max z
  8733. */
  8734. getDepthMaxZ(activeCamera: Camera): number;
  8735. }
  8736. /**
  8737. * Base implementation IShadowLight
  8738. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8739. */
  8740. export abstract class ShadowLight extends Light implements IShadowLight {
  8741. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8742. protected _position: Vector3;
  8743. protected _setPosition(value: Vector3): void;
  8744. /**
  8745. * Sets the position the shadow will be casted from. Also use as the light position for both
  8746. * point and spot lights.
  8747. */
  8748. /**
  8749. * Sets the position the shadow will be casted from. Also use as the light position for both
  8750. * point and spot lights.
  8751. */
  8752. position: Vector3;
  8753. protected _direction: Vector3;
  8754. protected _setDirection(value: Vector3): void;
  8755. /**
  8756. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8757. * Also use as the light direction on spot and directional lights.
  8758. */
  8759. /**
  8760. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8761. * Also use as the light direction on spot and directional lights.
  8762. */
  8763. direction: Vector3;
  8764. private _shadowMinZ;
  8765. /**
  8766. * Gets the shadow projection clipping minimum z value.
  8767. */
  8768. /**
  8769. * Sets the shadow projection clipping minimum z value.
  8770. */
  8771. shadowMinZ: number;
  8772. private _shadowMaxZ;
  8773. /**
  8774. * Sets the shadow projection clipping maximum z value.
  8775. */
  8776. /**
  8777. * Gets the shadow projection clipping maximum z value.
  8778. */
  8779. shadowMaxZ: number;
  8780. /**
  8781. * Callback defining a custom Projection Matrix Builder.
  8782. * This can be used to override the default projection matrix computation.
  8783. */
  8784. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8785. /**
  8786. * The transformed position. Position of the light in world space taking parenting in account.
  8787. */
  8788. transformedPosition: Vector3;
  8789. /**
  8790. * The transformed direction. Direction of the light in world space taking parenting in account.
  8791. */
  8792. transformedDirection: Vector3;
  8793. private _needProjectionMatrixCompute;
  8794. /**
  8795. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8796. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8797. */
  8798. computeTransformedInformation(): boolean;
  8799. /**
  8800. * Return the depth scale used for the shadow map.
  8801. * @returns the depth scale.
  8802. */
  8803. getDepthScale(): number;
  8804. /**
  8805. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8806. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8807. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8808. */
  8809. getShadowDirection(faceIndex?: number): Vector3;
  8810. /**
  8811. * Returns the ShadowLight absolute position in the World.
  8812. * @returns the position vector in world space
  8813. */
  8814. getAbsolutePosition(): Vector3;
  8815. /**
  8816. * Sets the ShadowLight direction toward the passed target.
  8817. * @param target The point to target in local space
  8818. * @returns the updated ShadowLight direction
  8819. */
  8820. setDirectionToTarget(target: Vector3): Vector3;
  8821. /**
  8822. * Returns the light rotation in euler definition.
  8823. * @returns the x y z rotation in local space.
  8824. */
  8825. getRotation(): Vector3;
  8826. /**
  8827. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8828. * @returns true if a cube texture needs to be use
  8829. */
  8830. needCube(): boolean;
  8831. /**
  8832. * Detects if the projection matrix requires to be recomputed this frame.
  8833. * @returns true if it requires to be recomputed otherwise, false.
  8834. */
  8835. needProjectionMatrixCompute(): boolean;
  8836. /**
  8837. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8838. */
  8839. forceProjectionMatrixCompute(): void;
  8840. /** @hidden */
  8841. _initCache(): void;
  8842. /** @hidden */
  8843. _isSynchronized(): boolean;
  8844. /**
  8845. * Computes the world matrix of the node
  8846. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8847. * @returns the world matrix
  8848. */
  8849. computeWorldMatrix(force?: boolean): Matrix;
  8850. /**
  8851. * Gets the minZ used for shadow according to both the scene and the light.
  8852. * @param activeCamera The camera we are returning the min for
  8853. * @returns the depth min z
  8854. */
  8855. getDepthMinZ(activeCamera: Camera): number;
  8856. /**
  8857. * Gets the maxZ used for shadow according to both the scene and the light.
  8858. * @param activeCamera The camera we are returning the max for
  8859. * @returns the depth max z
  8860. */
  8861. getDepthMaxZ(activeCamera: Camera): number;
  8862. /**
  8863. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8864. * @param matrix The materix to updated with the projection information
  8865. * @param viewMatrix The transform matrix of the light
  8866. * @param renderList The list of mesh to render in the map
  8867. * @returns The current light
  8868. */
  8869. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8870. }
  8871. }
  8872. declare module "babylonjs/Materials/materialHelper" {
  8873. import { Nullable } from "babylonjs/types";
  8874. import { Scene } from "babylonjs/scene";
  8875. import { Engine } from "babylonjs/Engines/engine";
  8876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8877. import { Light } from "babylonjs/Lights/light";
  8878. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8879. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8881. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8882. /**
  8883. * "Static Class" containing the most commonly used helper while dealing with material for
  8884. * rendering purpose.
  8885. *
  8886. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8887. *
  8888. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8889. */
  8890. export class MaterialHelper {
  8891. /**
  8892. * Bind the current view position to an effect.
  8893. * @param effect The effect to be bound
  8894. * @param scene The scene the eyes position is used from
  8895. */
  8896. static BindEyePosition(effect: Effect, scene: Scene): void;
  8897. /**
  8898. * Helps preparing the defines values about the UVs in used in the effect.
  8899. * UVs are shared as much as we can accross channels in the shaders.
  8900. * @param texture The texture we are preparing the UVs for
  8901. * @param defines The defines to update
  8902. * @param key The channel key "diffuse", "specular"... used in the shader
  8903. */
  8904. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8905. /**
  8906. * Binds a texture matrix value to its corrsponding uniform
  8907. * @param texture The texture to bind the matrix for
  8908. * @param uniformBuffer The uniform buffer receivin the data
  8909. * @param key The channel key "diffuse", "specular"... used in the shader
  8910. */
  8911. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8912. /**
  8913. * Gets the current status of the fog (should it be enabled?)
  8914. * @param mesh defines the mesh to evaluate for fog support
  8915. * @param scene defines the hosting scene
  8916. * @returns true if fog must be enabled
  8917. */
  8918. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8919. /**
  8920. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8921. * @param mesh defines the current mesh
  8922. * @param scene defines the current scene
  8923. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8924. * @param pointsCloud defines if point cloud rendering has to be turned on
  8925. * @param fogEnabled defines if fog has to be turned on
  8926. * @param alphaTest defines if alpha testing has to be turned on
  8927. * @param defines defines the current list of defines
  8928. */
  8929. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8930. /**
  8931. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8932. * @param scene defines the current scene
  8933. * @param engine defines the current engine
  8934. * @param defines specifies the list of active defines
  8935. * @param useInstances defines if instances have to be turned on
  8936. * @param useClipPlane defines if clip plane have to be turned on
  8937. */
  8938. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8939. /**
  8940. * Prepares the defines for bones
  8941. * @param mesh The mesh containing the geometry data we will draw
  8942. * @param defines The defines to update
  8943. */
  8944. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8945. /**
  8946. * Prepares the defines for morph targets
  8947. * @param mesh The mesh containing the geometry data we will draw
  8948. * @param defines The defines to update
  8949. */
  8950. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8951. /**
  8952. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8953. * @param mesh The mesh containing the geometry data we will draw
  8954. * @param defines The defines to update
  8955. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8956. * @param useBones Precise whether bones should be used or not (override mesh info)
  8957. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8958. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8959. * @returns false if defines are considered not dirty and have not been checked
  8960. */
  8961. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8962. /**
  8963. * Prepares the defines related to multiview
  8964. * @param scene The scene we are intending to draw
  8965. * @param defines The defines to update
  8966. */
  8967. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8968. /**
  8969. * Prepares the defines related to the light information passed in parameter
  8970. * @param scene The scene we are intending to draw
  8971. * @param mesh The mesh the effect is compiling for
  8972. * @param light The light the effect is compiling for
  8973. * @param lightIndex The index of the light
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param state Defines the current state regarding what is needed (normals, etc...)
  8977. */
  8978. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8979. needNormals: boolean;
  8980. needRebuild: boolean;
  8981. shadowEnabled: boolean;
  8982. specularEnabled: boolean;
  8983. lightmapMode: boolean;
  8984. }): void;
  8985. /**
  8986. * Prepares the defines related to the light information passed in parameter
  8987. * @param scene The scene we are intending to draw
  8988. * @param mesh The mesh the effect is compiling for
  8989. * @param defines The defines to update
  8990. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8991. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8992. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8993. * @returns true if normals will be required for the rest of the effect
  8994. */
  8995. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8996. /**
  8997. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8998. * @param lightIndex defines the light index
  8999. * @param uniformsList The uniform list
  9000. * @param samplersList The sampler list
  9001. * @param projectedLightTexture defines if projected texture must be used
  9002. * @param uniformBuffersList defines an optional list of uniform buffers
  9003. */
  9004. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9005. /**
  9006. * Prepares the uniforms and samplers list to be used in the effect
  9007. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9008. * @param samplersList The sampler list
  9009. * @param defines The defines helping in the list generation
  9010. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9011. */
  9012. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9013. /**
  9014. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9015. * @param defines The defines to update while falling back
  9016. * @param fallbacks The authorized effect fallbacks
  9017. * @param maxSimultaneousLights The maximum number of lights allowed
  9018. * @param rank the current rank of the Effect
  9019. * @returns The newly affected rank
  9020. */
  9021. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9022. private static _TmpMorphInfluencers;
  9023. /**
  9024. * Prepares the list of attributes required for morph targets according to the effect defines.
  9025. * @param attribs The current list of supported attribs
  9026. * @param mesh The mesh to prepare the morph targets attributes for
  9027. * @param influencers The number of influencers
  9028. */
  9029. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9030. /**
  9031. * Prepares the list of attributes required for morph targets according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param mesh The mesh to prepare the morph targets attributes for
  9034. * @param defines The current Defines of the effect
  9035. */
  9036. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9037. /**
  9038. * Prepares the list of attributes required for bones according to the effect defines.
  9039. * @param attribs The current list of supported attribs
  9040. * @param mesh The mesh to prepare the bones attributes for
  9041. * @param defines The current Defines of the effect
  9042. * @param fallbacks The current efffect fallback strategy
  9043. */
  9044. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9045. /**
  9046. * Check and prepare the list of attributes required for instances according to the effect defines.
  9047. * @param attribs The current list of supported attribs
  9048. * @param defines The current MaterialDefines of the effect
  9049. */
  9050. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9051. /**
  9052. * Add the list of attributes required for instances to the attribs array.
  9053. * @param attribs The current list of supported attribs
  9054. */
  9055. static PushAttributesForInstances(attribs: string[]): void;
  9056. /**
  9057. * Binds the light shadow information to the effect for the given mesh.
  9058. * @param light The light containing the generator
  9059. * @param scene The scene the lights belongs to
  9060. * @param mesh The mesh we are binding the information to render
  9061. * @param lightIndex The light index in the effect used to render the mesh
  9062. * @param effect The effect we are binding the data to
  9063. */
  9064. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9065. /**
  9066. * Binds the light information to the effect.
  9067. * @param light The light containing the generator
  9068. * @param effect The effect we are binding the data to
  9069. * @param lightIndex The light index in the effect used to render
  9070. */
  9071. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9072. /**
  9073. * Binds the lights information from the scene to the effect for the given mesh.
  9074. * @param light Light to bind
  9075. * @param lightIndex Light index
  9076. * @param scene The scene where the light belongs to
  9077. * @param mesh The mesh we are binding the information to render
  9078. * @param effect The effect we are binding the data to
  9079. * @param useSpecular Defines if specular is supported
  9080. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9081. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9082. */
  9083. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9084. /**
  9085. * Binds the lights information from the scene to the effect for the given mesh.
  9086. * @param scene The scene the lights belongs to
  9087. * @param mesh The mesh we are binding the information to render
  9088. * @param effect The effect we are binding the data to
  9089. * @param defines The generated defines for the effect
  9090. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9091. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9092. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9093. */
  9094. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9095. private static _tempFogColor;
  9096. /**
  9097. * Binds the fog information from the scene to the effect for the given mesh.
  9098. * @param scene The scene the lights belongs to
  9099. * @param mesh The mesh we are binding the information to render
  9100. * @param effect The effect we are binding the data to
  9101. * @param linearSpace Defines if the fog effect is applied in linear space
  9102. */
  9103. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9104. /**
  9105. * Binds the bones information from the mesh to the effect.
  9106. * @param mesh The mesh we are binding the information to render
  9107. * @param effect The effect we are binding the data to
  9108. */
  9109. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9110. /**
  9111. * Binds the morph targets information from the mesh to the effect.
  9112. * @param abstractMesh The mesh we are binding the information to render
  9113. * @param effect The effect we are binding the data to
  9114. */
  9115. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9116. /**
  9117. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9118. * @param defines The generated defines used in the effect
  9119. * @param effect The effect we are binding the data to
  9120. * @param scene The scene we are willing to render with logarithmic scale for
  9121. */
  9122. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9123. /**
  9124. * Binds the clip plane information from the scene to the effect.
  9125. * @param scene The scene the clip plane information are extracted from
  9126. * @param effect The effect we are binding the data to
  9127. */
  9128. static BindClipPlane(effect: Effect, scene: Scene): void;
  9129. }
  9130. }
  9131. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9132. /** @hidden */
  9133. export var packingFunctions: {
  9134. name: string;
  9135. shader: string;
  9136. };
  9137. }
  9138. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9139. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9140. /** @hidden */
  9141. export var shadowMapPixelShader: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9147. /** @hidden */
  9148. export var bonesDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9154. /** @hidden */
  9155. export var morphTargetsVertexGlobalDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9161. /** @hidden */
  9162. export var morphTargetsVertexDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9168. /** @hidden */
  9169. export var instancesDeclaration: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9175. /** @hidden */
  9176. export var helperFunctions: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9182. /** @hidden */
  9183. export var morphTargetsVertex: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9189. /** @hidden */
  9190. export var instancesVertex: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9196. /** @hidden */
  9197. export var bonesVertex: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9203. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9204. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9205. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9206. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9207. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9208. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9209. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9210. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9211. /** @hidden */
  9212. export var shadowMapVertexShader: {
  9213. name: string;
  9214. shader: string;
  9215. };
  9216. }
  9217. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9218. /** @hidden */
  9219. export var depthBoxBlurPixelShader: {
  9220. name: string;
  9221. shader: string;
  9222. };
  9223. }
  9224. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9225. import { Nullable } from "babylonjs/types";
  9226. import { Scene } from "babylonjs/scene";
  9227. import { Matrix } from "babylonjs/Maths/math.vector";
  9228. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9230. import { Mesh } from "babylonjs/Meshes/mesh";
  9231. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9232. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9233. import { Effect } from "babylonjs/Materials/effect";
  9234. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9235. import "babylonjs/Shaders/shadowMap.fragment";
  9236. import "babylonjs/Shaders/shadowMap.vertex";
  9237. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9238. import { Observable } from "babylonjs/Misc/observable";
  9239. /**
  9240. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9241. */
  9242. export interface ICustomShaderOptions {
  9243. /**
  9244. * Gets or sets the custom shader name to use
  9245. */
  9246. shaderName: string;
  9247. /**
  9248. * The list of attribute names used in the shader
  9249. */
  9250. attributes?: string[];
  9251. /**
  9252. * The list of unifrom names used in the shader
  9253. */
  9254. uniforms?: string[];
  9255. /**
  9256. * The list of sampler names used in the shader
  9257. */
  9258. samplers?: string[];
  9259. /**
  9260. * The list of defines used in the shader
  9261. */
  9262. defines?: string[];
  9263. }
  9264. /**
  9265. * Interface to implement to create a shadow generator compatible with BJS.
  9266. */
  9267. export interface IShadowGenerator {
  9268. /**
  9269. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9270. * @returns The render target texture if present otherwise, null
  9271. */
  9272. getShadowMap(): Nullable<RenderTargetTexture>;
  9273. /**
  9274. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9275. * @returns The render target texture if the shadow map is present otherwise, null
  9276. */
  9277. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9278. /**
  9279. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9280. * @param subMesh The submesh we want to render in the shadow map
  9281. * @param useInstances Defines wether will draw in the map using instances
  9282. * @returns true if ready otherwise, false
  9283. */
  9284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9285. /**
  9286. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9287. * @param defines Defines of the material we want to update
  9288. * @param lightIndex Index of the light in the enabled light list of the material
  9289. */
  9290. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9291. /**
  9292. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9293. * defined in the generator but impacting the effect).
  9294. * It implies the unifroms available on the materials are the standard BJS ones.
  9295. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9296. * @param effect The effect we are binfing the information for
  9297. */
  9298. bindShadowLight(lightIndex: string, effect: Effect): void;
  9299. /**
  9300. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9301. * (eq to shadow prjection matrix * light transform matrix)
  9302. * @returns The transform matrix used to create the shadow map
  9303. */
  9304. getTransformMatrix(): Matrix;
  9305. /**
  9306. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9307. * Cube and 2D textures for instance.
  9308. */
  9309. recreateShadowMap(): void;
  9310. /**
  9311. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9312. * @param onCompiled Callback triggered at the and of the effects compilation
  9313. * @param options Sets of optional options forcing the compilation with different modes
  9314. */
  9315. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9316. useInstances: boolean;
  9317. }>): void;
  9318. /**
  9319. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9320. * @param options Sets of optional options forcing the compilation with different modes
  9321. * @returns A promise that resolves when the compilation completes
  9322. */
  9323. forceCompilationAsync(options?: Partial<{
  9324. useInstances: boolean;
  9325. }>): Promise<void>;
  9326. /**
  9327. * Serializes the shadow generator setup to a json object.
  9328. * @returns The serialized JSON object
  9329. */
  9330. serialize(): any;
  9331. /**
  9332. * Disposes the Shadow map and related Textures and effects.
  9333. */
  9334. dispose(): void;
  9335. }
  9336. /**
  9337. * Default implementation IShadowGenerator.
  9338. * This is the main object responsible of generating shadows in the framework.
  9339. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9340. */
  9341. export class ShadowGenerator implements IShadowGenerator {
  9342. /**
  9343. * Shadow generator mode None: no filtering applied.
  9344. */
  9345. static readonly FILTER_NONE: number;
  9346. /**
  9347. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9348. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9349. */
  9350. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9351. /**
  9352. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9353. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9354. */
  9355. static readonly FILTER_POISSONSAMPLING: number;
  9356. /**
  9357. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9358. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9359. */
  9360. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9361. /**
  9362. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9363. * edge artifacts on steep falloff.
  9364. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9365. */
  9366. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9367. /**
  9368. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9369. * edge artifacts on steep falloff.
  9370. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9371. */
  9372. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9373. /**
  9374. * Shadow generator mode PCF: Percentage Closer Filtering
  9375. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9376. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9377. */
  9378. static readonly FILTER_PCF: number;
  9379. /**
  9380. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9381. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9382. * Contact Hardening
  9383. */
  9384. static readonly FILTER_PCSS: number;
  9385. /**
  9386. * Reserved for PCF and PCSS
  9387. * Highest Quality.
  9388. *
  9389. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9390. *
  9391. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9392. */
  9393. static readonly QUALITY_HIGH: number;
  9394. /**
  9395. * Reserved for PCF and PCSS
  9396. * Good tradeoff for quality/perf cross devices
  9397. *
  9398. * Execute PCF on a 3*3 kernel.
  9399. *
  9400. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9401. */
  9402. static readonly QUALITY_MEDIUM: number;
  9403. /**
  9404. * Reserved for PCF and PCSS
  9405. * The lowest quality but the fastest.
  9406. *
  9407. * Execute PCF on a 1*1 kernel.
  9408. *
  9409. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9410. */
  9411. static readonly QUALITY_LOW: number;
  9412. /** Gets or sets the custom shader name to use */
  9413. customShaderOptions: ICustomShaderOptions;
  9414. /**
  9415. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9416. */
  9417. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9418. /**
  9419. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9420. */
  9421. onAfterShadowMapRenderObservable: Observable<Effect>;
  9422. /**
  9423. * Observable triggered before a mesh is rendered in the shadow map.
  9424. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9425. */
  9426. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9427. /**
  9428. * Observable triggered after a mesh is rendered in the shadow map.
  9429. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9430. */
  9431. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9432. private _bias;
  9433. /**
  9434. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9435. */
  9436. /**
  9437. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9438. */
  9439. bias: number;
  9440. private _normalBias;
  9441. /**
  9442. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9443. */
  9444. /**
  9445. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9446. */
  9447. normalBias: number;
  9448. private _blurBoxOffset;
  9449. /**
  9450. * Gets the blur box offset: offset applied during the blur pass.
  9451. * Only useful if useKernelBlur = false
  9452. */
  9453. /**
  9454. * Sets the blur box offset: offset applied during the blur pass.
  9455. * Only useful if useKernelBlur = false
  9456. */
  9457. blurBoxOffset: number;
  9458. private _blurScale;
  9459. /**
  9460. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9461. * 2 means half of the size.
  9462. */
  9463. /**
  9464. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9465. * 2 means half of the size.
  9466. */
  9467. blurScale: number;
  9468. private _blurKernel;
  9469. /**
  9470. * Gets the blur kernel: kernel size of the blur pass.
  9471. * Only useful if useKernelBlur = true
  9472. */
  9473. /**
  9474. * Sets the blur kernel: kernel size of the blur pass.
  9475. * Only useful if useKernelBlur = true
  9476. */
  9477. blurKernel: number;
  9478. private _useKernelBlur;
  9479. /**
  9480. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9481. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9482. */
  9483. /**
  9484. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9485. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9486. */
  9487. useKernelBlur: boolean;
  9488. private _depthScale;
  9489. /**
  9490. * Gets the depth scale used in ESM mode.
  9491. */
  9492. /**
  9493. * Sets the depth scale used in ESM mode.
  9494. * This can override the scale stored on the light.
  9495. */
  9496. depthScale: number;
  9497. private _filter;
  9498. /**
  9499. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9500. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9501. */
  9502. /**
  9503. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9504. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9505. */
  9506. filter: number;
  9507. /**
  9508. * Gets if the current filter is set to Poisson Sampling.
  9509. */
  9510. /**
  9511. * Sets the current filter to Poisson Sampling.
  9512. */
  9513. usePoissonSampling: boolean;
  9514. /**
  9515. * Gets if the current filter is set to ESM.
  9516. */
  9517. /**
  9518. * Sets the current filter is to ESM.
  9519. */
  9520. useExponentialShadowMap: boolean;
  9521. /**
  9522. * Gets if the current filter is set to filtered ESM.
  9523. */
  9524. /**
  9525. * Gets if the current filter is set to filtered ESM.
  9526. */
  9527. useBlurExponentialShadowMap: boolean;
  9528. /**
  9529. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9530. * exponential to prevent steep falloff artifacts).
  9531. */
  9532. /**
  9533. * Sets the current filter to "close ESM" (using the inverse of the
  9534. * exponential to prevent steep falloff artifacts).
  9535. */
  9536. useCloseExponentialShadowMap: boolean;
  9537. /**
  9538. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9539. * exponential to prevent steep falloff artifacts).
  9540. */
  9541. /**
  9542. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9543. * exponential to prevent steep falloff artifacts).
  9544. */
  9545. useBlurCloseExponentialShadowMap: boolean;
  9546. /**
  9547. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCF" (percentage closer filtering).
  9551. */
  9552. usePercentageCloserFiltering: boolean;
  9553. private _filteringQuality;
  9554. /**
  9555. * Gets the PCF or PCSS Quality.
  9556. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9557. */
  9558. /**
  9559. * Sets the PCF or PCSS Quality.
  9560. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9561. */
  9562. filteringQuality: number;
  9563. /**
  9564. * Gets if the current filter is set to "PCSS" (contact hardening).
  9565. */
  9566. /**
  9567. * Sets the current filter to "PCSS" (contact hardening).
  9568. */
  9569. useContactHardeningShadow: boolean;
  9570. private _contactHardeningLightSizeUVRatio;
  9571. /**
  9572. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9573. * Using a ratio helps keeping shape stability independently of the map size.
  9574. *
  9575. * It does not account for the light projection as it was having too much
  9576. * instability during the light setup or during light position changes.
  9577. *
  9578. * Only valid if useContactHardeningShadow is true.
  9579. */
  9580. /**
  9581. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9582. * Using a ratio helps keeping shape stability independently of the map size.
  9583. *
  9584. * It does not account for the light projection as it was having too much
  9585. * instability during the light setup or during light position changes.
  9586. *
  9587. * Only valid if useContactHardeningShadow is true.
  9588. */
  9589. contactHardeningLightSizeUVRatio: number;
  9590. private _darkness;
  9591. /** Gets or sets the actual darkness of a shadow */
  9592. darkness: number;
  9593. /**
  9594. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9595. * 0 means strongest and 1 would means no shadow.
  9596. * @returns the darkness.
  9597. */
  9598. getDarkness(): number;
  9599. /**
  9600. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9601. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9602. * @returns the shadow generator allowing fluent coding.
  9603. */
  9604. setDarkness(darkness: number): ShadowGenerator;
  9605. private _transparencyShadow;
  9606. /** Gets or sets the ability to have transparent shadow */
  9607. transparencyShadow: boolean;
  9608. /**
  9609. * Sets the ability to have transparent shadow (boolean).
  9610. * @param transparent True if transparent else False
  9611. * @returns the shadow generator allowing fluent coding
  9612. */
  9613. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9614. private _shadowMap;
  9615. private _shadowMap2;
  9616. /**
  9617. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9618. * @returns The render target texture if present otherwise, null
  9619. */
  9620. getShadowMap(): Nullable<RenderTargetTexture>;
  9621. /**
  9622. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9623. * @returns The render target texture if the shadow map is present otherwise, null
  9624. */
  9625. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9626. /**
  9627. * Gets the class name of that object
  9628. * @returns "ShadowGenerator"
  9629. */
  9630. getClassName(): string;
  9631. /**
  9632. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9633. * @param mesh Mesh to add
  9634. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9635. * @returns the Shadow Generator itself
  9636. */
  9637. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9638. /**
  9639. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9640. * @param mesh Mesh to remove
  9641. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9642. * @returns the Shadow Generator itself
  9643. */
  9644. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9645. /**
  9646. * Controls the extent to which the shadows fade out at the edge of the frustum
  9647. * Used only by directionals and spots
  9648. */
  9649. frustumEdgeFalloff: number;
  9650. private _light;
  9651. /**
  9652. * Returns the associated light object.
  9653. * @returns the light generating the shadow
  9654. */
  9655. getLight(): IShadowLight;
  9656. /**
  9657. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9658. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9659. * It might on the other hand introduce peter panning.
  9660. */
  9661. forceBackFacesOnly: boolean;
  9662. private _scene;
  9663. private _lightDirection;
  9664. private _effect;
  9665. private _viewMatrix;
  9666. private _projectionMatrix;
  9667. private _transformMatrix;
  9668. private _cachedPosition;
  9669. private _cachedDirection;
  9670. private _cachedDefines;
  9671. private _currentRenderID;
  9672. private _boxBlurPostprocess;
  9673. private _kernelBlurXPostprocess;
  9674. private _kernelBlurYPostprocess;
  9675. private _blurPostProcesses;
  9676. private _mapSize;
  9677. private _currentFaceIndex;
  9678. private _currentFaceIndexCache;
  9679. private _textureType;
  9680. private _defaultTextureMatrix;
  9681. /** @hidden */
  9682. static _SceneComponentInitialization: (scene: Scene) => void;
  9683. /**
  9684. * Creates a ShadowGenerator object.
  9685. * A ShadowGenerator is the required tool to use the shadows.
  9686. * Each light casting shadows needs to use its own ShadowGenerator.
  9687. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9688. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9689. * @param light The light object generating the shadows.
  9690. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9691. */
  9692. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9693. private _initializeGenerator;
  9694. private _initializeShadowMap;
  9695. private _initializeBlurRTTAndPostProcesses;
  9696. private _renderForShadowMap;
  9697. private _renderSubMeshForShadowMap;
  9698. private _applyFilterValues;
  9699. /**
  9700. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9701. * @param onCompiled Callback triggered at the and of the effects compilation
  9702. * @param options Sets of optional options forcing the compilation with different modes
  9703. */
  9704. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9705. useInstances: boolean;
  9706. }>): void;
  9707. /**
  9708. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9709. * @param options Sets of optional options forcing the compilation with different modes
  9710. * @returns A promise that resolves when the compilation completes
  9711. */
  9712. forceCompilationAsync(options?: Partial<{
  9713. useInstances: boolean;
  9714. }>): Promise<void>;
  9715. /**
  9716. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9717. * @param subMesh The submesh we want to render in the shadow map
  9718. * @param useInstances Defines wether will draw in the map using instances
  9719. * @returns true if ready otherwise, false
  9720. */
  9721. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9722. /**
  9723. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9724. * @param defines Defines of the material we want to update
  9725. * @param lightIndex Index of the light in the enabled light list of the material
  9726. */
  9727. prepareDefines(defines: any, lightIndex: number): void;
  9728. /**
  9729. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9730. * defined in the generator but impacting the effect).
  9731. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9732. * @param effect The effect we are binfing the information for
  9733. */
  9734. bindShadowLight(lightIndex: string, effect: Effect): void;
  9735. /**
  9736. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9737. * (eq to shadow prjection matrix * light transform matrix)
  9738. * @returns The transform matrix used to create the shadow map
  9739. */
  9740. getTransformMatrix(): Matrix;
  9741. /**
  9742. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9743. * Cube and 2D textures for instance.
  9744. */
  9745. recreateShadowMap(): void;
  9746. private _disposeBlurPostProcesses;
  9747. private _disposeRTTandPostProcesses;
  9748. /**
  9749. * Disposes the ShadowGenerator.
  9750. * Returns nothing.
  9751. */
  9752. dispose(): void;
  9753. /**
  9754. * Serializes the shadow generator setup to a json object.
  9755. * @returns The serialized JSON object
  9756. */
  9757. serialize(): any;
  9758. /**
  9759. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9760. * @param parsedShadowGenerator The JSON object to parse
  9761. * @param scene The scene to create the shadow map for
  9762. * @returns The parsed shadow generator
  9763. */
  9764. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9765. }
  9766. }
  9767. declare module "babylonjs/Lights/light" {
  9768. import { Nullable } from "babylonjs/types";
  9769. import { Scene } from "babylonjs/scene";
  9770. import { Vector3 } from "babylonjs/Maths/math.vector";
  9771. import { Color3 } from "babylonjs/Maths/math.color";
  9772. import { Node } from "babylonjs/node";
  9773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9774. import { Effect } from "babylonjs/Materials/effect";
  9775. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9776. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9777. /**
  9778. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9779. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9780. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9781. */
  9782. export abstract class Light extends Node {
  9783. /**
  9784. * Falloff Default: light is falling off following the material specification:
  9785. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9786. */
  9787. static readonly FALLOFF_DEFAULT: number;
  9788. /**
  9789. * Falloff Physical: light is falling off following the inverse squared distance law.
  9790. */
  9791. static readonly FALLOFF_PHYSICAL: number;
  9792. /**
  9793. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9794. * to enhance interoperability with other engines.
  9795. */
  9796. static readonly FALLOFF_GLTF: number;
  9797. /**
  9798. * Falloff Standard: light is falling off like in the standard material
  9799. * to enhance interoperability with other materials.
  9800. */
  9801. static readonly FALLOFF_STANDARD: number;
  9802. /**
  9803. * If every light affecting the material is in this lightmapMode,
  9804. * material.lightmapTexture adds or multiplies
  9805. * (depends on material.useLightmapAsShadowmap)
  9806. * after every other light calculations.
  9807. */
  9808. static readonly LIGHTMAP_DEFAULT: number;
  9809. /**
  9810. * material.lightmapTexture as only diffuse lighting from this light
  9811. * adds only specular lighting from this light
  9812. * adds dynamic shadows
  9813. */
  9814. static readonly LIGHTMAP_SPECULAR: number;
  9815. /**
  9816. * material.lightmapTexture as only lighting
  9817. * no light calculation from this light
  9818. * only adds dynamic shadows from this light
  9819. */
  9820. static readonly LIGHTMAP_SHADOWSONLY: number;
  9821. /**
  9822. * Each light type uses the default quantity according to its type:
  9823. * point/spot lights use luminous intensity
  9824. * directional lights use illuminance
  9825. */
  9826. static readonly INTENSITYMODE_AUTOMATIC: number;
  9827. /**
  9828. * lumen (lm)
  9829. */
  9830. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9831. /**
  9832. * candela (lm/sr)
  9833. */
  9834. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9835. /**
  9836. * lux (lm/m^2)
  9837. */
  9838. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9839. /**
  9840. * nit (cd/m^2)
  9841. */
  9842. static readonly INTENSITYMODE_LUMINANCE: number;
  9843. /**
  9844. * Light type const id of the point light.
  9845. */
  9846. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9847. /**
  9848. * Light type const id of the directional light.
  9849. */
  9850. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9851. /**
  9852. * Light type const id of the spot light.
  9853. */
  9854. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9855. /**
  9856. * Light type const id of the hemispheric light.
  9857. */
  9858. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9859. /**
  9860. * Diffuse gives the basic color to an object.
  9861. */
  9862. diffuse: Color3;
  9863. /**
  9864. * Specular produces a highlight color on an object.
  9865. * Note: This is note affecting PBR materials.
  9866. */
  9867. specular: Color3;
  9868. /**
  9869. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9870. * falling off base on range or angle.
  9871. * This can be set to any values in Light.FALLOFF_x.
  9872. *
  9873. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9874. * other types of materials.
  9875. */
  9876. falloffType: number;
  9877. /**
  9878. * Strength of the light.
  9879. * Note: By default it is define in the framework own unit.
  9880. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9881. */
  9882. intensity: number;
  9883. private _range;
  9884. protected _inverseSquaredRange: number;
  9885. /**
  9886. * Defines how far from the source the light is impacting in scene units.
  9887. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9888. */
  9889. /**
  9890. * Defines how far from the source the light is impacting in scene units.
  9891. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9892. */
  9893. range: number;
  9894. /**
  9895. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9896. * of light.
  9897. */
  9898. private _photometricScale;
  9899. private _intensityMode;
  9900. /**
  9901. * Gets the photometric scale used to interpret the intensity.
  9902. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9903. */
  9904. /**
  9905. * Sets the photometric scale used to interpret the intensity.
  9906. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9907. */
  9908. intensityMode: number;
  9909. private _radius;
  9910. /**
  9911. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9912. */
  9913. /**
  9914. * sets the light radius used by PBR Materials to simulate soft area lights.
  9915. */
  9916. radius: number;
  9917. private _renderPriority;
  9918. /**
  9919. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9920. * exceeding the number allowed of the materials.
  9921. */
  9922. renderPriority: number;
  9923. private _shadowEnabled;
  9924. /**
  9925. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9926. * the current shadow generator.
  9927. */
  9928. /**
  9929. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9930. * the current shadow generator.
  9931. */
  9932. shadowEnabled: boolean;
  9933. private _includedOnlyMeshes;
  9934. /**
  9935. * Gets the only meshes impacted by this light.
  9936. */
  9937. /**
  9938. * Sets the only meshes impacted by this light.
  9939. */
  9940. includedOnlyMeshes: AbstractMesh[];
  9941. private _excludedMeshes;
  9942. /**
  9943. * Gets the meshes not impacted by this light.
  9944. */
  9945. /**
  9946. * Sets the meshes not impacted by this light.
  9947. */
  9948. excludedMeshes: AbstractMesh[];
  9949. private _excludeWithLayerMask;
  9950. /**
  9951. * Gets the layer id use to find what meshes are not impacted by the light.
  9952. * Inactive if 0
  9953. */
  9954. /**
  9955. * Sets the layer id use to find what meshes are not impacted by the light.
  9956. * Inactive if 0
  9957. */
  9958. excludeWithLayerMask: number;
  9959. private _includeOnlyWithLayerMask;
  9960. /**
  9961. * Gets the layer id use to find what meshes are impacted by the light.
  9962. * Inactive if 0
  9963. */
  9964. /**
  9965. * Sets the layer id use to find what meshes are impacted by the light.
  9966. * Inactive if 0
  9967. */
  9968. includeOnlyWithLayerMask: number;
  9969. private _lightmapMode;
  9970. /**
  9971. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9972. */
  9973. /**
  9974. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9975. */
  9976. lightmapMode: number;
  9977. /**
  9978. * Shadow generator associted to the light.
  9979. * @hidden Internal use only.
  9980. */
  9981. _shadowGenerator: Nullable<IShadowGenerator>;
  9982. /**
  9983. * @hidden Internal use only.
  9984. */
  9985. _excludedMeshesIds: string[];
  9986. /**
  9987. * @hidden Internal use only.
  9988. */
  9989. _includedOnlyMeshesIds: string[];
  9990. /**
  9991. * The current light unifom buffer.
  9992. * @hidden Internal use only.
  9993. */
  9994. _uniformBuffer: UniformBuffer;
  9995. /**
  9996. * Creates a Light object in the scene.
  9997. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9998. * @param name The firendly name of the light
  9999. * @param scene The scene the light belongs too
  10000. */
  10001. constructor(name: string, scene: Scene);
  10002. protected abstract _buildUniformLayout(): void;
  10003. /**
  10004. * Sets the passed Effect "effect" with the Light information.
  10005. * @param effect The effect to update
  10006. * @param lightIndex The index of the light in the effect to update
  10007. * @returns The light
  10008. */
  10009. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10010. /**
  10011. * Sets the passed Effect "effect" with the Light information.
  10012. * @param effect The effect to update
  10013. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10014. * @returns The light
  10015. */
  10016. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10017. /**
  10018. * Returns the string "Light".
  10019. * @returns the class name
  10020. */
  10021. getClassName(): string;
  10022. /** @hidden */
  10023. readonly _isLight: boolean;
  10024. /**
  10025. * Converts the light information to a readable string for debug purpose.
  10026. * @param fullDetails Supports for multiple levels of logging within scene loading
  10027. * @returns the human readable light info
  10028. */
  10029. toString(fullDetails?: boolean): string;
  10030. /** @hidden */
  10031. protected _syncParentEnabledState(): void;
  10032. /**
  10033. * Set the enabled state of this node.
  10034. * @param value - the new enabled state
  10035. */
  10036. setEnabled(value: boolean): void;
  10037. /**
  10038. * Returns the Light associated shadow generator if any.
  10039. * @return the associated shadow generator.
  10040. */
  10041. getShadowGenerator(): Nullable<IShadowGenerator>;
  10042. /**
  10043. * Returns a Vector3, the absolute light position in the World.
  10044. * @returns the world space position of the light
  10045. */
  10046. getAbsolutePosition(): Vector3;
  10047. /**
  10048. * Specifies if the light will affect the passed mesh.
  10049. * @param mesh The mesh to test against the light
  10050. * @return true the mesh is affected otherwise, false.
  10051. */
  10052. canAffectMesh(mesh: AbstractMesh): boolean;
  10053. /**
  10054. * Sort function to order lights for rendering.
  10055. * @param a First Light object to compare to second.
  10056. * @param b Second Light object to compare first.
  10057. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10058. */
  10059. static CompareLightsPriority(a: Light, b: Light): number;
  10060. /**
  10061. * Releases resources associated with this node.
  10062. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10063. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10064. */
  10065. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10066. /**
  10067. * Returns the light type ID (integer).
  10068. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10069. */
  10070. getTypeID(): number;
  10071. /**
  10072. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10073. * @returns the scaled intensity in intensity mode unit
  10074. */
  10075. getScaledIntensity(): number;
  10076. /**
  10077. * Returns a new Light object, named "name", from the current one.
  10078. * @param name The name of the cloned light
  10079. * @returns the new created light
  10080. */
  10081. clone(name: string): Nullable<Light>;
  10082. /**
  10083. * Serializes the current light into a Serialization object.
  10084. * @returns the serialized object.
  10085. */
  10086. serialize(): any;
  10087. /**
  10088. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10089. * This new light is named "name" and added to the passed scene.
  10090. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10091. * @param name The friendly name of the light
  10092. * @param scene The scene the new light will belong to
  10093. * @returns the constructor function
  10094. */
  10095. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10096. /**
  10097. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10098. * @param parsedLight The JSON representation of the light
  10099. * @param scene The scene to create the parsed light in
  10100. * @returns the created light after parsing
  10101. */
  10102. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10103. private _hookArrayForExcluded;
  10104. private _hookArrayForIncludedOnly;
  10105. private _resyncMeshes;
  10106. /**
  10107. * Forces the meshes to update their light related information in their rendering used effects
  10108. * @hidden Internal Use Only
  10109. */
  10110. _markMeshesAsLightDirty(): void;
  10111. /**
  10112. * Recomputes the cached photometric scale if needed.
  10113. */
  10114. private _computePhotometricScale;
  10115. /**
  10116. * Returns the Photometric Scale according to the light type and intensity mode.
  10117. */
  10118. private _getPhotometricScale;
  10119. /**
  10120. * Reorder the light in the scene according to their defined priority.
  10121. * @hidden Internal Use Only
  10122. */
  10123. _reorderLightsInScene(): void;
  10124. /**
  10125. * Prepares the list of defines specific to the light type.
  10126. * @param defines the list of defines
  10127. * @param lightIndex defines the index of the light for the effect
  10128. */
  10129. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10130. }
  10131. }
  10132. declare module "babylonjs/Actions/action" {
  10133. import { Observable } from "babylonjs/Misc/observable";
  10134. import { Condition } from "babylonjs/Actions/condition";
  10135. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10136. import { ActionManager } from "babylonjs/Actions/actionManager";
  10137. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10138. /**
  10139. * Interface used to define Action
  10140. */
  10141. export interface IAction {
  10142. /**
  10143. * Trigger for the action
  10144. */
  10145. trigger: number;
  10146. /** Options of the trigger */
  10147. triggerOptions: any;
  10148. /**
  10149. * Gets the trigger parameters
  10150. * @returns the trigger parameters
  10151. */
  10152. getTriggerParameter(): any;
  10153. /**
  10154. * Internal only - executes current action event
  10155. * @hidden
  10156. */
  10157. _executeCurrent(evt?: ActionEvent): void;
  10158. /**
  10159. * Serialize placeholder for child classes
  10160. * @param parent of child
  10161. * @returns the serialized object
  10162. */
  10163. serialize(parent: any): any;
  10164. /**
  10165. * Internal only
  10166. * @hidden
  10167. */
  10168. _prepare(): void;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: AbstractActionManager;
  10174. /**
  10175. * Adds action to chain of actions, may be a DoNothingAction
  10176. * @param action defines the next action to execute
  10177. * @returns The action passed in
  10178. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10179. */
  10180. then(action: IAction): IAction;
  10181. }
  10182. /**
  10183. * The action to be carried out following a trigger
  10184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10185. */
  10186. export class Action implements IAction {
  10187. /** the trigger, with or without parameters, for the action */
  10188. triggerOptions: any;
  10189. /**
  10190. * Trigger for the action
  10191. */
  10192. trigger: number;
  10193. /**
  10194. * Internal only - manager for action
  10195. * @hidden
  10196. */
  10197. _actionManager: ActionManager;
  10198. private _nextActiveAction;
  10199. private _child;
  10200. private _condition?;
  10201. private _triggerParameter;
  10202. /**
  10203. * An event triggered prior to action being executed.
  10204. */
  10205. onBeforeExecuteObservable: Observable<Action>;
  10206. /**
  10207. * Creates a new Action
  10208. * @param triggerOptions the trigger, with or without parameters, for the action
  10209. * @param condition an optional determinant of action
  10210. */
  10211. constructor(
  10212. /** the trigger, with or without parameters, for the action */
  10213. triggerOptions: any, condition?: Condition);
  10214. /**
  10215. * Internal only
  10216. * @hidden
  10217. */
  10218. _prepare(): void;
  10219. /**
  10220. * Gets the trigger parameters
  10221. * @returns the trigger parameters
  10222. */
  10223. getTriggerParameter(): any;
  10224. /**
  10225. * Internal only - executes current action event
  10226. * @hidden
  10227. */
  10228. _executeCurrent(evt?: ActionEvent): void;
  10229. /**
  10230. * Execute placeholder for child classes
  10231. * @param evt optional action event
  10232. */
  10233. execute(evt?: ActionEvent): void;
  10234. /**
  10235. * Skips to next active action
  10236. */
  10237. skipToNextActiveAction(): void;
  10238. /**
  10239. * Adds action to chain of actions, may be a DoNothingAction
  10240. * @param action defines the next action to execute
  10241. * @returns The action passed in
  10242. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10243. */
  10244. then(action: Action): Action;
  10245. /**
  10246. * Internal only
  10247. * @hidden
  10248. */
  10249. _getProperty(propertyPath: string): string;
  10250. /**
  10251. * Internal only
  10252. * @hidden
  10253. */
  10254. _getEffectiveTarget(target: any, propertyPath: string): any;
  10255. /**
  10256. * Serialize placeholder for child classes
  10257. * @param parent of child
  10258. * @returns the serialized object
  10259. */
  10260. serialize(parent: any): any;
  10261. /**
  10262. * Internal only called by serialize
  10263. * @hidden
  10264. */
  10265. protected _serialize(serializedAction: any, parent?: any): any;
  10266. /**
  10267. * Internal only
  10268. * @hidden
  10269. */
  10270. static _SerializeValueAsString: (value: any) => string;
  10271. /**
  10272. * Internal only
  10273. * @hidden
  10274. */
  10275. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10276. name: string;
  10277. targetType: string;
  10278. value: string;
  10279. };
  10280. }
  10281. }
  10282. declare module "babylonjs/Actions/condition" {
  10283. import { ActionManager } from "babylonjs/Actions/actionManager";
  10284. /**
  10285. * A Condition applied to an Action
  10286. */
  10287. export class Condition {
  10288. /**
  10289. * Internal only - manager for action
  10290. * @hidden
  10291. */
  10292. _actionManager: ActionManager;
  10293. /**
  10294. * Internal only
  10295. * @hidden
  10296. */
  10297. _evaluationId: number;
  10298. /**
  10299. * Internal only
  10300. * @hidden
  10301. */
  10302. _currentResult: boolean;
  10303. /**
  10304. * Creates a new Condition
  10305. * @param actionManager the manager of the action the condition is applied to
  10306. */
  10307. constructor(actionManager: ActionManager);
  10308. /**
  10309. * Check if the current condition is valid
  10310. * @returns a boolean
  10311. */
  10312. isValid(): boolean;
  10313. /**
  10314. * Internal only
  10315. * @hidden
  10316. */
  10317. _getProperty(propertyPath: string): string;
  10318. /**
  10319. * Internal only
  10320. * @hidden
  10321. */
  10322. _getEffectiveTarget(target: any, propertyPath: string): any;
  10323. /**
  10324. * Serialize placeholder for child classes
  10325. * @returns the serialized object
  10326. */
  10327. serialize(): any;
  10328. /**
  10329. * Internal only
  10330. * @hidden
  10331. */
  10332. protected _serialize(serializedCondition: any): any;
  10333. }
  10334. /**
  10335. * Defines specific conditional operators as extensions of Condition
  10336. */
  10337. export class ValueCondition extends Condition {
  10338. /** path to specify the property of the target the conditional operator uses */
  10339. propertyPath: string;
  10340. /** the value compared by the conditional operator against the current value of the property */
  10341. value: any;
  10342. /** the conditional operator, default ValueCondition.IsEqual */
  10343. operator: number;
  10344. /**
  10345. * Internal only
  10346. * @hidden
  10347. */
  10348. private static _IsEqual;
  10349. /**
  10350. * Internal only
  10351. * @hidden
  10352. */
  10353. private static _IsDifferent;
  10354. /**
  10355. * Internal only
  10356. * @hidden
  10357. */
  10358. private static _IsGreater;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */
  10363. private static _IsLesser;
  10364. /**
  10365. * returns the number for IsEqual
  10366. */
  10367. static readonly IsEqual: number;
  10368. /**
  10369. * Returns the number for IsDifferent
  10370. */
  10371. static readonly IsDifferent: number;
  10372. /**
  10373. * Returns the number for IsGreater
  10374. */
  10375. static readonly IsGreater: number;
  10376. /**
  10377. * Returns the number for IsLesser
  10378. */
  10379. static readonly IsLesser: number;
  10380. /**
  10381. * Internal only The action manager for the condition
  10382. * @hidden
  10383. */
  10384. _actionManager: ActionManager;
  10385. /**
  10386. * Internal only
  10387. * @hidden
  10388. */
  10389. private _target;
  10390. /**
  10391. * Internal only
  10392. * @hidden
  10393. */
  10394. private _effectiveTarget;
  10395. /**
  10396. * Internal only
  10397. * @hidden
  10398. */
  10399. private _property;
  10400. /**
  10401. * Creates a new ValueCondition
  10402. * @param actionManager manager for the action the condition applies to
  10403. * @param target for the action
  10404. * @param propertyPath path to specify the property of the target the conditional operator uses
  10405. * @param value the value compared by the conditional operator against the current value of the property
  10406. * @param operator the conditional operator, default ValueCondition.IsEqual
  10407. */
  10408. constructor(actionManager: ActionManager, target: any,
  10409. /** path to specify the property of the target the conditional operator uses */
  10410. propertyPath: string,
  10411. /** the value compared by the conditional operator against the current value of the property */
  10412. value: any,
  10413. /** the conditional operator, default ValueCondition.IsEqual */
  10414. operator?: number);
  10415. /**
  10416. * Compares the given value with the property value for the specified conditional operator
  10417. * @returns the result of the comparison
  10418. */
  10419. isValid(): boolean;
  10420. /**
  10421. * Serialize the ValueCondition into a JSON compatible object
  10422. * @returns serialization object
  10423. */
  10424. serialize(): any;
  10425. /**
  10426. * Gets the name of the conditional operator for the ValueCondition
  10427. * @param operator the conditional operator
  10428. * @returns the name
  10429. */
  10430. static GetOperatorName(operator: number): string;
  10431. }
  10432. /**
  10433. * Defines a predicate condition as an extension of Condition
  10434. */
  10435. export class PredicateCondition extends Condition {
  10436. /** defines the predicate function used to validate the condition */
  10437. predicate: () => boolean;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Creates a new PredicateCondition
  10445. * @param actionManager manager for the action the condition applies to
  10446. * @param predicate defines the predicate function used to validate the condition
  10447. */
  10448. constructor(actionManager: ActionManager,
  10449. /** defines the predicate function used to validate the condition */
  10450. predicate: () => boolean);
  10451. /**
  10452. * @returns the validity of the predicate condition
  10453. */
  10454. isValid(): boolean;
  10455. }
  10456. /**
  10457. * Defines a state condition as an extension of Condition
  10458. */
  10459. export class StateCondition extends Condition {
  10460. /** Value to compare with target state */
  10461. value: string;
  10462. /**
  10463. * Internal only - manager for action
  10464. * @hidden
  10465. */
  10466. _actionManager: ActionManager;
  10467. /**
  10468. * Internal only
  10469. * @hidden
  10470. */
  10471. private _target;
  10472. /**
  10473. * Creates a new StateCondition
  10474. * @param actionManager manager for the action the condition applies to
  10475. * @param target of the condition
  10476. * @param value to compare with target state
  10477. */
  10478. constructor(actionManager: ActionManager, target: any,
  10479. /** Value to compare with target state */
  10480. value: string);
  10481. /**
  10482. * Gets a boolean indicating if the current condition is met
  10483. * @returns the validity of the state
  10484. */
  10485. isValid(): boolean;
  10486. /**
  10487. * Serialize the StateCondition into a JSON compatible object
  10488. * @returns serialization object
  10489. */
  10490. serialize(): any;
  10491. }
  10492. }
  10493. declare module "babylonjs/Actions/directActions" {
  10494. import { Action } from "babylonjs/Actions/action";
  10495. import { Condition } from "babylonjs/Actions/condition";
  10496. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10497. /**
  10498. * This defines an action responsible to toggle a boolean once triggered.
  10499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10500. */
  10501. export class SwitchBooleanAction extends Action {
  10502. /**
  10503. * The path to the boolean property in the target object
  10504. */
  10505. propertyPath: string;
  10506. private _target;
  10507. private _effectiveTarget;
  10508. private _property;
  10509. /**
  10510. * Instantiate the action
  10511. * @param triggerOptions defines the trigger options
  10512. * @param target defines the object containing the boolean
  10513. * @param propertyPath defines the path to the boolean property in the target object
  10514. * @param condition defines the trigger related conditions
  10515. */
  10516. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10517. /** @hidden */
  10518. _prepare(): void;
  10519. /**
  10520. * Execute the action toggle the boolean value.
  10521. */
  10522. execute(): void;
  10523. /**
  10524. * Serializes the actions and its related information.
  10525. * @param parent defines the object to serialize in
  10526. * @returns the serialized object
  10527. */
  10528. serialize(parent: any): any;
  10529. }
  10530. /**
  10531. * This defines an action responsible to set a the state field of the target
  10532. * to a desired value once triggered.
  10533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10534. */
  10535. export class SetStateAction extends Action {
  10536. /**
  10537. * The value to store in the state field.
  10538. */
  10539. value: string;
  10540. private _target;
  10541. /**
  10542. * Instantiate the action
  10543. * @param triggerOptions defines the trigger options
  10544. * @param target defines the object containing the state property
  10545. * @param value defines the value to store in the state field
  10546. * @param condition defines the trigger related conditions
  10547. */
  10548. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10549. /**
  10550. * Execute the action and store the value on the target state property.
  10551. */
  10552. execute(): void;
  10553. /**
  10554. * Serializes the actions and its related information.
  10555. * @param parent defines the object to serialize in
  10556. * @returns the serialized object
  10557. */
  10558. serialize(parent: any): any;
  10559. }
  10560. /**
  10561. * This defines an action responsible to set a property of the target
  10562. * to a desired value once triggered.
  10563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10564. */
  10565. export class SetValueAction extends Action {
  10566. /**
  10567. * The path of the property to set in the target.
  10568. */
  10569. propertyPath: string;
  10570. /**
  10571. * The value to set in the property
  10572. */
  10573. value: any;
  10574. private _target;
  10575. private _effectiveTarget;
  10576. private _property;
  10577. /**
  10578. * Instantiate the action
  10579. * @param triggerOptions defines the trigger options
  10580. * @param target defines the object containing the property
  10581. * @param propertyPath defines the path of the property to set in the target
  10582. * @param value defines the value to set in the property
  10583. * @param condition defines the trigger related conditions
  10584. */
  10585. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10586. /** @hidden */
  10587. _prepare(): void;
  10588. /**
  10589. * Execute the action and set the targetted property to the desired value.
  10590. */
  10591. execute(): void;
  10592. /**
  10593. * Serializes the actions and its related information.
  10594. * @param parent defines the object to serialize in
  10595. * @returns the serialized object
  10596. */
  10597. serialize(parent: any): any;
  10598. }
  10599. /**
  10600. * This defines an action responsible to increment the target value
  10601. * to a desired value once triggered.
  10602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10603. */
  10604. export class IncrementValueAction extends Action {
  10605. /**
  10606. * The path of the property to increment in the target.
  10607. */
  10608. propertyPath: string;
  10609. /**
  10610. * The value we should increment the property by.
  10611. */
  10612. value: any;
  10613. private _target;
  10614. private _effectiveTarget;
  10615. private _property;
  10616. /**
  10617. * Instantiate the action
  10618. * @param triggerOptions defines the trigger options
  10619. * @param target defines the object containing the property
  10620. * @param propertyPath defines the path of the property to increment in the target
  10621. * @param value defines the value value we should increment the property by
  10622. * @param condition defines the trigger related conditions
  10623. */
  10624. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10625. /** @hidden */
  10626. _prepare(): void;
  10627. /**
  10628. * Execute the action and increment the target of the value amount.
  10629. */
  10630. execute(): void;
  10631. /**
  10632. * Serializes the actions and its related information.
  10633. * @param parent defines the object to serialize in
  10634. * @returns the serialized object
  10635. */
  10636. serialize(parent: any): any;
  10637. }
  10638. /**
  10639. * This defines an action responsible to start an animation once triggered.
  10640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10641. */
  10642. export class PlayAnimationAction extends Action {
  10643. /**
  10644. * Where the animation should start (animation frame)
  10645. */
  10646. from: number;
  10647. /**
  10648. * Where the animation should stop (animation frame)
  10649. */
  10650. to: number;
  10651. /**
  10652. * Define if the animation should loop or stop after the first play.
  10653. */
  10654. loop?: boolean;
  10655. private _target;
  10656. /**
  10657. * Instantiate the action
  10658. * @param triggerOptions defines the trigger options
  10659. * @param target defines the target animation or animation name
  10660. * @param from defines from where the animation should start (animation frame)
  10661. * @param end defines where the animation should stop (animation frame)
  10662. * @param loop defines if the animation should loop or stop after the first play
  10663. * @param condition defines the trigger related conditions
  10664. */
  10665. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10666. /** @hidden */
  10667. _prepare(): void;
  10668. /**
  10669. * Execute the action and play the animation.
  10670. */
  10671. execute(): void;
  10672. /**
  10673. * Serializes the actions and its related information.
  10674. * @param parent defines the object to serialize in
  10675. * @returns the serialized object
  10676. */
  10677. serialize(parent: any): any;
  10678. }
  10679. /**
  10680. * This defines an action responsible to stop an animation once triggered.
  10681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10682. */
  10683. export class StopAnimationAction extends Action {
  10684. private _target;
  10685. /**
  10686. * Instantiate the action
  10687. * @param triggerOptions defines the trigger options
  10688. * @param target defines the target animation or animation name
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions: any, target: any, condition?: Condition);
  10692. /** @hidden */
  10693. _prepare(): void;
  10694. /**
  10695. * Execute the action and stop the animation.
  10696. */
  10697. execute(): void;
  10698. /**
  10699. * Serializes the actions and its related information.
  10700. * @param parent defines the object to serialize in
  10701. * @returns the serialized object
  10702. */
  10703. serialize(parent: any): any;
  10704. }
  10705. /**
  10706. * This defines an action responsible that does nothing once triggered.
  10707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10708. */
  10709. export class DoNothingAction extends Action {
  10710. /**
  10711. * Instantiate the action
  10712. * @param triggerOptions defines the trigger options
  10713. * @param condition defines the trigger related conditions
  10714. */
  10715. constructor(triggerOptions?: any, condition?: Condition);
  10716. /**
  10717. * Execute the action and do nothing.
  10718. */
  10719. execute(): void;
  10720. /**
  10721. * Serializes the actions and its related information.
  10722. * @param parent defines the object to serialize in
  10723. * @returns the serialized object
  10724. */
  10725. serialize(parent: any): any;
  10726. }
  10727. /**
  10728. * This defines an action responsible to trigger several actions once triggered.
  10729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10730. */
  10731. export class CombineAction extends Action {
  10732. /**
  10733. * The list of aggregated animations to run.
  10734. */
  10735. children: Action[];
  10736. /**
  10737. * Instantiate the action
  10738. * @param triggerOptions defines the trigger options
  10739. * @param children defines the list of aggregated animations to run
  10740. * @param condition defines the trigger related conditions
  10741. */
  10742. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10743. /** @hidden */
  10744. _prepare(): void;
  10745. /**
  10746. * Execute the action and executes all the aggregated actions.
  10747. */
  10748. execute(evt: ActionEvent): void;
  10749. /**
  10750. * Serializes the actions and its related information.
  10751. * @param parent defines the object to serialize in
  10752. * @returns the serialized object
  10753. */
  10754. serialize(parent: any): any;
  10755. }
  10756. /**
  10757. * This defines an action responsible to run code (external event) once triggered.
  10758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10759. */
  10760. export class ExecuteCodeAction extends Action {
  10761. /**
  10762. * The callback function to run.
  10763. */
  10764. func: (evt: ActionEvent) => void;
  10765. /**
  10766. * Instantiate the action
  10767. * @param triggerOptions defines the trigger options
  10768. * @param func defines the callback function to run
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10772. /**
  10773. * Execute the action and run the attached code.
  10774. */
  10775. execute(evt: ActionEvent): void;
  10776. }
  10777. /**
  10778. * This defines an action responsible to set the parent property of the target once triggered.
  10779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10780. */
  10781. export class SetParentAction extends Action {
  10782. private _parent;
  10783. private _target;
  10784. /**
  10785. * Instantiate the action
  10786. * @param triggerOptions defines the trigger options
  10787. * @param target defines the target containing the parent property
  10788. * @param parent defines from where the animation should start (animation frame)
  10789. * @param condition defines the trigger related conditions
  10790. */
  10791. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10792. /** @hidden */
  10793. _prepare(): void;
  10794. /**
  10795. * Execute the action and set the parent property.
  10796. */
  10797. execute(): void;
  10798. /**
  10799. * Serializes the actions and its related information.
  10800. * @param parent defines the object to serialize in
  10801. * @returns the serialized object
  10802. */
  10803. serialize(parent: any): any;
  10804. }
  10805. }
  10806. declare module "babylonjs/Actions/actionManager" {
  10807. import { Nullable } from "babylonjs/types";
  10808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10809. import { Scene } from "babylonjs/scene";
  10810. import { IAction } from "babylonjs/Actions/action";
  10811. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10812. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10813. /**
  10814. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10815. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10817. */
  10818. export class ActionManager extends AbstractActionManager {
  10819. /**
  10820. * Nothing
  10821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10822. */
  10823. static readonly NothingTrigger: number;
  10824. /**
  10825. * On pick
  10826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10827. */
  10828. static readonly OnPickTrigger: number;
  10829. /**
  10830. * On left pick
  10831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10832. */
  10833. static readonly OnLeftPickTrigger: number;
  10834. /**
  10835. * On right pick
  10836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10837. */
  10838. static readonly OnRightPickTrigger: number;
  10839. /**
  10840. * On center pick
  10841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10842. */
  10843. static readonly OnCenterPickTrigger: number;
  10844. /**
  10845. * On pick down
  10846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10847. */
  10848. static readonly OnPickDownTrigger: number;
  10849. /**
  10850. * On double pick
  10851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10852. */
  10853. static readonly OnDoublePickTrigger: number;
  10854. /**
  10855. * On pick up
  10856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10857. */
  10858. static readonly OnPickUpTrigger: number;
  10859. /**
  10860. * On pick out.
  10861. * This trigger will only be raised if you also declared a OnPickDown
  10862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10863. */
  10864. static readonly OnPickOutTrigger: number;
  10865. /**
  10866. * On long press
  10867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10868. */
  10869. static readonly OnLongPressTrigger: number;
  10870. /**
  10871. * On pointer over
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10873. */
  10874. static readonly OnPointerOverTrigger: number;
  10875. /**
  10876. * On pointer out
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10878. */
  10879. static readonly OnPointerOutTrigger: number;
  10880. /**
  10881. * On every frame
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10883. */
  10884. static readonly OnEveryFrameTrigger: number;
  10885. /**
  10886. * On intersection enter
  10887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10888. */
  10889. static readonly OnIntersectionEnterTrigger: number;
  10890. /**
  10891. * On intersection exit
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10893. */
  10894. static readonly OnIntersectionExitTrigger: number;
  10895. /**
  10896. * On key down
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10898. */
  10899. static readonly OnKeyDownTrigger: number;
  10900. /**
  10901. * On key up
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10903. */
  10904. static readonly OnKeyUpTrigger: number;
  10905. private _scene;
  10906. /**
  10907. * Creates a new action manager
  10908. * @param scene defines the hosting scene
  10909. */
  10910. constructor(scene: Scene);
  10911. /**
  10912. * Releases all associated resources
  10913. */
  10914. dispose(): void;
  10915. /**
  10916. * Gets hosting scene
  10917. * @returns the hosting scene
  10918. */
  10919. getScene(): Scene;
  10920. /**
  10921. * Does this action manager handles actions of any of the given triggers
  10922. * @param triggers defines the triggers to be tested
  10923. * @return a boolean indicating whether one (or more) of the triggers is handled
  10924. */
  10925. hasSpecificTriggers(triggers: number[]): boolean;
  10926. /**
  10927. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10928. * speed.
  10929. * @param triggerA defines the trigger to be tested
  10930. * @param triggerB defines the trigger to be tested
  10931. * @return a boolean indicating whether one (or more) of the triggers is handled
  10932. */
  10933. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10934. /**
  10935. * Does this action manager handles actions of a given trigger
  10936. * @param trigger defines the trigger to be tested
  10937. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10938. * @return whether the trigger is handled
  10939. */
  10940. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10941. /**
  10942. * Does this action manager has pointer triggers
  10943. */
  10944. readonly hasPointerTriggers: boolean;
  10945. /**
  10946. * Does this action manager has pick triggers
  10947. */
  10948. readonly hasPickTriggers: boolean;
  10949. /**
  10950. * Registers an action to this action manager
  10951. * @param action defines the action to be registered
  10952. * @return the action amended (prepared) after registration
  10953. */
  10954. registerAction(action: IAction): Nullable<IAction>;
  10955. /**
  10956. * Unregisters an action to this action manager
  10957. * @param action defines the action to be unregistered
  10958. * @return a boolean indicating whether the action has been unregistered
  10959. */
  10960. unregisterAction(action: IAction): Boolean;
  10961. /**
  10962. * Process a specific trigger
  10963. * @param trigger defines the trigger to process
  10964. * @param evt defines the event details to be processed
  10965. */
  10966. processTrigger(trigger: number, evt?: IActionEvent): void;
  10967. /** @hidden */
  10968. _getEffectiveTarget(target: any, propertyPath: string): any;
  10969. /** @hidden */
  10970. _getProperty(propertyPath: string): string;
  10971. /**
  10972. * Serialize this manager to a JSON object
  10973. * @param name defines the property name to store this manager
  10974. * @returns a JSON representation of this manager
  10975. */
  10976. serialize(name: string): any;
  10977. /**
  10978. * Creates a new ActionManager from a JSON data
  10979. * @param parsedActions defines the JSON data to read from
  10980. * @param object defines the hosting mesh
  10981. * @param scene defines the hosting scene
  10982. */
  10983. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10984. /**
  10985. * Get a trigger name by index
  10986. * @param trigger defines the trigger index
  10987. * @returns a trigger name
  10988. */
  10989. static GetTriggerName(trigger: number): string;
  10990. }
  10991. }
  10992. declare module "babylonjs/Culling/ray" {
  10993. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10994. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10996. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10997. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10998. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10999. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11000. import { Plane } from "babylonjs/Maths/math.plane";
  11001. /**
  11002. * Class representing a ray with position and direction
  11003. */
  11004. export class Ray {
  11005. /** origin point */
  11006. origin: Vector3;
  11007. /** direction */
  11008. direction: Vector3;
  11009. /** length of the ray */
  11010. length: number;
  11011. private static readonly TmpVector3;
  11012. private _tmpRay;
  11013. /**
  11014. * Creates a new ray
  11015. * @param origin origin point
  11016. * @param direction direction
  11017. * @param length length of the ray
  11018. */
  11019. constructor(
  11020. /** origin point */
  11021. origin: Vector3,
  11022. /** direction */
  11023. direction: Vector3,
  11024. /** length of the ray */
  11025. length?: number);
  11026. /**
  11027. * Checks if the ray intersects a box
  11028. * @param minimum bound of the box
  11029. * @param maximum bound of the box
  11030. * @param intersectionTreshold extra extend to be added to the box in all direction
  11031. * @returns if the box was hit
  11032. */
  11033. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11034. /**
  11035. * Checks if the ray intersects a box
  11036. * @param box the bounding box to check
  11037. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11038. * @returns if the box was hit
  11039. */
  11040. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11041. /**
  11042. * If the ray hits a sphere
  11043. * @param sphere the bounding sphere to check
  11044. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11045. * @returns true if it hits the sphere
  11046. */
  11047. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11048. /**
  11049. * If the ray hits a triange
  11050. * @param vertex0 triangle vertex
  11051. * @param vertex1 triangle vertex
  11052. * @param vertex2 triangle vertex
  11053. * @returns intersection information if hit
  11054. */
  11055. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11056. /**
  11057. * Checks if ray intersects a plane
  11058. * @param plane the plane to check
  11059. * @returns the distance away it was hit
  11060. */
  11061. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11062. /**
  11063. * Calculate the intercept of a ray on a given axis
  11064. * @param axis to check 'x' | 'y' | 'z'
  11065. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11066. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11067. */
  11068. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11069. /**
  11070. * Checks if ray intersects a mesh
  11071. * @param mesh the mesh to check
  11072. * @param fastCheck if only the bounding box should checked
  11073. * @returns picking info of the intersecton
  11074. */
  11075. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11076. /**
  11077. * Checks if ray intersects a mesh
  11078. * @param meshes the meshes to check
  11079. * @param fastCheck if only the bounding box should checked
  11080. * @param results array to store result in
  11081. * @returns Array of picking infos
  11082. */
  11083. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11084. private _comparePickingInfo;
  11085. private static smallnum;
  11086. private static rayl;
  11087. /**
  11088. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11089. * @param sega the first point of the segment to test the intersection against
  11090. * @param segb the second point of the segment to test the intersection against
  11091. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11092. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11093. */
  11094. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11095. /**
  11096. * Update the ray from viewport position
  11097. * @param x position
  11098. * @param y y position
  11099. * @param viewportWidth viewport width
  11100. * @param viewportHeight viewport height
  11101. * @param world world matrix
  11102. * @param view view matrix
  11103. * @param projection projection matrix
  11104. * @returns this ray updated
  11105. */
  11106. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11107. /**
  11108. * Creates a ray with origin and direction of 0,0,0
  11109. * @returns the new ray
  11110. */
  11111. static Zero(): Ray;
  11112. /**
  11113. * Creates a new ray from screen space and viewport
  11114. * @param x position
  11115. * @param y y position
  11116. * @param viewportWidth viewport width
  11117. * @param viewportHeight viewport height
  11118. * @param world world matrix
  11119. * @param view view matrix
  11120. * @param projection projection matrix
  11121. * @returns new ray
  11122. */
  11123. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11124. /**
  11125. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11126. * transformed to the given world matrix.
  11127. * @param origin The origin point
  11128. * @param end The end point
  11129. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11130. * @returns the new ray
  11131. */
  11132. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11133. /**
  11134. * Transforms a ray by a matrix
  11135. * @param ray ray to transform
  11136. * @param matrix matrix to apply
  11137. * @returns the resulting new ray
  11138. */
  11139. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11140. /**
  11141. * Transforms a ray by a matrix
  11142. * @param ray ray to transform
  11143. * @param matrix matrix to apply
  11144. * @param result ray to store result in
  11145. */
  11146. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11147. /**
  11148. * Unproject a ray from screen space to object space
  11149. * @param sourceX defines the screen space x coordinate to use
  11150. * @param sourceY defines the screen space y coordinate to use
  11151. * @param viewportWidth defines the current width of the viewport
  11152. * @param viewportHeight defines the current height of the viewport
  11153. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11154. * @param view defines the view matrix to use
  11155. * @param projection defines the projection matrix to use
  11156. */
  11157. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11158. }
  11159. /**
  11160. * Type used to define predicate used to select faces when a mesh intersection is detected
  11161. */
  11162. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11163. module "babylonjs/scene" {
  11164. interface Scene {
  11165. /** @hidden */
  11166. _tempPickingRay: Nullable<Ray>;
  11167. /** @hidden */
  11168. _cachedRayForTransform: Ray;
  11169. /** @hidden */
  11170. _pickWithRayInverseMatrix: Matrix;
  11171. /** @hidden */
  11172. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11173. /** @hidden */
  11174. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11175. }
  11176. }
  11177. }
  11178. declare module "babylonjs/sceneComponent" {
  11179. import { Scene } from "babylonjs/scene";
  11180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11181. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11182. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11183. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11184. import { Nullable } from "babylonjs/types";
  11185. import { Camera } from "babylonjs/Cameras/camera";
  11186. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11187. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11188. import { AbstractScene } from "babylonjs/abstractScene";
  11189. /**
  11190. * Groups all the scene component constants in one place to ease maintenance.
  11191. * @hidden
  11192. */
  11193. export class SceneComponentConstants {
  11194. static readonly NAME_EFFECTLAYER: string;
  11195. static readonly NAME_LAYER: string;
  11196. static readonly NAME_LENSFLARESYSTEM: string;
  11197. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11198. static readonly NAME_PARTICLESYSTEM: string;
  11199. static readonly NAME_GAMEPAD: string;
  11200. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11201. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11202. static readonly NAME_DEPTHRENDERER: string;
  11203. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11204. static readonly NAME_SPRITE: string;
  11205. static readonly NAME_OUTLINERENDERER: string;
  11206. static readonly NAME_PROCEDURALTEXTURE: string;
  11207. static readonly NAME_SHADOWGENERATOR: string;
  11208. static readonly NAME_OCTREE: string;
  11209. static readonly NAME_PHYSICSENGINE: string;
  11210. static readonly NAME_AUDIO: string;
  11211. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11212. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11213. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11214. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11215. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11216. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11217. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11218. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11219. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11220. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11221. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11222. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11223. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11224. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11225. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11226. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11227. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11228. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11229. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11230. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11231. static readonly STEP_AFTERRENDER_AUDIO: number;
  11232. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11233. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11234. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11235. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11236. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11237. static readonly STEP_POINTERMOVE_SPRITE: number;
  11238. static readonly STEP_POINTERDOWN_SPRITE: number;
  11239. static readonly STEP_POINTERUP_SPRITE: number;
  11240. }
  11241. /**
  11242. * This represents a scene component.
  11243. *
  11244. * This is used to decouple the dependency the scene is having on the different workloads like
  11245. * layers, post processes...
  11246. */
  11247. export interface ISceneComponent {
  11248. /**
  11249. * The name of the component. Each component must have a unique name.
  11250. */
  11251. name: string;
  11252. /**
  11253. * The scene the component belongs to.
  11254. */
  11255. scene: Scene;
  11256. /**
  11257. * Register the component to one instance of a scene.
  11258. */
  11259. register(): void;
  11260. /**
  11261. * Rebuilds the elements related to this component in case of
  11262. * context lost for instance.
  11263. */
  11264. rebuild(): void;
  11265. /**
  11266. * Disposes the component and the associated ressources.
  11267. */
  11268. dispose(): void;
  11269. }
  11270. /**
  11271. * This represents a SERIALIZABLE scene component.
  11272. *
  11273. * This extends Scene Component to add Serialization methods on top.
  11274. */
  11275. export interface ISceneSerializableComponent extends ISceneComponent {
  11276. /**
  11277. * Adds all the elements from the container to the scene
  11278. * @param container the container holding the elements
  11279. */
  11280. addFromContainer(container: AbstractScene): void;
  11281. /**
  11282. * Removes all the elements in the container from the scene
  11283. * @param container contains the elements to remove
  11284. * @param dispose if the removed element should be disposed (default: false)
  11285. */
  11286. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11287. /**
  11288. * Serializes the component data to the specified json object
  11289. * @param serializationObject The object to serialize to
  11290. */
  11291. serialize(serializationObject: any): void;
  11292. }
  11293. /**
  11294. * Strong typing of a Mesh related stage step action
  11295. */
  11296. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11297. /**
  11298. * Strong typing of a Evaluate Sub Mesh related stage step action
  11299. */
  11300. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11301. /**
  11302. * Strong typing of a Active Mesh related stage step action
  11303. */
  11304. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11305. /**
  11306. * Strong typing of a Camera related stage step action
  11307. */
  11308. export type CameraStageAction = (camera: Camera) => void;
  11309. /**
  11310. * Strong typing of a Camera Frame buffer related stage step action
  11311. */
  11312. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11313. /**
  11314. * Strong typing of a Render Target related stage step action
  11315. */
  11316. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11317. /**
  11318. * Strong typing of a RenderingGroup related stage step action
  11319. */
  11320. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11321. /**
  11322. * Strong typing of a Mesh Render related stage step action
  11323. */
  11324. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11325. /**
  11326. * Strong typing of a simple stage step action
  11327. */
  11328. export type SimpleStageAction = () => void;
  11329. /**
  11330. * Strong typing of a render target action.
  11331. */
  11332. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11333. /**
  11334. * Strong typing of a pointer move action.
  11335. */
  11336. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11337. /**
  11338. * Strong typing of a pointer up/down action.
  11339. */
  11340. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11341. /**
  11342. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11343. * @hidden
  11344. */
  11345. export class Stage<T extends Function> extends Array<{
  11346. index: number;
  11347. component: ISceneComponent;
  11348. action: T;
  11349. }> {
  11350. /**
  11351. * Hide ctor from the rest of the world.
  11352. * @param items The items to add.
  11353. */
  11354. private constructor();
  11355. /**
  11356. * Creates a new Stage.
  11357. * @returns A new instance of a Stage
  11358. */
  11359. static Create<T extends Function>(): Stage<T>;
  11360. /**
  11361. * Registers a step in an ordered way in the targeted stage.
  11362. * @param index Defines the position to register the step in
  11363. * @param component Defines the component attached to the step
  11364. * @param action Defines the action to launch during the step
  11365. */
  11366. registerStep(index: number, component: ISceneComponent, action: T): void;
  11367. /**
  11368. * Clears all the steps from the stage.
  11369. */
  11370. clear(): void;
  11371. }
  11372. }
  11373. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11374. import { Nullable } from "babylonjs/types";
  11375. import { Observable } from "babylonjs/Misc/observable";
  11376. import { Scene } from "babylonjs/scene";
  11377. import { Sprite } from "babylonjs/Sprites/sprite";
  11378. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11379. import { Ray } from "babylonjs/Culling/ray";
  11380. import { Camera } from "babylonjs/Cameras/camera";
  11381. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11382. import { ISceneComponent } from "babylonjs/sceneComponent";
  11383. module "babylonjs/scene" {
  11384. interface Scene {
  11385. /** @hidden */
  11386. _pointerOverSprite: Nullable<Sprite>;
  11387. /** @hidden */
  11388. _pickedDownSprite: Nullable<Sprite>;
  11389. /** @hidden */
  11390. _tempSpritePickingRay: Nullable<Ray>;
  11391. /**
  11392. * All of the sprite managers added to this scene
  11393. * @see http://doc.babylonjs.com/babylon101/sprites
  11394. */
  11395. spriteManagers: Array<ISpriteManager>;
  11396. /**
  11397. * An event triggered when sprites rendering is about to start
  11398. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11399. */
  11400. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11401. /**
  11402. * An event triggered when sprites rendering is done
  11403. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11404. */
  11405. onAfterSpritesRenderingObservable: Observable<Scene>;
  11406. /** @hidden */
  11407. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11408. /** Launch a ray to try to pick a sprite in the scene
  11409. * @param x position on screen
  11410. * @param y position on screen
  11411. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11412. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11413. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11414. * @returns a PickingInfo
  11415. */
  11416. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11417. /** Use the given ray to pick a sprite in the scene
  11418. * @param ray The ray (in world space) to use to pick meshes
  11419. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11420. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11421. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11422. * @returns a PickingInfo
  11423. */
  11424. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11425. /** @hidden */
  11426. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11427. /** Launch a ray to try to pick sprites in the scene
  11428. * @param x position on screen
  11429. * @param y position on screen
  11430. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11431. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11432. * @returns a PickingInfo array
  11433. */
  11434. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11435. /** Use the given ray to pick sprites in the scene
  11436. * @param ray The ray (in world space) to use to pick meshes
  11437. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11438. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11439. * @returns a PickingInfo array
  11440. */
  11441. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11442. /**
  11443. * Force the sprite under the pointer
  11444. * @param sprite defines the sprite to use
  11445. */
  11446. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11447. /**
  11448. * Gets the sprite under the pointer
  11449. * @returns a Sprite or null if no sprite is under the pointer
  11450. */
  11451. getPointerOverSprite(): Nullable<Sprite>;
  11452. }
  11453. }
  11454. /**
  11455. * Defines the sprite scene component responsible to manage sprites
  11456. * in a given scene.
  11457. */
  11458. export class SpriteSceneComponent implements ISceneComponent {
  11459. /**
  11460. * The component name helpfull to identify the component in the list of scene components.
  11461. */
  11462. readonly name: string;
  11463. /**
  11464. * The scene the component belongs to.
  11465. */
  11466. scene: Scene;
  11467. /** @hidden */
  11468. private _spritePredicate;
  11469. /**
  11470. * Creates a new instance of the component for the given scene
  11471. * @param scene Defines the scene to register the component in
  11472. */
  11473. constructor(scene: Scene);
  11474. /**
  11475. * Registers the component in a given scene
  11476. */
  11477. register(): void;
  11478. /**
  11479. * Rebuilds the elements related to this component in case of
  11480. * context lost for instance.
  11481. */
  11482. rebuild(): void;
  11483. /**
  11484. * Disposes the component and the associated ressources.
  11485. */
  11486. dispose(): void;
  11487. private _pickSpriteButKeepRay;
  11488. private _pointerMove;
  11489. private _pointerDown;
  11490. private _pointerUp;
  11491. }
  11492. }
  11493. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11494. /** @hidden */
  11495. export var fogFragmentDeclaration: {
  11496. name: string;
  11497. shader: string;
  11498. };
  11499. }
  11500. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11501. /** @hidden */
  11502. export var fogFragment: {
  11503. name: string;
  11504. shader: string;
  11505. };
  11506. }
  11507. declare module "babylonjs/Shaders/sprites.fragment" {
  11508. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11509. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11510. /** @hidden */
  11511. export var spritesPixelShader: {
  11512. name: string;
  11513. shader: string;
  11514. };
  11515. }
  11516. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11517. /** @hidden */
  11518. export var fogVertexDeclaration: {
  11519. name: string;
  11520. shader: string;
  11521. };
  11522. }
  11523. declare module "babylonjs/Shaders/sprites.vertex" {
  11524. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11525. /** @hidden */
  11526. export var spritesVertexShader: {
  11527. name: string;
  11528. shader: string;
  11529. };
  11530. }
  11531. declare module "babylonjs/Sprites/spriteManager" {
  11532. import { IDisposable, Scene } from "babylonjs/scene";
  11533. import { Nullable } from "babylonjs/types";
  11534. import { Observable } from "babylonjs/Misc/observable";
  11535. import { Sprite } from "babylonjs/Sprites/sprite";
  11536. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11537. import { Camera } from "babylonjs/Cameras/camera";
  11538. import { Texture } from "babylonjs/Materials/Textures/texture";
  11539. import "babylonjs/Shaders/sprites.fragment";
  11540. import "babylonjs/Shaders/sprites.vertex";
  11541. import { Ray } from "babylonjs/Culling/ray";
  11542. /**
  11543. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11544. */
  11545. export interface ISpriteManager extends IDisposable {
  11546. /**
  11547. * Restricts the camera to viewing objects with the same layerMask.
  11548. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11549. */
  11550. layerMask: number;
  11551. /**
  11552. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11553. */
  11554. isPickable: boolean;
  11555. /**
  11556. * Specifies the rendering group id for this mesh (0 by default)
  11557. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11558. */
  11559. renderingGroupId: number;
  11560. /**
  11561. * Defines the list of sprites managed by the manager.
  11562. */
  11563. sprites: Array<Sprite>;
  11564. /**
  11565. * Tests the intersection of a sprite with a specific ray.
  11566. * @param ray The ray we are sending to test the collision
  11567. * @param camera The camera space we are sending rays in
  11568. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11569. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11570. * @returns picking info or null.
  11571. */
  11572. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11573. /**
  11574. * Intersects the sprites with a ray
  11575. * @param ray defines the ray to intersect with
  11576. * @param camera defines the current active camera
  11577. * @param predicate defines a predicate used to select candidate sprites
  11578. * @returns null if no hit or a PickingInfo array
  11579. */
  11580. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11581. /**
  11582. * Renders the list of sprites on screen.
  11583. */
  11584. render(): void;
  11585. }
  11586. /**
  11587. * Class used to manage multiple sprites on the same spritesheet
  11588. * @see http://doc.babylonjs.com/babylon101/sprites
  11589. */
  11590. export class SpriteManager implements ISpriteManager {
  11591. /** defines the manager's name */
  11592. name: string;
  11593. /** Gets the list of sprites */
  11594. sprites: Sprite[];
  11595. /** Gets or sets the rendering group id (0 by default) */
  11596. renderingGroupId: number;
  11597. /** Gets or sets camera layer mask */
  11598. layerMask: number;
  11599. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11600. fogEnabled: boolean;
  11601. /** Gets or sets a boolean indicating if the sprites are pickable */
  11602. isPickable: boolean;
  11603. /** Defines the default width of a cell in the spritesheet */
  11604. cellWidth: number;
  11605. /** Defines the default height of a cell in the spritesheet */
  11606. cellHeight: number;
  11607. /** Associative array from JSON sprite data file */
  11608. private _cellData;
  11609. /** Array of sprite names from JSON sprite data file */
  11610. private _spriteMap;
  11611. /** True when packed cell data from JSON file is ready*/
  11612. private _packedAndReady;
  11613. /**
  11614. * An event triggered when the manager is disposed.
  11615. */
  11616. onDisposeObservable: Observable<SpriteManager>;
  11617. private _onDisposeObserver;
  11618. /**
  11619. * Callback called when the manager is disposed
  11620. */
  11621. onDispose: () => void;
  11622. private _capacity;
  11623. private _fromPacked;
  11624. private _spriteTexture;
  11625. private _epsilon;
  11626. private _scene;
  11627. private _vertexData;
  11628. private _buffer;
  11629. private _vertexBuffers;
  11630. private _indexBuffer;
  11631. private _effectBase;
  11632. private _effectFog;
  11633. /**
  11634. * Gets or sets the spritesheet texture
  11635. */
  11636. texture: Texture;
  11637. /**
  11638. * Creates a new sprite manager
  11639. * @param name defines the manager's name
  11640. * @param imgUrl defines the sprite sheet url
  11641. * @param capacity defines the maximum allowed number of sprites
  11642. * @param cellSize defines the size of a sprite cell
  11643. * @param scene defines the hosting scene
  11644. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11645. * @param samplingMode defines the smapling mode to use with spritesheet
  11646. * @param fromPacked set to false; do not alter
  11647. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11648. */
  11649. constructor(
  11650. /** defines the manager's name */
  11651. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11652. private _makePacked;
  11653. private _appendSpriteVertex;
  11654. /**
  11655. * Intersects the sprites with a ray
  11656. * @param ray defines the ray to intersect with
  11657. * @param camera defines the current active camera
  11658. * @param predicate defines a predicate used to select candidate sprites
  11659. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11660. * @returns null if no hit or a PickingInfo
  11661. */
  11662. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11663. /**
  11664. * Intersects the sprites with a ray
  11665. * @param ray defines the ray to intersect with
  11666. * @param camera defines the current active camera
  11667. * @param predicate defines a predicate used to select candidate sprites
  11668. * @returns null if no hit or a PickingInfo array
  11669. */
  11670. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11671. /**
  11672. * Render all child sprites
  11673. */
  11674. render(): void;
  11675. /**
  11676. * Release associated resources
  11677. */
  11678. dispose(): void;
  11679. }
  11680. }
  11681. declare module "babylonjs/Sprites/sprite" {
  11682. import { Vector3 } from "babylonjs/Maths/math.vector";
  11683. import { Nullable } from "babylonjs/types";
  11684. import { ActionManager } from "babylonjs/Actions/actionManager";
  11685. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11686. import { Color4 } from "babylonjs/Maths/math.color";
  11687. /**
  11688. * Class used to represent a sprite
  11689. * @see http://doc.babylonjs.com/babylon101/sprites
  11690. */
  11691. export class Sprite {
  11692. /** defines the name */
  11693. name: string;
  11694. /** Gets or sets the current world position */
  11695. position: Vector3;
  11696. /** Gets or sets the main color */
  11697. color: Color4;
  11698. /** Gets or sets the width */
  11699. width: number;
  11700. /** Gets or sets the height */
  11701. height: number;
  11702. /** Gets or sets rotation angle */
  11703. angle: number;
  11704. /** Gets or sets the cell index in the sprite sheet */
  11705. cellIndex: number;
  11706. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11707. cellRef: string;
  11708. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11709. invertU: number;
  11710. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11711. invertV: number;
  11712. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11713. disposeWhenFinishedAnimating: boolean;
  11714. /** Gets the list of attached animations */
  11715. animations: Animation[];
  11716. /** Gets or sets a boolean indicating if the sprite can be picked */
  11717. isPickable: boolean;
  11718. /**
  11719. * Gets or sets the associated action manager
  11720. */
  11721. actionManager: Nullable<ActionManager>;
  11722. private _animationStarted;
  11723. private _loopAnimation;
  11724. private _fromIndex;
  11725. private _toIndex;
  11726. private _delay;
  11727. private _direction;
  11728. private _manager;
  11729. private _time;
  11730. private _onAnimationEnd;
  11731. /**
  11732. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11733. */
  11734. isVisible: boolean;
  11735. /**
  11736. * Gets or sets the sprite size
  11737. */
  11738. size: number;
  11739. /**
  11740. * Creates a new Sprite
  11741. * @param name defines the name
  11742. * @param manager defines the manager
  11743. */
  11744. constructor(
  11745. /** defines the name */
  11746. name: string, manager: ISpriteManager);
  11747. /**
  11748. * Starts an animation
  11749. * @param from defines the initial key
  11750. * @param to defines the end key
  11751. * @param loop defines if the animation must loop
  11752. * @param delay defines the start delay (in ms)
  11753. * @param onAnimationEnd defines a callback to call when animation ends
  11754. */
  11755. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11756. /** Stops current animation (if any) */
  11757. stopAnimation(): void;
  11758. /** @hidden */
  11759. _animate(deltaTime: number): void;
  11760. /** Release associated resources */
  11761. dispose(): void;
  11762. }
  11763. }
  11764. declare module "babylonjs/Collisions/pickingInfo" {
  11765. import { Nullable } from "babylonjs/types";
  11766. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11768. import { Sprite } from "babylonjs/Sprites/sprite";
  11769. import { Ray } from "babylonjs/Culling/ray";
  11770. /**
  11771. * Information about the result of picking within a scene
  11772. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11773. */
  11774. export class PickingInfo {
  11775. /** @hidden */
  11776. _pickingUnavailable: boolean;
  11777. /**
  11778. * If the pick collided with an object
  11779. */
  11780. hit: boolean;
  11781. /**
  11782. * Distance away where the pick collided
  11783. */
  11784. distance: number;
  11785. /**
  11786. * The location of pick collision
  11787. */
  11788. pickedPoint: Nullable<Vector3>;
  11789. /**
  11790. * The mesh corresponding the the pick collision
  11791. */
  11792. pickedMesh: Nullable<AbstractMesh>;
  11793. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11794. bu: number;
  11795. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11796. bv: number;
  11797. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11798. faceId: number;
  11799. /** Id of the the submesh that was picked */
  11800. subMeshId: number;
  11801. /** If a sprite was picked, this will be the sprite the pick collided with */
  11802. pickedSprite: Nullable<Sprite>;
  11803. /**
  11804. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11805. */
  11806. originMesh: Nullable<AbstractMesh>;
  11807. /**
  11808. * The ray that was used to perform the picking.
  11809. */
  11810. ray: Nullable<Ray>;
  11811. /**
  11812. * Gets the normal correspodning to the face the pick collided with
  11813. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11814. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11815. * @returns The normal correspodning to the face the pick collided with
  11816. */
  11817. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11818. /**
  11819. * Gets the texture coordinates of where the pick occured
  11820. * @returns the vector containing the coordnates of the texture
  11821. */
  11822. getTextureCoordinates(): Nullable<Vector2>;
  11823. }
  11824. }
  11825. declare module "babylonjs/Events/pointerEvents" {
  11826. import { Nullable } from "babylonjs/types";
  11827. import { Vector2 } from "babylonjs/Maths/math.vector";
  11828. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11829. import { Ray } from "babylonjs/Culling/ray";
  11830. /**
  11831. * Gather the list of pointer event types as constants.
  11832. */
  11833. export class PointerEventTypes {
  11834. /**
  11835. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11836. */
  11837. static readonly POINTERDOWN: number;
  11838. /**
  11839. * The pointerup event is fired when a pointer is no longer active.
  11840. */
  11841. static readonly POINTERUP: number;
  11842. /**
  11843. * The pointermove event is fired when a pointer changes coordinates.
  11844. */
  11845. static readonly POINTERMOVE: number;
  11846. /**
  11847. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11848. */
  11849. static readonly POINTERWHEEL: number;
  11850. /**
  11851. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11852. */
  11853. static readonly POINTERPICK: number;
  11854. /**
  11855. * The pointertap event is fired when a the object has been touched and released without drag.
  11856. */
  11857. static readonly POINTERTAP: number;
  11858. /**
  11859. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11860. */
  11861. static readonly POINTERDOUBLETAP: number;
  11862. }
  11863. /**
  11864. * Base class of pointer info types.
  11865. */
  11866. export class PointerInfoBase {
  11867. /**
  11868. * Defines the type of event (PointerEventTypes)
  11869. */
  11870. type: number;
  11871. /**
  11872. * Defines the related dom event
  11873. */
  11874. event: PointerEvent | MouseWheelEvent;
  11875. /**
  11876. * Instantiates the base class of pointers info.
  11877. * @param type Defines the type of event (PointerEventTypes)
  11878. * @param event Defines the related dom event
  11879. */
  11880. constructor(
  11881. /**
  11882. * Defines the type of event (PointerEventTypes)
  11883. */
  11884. type: number,
  11885. /**
  11886. * Defines the related dom event
  11887. */
  11888. event: PointerEvent | MouseWheelEvent);
  11889. }
  11890. /**
  11891. * This class is used to store pointer related info for the onPrePointerObservable event.
  11892. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11893. */
  11894. export class PointerInfoPre extends PointerInfoBase {
  11895. /**
  11896. * Ray from a pointer if availible (eg. 6dof controller)
  11897. */
  11898. ray: Nullable<Ray>;
  11899. /**
  11900. * Defines the local position of the pointer on the canvas.
  11901. */
  11902. localPosition: Vector2;
  11903. /**
  11904. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11905. */
  11906. skipOnPointerObservable: boolean;
  11907. /**
  11908. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11909. * @param type Defines the type of event (PointerEventTypes)
  11910. * @param event Defines the related dom event
  11911. * @param localX Defines the local x coordinates of the pointer when the event occured
  11912. * @param localY Defines the local y coordinates of the pointer when the event occured
  11913. */
  11914. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11915. }
  11916. /**
  11917. * This type contains all the data related to a pointer event in Babylon.js.
  11918. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  11919. */
  11920. export class PointerInfo extends PointerInfoBase {
  11921. /**
  11922. * Defines the picking info associated to the info (if any)\
  11923. */
  11924. pickInfo: Nullable<PickingInfo>;
  11925. /**
  11926. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11927. * @param type Defines the type of event (PointerEventTypes)
  11928. * @param event Defines the related dom event
  11929. * @param pickInfo Defines the picking info associated to the info (if any)\
  11930. */
  11931. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11932. /**
  11933. * Defines the picking info associated to the info (if any)\
  11934. */
  11935. pickInfo: Nullable<PickingInfo>);
  11936. }
  11937. /**
  11938. * Data relating to a touch event on the screen.
  11939. */
  11940. export interface PointerTouch {
  11941. /**
  11942. * X coordinate of touch.
  11943. */
  11944. x: number;
  11945. /**
  11946. * Y coordinate of touch.
  11947. */
  11948. y: number;
  11949. /**
  11950. * Id of touch. Unique for each finger.
  11951. */
  11952. pointerId: number;
  11953. /**
  11954. * Event type passed from DOM.
  11955. */
  11956. type: any;
  11957. }
  11958. }
  11959. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11960. import { Observable } from "babylonjs/Misc/observable";
  11961. import { Nullable } from "babylonjs/types";
  11962. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11963. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11964. /**
  11965. * Manage the mouse inputs to control the movement of a free camera.
  11966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11967. */
  11968. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11969. /**
  11970. * Define if touch is enabled in the mouse input
  11971. */
  11972. touchEnabled: boolean;
  11973. /**
  11974. * Defines the camera the input is attached to.
  11975. */
  11976. camera: FreeCamera;
  11977. /**
  11978. * Defines the buttons associated with the input to handle camera move.
  11979. */
  11980. buttons: number[];
  11981. /**
  11982. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11983. */
  11984. angularSensibility: number;
  11985. private _pointerInput;
  11986. private _onMouseMove;
  11987. private _observer;
  11988. private previousPosition;
  11989. /**
  11990. * Observable for when a pointer move event occurs containing the move offset
  11991. */
  11992. onPointerMovedObservable: Observable<{
  11993. offsetX: number;
  11994. offsetY: number;
  11995. }>;
  11996. /**
  11997. * @hidden
  11998. * If the camera should be rotated automatically based on pointer movement
  11999. */
  12000. _allowCameraRotation: boolean;
  12001. /**
  12002. * Manage the mouse inputs to control the movement of a free camera.
  12003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12004. * @param touchEnabled Defines if touch is enabled or not
  12005. */
  12006. constructor(
  12007. /**
  12008. * Define if touch is enabled in the mouse input
  12009. */
  12010. touchEnabled?: boolean);
  12011. /**
  12012. * Attach the input controls to a specific dom element to get the input from.
  12013. * @param element Defines the element the controls should be listened from
  12014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12015. */
  12016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12017. /**
  12018. * Called on JS contextmenu event.
  12019. * Override this method to provide functionality.
  12020. */
  12021. protected onContextMenu(evt: PointerEvent): void;
  12022. /**
  12023. * Detach the current controls from the specified dom element.
  12024. * @param element Defines the element to stop listening the inputs from
  12025. */
  12026. detachControl(element: Nullable<HTMLElement>): void;
  12027. /**
  12028. * Gets the class name of the current intput.
  12029. * @returns the class name
  12030. */
  12031. getClassName(): string;
  12032. /**
  12033. * Get the friendly name associated with the input class.
  12034. * @returns the input friendly name
  12035. */
  12036. getSimpleName(): string;
  12037. }
  12038. }
  12039. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12040. import { Nullable } from "babylonjs/types";
  12041. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12042. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12043. /**
  12044. * Manage the touch inputs to control the movement of a free camera.
  12045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12046. */
  12047. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12048. /**
  12049. * Defines the camera the input is attached to.
  12050. */
  12051. camera: FreeCamera;
  12052. /**
  12053. * Defines the touch sensibility for rotation.
  12054. * The higher the faster.
  12055. */
  12056. touchAngularSensibility: number;
  12057. /**
  12058. * Defines the touch sensibility for move.
  12059. * The higher the faster.
  12060. */
  12061. touchMoveSensibility: number;
  12062. private _offsetX;
  12063. private _offsetY;
  12064. private _pointerPressed;
  12065. private _pointerInput;
  12066. private _observer;
  12067. private _onLostFocus;
  12068. /**
  12069. * Attach the input controls to a specific dom element to get the input from.
  12070. * @param element Defines the element the controls should be listened from
  12071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12072. */
  12073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12074. /**
  12075. * Detach the current controls from the specified dom element.
  12076. * @param element Defines the element to stop listening the inputs from
  12077. */
  12078. detachControl(element: Nullable<HTMLElement>): void;
  12079. /**
  12080. * Update the current camera state depending on the inputs that have been used this frame.
  12081. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12082. */
  12083. checkInputs(): void;
  12084. /**
  12085. * Gets the class name of the current intput.
  12086. * @returns the class name
  12087. */
  12088. getClassName(): string;
  12089. /**
  12090. * Get the friendly name associated with the input class.
  12091. * @returns the input friendly name
  12092. */
  12093. getSimpleName(): string;
  12094. }
  12095. }
  12096. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12097. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12098. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12099. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12100. import { Nullable } from "babylonjs/types";
  12101. /**
  12102. * Default Inputs manager for the FreeCamera.
  12103. * It groups all the default supported inputs for ease of use.
  12104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12105. */
  12106. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12107. /**
  12108. * @hidden
  12109. */
  12110. _mouseInput: Nullable<FreeCameraMouseInput>;
  12111. /**
  12112. * Instantiates a new FreeCameraInputsManager.
  12113. * @param camera Defines the camera the inputs belong to
  12114. */
  12115. constructor(camera: FreeCamera);
  12116. /**
  12117. * Add keyboard input support to the input manager.
  12118. * @returns the current input manager
  12119. */
  12120. addKeyboard(): FreeCameraInputsManager;
  12121. /**
  12122. * Add mouse input support to the input manager.
  12123. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12124. * @returns the current input manager
  12125. */
  12126. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12127. /**
  12128. * Removes the mouse input support from the manager
  12129. * @returns the current input manager
  12130. */
  12131. removeMouse(): FreeCameraInputsManager;
  12132. /**
  12133. * Add touch input support to the input manager.
  12134. * @returns the current input manager
  12135. */
  12136. addTouch(): FreeCameraInputsManager;
  12137. /**
  12138. * Remove all attached input methods from a camera
  12139. */
  12140. clear(): void;
  12141. }
  12142. }
  12143. declare module "babylonjs/Cameras/freeCamera" {
  12144. import { Vector3 } from "babylonjs/Maths/math.vector";
  12145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12146. import { Scene } from "babylonjs/scene";
  12147. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12148. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12149. /**
  12150. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12151. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12153. */
  12154. export class FreeCamera extends TargetCamera {
  12155. /**
  12156. * Define the collision ellipsoid of the camera.
  12157. * This is helpful to simulate a camera body like the player body around the camera
  12158. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12159. */
  12160. ellipsoid: Vector3;
  12161. /**
  12162. * Define an offset for the position of the ellipsoid around the camera.
  12163. * This can be helpful to determine the center of the body near the gravity center of the body
  12164. * instead of its head.
  12165. */
  12166. ellipsoidOffset: Vector3;
  12167. /**
  12168. * Enable or disable collisions of the camera with the rest of the scene objects.
  12169. */
  12170. checkCollisions: boolean;
  12171. /**
  12172. * Enable or disable gravity on the camera.
  12173. */
  12174. applyGravity: boolean;
  12175. /**
  12176. * Define the input manager associated to the camera.
  12177. */
  12178. inputs: FreeCameraInputsManager;
  12179. /**
  12180. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12181. * Higher values reduce sensitivity.
  12182. */
  12183. /**
  12184. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12185. * Higher values reduce sensitivity.
  12186. */
  12187. angularSensibility: number;
  12188. /**
  12189. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12190. */
  12191. keysUp: number[];
  12192. /**
  12193. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12194. */
  12195. keysDown: number[];
  12196. /**
  12197. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12198. */
  12199. keysLeft: number[];
  12200. /**
  12201. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12202. */
  12203. keysRight: number[];
  12204. /**
  12205. * Event raised when the camera collide with a mesh in the scene.
  12206. */
  12207. onCollide: (collidedMesh: AbstractMesh) => void;
  12208. private _collider;
  12209. private _needMoveForGravity;
  12210. private _oldPosition;
  12211. private _diffPosition;
  12212. private _newPosition;
  12213. /** @hidden */
  12214. _localDirection: Vector3;
  12215. /** @hidden */
  12216. _transformedDirection: Vector3;
  12217. /**
  12218. * Instantiates a Free Camera.
  12219. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12220. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12221. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12222. * @param name Define the name of the camera in the scene
  12223. * @param position Define the start position of the camera in the scene
  12224. * @param scene Define the scene the camera belongs to
  12225. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12226. */
  12227. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12228. /**
  12229. * Attached controls to the current camera.
  12230. * @param element Defines the element the controls should be listened from
  12231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12232. */
  12233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12234. /**
  12235. * Detach the current controls from the camera.
  12236. * The camera will stop reacting to inputs.
  12237. * @param element Defines the element to stop listening the inputs from
  12238. */
  12239. detachControl(element: HTMLElement): void;
  12240. private _collisionMask;
  12241. /**
  12242. * Define a collision mask to limit the list of object the camera can collide with
  12243. */
  12244. collisionMask: number;
  12245. /** @hidden */
  12246. _collideWithWorld(displacement: Vector3): void;
  12247. private _onCollisionPositionChange;
  12248. /** @hidden */
  12249. _checkInputs(): void;
  12250. /** @hidden */
  12251. _decideIfNeedsToMove(): boolean;
  12252. /** @hidden */
  12253. _updatePosition(): void;
  12254. /**
  12255. * Destroy the camera and release the current resources hold by it.
  12256. */
  12257. dispose(): void;
  12258. /**
  12259. * Gets the current object class name.
  12260. * @return the class name
  12261. */
  12262. getClassName(): string;
  12263. }
  12264. }
  12265. declare module "babylonjs/Gamepads/gamepad" {
  12266. import { Observable } from "babylonjs/Misc/observable";
  12267. /**
  12268. * Represents a gamepad control stick position
  12269. */
  12270. export class StickValues {
  12271. /**
  12272. * The x component of the control stick
  12273. */
  12274. x: number;
  12275. /**
  12276. * The y component of the control stick
  12277. */
  12278. y: number;
  12279. /**
  12280. * Initializes the gamepad x and y control stick values
  12281. * @param x The x component of the gamepad control stick value
  12282. * @param y The y component of the gamepad control stick value
  12283. */
  12284. constructor(
  12285. /**
  12286. * The x component of the control stick
  12287. */
  12288. x: number,
  12289. /**
  12290. * The y component of the control stick
  12291. */
  12292. y: number);
  12293. }
  12294. /**
  12295. * An interface which manages callbacks for gamepad button changes
  12296. */
  12297. export interface GamepadButtonChanges {
  12298. /**
  12299. * Called when a gamepad has been changed
  12300. */
  12301. changed: boolean;
  12302. /**
  12303. * Called when a gamepad press event has been triggered
  12304. */
  12305. pressChanged: boolean;
  12306. /**
  12307. * Called when a touch event has been triggered
  12308. */
  12309. touchChanged: boolean;
  12310. /**
  12311. * Called when a value has changed
  12312. */
  12313. valueChanged: boolean;
  12314. }
  12315. /**
  12316. * Represents a gamepad
  12317. */
  12318. export class Gamepad {
  12319. /**
  12320. * The id of the gamepad
  12321. */
  12322. id: string;
  12323. /**
  12324. * The index of the gamepad
  12325. */
  12326. index: number;
  12327. /**
  12328. * The browser gamepad
  12329. */
  12330. browserGamepad: any;
  12331. /**
  12332. * Specifies what type of gamepad this represents
  12333. */
  12334. type: number;
  12335. private _leftStick;
  12336. private _rightStick;
  12337. /** @hidden */
  12338. _isConnected: boolean;
  12339. private _leftStickAxisX;
  12340. private _leftStickAxisY;
  12341. private _rightStickAxisX;
  12342. private _rightStickAxisY;
  12343. /**
  12344. * Triggered when the left control stick has been changed
  12345. */
  12346. private _onleftstickchanged;
  12347. /**
  12348. * Triggered when the right control stick has been changed
  12349. */
  12350. private _onrightstickchanged;
  12351. /**
  12352. * Represents a gamepad controller
  12353. */
  12354. static GAMEPAD: number;
  12355. /**
  12356. * Represents a generic controller
  12357. */
  12358. static GENERIC: number;
  12359. /**
  12360. * Represents an XBox controller
  12361. */
  12362. static XBOX: number;
  12363. /**
  12364. * Represents a pose-enabled controller
  12365. */
  12366. static POSE_ENABLED: number;
  12367. /**
  12368. * Represents an Dual Shock controller
  12369. */
  12370. static DUALSHOCK: number;
  12371. /**
  12372. * Specifies whether the left control stick should be Y-inverted
  12373. */
  12374. protected _invertLeftStickY: boolean;
  12375. /**
  12376. * Specifies if the gamepad has been connected
  12377. */
  12378. readonly isConnected: boolean;
  12379. /**
  12380. * Initializes the gamepad
  12381. * @param id The id of the gamepad
  12382. * @param index The index of the gamepad
  12383. * @param browserGamepad The browser gamepad
  12384. * @param leftStickX The x component of the left joystick
  12385. * @param leftStickY The y component of the left joystick
  12386. * @param rightStickX The x component of the right joystick
  12387. * @param rightStickY The y component of the right joystick
  12388. */
  12389. constructor(
  12390. /**
  12391. * The id of the gamepad
  12392. */
  12393. id: string,
  12394. /**
  12395. * The index of the gamepad
  12396. */
  12397. index: number,
  12398. /**
  12399. * The browser gamepad
  12400. */
  12401. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12402. /**
  12403. * Callback triggered when the left joystick has changed
  12404. * @param callback
  12405. */
  12406. onleftstickchanged(callback: (values: StickValues) => void): void;
  12407. /**
  12408. * Callback triggered when the right joystick has changed
  12409. * @param callback
  12410. */
  12411. onrightstickchanged(callback: (values: StickValues) => void): void;
  12412. /**
  12413. * Gets the left joystick
  12414. */
  12415. /**
  12416. * Sets the left joystick values
  12417. */
  12418. leftStick: StickValues;
  12419. /**
  12420. * Gets the right joystick
  12421. */
  12422. /**
  12423. * Sets the right joystick value
  12424. */
  12425. rightStick: StickValues;
  12426. /**
  12427. * Updates the gamepad joystick positions
  12428. */
  12429. update(): void;
  12430. /**
  12431. * Disposes the gamepad
  12432. */
  12433. dispose(): void;
  12434. }
  12435. /**
  12436. * Represents a generic gamepad
  12437. */
  12438. export class GenericPad extends Gamepad {
  12439. private _buttons;
  12440. private _onbuttondown;
  12441. private _onbuttonup;
  12442. /**
  12443. * Observable triggered when a button has been pressed
  12444. */
  12445. onButtonDownObservable: Observable<number>;
  12446. /**
  12447. * Observable triggered when a button has been released
  12448. */
  12449. onButtonUpObservable: Observable<number>;
  12450. /**
  12451. * Callback triggered when a button has been pressed
  12452. * @param callback Called when a button has been pressed
  12453. */
  12454. onbuttondown(callback: (buttonPressed: number) => void): void;
  12455. /**
  12456. * Callback triggered when a button has been released
  12457. * @param callback Called when a button has been released
  12458. */
  12459. onbuttonup(callback: (buttonReleased: number) => void): void;
  12460. /**
  12461. * Initializes the generic gamepad
  12462. * @param id The id of the generic gamepad
  12463. * @param index The index of the generic gamepad
  12464. * @param browserGamepad The browser gamepad
  12465. */
  12466. constructor(id: string, index: number, browserGamepad: any);
  12467. private _setButtonValue;
  12468. /**
  12469. * Updates the generic gamepad
  12470. */
  12471. update(): void;
  12472. /**
  12473. * Disposes the generic gamepad
  12474. */
  12475. dispose(): void;
  12476. }
  12477. }
  12478. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12479. import { Nullable } from "babylonjs/types";
  12480. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12481. import { Scene } from "babylonjs/scene";
  12482. module "babylonjs/Engines/engine" {
  12483. interface Engine {
  12484. /**
  12485. * Creates a raw texture
  12486. * @param data defines the data to store in the texture
  12487. * @param width defines the width of the texture
  12488. * @param height defines the height of the texture
  12489. * @param format defines the format of the data
  12490. * @param generateMipMaps defines if the engine should generate the mip levels
  12491. * @param invertY defines if data must be stored with Y axis inverted
  12492. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12493. * @param compression defines the compression used (null by default)
  12494. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12495. * @returns the raw texture inside an InternalTexture
  12496. */
  12497. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12498. /**
  12499. * Update a raw texture
  12500. * @param texture defines the texture to update
  12501. * @param data defines the data to store in the texture
  12502. * @param format defines the format of the data
  12503. * @param invertY defines if data must be stored with Y axis inverted
  12504. */
  12505. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12506. /**
  12507. * Update a raw texture
  12508. * @param texture defines the texture to update
  12509. * @param data defines the data to store in the texture
  12510. * @param format defines the format of the data
  12511. * @param invertY defines if data must be stored with Y axis inverted
  12512. * @param compression defines the compression used (null by default)
  12513. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12514. */
  12515. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12516. /**
  12517. * Creates a new raw cube texture
  12518. * @param data defines the array of data to use to create each face
  12519. * @param size defines the size of the textures
  12520. * @param format defines the format of the data
  12521. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12522. * @param generateMipMaps defines if the engine should generate the mip levels
  12523. * @param invertY defines if data must be stored with Y axis inverted
  12524. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12525. * @param compression defines the compression used (null by default)
  12526. * @returns the cube texture as an InternalTexture
  12527. */
  12528. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12529. /**
  12530. * Update a raw cube texture
  12531. * @param texture defines the texture to udpdate
  12532. * @param data defines the data to store
  12533. * @param format defines the data format
  12534. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12535. * @param invertY defines if data must be stored with Y axis inverted
  12536. */
  12537. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12538. /**
  12539. * Update a raw cube texture
  12540. * @param texture defines the texture to udpdate
  12541. * @param data defines the data to store
  12542. * @param format defines the data format
  12543. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12544. * @param invertY defines if data must be stored with Y axis inverted
  12545. * @param compression defines the compression used (null by default)
  12546. */
  12547. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12548. /**
  12549. * Update a raw cube texture
  12550. * @param texture defines the texture to udpdate
  12551. * @param data defines the data to store
  12552. * @param format defines the data format
  12553. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12554. * @param invertY defines if data must be stored with Y axis inverted
  12555. * @param compression defines the compression used (null by default)
  12556. * @param level defines which level of the texture to update
  12557. */
  12558. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12559. /**
  12560. * Creates a new raw cube texture from a specified url
  12561. * @param url defines the url where the data is located
  12562. * @param scene defines the current scene
  12563. * @param size defines the size of the textures
  12564. * @param format defines the format of the data
  12565. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12566. * @param noMipmap defines if the engine should avoid generating the mip levels
  12567. * @param callback defines a callback used to extract texture data from loaded data
  12568. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12569. * @param onLoad defines a callback called when texture is loaded
  12570. * @param onError defines a callback called if there is an error
  12571. * @returns the cube texture as an InternalTexture
  12572. */
  12573. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12574. /**
  12575. * Creates a new raw cube texture from a specified url
  12576. * @param url defines the url where the data is located
  12577. * @param scene defines the current scene
  12578. * @param size defines the size of the textures
  12579. * @param format defines the format of the data
  12580. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12581. * @param noMipmap defines if the engine should avoid generating the mip levels
  12582. * @param callback defines a callback used to extract texture data from loaded data
  12583. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12584. * @param onLoad defines a callback called when texture is loaded
  12585. * @param onError defines a callback called if there is an error
  12586. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12587. * @param invertY defines if data must be stored with Y axis inverted
  12588. * @returns the cube texture as an InternalTexture
  12589. */
  12590. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12591. /**
  12592. * Creates a new raw 3D texture
  12593. * @param data defines the data used to create the texture
  12594. * @param width defines the width of the texture
  12595. * @param height defines the height of the texture
  12596. * @param depth defines the depth of the texture
  12597. * @param format defines the format of the texture
  12598. * @param generateMipMaps defines if the engine must generate mip levels
  12599. * @param invertY defines if data must be stored with Y axis inverted
  12600. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12601. * @param compression defines the compressed used (can be null)
  12602. * @param textureType defines the compressed used (can be null)
  12603. * @returns a new raw 3D texture (stored in an InternalTexture)
  12604. */
  12605. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12606. /**
  12607. * Update a raw 3D texture
  12608. * @param texture defines the texture to update
  12609. * @param data defines the data to store
  12610. * @param format defines the data format
  12611. * @param invertY defines if data must be stored with Y axis inverted
  12612. */
  12613. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12614. /**
  12615. * Update a raw 3D texture
  12616. * @param texture defines the texture to update
  12617. * @param data defines the data to store
  12618. * @param format defines the data format
  12619. * @param invertY defines if data must be stored with Y axis inverted
  12620. * @param compression defines the used compression (can be null)
  12621. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12622. */
  12623. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12624. }
  12625. }
  12626. }
  12627. declare module "babylonjs/Materials/Textures/rawTexture" {
  12628. import { Scene } from "babylonjs/scene";
  12629. import { Texture } from "babylonjs/Materials/Textures/texture";
  12630. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12631. /**
  12632. * Raw texture can help creating a texture directly from an array of data.
  12633. * This can be super useful if you either get the data from an uncompressed source or
  12634. * if you wish to create your texture pixel by pixel.
  12635. */
  12636. export class RawTexture extends Texture {
  12637. /**
  12638. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12639. */
  12640. format: number;
  12641. private _engine;
  12642. /**
  12643. * Instantiates a new RawTexture.
  12644. * Raw texture can help creating a texture directly from an array of data.
  12645. * This can be super useful if you either get the data from an uncompressed source or
  12646. * if you wish to create your texture pixel by pixel.
  12647. * @param data define the array of data to use to create the texture
  12648. * @param width define the width of the texture
  12649. * @param height define the height of the texture
  12650. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12651. * @param scene define the scene the texture belongs to
  12652. * @param generateMipMaps define whether mip maps should be generated or not
  12653. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12654. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12655. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12656. */
  12657. constructor(data: ArrayBufferView, width: number, height: number,
  12658. /**
  12659. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12660. */
  12661. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12662. /**
  12663. * Updates the texture underlying data.
  12664. * @param data Define the new data of the texture
  12665. */
  12666. update(data: ArrayBufferView): void;
  12667. /**
  12668. * Creates a luminance texture from some data.
  12669. * @param data Define the texture data
  12670. * @param width Define the width of the texture
  12671. * @param height Define the height of the texture
  12672. * @param scene Define the scene the texture belongs to
  12673. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12674. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12675. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12676. * @returns the luminance texture
  12677. */
  12678. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12679. /**
  12680. * Creates a luminance alpha texture from some data.
  12681. * @param data Define the texture data
  12682. * @param width Define the width of the texture
  12683. * @param height Define the height of the texture
  12684. * @param scene Define the scene the texture belongs to
  12685. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12686. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12687. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12688. * @returns the luminance alpha texture
  12689. */
  12690. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12691. /**
  12692. * Creates an alpha texture from some data.
  12693. * @param data Define the texture data
  12694. * @param width Define the width of the texture
  12695. * @param height Define the height of the texture
  12696. * @param scene Define the scene the texture belongs to
  12697. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12698. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12699. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12700. * @returns the alpha texture
  12701. */
  12702. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12703. /**
  12704. * Creates a RGB texture from some data.
  12705. * @param data Define the texture data
  12706. * @param width Define the width of the texture
  12707. * @param height Define the height of the texture
  12708. * @param scene Define the scene the texture belongs to
  12709. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12710. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12711. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12712. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12713. * @returns the RGB alpha texture
  12714. */
  12715. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12716. /**
  12717. * Creates a RGBA texture from some data.
  12718. * @param data Define the texture data
  12719. * @param width Define the width of the texture
  12720. * @param height Define the height of the texture
  12721. * @param scene Define the scene the texture belongs to
  12722. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12723. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12724. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12725. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12726. * @returns the RGBA texture
  12727. */
  12728. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12729. /**
  12730. * Creates a R texture from some data.
  12731. * @param data Define the texture data
  12732. * @param width Define the width of the texture
  12733. * @param height Define the height of the texture
  12734. * @param scene Define the scene the texture belongs to
  12735. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12736. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12737. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12738. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12739. * @returns the R texture
  12740. */
  12741. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12742. }
  12743. }
  12744. declare module "babylonjs/Maths/math.size" {
  12745. /**
  12746. * Interface for the size containing width and height
  12747. */
  12748. export interface ISize {
  12749. /**
  12750. * Width
  12751. */
  12752. width: number;
  12753. /**
  12754. * Heighht
  12755. */
  12756. height: number;
  12757. }
  12758. /**
  12759. * Size containing widht and height
  12760. */
  12761. export class Size implements ISize {
  12762. /**
  12763. * Width
  12764. */
  12765. width: number;
  12766. /**
  12767. * Height
  12768. */
  12769. height: number;
  12770. /**
  12771. * Creates a Size object from the given width and height (floats).
  12772. * @param width width of the new size
  12773. * @param height height of the new size
  12774. */
  12775. constructor(width: number, height: number);
  12776. /**
  12777. * Returns a string with the Size width and height
  12778. * @returns a string with the Size width and height
  12779. */
  12780. toString(): string;
  12781. /**
  12782. * "Size"
  12783. * @returns the string "Size"
  12784. */
  12785. getClassName(): string;
  12786. /**
  12787. * Returns the Size hash code.
  12788. * @returns a hash code for a unique width and height
  12789. */
  12790. getHashCode(): number;
  12791. /**
  12792. * Updates the current size from the given one.
  12793. * @param src the given size
  12794. */
  12795. copyFrom(src: Size): void;
  12796. /**
  12797. * Updates in place the current Size from the given floats.
  12798. * @param width width of the new size
  12799. * @param height height of the new size
  12800. * @returns the updated Size.
  12801. */
  12802. copyFromFloats(width: number, height: number): Size;
  12803. /**
  12804. * Updates in place the current Size from the given floats.
  12805. * @param width width to set
  12806. * @param height height to set
  12807. * @returns the updated Size.
  12808. */
  12809. set(width: number, height: number): Size;
  12810. /**
  12811. * Multiplies the width and height by numbers
  12812. * @param w factor to multiple the width by
  12813. * @param h factor to multiple the height by
  12814. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12815. */
  12816. multiplyByFloats(w: number, h: number): Size;
  12817. /**
  12818. * Clones the size
  12819. * @returns a new Size copied from the given one.
  12820. */
  12821. clone(): Size;
  12822. /**
  12823. * True if the current Size and the given one width and height are strictly equal.
  12824. * @param other the other size to compare against
  12825. * @returns True if the current Size and the given one width and height are strictly equal.
  12826. */
  12827. equals(other: Size): boolean;
  12828. /**
  12829. * The surface of the Size : width * height (float).
  12830. */
  12831. readonly surface: number;
  12832. /**
  12833. * Create a new size of zero
  12834. * @returns a new Size set to (0.0, 0.0)
  12835. */
  12836. static Zero(): Size;
  12837. /**
  12838. * Sums the width and height of two sizes
  12839. * @param otherSize size to add to this size
  12840. * @returns a new Size set as the addition result of the current Size and the given one.
  12841. */
  12842. add(otherSize: Size): Size;
  12843. /**
  12844. * Subtracts the width and height of two
  12845. * @param otherSize size to subtract to this size
  12846. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12847. */
  12848. subtract(otherSize: Size): Size;
  12849. /**
  12850. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12851. * @param start starting size to lerp between
  12852. * @param end end size to lerp between
  12853. * @param amount amount to lerp between the start and end values
  12854. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12855. */
  12856. static Lerp(start: Size, end: Size, amount: number): Size;
  12857. }
  12858. }
  12859. declare module "babylonjs/Animations/runtimeAnimation" {
  12860. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12861. import { Animatable } from "babylonjs/Animations/animatable";
  12862. import { Scene } from "babylonjs/scene";
  12863. /**
  12864. * Defines a runtime animation
  12865. */
  12866. export class RuntimeAnimation {
  12867. private _events;
  12868. /**
  12869. * The current frame of the runtime animation
  12870. */
  12871. private _currentFrame;
  12872. /**
  12873. * The animation used by the runtime animation
  12874. */
  12875. private _animation;
  12876. /**
  12877. * The target of the runtime animation
  12878. */
  12879. private _target;
  12880. /**
  12881. * The initiating animatable
  12882. */
  12883. private _host;
  12884. /**
  12885. * The original value of the runtime animation
  12886. */
  12887. private _originalValue;
  12888. /**
  12889. * The original blend value of the runtime animation
  12890. */
  12891. private _originalBlendValue;
  12892. /**
  12893. * The offsets cache of the runtime animation
  12894. */
  12895. private _offsetsCache;
  12896. /**
  12897. * The high limits cache of the runtime animation
  12898. */
  12899. private _highLimitsCache;
  12900. /**
  12901. * Specifies if the runtime animation has been stopped
  12902. */
  12903. private _stopped;
  12904. /**
  12905. * The blending factor of the runtime animation
  12906. */
  12907. private _blendingFactor;
  12908. /**
  12909. * The BabylonJS scene
  12910. */
  12911. private _scene;
  12912. /**
  12913. * The current value of the runtime animation
  12914. */
  12915. private _currentValue;
  12916. /** @hidden */
  12917. _animationState: _IAnimationState;
  12918. /**
  12919. * The active target of the runtime animation
  12920. */
  12921. private _activeTargets;
  12922. private _currentActiveTarget;
  12923. private _directTarget;
  12924. /**
  12925. * The target path of the runtime animation
  12926. */
  12927. private _targetPath;
  12928. /**
  12929. * The weight of the runtime animation
  12930. */
  12931. private _weight;
  12932. /**
  12933. * The ratio offset of the runtime animation
  12934. */
  12935. private _ratioOffset;
  12936. /**
  12937. * The previous delay of the runtime animation
  12938. */
  12939. private _previousDelay;
  12940. /**
  12941. * The previous ratio of the runtime animation
  12942. */
  12943. private _previousRatio;
  12944. private _enableBlending;
  12945. private _keys;
  12946. private _minFrame;
  12947. private _maxFrame;
  12948. private _minValue;
  12949. private _maxValue;
  12950. private _targetIsArray;
  12951. /**
  12952. * Gets the current frame of the runtime animation
  12953. */
  12954. readonly currentFrame: number;
  12955. /**
  12956. * Gets the weight of the runtime animation
  12957. */
  12958. readonly weight: number;
  12959. /**
  12960. * Gets the current value of the runtime animation
  12961. */
  12962. readonly currentValue: any;
  12963. /**
  12964. * Gets the target path of the runtime animation
  12965. */
  12966. readonly targetPath: string;
  12967. /**
  12968. * Gets the actual target of the runtime animation
  12969. */
  12970. readonly target: any;
  12971. /** @hidden */
  12972. _onLoop: () => void;
  12973. /**
  12974. * Create a new RuntimeAnimation object
  12975. * @param target defines the target of the animation
  12976. * @param animation defines the source animation object
  12977. * @param scene defines the hosting scene
  12978. * @param host defines the initiating Animatable
  12979. */
  12980. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12981. private _preparePath;
  12982. /**
  12983. * Gets the animation from the runtime animation
  12984. */
  12985. readonly animation: Animation;
  12986. /**
  12987. * Resets the runtime animation to the beginning
  12988. * @param restoreOriginal defines whether to restore the target property to the original value
  12989. */
  12990. reset(restoreOriginal?: boolean): void;
  12991. /**
  12992. * Specifies if the runtime animation is stopped
  12993. * @returns Boolean specifying if the runtime animation is stopped
  12994. */
  12995. isStopped(): boolean;
  12996. /**
  12997. * Disposes of the runtime animation
  12998. */
  12999. dispose(): void;
  13000. /**
  13001. * Apply the interpolated value to the target
  13002. * @param currentValue defines the value computed by the animation
  13003. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13004. */
  13005. setValue(currentValue: any, weight: number): void;
  13006. private _getOriginalValues;
  13007. private _setValue;
  13008. /**
  13009. * Gets the loop pmode of the runtime animation
  13010. * @returns Loop Mode
  13011. */
  13012. private _getCorrectLoopMode;
  13013. /**
  13014. * Move the current animation to a given frame
  13015. * @param frame defines the frame to move to
  13016. */
  13017. goToFrame(frame: number): void;
  13018. /**
  13019. * @hidden Internal use only
  13020. */
  13021. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13022. /**
  13023. * Execute the current animation
  13024. * @param delay defines the delay to add to the current frame
  13025. * @param from defines the lower bound of the animation range
  13026. * @param to defines the upper bound of the animation range
  13027. * @param loop defines if the current animation must loop
  13028. * @param speedRatio defines the current speed ratio
  13029. * @param weight defines the weight of the animation (default is -1 so no weight)
  13030. * @param onLoop optional callback called when animation loops
  13031. * @returns a boolean indicating if the animation is running
  13032. */
  13033. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13034. }
  13035. }
  13036. declare module "babylonjs/Animations/animatable" {
  13037. import { Animation } from "babylonjs/Animations/animation";
  13038. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13039. import { Nullable } from "babylonjs/types";
  13040. import { Observable } from "babylonjs/Misc/observable";
  13041. import { Scene } from "babylonjs/scene";
  13042. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13043. import { Node } from "babylonjs/node";
  13044. /**
  13045. * Class used to store an actual running animation
  13046. */
  13047. export class Animatable {
  13048. /** defines the target object */
  13049. target: any;
  13050. /** defines the starting frame number (default is 0) */
  13051. fromFrame: number;
  13052. /** defines the ending frame number (default is 100) */
  13053. toFrame: number;
  13054. /** defines if the animation must loop (default is false) */
  13055. loopAnimation: boolean;
  13056. /** defines a callback to call when animation ends if it is not looping */
  13057. onAnimationEnd?: (() => void) | null | undefined;
  13058. /** defines a callback to call when animation loops */
  13059. onAnimationLoop?: (() => void) | null | undefined;
  13060. private _localDelayOffset;
  13061. private _pausedDelay;
  13062. private _runtimeAnimations;
  13063. private _paused;
  13064. private _scene;
  13065. private _speedRatio;
  13066. private _weight;
  13067. private _syncRoot;
  13068. /**
  13069. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13070. * This will only apply for non looping animation (default is true)
  13071. */
  13072. disposeOnEnd: boolean;
  13073. /**
  13074. * Gets a boolean indicating if the animation has started
  13075. */
  13076. animationStarted: boolean;
  13077. /**
  13078. * Observer raised when the animation ends
  13079. */
  13080. onAnimationEndObservable: Observable<Animatable>;
  13081. /**
  13082. * Observer raised when the animation loops
  13083. */
  13084. onAnimationLoopObservable: Observable<Animatable>;
  13085. /**
  13086. * Gets the root Animatable used to synchronize and normalize animations
  13087. */
  13088. readonly syncRoot: Nullable<Animatable>;
  13089. /**
  13090. * Gets the current frame of the first RuntimeAnimation
  13091. * Used to synchronize Animatables
  13092. */
  13093. readonly masterFrame: number;
  13094. /**
  13095. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13096. */
  13097. weight: number;
  13098. /**
  13099. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13100. */
  13101. speedRatio: number;
  13102. /**
  13103. * Creates a new Animatable
  13104. * @param scene defines the hosting scene
  13105. * @param target defines the target object
  13106. * @param fromFrame defines the starting frame number (default is 0)
  13107. * @param toFrame defines the ending frame number (default is 100)
  13108. * @param loopAnimation defines if the animation must loop (default is false)
  13109. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13110. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13111. * @param animations defines a group of animation to add to the new Animatable
  13112. * @param onAnimationLoop defines a callback to call when animation loops
  13113. */
  13114. constructor(scene: Scene,
  13115. /** defines the target object */
  13116. target: any,
  13117. /** defines the starting frame number (default is 0) */
  13118. fromFrame?: number,
  13119. /** defines the ending frame number (default is 100) */
  13120. toFrame?: number,
  13121. /** defines if the animation must loop (default is false) */
  13122. loopAnimation?: boolean, speedRatio?: number,
  13123. /** defines a callback to call when animation ends if it is not looping */
  13124. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13125. /** defines a callback to call when animation loops */
  13126. onAnimationLoop?: (() => void) | null | undefined);
  13127. /**
  13128. * Synchronize and normalize current Animatable with a source Animatable
  13129. * This is useful when using animation weights and when animations are not of the same length
  13130. * @param root defines the root Animatable to synchronize with
  13131. * @returns the current Animatable
  13132. */
  13133. syncWith(root: Animatable): Animatable;
  13134. /**
  13135. * Gets the list of runtime animations
  13136. * @returns an array of RuntimeAnimation
  13137. */
  13138. getAnimations(): RuntimeAnimation[];
  13139. /**
  13140. * Adds more animations to the current animatable
  13141. * @param target defines the target of the animations
  13142. * @param animations defines the new animations to add
  13143. */
  13144. appendAnimations(target: any, animations: Animation[]): void;
  13145. /**
  13146. * Gets the source animation for a specific property
  13147. * @param property defines the propertyu to look for
  13148. * @returns null or the source animation for the given property
  13149. */
  13150. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13151. /**
  13152. * Gets the runtime animation for a specific property
  13153. * @param property defines the propertyu to look for
  13154. * @returns null or the runtime animation for the given property
  13155. */
  13156. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13157. /**
  13158. * Resets the animatable to its original state
  13159. */
  13160. reset(): void;
  13161. /**
  13162. * Allows the animatable to blend with current running animations
  13163. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13164. * @param blendingSpeed defines the blending speed to use
  13165. */
  13166. enableBlending(blendingSpeed: number): void;
  13167. /**
  13168. * Disable animation blending
  13169. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13170. */
  13171. disableBlending(): void;
  13172. /**
  13173. * Jump directly to a given frame
  13174. * @param frame defines the frame to jump to
  13175. */
  13176. goToFrame(frame: number): void;
  13177. /**
  13178. * Pause the animation
  13179. */
  13180. pause(): void;
  13181. /**
  13182. * Restart the animation
  13183. */
  13184. restart(): void;
  13185. private _raiseOnAnimationEnd;
  13186. /**
  13187. * Stop and delete the current animation
  13188. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13189. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  13190. */
  13191. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13192. /**
  13193. * Wait asynchronously for the animation to end
  13194. * @returns a promise which will be fullfilled when the animation ends
  13195. */
  13196. waitAsync(): Promise<Animatable>;
  13197. /** @hidden */
  13198. _animate(delay: number): boolean;
  13199. }
  13200. module "babylonjs/scene" {
  13201. interface Scene {
  13202. /** @hidden */
  13203. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13204. /** @hidden */
  13205. _processLateAnimationBindingsForMatrices(holder: {
  13206. totalWeight: number;
  13207. animations: RuntimeAnimation[];
  13208. originalValue: Matrix;
  13209. }): any;
  13210. /** @hidden */
  13211. _processLateAnimationBindingsForQuaternions(holder: {
  13212. totalWeight: number;
  13213. animations: RuntimeAnimation[];
  13214. originalValue: Quaternion;
  13215. }, refQuaternion: Quaternion): Quaternion;
  13216. /** @hidden */
  13217. _processLateAnimationBindings(): void;
  13218. /**
  13219. * Will start the animation sequence of a given target
  13220. * @param target defines the target
  13221. * @param from defines from which frame should animation start
  13222. * @param to defines until which frame should animation run.
  13223. * @param weight defines the weight to apply to the animation (1.0 by default)
  13224. * @param loop defines if the animation loops
  13225. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13226. * @param onAnimationEnd defines the function to be executed when the animation ends
  13227. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13228. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13229. * @param onAnimationLoop defines the callback to call when an animation loops
  13230. * @returns the animatable object created for this animation
  13231. */
  13232. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13233. /**
  13234. * Will start the animation sequence of a given target
  13235. * @param target defines the target
  13236. * @param from defines from which frame should animation start
  13237. * @param to defines until which frame should animation run.
  13238. * @param loop defines if the animation loops
  13239. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13240. * @param onAnimationEnd defines the function to be executed when the animation ends
  13241. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13242. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13243. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13244. * @param onAnimationLoop defines the callback to call when an animation loops
  13245. * @returns the animatable object created for this animation
  13246. */
  13247. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13248. /**
  13249. * Will start the animation sequence of a given target and its hierarchy
  13250. * @param target defines the target
  13251. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13252. * @param from defines from which frame should animation start
  13253. * @param to defines until which frame should animation run.
  13254. * @param loop defines if the animation loops
  13255. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13256. * @param onAnimationEnd defines the function to be executed when the animation ends
  13257. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13258. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13259. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13260. * @param onAnimationLoop defines the callback to call when an animation loops
  13261. * @returns the list of created animatables
  13262. */
  13263. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13264. /**
  13265. * Begin a new animation on a given node
  13266. * @param target defines the target where the animation will take place
  13267. * @param animations defines the list of animations to start
  13268. * @param from defines the initial value
  13269. * @param to defines the final value
  13270. * @param loop defines if you want animation to loop (off by default)
  13271. * @param speedRatio defines the speed ratio to apply to all animations
  13272. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13273. * @param onAnimationLoop defines the callback to call when an animation loops
  13274. * @returns the list of created animatables
  13275. */
  13276. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13277. /**
  13278. * Begin a new animation on a given node and its hierarchy
  13279. * @param target defines the root node where the animation will take place
  13280. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13281. * @param animations defines the list of animations to start
  13282. * @param from defines the initial value
  13283. * @param to defines the final value
  13284. * @param loop defines if you want animation to loop (off by default)
  13285. * @param speedRatio defines the speed ratio to apply to all animations
  13286. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13287. * @param onAnimationLoop defines the callback to call when an animation loops
  13288. * @returns the list of animatables created for all nodes
  13289. */
  13290. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13291. /**
  13292. * Gets the animatable associated with a specific target
  13293. * @param target defines the target of the animatable
  13294. * @returns the required animatable if found
  13295. */
  13296. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13297. /**
  13298. * Gets all animatables associated with a given target
  13299. * @param target defines the target to look animatables for
  13300. * @returns an array of Animatables
  13301. */
  13302. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13303. /**
  13304. * Stops and removes all animations that have been applied to the scene
  13305. */
  13306. stopAllAnimations(): void;
  13307. }
  13308. }
  13309. module "babylonjs/Bones/bone" {
  13310. interface Bone {
  13311. /**
  13312. * Copy an animation range from another bone
  13313. * @param source defines the source bone
  13314. * @param rangeName defines the range name to copy
  13315. * @param frameOffset defines the frame offset
  13316. * @param rescaleAsRequired defines if rescaling must be applied if required
  13317. * @param skelDimensionsRatio defines the scaling ratio
  13318. * @returns true if operation was successful
  13319. */
  13320. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13321. }
  13322. }
  13323. }
  13324. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13325. /**
  13326. * Class used to override all child animations of a given target
  13327. */
  13328. export class AnimationPropertiesOverride {
  13329. /**
  13330. * Gets or sets a value indicating if animation blending must be used
  13331. */
  13332. enableBlending: boolean;
  13333. /**
  13334. * Gets or sets the blending speed to use when enableBlending is true
  13335. */
  13336. blendingSpeed: number;
  13337. /**
  13338. * Gets or sets the default loop mode to use
  13339. */
  13340. loopMode: number;
  13341. }
  13342. }
  13343. declare module "babylonjs/Bones/skeleton" {
  13344. import { Bone } from "babylonjs/Bones/bone";
  13345. import { Observable } from "babylonjs/Misc/observable";
  13346. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13347. import { Scene } from "babylonjs/scene";
  13348. import { Nullable } from "babylonjs/types";
  13349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13350. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13351. import { Animatable } from "babylonjs/Animations/animatable";
  13352. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13353. import { Animation } from "babylonjs/Animations/animation";
  13354. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13355. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13356. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13357. /**
  13358. * Class used to handle skinning animations
  13359. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13360. */
  13361. export class Skeleton implements IAnimatable {
  13362. /** defines the skeleton name */
  13363. name: string;
  13364. /** defines the skeleton Id */
  13365. id: string;
  13366. /**
  13367. * Defines the list of child bones
  13368. */
  13369. bones: Bone[];
  13370. /**
  13371. * Defines an estimate of the dimension of the skeleton at rest
  13372. */
  13373. dimensionsAtRest: Vector3;
  13374. /**
  13375. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13376. */
  13377. needInitialSkinMatrix: boolean;
  13378. /**
  13379. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13380. */
  13381. overrideMesh: Nullable<AbstractMesh>;
  13382. /**
  13383. * Gets the list of animations attached to this skeleton
  13384. */
  13385. animations: Array<Animation>;
  13386. private _scene;
  13387. private _isDirty;
  13388. private _transformMatrices;
  13389. private _transformMatrixTexture;
  13390. private _meshesWithPoseMatrix;
  13391. private _animatables;
  13392. private _identity;
  13393. private _synchronizedWithMesh;
  13394. private _ranges;
  13395. private _lastAbsoluteTransformsUpdateId;
  13396. private _canUseTextureForBones;
  13397. private _uniqueId;
  13398. /** @hidden */
  13399. _numBonesWithLinkedTransformNode: number;
  13400. /** @hidden */
  13401. _hasWaitingData: Nullable<boolean>;
  13402. /**
  13403. * Specifies if the skeleton should be serialized
  13404. */
  13405. doNotSerialize: boolean;
  13406. private _useTextureToStoreBoneMatrices;
  13407. /**
  13408. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13409. * Please note that this option is not available if the hardware does not support it
  13410. */
  13411. useTextureToStoreBoneMatrices: boolean;
  13412. private _animationPropertiesOverride;
  13413. /**
  13414. * Gets or sets the animation properties override
  13415. */
  13416. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13417. /**
  13418. * List of inspectable custom properties (used by the Inspector)
  13419. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13420. */
  13421. inspectableCustomProperties: IInspectable[];
  13422. /**
  13423. * An observable triggered before computing the skeleton's matrices
  13424. */
  13425. onBeforeComputeObservable: Observable<Skeleton>;
  13426. /**
  13427. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13428. */
  13429. readonly isUsingTextureForMatrices: boolean;
  13430. /**
  13431. * Gets the unique ID of this skeleton
  13432. */
  13433. readonly uniqueId: number;
  13434. /**
  13435. * Creates a new skeleton
  13436. * @param name defines the skeleton name
  13437. * @param id defines the skeleton Id
  13438. * @param scene defines the hosting scene
  13439. */
  13440. constructor(
  13441. /** defines the skeleton name */
  13442. name: string,
  13443. /** defines the skeleton Id */
  13444. id: string, scene: Scene);
  13445. /**
  13446. * Gets the current object class name.
  13447. * @return the class name
  13448. */
  13449. getClassName(): string;
  13450. /**
  13451. * Returns an array containing the root bones
  13452. * @returns an array containing the root bones
  13453. */
  13454. getChildren(): Array<Bone>;
  13455. /**
  13456. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13457. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13458. * @returns a Float32Array containing matrices data
  13459. */
  13460. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13461. /**
  13462. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13463. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13464. * @returns a raw texture containing the data
  13465. */
  13466. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13467. /**
  13468. * Gets the current hosting scene
  13469. * @returns a scene object
  13470. */
  13471. getScene(): Scene;
  13472. /**
  13473. * Gets a string representing the current skeleton data
  13474. * @param fullDetails defines a boolean indicating if we want a verbose version
  13475. * @returns a string representing the current skeleton data
  13476. */
  13477. toString(fullDetails?: boolean): string;
  13478. /**
  13479. * Get bone's index searching by name
  13480. * @param name defines bone's name to search for
  13481. * @return the indice of the bone. Returns -1 if not found
  13482. */
  13483. getBoneIndexByName(name: string): number;
  13484. /**
  13485. * Creater a new animation range
  13486. * @param name defines the name of the range
  13487. * @param from defines the start key
  13488. * @param to defines the end key
  13489. */
  13490. createAnimationRange(name: string, from: number, to: number): void;
  13491. /**
  13492. * Delete a specific animation range
  13493. * @param name defines the name of the range
  13494. * @param deleteFrames defines if frames must be removed as well
  13495. */
  13496. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13497. /**
  13498. * Gets a specific animation range
  13499. * @param name defines the name of the range to look for
  13500. * @returns the requested animation range or null if not found
  13501. */
  13502. getAnimationRange(name: string): Nullable<AnimationRange>;
  13503. /**
  13504. * Gets the list of all animation ranges defined on this skeleton
  13505. * @returns an array
  13506. */
  13507. getAnimationRanges(): Nullable<AnimationRange>[];
  13508. /**
  13509. * Copy animation range from a source skeleton.
  13510. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13511. * @param source defines the source skeleton
  13512. * @param name defines the name of the range to copy
  13513. * @param rescaleAsRequired defines if rescaling must be applied if required
  13514. * @returns true if operation was successful
  13515. */
  13516. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13517. /**
  13518. * Forces the skeleton to go to rest pose
  13519. */
  13520. returnToRest(): void;
  13521. private _getHighestAnimationFrame;
  13522. /**
  13523. * Begin a specific animation range
  13524. * @param name defines the name of the range to start
  13525. * @param loop defines if looping must be turned on (false by default)
  13526. * @param speedRatio defines the speed ratio to apply (1 by default)
  13527. * @param onAnimationEnd defines a callback which will be called when animation will end
  13528. * @returns a new animatable
  13529. */
  13530. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13531. /** @hidden */
  13532. _markAsDirty(): void;
  13533. /** @hidden */
  13534. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13535. /** @hidden */
  13536. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13537. private _computeTransformMatrices;
  13538. /**
  13539. * Build all resources required to render a skeleton
  13540. */
  13541. prepare(): void;
  13542. /**
  13543. * Gets the list of animatables currently running for this skeleton
  13544. * @returns an array of animatables
  13545. */
  13546. getAnimatables(): IAnimatable[];
  13547. /**
  13548. * Clone the current skeleton
  13549. * @param name defines the name of the new skeleton
  13550. * @param id defines the id of the new skeleton
  13551. * @returns the new skeleton
  13552. */
  13553. clone(name: string, id: string): Skeleton;
  13554. /**
  13555. * Enable animation blending for this skeleton
  13556. * @param blendingSpeed defines the blending speed to apply
  13557. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13558. */
  13559. enableBlending(blendingSpeed?: number): void;
  13560. /**
  13561. * Releases all resources associated with the current skeleton
  13562. */
  13563. dispose(): void;
  13564. /**
  13565. * Serialize the skeleton in a JSON object
  13566. * @returns a JSON object
  13567. */
  13568. serialize(): any;
  13569. /**
  13570. * Creates a new skeleton from serialized data
  13571. * @param parsedSkeleton defines the serialized data
  13572. * @param scene defines the hosting scene
  13573. * @returns a new skeleton
  13574. */
  13575. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13576. /**
  13577. * Compute all node absolute transforms
  13578. * @param forceUpdate defines if computation must be done even if cache is up to date
  13579. */
  13580. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13581. /**
  13582. * Gets the root pose matrix
  13583. * @returns a matrix
  13584. */
  13585. getPoseMatrix(): Nullable<Matrix>;
  13586. /**
  13587. * Sorts bones per internal index
  13588. */
  13589. sortBones(): void;
  13590. private _sortBones;
  13591. }
  13592. }
  13593. declare module "babylonjs/Bones/bone" {
  13594. import { Skeleton } from "babylonjs/Bones/skeleton";
  13595. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13596. import { Nullable } from "babylonjs/types";
  13597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13598. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13599. import { Node } from "babylonjs/node";
  13600. import { Space } from "babylonjs/Maths/math.axis";
  13601. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13602. /**
  13603. * Class used to store bone information
  13604. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13605. */
  13606. export class Bone extends Node {
  13607. /**
  13608. * defines the bone name
  13609. */
  13610. name: string;
  13611. private static _tmpVecs;
  13612. private static _tmpQuat;
  13613. private static _tmpMats;
  13614. /**
  13615. * Gets the list of child bones
  13616. */
  13617. children: Bone[];
  13618. /** Gets the animations associated with this bone */
  13619. animations: import("babylonjs/Animations/animation").Animation[];
  13620. /**
  13621. * Gets or sets bone length
  13622. */
  13623. length: number;
  13624. /**
  13625. * @hidden Internal only
  13626. * Set this value to map this bone to a different index in the transform matrices
  13627. * Set this value to -1 to exclude the bone from the transform matrices
  13628. */
  13629. _index: Nullable<number>;
  13630. private _skeleton;
  13631. private _localMatrix;
  13632. private _restPose;
  13633. private _baseMatrix;
  13634. private _absoluteTransform;
  13635. private _invertedAbsoluteTransform;
  13636. private _parent;
  13637. private _scalingDeterminant;
  13638. private _worldTransform;
  13639. private _localScaling;
  13640. private _localRotation;
  13641. private _localPosition;
  13642. private _needToDecompose;
  13643. private _needToCompose;
  13644. /** @hidden */
  13645. _linkedTransformNode: Nullable<TransformNode>;
  13646. /** @hidden */
  13647. _waitingTransformNodeId: Nullable<string>;
  13648. /** @hidden */
  13649. /** @hidden */
  13650. _matrix: Matrix;
  13651. /**
  13652. * Create a new bone
  13653. * @param name defines the bone name
  13654. * @param skeleton defines the parent skeleton
  13655. * @param parentBone defines the parent (can be null if the bone is the root)
  13656. * @param localMatrix defines the local matrix
  13657. * @param restPose defines the rest pose matrix
  13658. * @param baseMatrix defines the base matrix
  13659. * @param index defines index of the bone in the hiearchy
  13660. */
  13661. constructor(
  13662. /**
  13663. * defines the bone name
  13664. */
  13665. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13666. /**
  13667. * Gets the current object class name.
  13668. * @return the class name
  13669. */
  13670. getClassName(): string;
  13671. /**
  13672. * Gets the parent skeleton
  13673. * @returns a skeleton
  13674. */
  13675. getSkeleton(): Skeleton;
  13676. /**
  13677. * Gets parent bone
  13678. * @returns a bone or null if the bone is the root of the bone hierarchy
  13679. */
  13680. getParent(): Nullable<Bone>;
  13681. /**
  13682. * Returns an array containing the root bones
  13683. * @returns an array containing the root bones
  13684. */
  13685. getChildren(): Array<Bone>;
  13686. /**
  13687. * Sets the parent bone
  13688. * @param parent defines the parent (can be null if the bone is the root)
  13689. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13690. */
  13691. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13692. /**
  13693. * Gets the local matrix
  13694. * @returns a matrix
  13695. */
  13696. getLocalMatrix(): Matrix;
  13697. /**
  13698. * Gets the base matrix (initial matrix which remains unchanged)
  13699. * @returns a matrix
  13700. */
  13701. getBaseMatrix(): Matrix;
  13702. /**
  13703. * Gets the rest pose matrix
  13704. * @returns a matrix
  13705. */
  13706. getRestPose(): Matrix;
  13707. /**
  13708. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13709. */
  13710. getWorldMatrix(): Matrix;
  13711. /**
  13712. * Sets the local matrix to rest pose matrix
  13713. */
  13714. returnToRest(): void;
  13715. /**
  13716. * Gets the inverse of the absolute transform matrix.
  13717. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13718. * @returns a matrix
  13719. */
  13720. getInvertedAbsoluteTransform(): Matrix;
  13721. /**
  13722. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13723. * @returns a matrix
  13724. */
  13725. getAbsoluteTransform(): Matrix;
  13726. /**
  13727. * Links with the given transform node.
  13728. * The local matrix of this bone is copied from the transform node every frame.
  13729. * @param transformNode defines the transform node to link to
  13730. */
  13731. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13732. /**
  13733. * Gets the node used to drive the bone's transformation
  13734. * @returns a transform node or null
  13735. */
  13736. getTransformNode(): Nullable<TransformNode>;
  13737. /** Gets or sets current position (in local space) */
  13738. position: Vector3;
  13739. /** Gets or sets current rotation (in local space) */
  13740. rotation: Vector3;
  13741. /** Gets or sets current rotation quaternion (in local space) */
  13742. rotationQuaternion: Quaternion;
  13743. /** Gets or sets current scaling (in local space) */
  13744. scaling: Vector3;
  13745. /**
  13746. * Gets the animation properties override
  13747. */
  13748. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13749. private _decompose;
  13750. private _compose;
  13751. /**
  13752. * Update the base and local matrices
  13753. * @param matrix defines the new base or local matrix
  13754. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13755. * @param updateLocalMatrix defines if the local matrix should be updated
  13756. */
  13757. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13758. /** @hidden */
  13759. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13760. /**
  13761. * Flag the bone as dirty (Forcing it to update everything)
  13762. */
  13763. markAsDirty(): void;
  13764. /** @hidden */
  13765. _markAsDirtyAndCompose(): void;
  13766. private _markAsDirtyAndDecompose;
  13767. /**
  13768. * Translate the bone in local or world space
  13769. * @param vec The amount to translate the bone
  13770. * @param space The space that the translation is in
  13771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13772. */
  13773. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13774. /**
  13775. * Set the postion of the bone in local or world space
  13776. * @param position The position to set the bone
  13777. * @param space The space that the position is in
  13778. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13779. */
  13780. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13781. /**
  13782. * Set the absolute position of the bone (world space)
  13783. * @param position The position to set the bone
  13784. * @param mesh The mesh that this bone is attached to
  13785. */
  13786. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13787. /**
  13788. * Scale the bone on the x, y and z axes (in local space)
  13789. * @param x The amount to scale the bone on the x axis
  13790. * @param y The amount to scale the bone on the y axis
  13791. * @param z The amount to scale the bone on the z axis
  13792. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13793. */
  13794. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13795. /**
  13796. * Set the bone scaling in local space
  13797. * @param scale defines the scaling vector
  13798. */
  13799. setScale(scale: Vector3): void;
  13800. /**
  13801. * Gets the current scaling in local space
  13802. * @returns the current scaling vector
  13803. */
  13804. getScale(): Vector3;
  13805. /**
  13806. * Gets the current scaling in local space and stores it in a target vector
  13807. * @param result defines the target vector
  13808. */
  13809. getScaleToRef(result: Vector3): void;
  13810. /**
  13811. * Set the yaw, pitch, and roll of the bone in local or world space
  13812. * @param yaw The rotation of the bone on the y axis
  13813. * @param pitch The rotation of the bone on the x axis
  13814. * @param roll The rotation of the bone on the z axis
  13815. * @param space The space that the axes of rotation are in
  13816. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13817. */
  13818. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13819. /**
  13820. * Add a rotation to the bone on an axis in local or world space
  13821. * @param axis The axis to rotate the bone on
  13822. * @param amount The amount to rotate the bone
  13823. * @param space The space that the axis is in
  13824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13825. */
  13826. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13827. /**
  13828. * Set the rotation of the bone to a particular axis angle in local or world space
  13829. * @param axis The axis to rotate the bone on
  13830. * @param angle The angle that the bone should be rotated to
  13831. * @param space The space that the axis is in
  13832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13833. */
  13834. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13835. /**
  13836. * Set the euler rotation of the bone in local of world space
  13837. * @param rotation The euler rotation that the bone should be set to
  13838. * @param space The space that the rotation is in
  13839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13840. */
  13841. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13842. /**
  13843. * Set the quaternion rotation of the bone in local of world space
  13844. * @param quat The quaternion rotation that the bone should be set to
  13845. * @param space The space that the rotation is in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. */
  13848. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13849. /**
  13850. * Set the rotation matrix of the bone in local of world space
  13851. * @param rotMat The rotation matrix that the bone should be set to
  13852. * @param space The space that the rotation is in
  13853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13854. */
  13855. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13856. private _rotateWithMatrix;
  13857. private _getNegativeRotationToRef;
  13858. /**
  13859. * Get the position of the bone in local or world space
  13860. * @param space The space that the returned position is in
  13861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13862. * @returns The position of the bone
  13863. */
  13864. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13865. /**
  13866. * Copy the position of the bone to a vector3 in local or world space
  13867. * @param space The space that the returned position is in
  13868. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13869. * @param result The vector3 to copy the position to
  13870. */
  13871. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13872. /**
  13873. * Get the absolute position of the bone (world space)
  13874. * @param mesh The mesh that this bone is attached to
  13875. * @returns The absolute position of the bone
  13876. */
  13877. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13878. /**
  13879. * Copy the absolute position of the bone (world space) to the result param
  13880. * @param mesh The mesh that this bone is attached to
  13881. * @param result The vector3 to copy the absolute position to
  13882. */
  13883. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13884. /**
  13885. * Compute the absolute transforms of this bone and its children
  13886. */
  13887. computeAbsoluteTransforms(): void;
  13888. /**
  13889. * Get the world direction from an axis that is in the local space of the bone
  13890. * @param localAxis The local direction that is used to compute the world direction
  13891. * @param mesh The mesh that this bone is attached to
  13892. * @returns The world direction
  13893. */
  13894. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13895. /**
  13896. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13897. * @param localAxis The local direction that is used to compute the world direction
  13898. * @param mesh The mesh that this bone is attached to
  13899. * @param result The vector3 that the world direction will be copied to
  13900. */
  13901. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13902. /**
  13903. * Get the euler rotation of the bone in local or world space
  13904. * @param space The space that the rotation should be in
  13905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13906. * @returns The euler rotation
  13907. */
  13908. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13909. /**
  13910. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13911. * @param space The space that the rotation should be in
  13912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13913. * @param result The vector3 that the rotation should be copied to
  13914. */
  13915. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13916. /**
  13917. * Get the quaternion rotation of the bone in either local or world space
  13918. * @param space The space that the rotation should be in
  13919. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13920. * @returns The quaternion rotation
  13921. */
  13922. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13923. /**
  13924. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13925. * @param space The space that the rotation should be in
  13926. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13927. * @param result The quaternion that the rotation should be copied to
  13928. */
  13929. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13930. /**
  13931. * Get the rotation matrix of the bone in local or world space
  13932. * @param space The space that the rotation should be in
  13933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13934. * @returns The rotation matrix
  13935. */
  13936. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13937. /**
  13938. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13939. * @param space The space that the rotation should be in
  13940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13941. * @param result The quaternion that the rotation should be copied to
  13942. */
  13943. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13944. /**
  13945. * Get the world position of a point that is in the local space of the bone
  13946. * @param position The local position
  13947. * @param mesh The mesh that this bone is attached to
  13948. * @returns The world position
  13949. */
  13950. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13951. /**
  13952. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13953. * @param position The local position
  13954. * @param mesh The mesh that this bone is attached to
  13955. * @param result The vector3 that the world position should be copied to
  13956. */
  13957. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13958. /**
  13959. * Get the local position of a point that is in world space
  13960. * @param position The world position
  13961. * @param mesh The mesh that this bone is attached to
  13962. * @returns The local position
  13963. */
  13964. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13965. /**
  13966. * Get the local position of a point that is in world space and copy it to the result param
  13967. * @param position The world position
  13968. * @param mesh The mesh that this bone is attached to
  13969. * @param result The vector3 that the local position should be copied to
  13970. */
  13971. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13972. }
  13973. }
  13974. declare module "babylonjs/Meshes/transformNode" {
  13975. import { DeepImmutable } from "babylonjs/types";
  13976. import { Observable } from "babylonjs/Misc/observable";
  13977. import { Nullable } from "babylonjs/types";
  13978. import { Camera } from "babylonjs/Cameras/camera";
  13979. import { Scene } from "babylonjs/scene";
  13980. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13981. import { Node } from "babylonjs/node";
  13982. import { Bone } from "babylonjs/Bones/bone";
  13983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13984. import { Space } from "babylonjs/Maths/math.axis";
  13985. /**
  13986. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13987. * @see https://doc.babylonjs.com/how_to/transformnode
  13988. */
  13989. export class TransformNode extends Node {
  13990. /**
  13991. * Object will not rotate to face the camera
  13992. */
  13993. static BILLBOARDMODE_NONE: number;
  13994. /**
  13995. * Object will rotate to face the camera but only on the x axis
  13996. */
  13997. static BILLBOARDMODE_X: number;
  13998. /**
  13999. * Object will rotate to face the camera but only on the y axis
  14000. */
  14001. static BILLBOARDMODE_Y: number;
  14002. /**
  14003. * Object will rotate to face the camera but only on the z axis
  14004. */
  14005. static BILLBOARDMODE_Z: number;
  14006. /**
  14007. * Object will rotate to face the camera
  14008. */
  14009. static BILLBOARDMODE_ALL: number;
  14010. /**
  14011. * Object will rotate to face the camera's position instead of orientation
  14012. */
  14013. static BILLBOARDMODE_USE_POSITION: number;
  14014. private _forward;
  14015. private _forwardInverted;
  14016. private _up;
  14017. private _right;
  14018. private _rightInverted;
  14019. private _position;
  14020. private _rotation;
  14021. private _rotationQuaternion;
  14022. protected _scaling: Vector3;
  14023. protected _isDirty: boolean;
  14024. private _transformToBoneReferal;
  14025. private _isAbsoluteSynced;
  14026. private _billboardMode;
  14027. /**
  14028. * Gets or sets the billboard mode. Default is 0.
  14029. *
  14030. * | Value | Type | Description |
  14031. * | --- | --- | --- |
  14032. * | 0 | BILLBOARDMODE_NONE | |
  14033. * | 1 | BILLBOARDMODE_X | |
  14034. * | 2 | BILLBOARDMODE_Y | |
  14035. * | 4 | BILLBOARDMODE_Z | |
  14036. * | 7 | BILLBOARDMODE_ALL | |
  14037. *
  14038. */
  14039. billboardMode: number;
  14040. private _preserveParentRotationForBillboard;
  14041. /**
  14042. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14043. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14044. */
  14045. preserveParentRotationForBillboard: boolean;
  14046. /**
  14047. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14048. */
  14049. scalingDeterminant: number;
  14050. private _infiniteDistance;
  14051. /**
  14052. * Gets or sets the distance of the object to max, often used by skybox
  14053. */
  14054. infiniteDistance: boolean;
  14055. /**
  14056. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14057. * By default the system will update normals to compensate
  14058. */
  14059. ignoreNonUniformScaling: boolean;
  14060. /**
  14061. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14062. */
  14063. reIntegrateRotationIntoRotationQuaternion: boolean;
  14064. /** @hidden */
  14065. _poseMatrix: Nullable<Matrix>;
  14066. /** @hidden */
  14067. _localMatrix: Matrix;
  14068. private _usePivotMatrix;
  14069. private _absolutePosition;
  14070. private _absoluteScaling;
  14071. private _absoluteRotationQuaternion;
  14072. private _pivotMatrix;
  14073. private _pivotMatrixInverse;
  14074. protected _postMultiplyPivotMatrix: boolean;
  14075. protected _isWorldMatrixFrozen: boolean;
  14076. /** @hidden */
  14077. _indexInSceneTransformNodesArray: number;
  14078. /**
  14079. * An event triggered after the world matrix is updated
  14080. */
  14081. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14082. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14083. /**
  14084. * Gets a string identifying the name of the class
  14085. * @returns "TransformNode" string
  14086. */
  14087. getClassName(): string;
  14088. /**
  14089. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14090. */
  14091. position: Vector3;
  14092. /**
  14093. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14094. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14095. */
  14096. rotation: Vector3;
  14097. /**
  14098. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14099. */
  14100. scaling: Vector3;
  14101. /**
  14102. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14103. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14104. */
  14105. rotationQuaternion: Nullable<Quaternion>;
  14106. /**
  14107. * The forward direction of that transform in world space.
  14108. */
  14109. readonly forward: Vector3;
  14110. /**
  14111. * The up direction of that transform in world space.
  14112. */
  14113. readonly up: Vector3;
  14114. /**
  14115. * The right direction of that transform in world space.
  14116. */
  14117. readonly right: Vector3;
  14118. /**
  14119. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14120. * @param matrix the matrix to copy the pose from
  14121. * @returns this TransformNode.
  14122. */
  14123. updatePoseMatrix(matrix: Matrix): TransformNode;
  14124. /**
  14125. * Returns the mesh Pose matrix.
  14126. * @returns the pose matrix
  14127. */
  14128. getPoseMatrix(): Matrix;
  14129. /** @hidden */
  14130. _isSynchronized(): boolean;
  14131. /** @hidden */
  14132. _initCache(): void;
  14133. /**
  14134. * Flag the transform node as dirty (Forcing it to update everything)
  14135. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14136. * @returns this transform node
  14137. */
  14138. markAsDirty(property: string): TransformNode;
  14139. /**
  14140. * Returns the current mesh absolute position.
  14141. * Returns a Vector3.
  14142. */
  14143. readonly absolutePosition: Vector3;
  14144. /**
  14145. * Returns the current mesh absolute scaling.
  14146. * Returns a Vector3.
  14147. */
  14148. readonly absoluteScaling: Vector3;
  14149. /**
  14150. * Returns the current mesh absolute rotation.
  14151. * Returns a Quaternion.
  14152. */
  14153. readonly absoluteRotationQuaternion: Quaternion;
  14154. /**
  14155. * Sets a new matrix to apply before all other transformation
  14156. * @param matrix defines the transform matrix
  14157. * @returns the current TransformNode
  14158. */
  14159. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14160. /**
  14161. * Sets a new pivot matrix to the current node
  14162. * @param matrix defines the new pivot matrix to use
  14163. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14164. * @returns the current TransformNode
  14165. */
  14166. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14167. /**
  14168. * Returns the mesh pivot matrix.
  14169. * Default : Identity.
  14170. * @returns the matrix
  14171. */
  14172. getPivotMatrix(): Matrix;
  14173. /**
  14174. * Instantiate (when possible) or clone that node with its hierarchy
  14175. * @param newParent defines the new parent to use for the instance (or clone)
  14176. * @returns an instance (or a clone) of the current node with its hiearchy
  14177. */
  14178. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14179. /**
  14180. * Prevents the World matrix to be computed any longer
  14181. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14182. * @returns the TransformNode.
  14183. */
  14184. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14185. /**
  14186. * Allows back the World matrix computation.
  14187. * @returns the TransformNode.
  14188. */
  14189. unfreezeWorldMatrix(): this;
  14190. /**
  14191. * True if the World matrix has been frozen.
  14192. */
  14193. readonly isWorldMatrixFrozen: boolean;
  14194. /**
  14195. * Retuns the mesh absolute position in the World.
  14196. * @returns a Vector3.
  14197. */
  14198. getAbsolutePosition(): Vector3;
  14199. /**
  14200. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14201. * @param absolutePosition the absolute position to set
  14202. * @returns the TransformNode.
  14203. */
  14204. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14205. /**
  14206. * Sets the mesh position in its local space.
  14207. * @param vector3 the position to set in localspace
  14208. * @returns the TransformNode.
  14209. */
  14210. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14211. /**
  14212. * Returns the mesh position in the local space from the current World matrix values.
  14213. * @returns a new Vector3.
  14214. */
  14215. getPositionExpressedInLocalSpace(): Vector3;
  14216. /**
  14217. * Translates the mesh along the passed Vector3 in its local space.
  14218. * @param vector3 the distance to translate in localspace
  14219. * @returns the TransformNode.
  14220. */
  14221. locallyTranslate(vector3: Vector3): TransformNode;
  14222. private static _lookAtVectorCache;
  14223. /**
  14224. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14225. * @param targetPoint the position (must be in same space as current mesh) to look at
  14226. * @param yawCor optional yaw (y-axis) correction in radians
  14227. * @param pitchCor optional pitch (x-axis) correction in radians
  14228. * @param rollCor optional roll (z-axis) correction in radians
  14229. * @param space the choosen space of the target
  14230. * @returns the TransformNode.
  14231. */
  14232. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14233. /**
  14234. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14235. * This Vector3 is expressed in the World space.
  14236. * @param localAxis axis to rotate
  14237. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14238. */
  14239. getDirection(localAxis: Vector3): Vector3;
  14240. /**
  14241. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14242. * localAxis is expressed in the mesh local space.
  14243. * result is computed in the Wordl space from the mesh World matrix.
  14244. * @param localAxis axis to rotate
  14245. * @param result the resulting transformnode
  14246. * @returns this TransformNode.
  14247. */
  14248. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14249. /**
  14250. * Sets this transform node rotation to the given local axis.
  14251. * @param localAxis the axis in local space
  14252. * @param yawCor optional yaw (y-axis) correction in radians
  14253. * @param pitchCor optional pitch (x-axis) correction in radians
  14254. * @param rollCor optional roll (z-axis) correction in radians
  14255. * @returns this TransformNode
  14256. */
  14257. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14258. /**
  14259. * Sets a new pivot point to the current node
  14260. * @param point defines the new pivot point to use
  14261. * @param space defines if the point is in world or local space (local by default)
  14262. * @returns the current TransformNode
  14263. */
  14264. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14265. /**
  14266. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14267. * @returns the pivot point
  14268. */
  14269. getPivotPoint(): Vector3;
  14270. /**
  14271. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14272. * @param result the vector3 to store the result
  14273. * @returns this TransformNode.
  14274. */
  14275. getPivotPointToRef(result: Vector3): TransformNode;
  14276. /**
  14277. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14278. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14279. */
  14280. getAbsolutePivotPoint(): Vector3;
  14281. /**
  14282. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14283. * @param result vector3 to store the result
  14284. * @returns this TransformNode.
  14285. */
  14286. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14287. /**
  14288. * Defines the passed node as the parent of the current node.
  14289. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14290. * @see https://doc.babylonjs.com/how_to/parenting
  14291. * @param node the node ot set as the parent
  14292. * @returns this TransformNode.
  14293. */
  14294. setParent(node: Nullable<Node>): TransformNode;
  14295. private _nonUniformScaling;
  14296. /**
  14297. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14298. */
  14299. readonly nonUniformScaling: boolean;
  14300. /** @hidden */
  14301. _updateNonUniformScalingState(value: boolean): boolean;
  14302. /**
  14303. * Attach the current TransformNode to another TransformNode associated with a bone
  14304. * @param bone Bone affecting the TransformNode
  14305. * @param affectedTransformNode TransformNode associated with the bone
  14306. * @returns this object
  14307. */
  14308. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14309. /**
  14310. * Detach the transform node if its associated with a bone
  14311. * @returns this object
  14312. */
  14313. detachFromBone(): TransformNode;
  14314. private static _rotationAxisCache;
  14315. /**
  14316. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14317. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14318. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14319. * The passed axis is also normalized.
  14320. * @param axis the axis to rotate around
  14321. * @param amount the amount to rotate in radians
  14322. * @param space Space to rotate in (Default: local)
  14323. * @returns the TransformNode.
  14324. */
  14325. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14326. /**
  14327. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14328. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14329. * The passed axis is also normalized. .
  14330. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14331. * @param point the point to rotate around
  14332. * @param axis the axis to rotate around
  14333. * @param amount the amount to rotate in radians
  14334. * @returns the TransformNode
  14335. */
  14336. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14337. /**
  14338. * Translates the mesh along the axis vector for the passed distance in the given space.
  14339. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14340. * @param axis the axis to translate in
  14341. * @param distance the distance to translate
  14342. * @param space Space to rotate in (Default: local)
  14343. * @returns the TransformNode.
  14344. */
  14345. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14346. /**
  14347. * Adds a rotation step to the mesh current rotation.
  14348. * x, y, z are Euler angles expressed in radians.
  14349. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14350. * This means this rotation is made in the mesh local space only.
  14351. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14352. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14353. * ```javascript
  14354. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14355. * ```
  14356. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14357. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14358. * @param x Rotation to add
  14359. * @param y Rotation to add
  14360. * @param z Rotation to add
  14361. * @returns the TransformNode.
  14362. */
  14363. addRotation(x: number, y: number, z: number): TransformNode;
  14364. /**
  14365. * @hidden
  14366. */
  14367. protected _getEffectiveParent(): Nullable<Node>;
  14368. /**
  14369. * Computes the world matrix of the node
  14370. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14371. * @returns the world matrix
  14372. */
  14373. computeWorldMatrix(force?: boolean): Matrix;
  14374. protected _afterComputeWorldMatrix(): void;
  14375. /**
  14376. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14377. * @param func callback function to add
  14378. *
  14379. * @returns the TransformNode.
  14380. */
  14381. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14382. /**
  14383. * Removes a registered callback function.
  14384. * @param func callback function to remove
  14385. * @returns the TransformNode.
  14386. */
  14387. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14388. /**
  14389. * Gets the position of the current mesh in camera space
  14390. * @param camera defines the camera to use
  14391. * @returns a position
  14392. */
  14393. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14394. /**
  14395. * Returns the distance from the mesh to the active camera
  14396. * @param camera defines the camera to use
  14397. * @returns the distance
  14398. */
  14399. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14400. /**
  14401. * Clone the current transform node
  14402. * @param name Name of the new clone
  14403. * @param newParent New parent for the clone
  14404. * @param doNotCloneChildren Do not clone children hierarchy
  14405. * @returns the new transform node
  14406. */
  14407. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14408. /**
  14409. * Serializes the objects information.
  14410. * @param currentSerializationObject defines the object to serialize in
  14411. * @returns the serialized object
  14412. */
  14413. serialize(currentSerializationObject?: any): any;
  14414. /**
  14415. * Returns a new TransformNode object parsed from the source provided.
  14416. * @param parsedTransformNode is the source.
  14417. * @param scene the scne the object belongs to
  14418. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14419. * @returns a new TransformNode object parsed from the source provided.
  14420. */
  14421. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14422. /**
  14423. * Get all child-transformNodes of this node
  14424. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14425. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14426. * @returns an array of TransformNode
  14427. */
  14428. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14429. /**
  14430. * Releases resources associated with this transform node.
  14431. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14432. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14433. */
  14434. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14435. /**
  14436. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14437. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14438. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14439. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14440. * @returns the current mesh
  14441. */
  14442. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14443. private _syncAbsoluteScalingAndRotation;
  14444. }
  14445. }
  14446. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14447. import { Observable } from "babylonjs/Misc/observable";
  14448. import { Nullable } from "babylonjs/types";
  14449. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14450. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14452. import { Ray } from "babylonjs/Culling/ray";
  14453. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14454. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14455. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14456. /**
  14457. * Defines the types of pose enabled controllers that are supported
  14458. */
  14459. export enum PoseEnabledControllerType {
  14460. /**
  14461. * HTC Vive
  14462. */
  14463. VIVE = 0,
  14464. /**
  14465. * Oculus Rift
  14466. */
  14467. OCULUS = 1,
  14468. /**
  14469. * Windows mixed reality
  14470. */
  14471. WINDOWS = 2,
  14472. /**
  14473. * Samsung gear VR
  14474. */
  14475. GEAR_VR = 3,
  14476. /**
  14477. * Google Daydream
  14478. */
  14479. DAYDREAM = 4,
  14480. /**
  14481. * Generic
  14482. */
  14483. GENERIC = 5
  14484. }
  14485. /**
  14486. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14487. */
  14488. export interface MutableGamepadButton {
  14489. /**
  14490. * Value of the button/trigger
  14491. */
  14492. value: number;
  14493. /**
  14494. * If the button/trigger is currently touched
  14495. */
  14496. touched: boolean;
  14497. /**
  14498. * If the button/trigger is currently pressed
  14499. */
  14500. pressed: boolean;
  14501. }
  14502. /**
  14503. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14504. * @hidden
  14505. */
  14506. export interface ExtendedGamepadButton extends GamepadButton {
  14507. /**
  14508. * If the button/trigger is currently pressed
  14509. */
  14510. readonly pressed: boolean;
  14511. /**
  14512. * If the button/trigger is currently touched
  14513. */
  14514. readonly touched: boolean;
  14515. /**
  14516. * Value of the button/trigger
  14517. */
  14518. readonly value: number;
  14519. }
  14520. /** @hidden */
  14521. export interface _GamePadFactory {
  14522. /**
  14523. * Returns wether or not the current gamepad can be created for this type of controller.
  14524. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14525. * @returns true if it can be created, otherwise false
  14526. */
  14527. canCreate(gamepadInfo: any): boolean;
  14528. /**
  14529. * Creates a new instance of the Gamepad.
  14530. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14531. * @returns the new gamepad instance
  14532. */
  14533. create(gamepadInfo: any): Gamepad;
  14534. }
  14535. /**
  14536. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14537. */
  14538. export class PoseEnabledControllerHelper {
  14539. /** @hidden */
  14540. static _ControllerFactories: _GamePadFactory[];
  14541. /** @hidden */
  14542. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14543. /**
  14544. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14545. * @param vrGamepad the gamepad to initialized
  14546. * @returns a vr controller of the type the gamepad identified as
  14547. */
  14548. static InitiateController(vrGamepad: any): Gamepad;
  14549. }
  14550. /**
  14551. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14552. */
  14553. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14554. /**
  14555. * If the controller is used in a webXR session
  14556. */
  14557. isXR: boolean;
  14558. private _deviceRoomPosition;
  14559. private _deviceRoomRotationQuaternion;
  14560. /**
  14561. * The device position in babylon space
  14562. */
  14563. devicePosition: Vector3;
  14564. /**
  14565. * The device rotation in babylon space
  14566. */
  14567. deviceRotationQuaternion: Quaternion;
  14568. /**
  14569. * The scale factor of the device in babylon space
  14570. */
  14571. deviceScaleFactor: number;
  14572. /**
  14573. * (Likely devicePosition should be used instead) The device position in its room space
  14574. */
  14575. position: Vector3;
  14576. /**
  14577. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14578. */
  14579. rotationQuaternion: Quaternion;
  14580. /**
  14581. * The type of controller (Eg. Windows mixed reality)
  14582. */
  14583. controllerType: PoseEnabledControllerType;
  14584. protected _calculatedPosition: Vector3;
  14585. private _calculatedRotation;
  14586. /**
  14587. * The raw pose from the device
  14588. */
  14589. rawPose: DevicePose;
  14590. private _trackPosition;
  14591. private _maxRotationDistFromHeadset;
  14592. private _draggedRoomRotation;
  14593. /**
  14594. * @hidden
  14595. */
  14596. _disableTrackPosition(fixedPosition: Vector3): void;
  14597. /**
  14598. * Internal, the mesh attached to the controller
  14599. * @hidden
  14600. */
  14601. _mesh: Nullable<AbstractMesh>;
  14602. private _poseControlledCamera;
  14603. private _leftHandSystemQuaternion;
  14604. /**
  14605. * Internal, matrix used to convert room space to babylon space
  14606. * @hidden
  14607. */
  14608. _deviceToWorld: Matrix;
  14609. /**
  14610. * Node to be used when casting a ray from the controller
  14611. * @hidden
  14612. */
  14613. _pointingPoseNode: Nullable<TransformNode>;
  14614. /**
  14615. * Name of the child mesh that can be used to cast a ray from the controller
  14616. */
  14617. static readonly POINTING_POSE: string;
  14618. /**
  14619. * Creates a new PoseEnabledController from a gamepad
  14620. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14621. */
  14622. constructor(browserGamepad: any);
  14623. private _workingMatrix;
  14624. /**
  14625. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14626. */
  14627. update(): void;
  14628. /**
  14629. * Updates only the pose device and mesh without doing any button event checking
  14630. */
  14631. protected _updatePoseAndMesh(): void;
  14632. /**
  14633. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14634. * @param poseData raw pose fromthe device
  14635. */
  14636. updateFromDevice(poseData: DevicePose): void;
  14637. /**
  14638. * @hidden
  14639. */
  14640. _meshAttachedObservable: Observable<AbstractMesh>;
  14641. /**
  14642. * Attaches a mesh to the controller
  14643. * @param mesh the mesh to be attached
  14644. */
  14645. attachToMesh(mesh: AbstractMesh): void;
  14646. /**
  14647. * Attaches the controllers mesh to a camera
  14648. * @param camera the camera the mesh should be attached to
  14649. */
  14650. attachToPoseControlledCamera(camera: TargetCamera): void;
  14651. /**
  14652. * Disposes of the controller
  14653. */
  14654. dispose(): void;
  14655. /**
  14656. * The mesh that is attached to the controller
  14657. */
  14658. readonly mesh: Nullable<AbstractMesh>;
  14659. /**
  14660. * Gets the ray of the controller in the direction the controller is pointing
  14661. * @param length the length the resulting ray should be
  14662. * @returns a ray in the direction the controller is pointing
  14663. */
  14664. getForwardRay(length?: number): Ray;
  14665. }
  14666. }
  14667. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14668. import { Observable } from "babylonjs/Misc/observable";
  14669. import { Scene } from "babylonjs/scene";
  14670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14671. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14672. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14673. /**
  14674. * Defines the WebVRController object that represents controllers tracked in 3D space
  14675. */
  14676. export abstract class WebVRController extends PoseEnabledController {
  14677. /**
  14678. * Internal, the default controller model for the controller
  14679. */
  14680. protected _defaultModel: AbstractMesh;
  14681. /**
  14682. * Fired when the trigger state has changed
  14683. */
  14684. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14685. /**
  14686. * Fired when the main button state has changed
  14687. */
  14688. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14689. /**
  14690. * Fired when the secondary button state has changed
  14691. */
  14692. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14693. /**
  14694. * Fired when the pad state has changed
  14695. */
  14696. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14697. /**
  14698. * Fired when controllers stick values have changed
  14699. */
  14700. onPadValuesChangedObservable: Observable<StickValues>;
  14701. /**
  14702. * Array of button availible on the controller
  14703. */
  14704. protected _buttons: Array<MutableGamepadButton>;
  14705. private _onButtonStateChange;
  14706. /**
  14707. * Fired when a controller button's state has changed
  14708. * @param callback the callback containing the button that was modified
  14709. */
  14710. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14711. /**
  14712. * X and Y axis corresponding to the controllers joystick
  14713. */
  14714. pad: StickValues;
  14715. /**
  14716. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14717. */
  14718. hand: string;
  14719. /**
  14720. * The default controller model for the controller
  14721. */
  14722. readonly defaultModel: AbstractMesh;
  14723. /**
  14724. * Creates a new WebVRController from a gamepad
  14725. * @param vrGamepad the gamepad that the WebVRController should be created from
  14726. */
  14727. constructor(vrGamepad: any);
  14728. /**
  14729. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14730. */
  14731. update(): void;
  14732. /**
  14733. * Function to be called when a button is modified
  14734. */
  14735. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14736. /**
  14737. * Loads a mesh and attaches it to the controller
  14738. * @param scene the scene the mesh should be added to
  14739. * @param meshLoaded callback for when the mesh has been loaded
  14740. */
  14741. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14742. private _setButtonValue;
  14743. private _changes;
  14744. private _checkChanges;
  14745. /**
  14746. * Disposes of th webVRCOntroller
  14747. */
  14748. dispose(): void;
  14749. }
  14750. }
  14751. declare module "babylonjs/Lights/hemisphericLight" {
  14752. import { Nullable } from "babylonjs/types";
  14753. import { Scene } from "babylonjs/scene";
  14754. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14755. import { Color3 } from "babylonjs/Maths/math.color";
  14756. import { Effect } from "babylonjs/Materials/effect";
  14757. import { Light } from "babylonjs/Lights/light";
  14758. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14759. /**
  14760. * The HemisphericLight simulates the ambient environment light,
  14761. * so the passed direction is the light reflection direction, not the incoming direction.
  14762. */
  14763. export class HemisphericLight extends Light {
  14764. /**
  14765. * The groundColor is the light in the opposite direction to the one specified during creation.
  14766. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  14767. */
  14768. groundColor: Color3;
  14769. /**
  14770. * The light reflection direction, not the incoming direction.
  14771. */
  14772. direction: Vector3;
  14773. /**
  14774. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14775. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14776. * The HemisphericLight can't cast shadows.
  14777. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14778. * @param name The friendly name of the light
  14779. * @param direction The direction of the light reflection
  14780. * @param scene The scene the light belongs to
  14781. */
  14782. constructor(name: string, direction: Vector3, scene: Scene);
  14783. protected _buildUniformLayout(): void;
  14784. /**
  14785. * Returns the string "HemisphericLight".
  14786. * @return The class name
  14787. */
  14788. getClassName(): string;
  14789. /**
  14790. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14791. * Returns the updated direction.
  14792. * @param target The target the direction should point to
  14793. * @return The computed direction
  14794. */
  14795. setDirectionToTarget(target: Vector3): Vector3;
  14796. /**
  14797. * Returns the shadow generator associated to the light.
  14798. * @returns Always null for hemispheric lights because it does not support shadows.
  14799. */
  14800. getShadowGenerator(): Nullable<IShadowGenerator>;
  14801. /**
  14802. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14803. * @param effect The effect to update
  14804. * @param lightIndex The index of the light in the effect to update
  14805. * @returns The hemispheric light
  14806. */
  14807. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14808. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14809. /**
  14810. * Computes the world matrix of the node
  14811. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14812. * @param useWasUpdatedFlag defines a reserved property
  14813. * @returns the world matrix
  14814. */
  14815. computeWorldMatrix(): Matrix;
  14816. /**
  14817. * Returns the integer 3.
  14818. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14819. */
  14820. getTypeID(): number;
  14821. /**
  14822. * Prepares the list of defines specific to the light type.
  14823. * @param defines the list of defines
  14824. * @param lightIndex defines the index of the light for the effect
  14825. */
  14826. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14827. }
  14828. }
  14829. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14830. /** @hidden */
  14831. export var vrMultiviewToSingleviewPixelShader: {
  14832. name: string;
  14833. shader: string;
  14834. };
  14835. }
  14836. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14837. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14838. import { Scene } from "babylonjs/scene";
  14839. /**
  14840. * Renders to multiple views with a single draw call
  14841. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14842. */
  14843. export class MultiviewRenderTarget extends RenderTargetTexture {
  14844. /**
  14845. * Creates a multiview render target
  14846. * @param scene scene used with the render target
  14847. * @param size the size of the render target (used for each view)
  14848. */
  14849. constructor(scene: Scene, size?: number | {
  14850. width: number;
  14851. height: number;
  14852. } | {
  14853. ratio: number;
  14854. });
  14855. /**
  14856. * @hidden
  14857. * @param faceIndex the face index, if its a cube texture
  14858. */
  14859. _bindFrameBuffer(faceIndex?: number): void;
  14860. /**
  14861. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14862. * @returns the view count
  14863. */
  14864. getViewCount(): number;
  14865. }
  14866. }
  14867. declare module "babylonjs/Maths/math.frustum" {
  14868. import { Matrix } from "babylonjs/Maths/math.vector";
  14869. import { DeepImmutable } from "babylonjs/types";
  14870. import { Plane } from "babylonjs/Maths/math.plane";
  14871. /**
  14872. * Represents a camera frustum
  14873. */
  14874. export class Frustum {
  14875. /**
  14876. * Gets the planes representing the frustum
  14877. * @param transform matrix to be applied to the returned planes
  14878. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14879. */
  14880. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14881. /**
  14882. * Gets the near frustum plane transformed by the transform matrix
  14883. * @param transform transformation matrix to be applied to the resulting frustum plane
  14884. * @param frustumPlane the resuling frustum plane
  14885. */
  14886. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14887. /**
  14888. * Gets the far frustum plane transformed by the transform matrix
  14889. * @param transform transformation matrix to be applied to the resulting frustum plane
  14890. * @param frustumPlane the resuling frustum plane
  14891. */
  14892. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14893. /**
  14894. * Gets the left frustum plane transformed by the transform matrix
  14895. * @param transform transformation matrix to be applied to the resulting frustum plane
  14896. * @param frustumPlane the resuling frustum plane
  14897. */
  14898. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14899. /**
  14900. * Gets the right frustum plane transformed by the transform matrix
  14901. * @param transform transformation matrix to be applied to the resulting frustum plane
  14902. * @param frustumPlane the resuling frustum plane
  14903. */
  14904. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14905. /**
  14906. * Gets the top frustum plane transformed by the transform matrix
  14907. * @param transform transformation matrix to be applied to the resulting frustum plane
  14908. * @param frustumPlane the resuling frustum plane
  14909. */
  14910. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14911. /**
  14912. * Gets the bottom frustum plane transformed by the transform matrix
  14913. * @param transform transformation matrix to be applied to the resulting frustum plane
  14914. * @param frustumPlane the resuling frustum plane
  14915. */
  14916. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14917. /**
  14918. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14919. * @param transform transformation matrix to be applied to the resulting frustum planes
  14920. * @param frustumPlanes the resuling frustum planes
  14921. */
  14922. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14923. }
  14924. }
  14925. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14926. import { Camera } from "babylonjs/Cameras/camera";
  14927. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14928. import { Nullable } from "babylonjs/types";
  14929. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14930. import { Matrix } from "babylonjs/Maths/math.vector";
  14931. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14932. module "babylonjs/Engines/engine" {
  14933. interface Engine {
  14934. /**
  14935. * Creates a new multiview render target
  14936. * @param width defines the width of the texture
  14937. * @param height defines the height of the texture
  14938. * @returns the created multiview texture
  14939. */
  14940. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14941. /**
  14942. * Binds a multiview framebuffer to be drawn to
  14943. * @param multiviewTexture texture to bind
  14944. */
  14945. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14946. }
  14947. }
  14948. module "babylonjs/Cameras/camera" {
  14949. interface Camera {
  14950. /**
  14951. * @hidden
  14952. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14953. */
  14954. _useMultiviewToSingleView: boolean;
  14955. /**
  14956. * @hidden
  14957. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14958. */
  14959. _multiviewTexture: Nullable<RenderTargetTexture>;
  14960. /**
  14961. * @hidden
  14962. * ensures the multiview texture of the camera exists and has the specified width/height
  14963. * @param width height to set on the multiview texture
  14964. * @param height width to set on the multiview texture
  14965. */
  14966. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14967. }
  14968. }
  14969. module "babylonjs/scene" {
  14970. interface Scene {
  14971. /** @hidden */
  14972. _transformMatrixR: Matrix;
  14973. /** @hidden */
  14974. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14975. /** @hidden */
  14976. _createMultiviewUbo(): void;
  14977. /** @hidden */
  14978. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14979. /** @hidden */
  14980. _renderMultiviewToSingleView(camera: Camera): void;
  14981. }
  14982. }
  14983. }
  14984. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14985. import { Camera } from "babylonjs/Cameras/camera";
  14986. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14987. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14988. import "babylonjs/Engines/Extensions/engine.multiview";
  14989. /**
  14990. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14991. * This will not be used for webXR as it supports displaying texture arrays directly
  14992. */
  14993. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14994. /**
  14995. * Initializes a VRMultiviewToSingleview
  14996. * @param name name of the post process
  14997. * @param camera camera to be applied to
  14998. * @param scaleFactor scaling factor to the size of the output texture
  14999. */
  15000. constructor(name: string, camera: Camera, scaleFactor: number);
  15001. }
  15002. }
  15003. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15004. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15005. import { Nullable } from "babylonjs/types";
  15006. import { Size } from "babylonjs/Maths/math.size";
  15007. import { Observable } from "babylonjs/Misc/observable";
  15008. module "babylonjs/Engines/engine" {
  15009. interface Engine {
  15010. /** @hidden */
  15011. _vrDisplay: any;
  15012. /** @hidden */
  15013. _vrSupported: boolean;
  15014. /** @hidden */
  15015. _oldSize: Size;
  15016. /** @hidden */
  15017. _oldHardwareScaleFactor: number;
  15018. /** @hidden */
  15019. _vrExclusivePointerMode: boolean;
  15020. /** @hidden */
  15021. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15022. /** @hidden */
  15023. _onVRDisplayPointerRestricted: () => void;
  15024. /** @hidden */
  15025. _onVRDisplayPointerUnrestricted: () => void;
  15026. /** @hidden */
  15027. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15028. /** @hidden */
  15029. _onVrDisplayDisconnect: Nullable<() => void>;
  15030. /** @hidden */
  15031. _onVrDisplayPresentChange: Nullable<() => void>;
  15032. /**
  15033. * Observable signaled when VR display mode changes
  15034. */
  15035. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15036. /**
  15037. * Observable signaled when VR request present is complete
  15038. */
  15039. onVRRequestPresentComplete: Observable<boolean>;
  15040. /**
  15041. * Observable signaled when VR request present starts
  15042. */
  15043. onVRRequestPresentStart: Observable<Engine>;
  15044. /**
  15045. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15046. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15047. */
  15048. isInVRExclusivePointerMode: boolean;
  15049. /**
  15050. * Gets a boolean indicating if a webVR device was detected
  15051. * @returns true if a webVR device was detected
  15052. */
  15053. isVRDevicePresent(): boolean;
  15054. /**
  15055. * Gets the current webVR device
  15056. * @returns the current webVR device (or null)
  15057. */
  15058. getVRDevice(): any;
  15059. /**
  15060. * Initializes a webVR display and starts listening to display change events
  15061. * The onVRDisplayChangedObservable will be notified upon these changes
  15062. * @returns A promise containing a VRDisplay and if vr is supported
  15063. */
  15064. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15065. /** @hidden */
  15066. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15067. /**
  15068. * Call this function to switch to webVR mode
  15069. * Will do nothing if webVR is not supported or if there is no webVR device
  15070. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15071. */
  15072. enableVR(): void;
  15073. /** @hidden */
  15074. _onVRFullScreenTriggered(): void;
  15075. }
  15076. }
  15077. }
  15078. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15079. import { Nullable } from "babylonjs/types";
  15080. import { Observable } from "babylonjs/Misc/observable";
  15081. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15082. import { Scene } from "babylonjs/scene";
  15083. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15084. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15085. import { Node } from "babylonjs/node";
  15086. import { Ray } from "babylonjs/Culling/ray";
  15087. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15088. import "babylonjs/Engines/Extensions/engine.webVR";
  15089. /**
  15090. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15091. * IMPORTANT!! The data is right-hand data.
  15092. * @export
  15093. * @interface DevicePose
  15094. */
  15095. export interface DevicePose {
  15096. /**
  15097. * The position of the device, values in array are [x,y,z].
  15098. */
  15099. readonly position: Nullable<Float32Array>;
  15100. /**
  15101. * The linearVelocity of the device, values in array are [x,y,z].
  15102. */
  15103. readonly linearVelocity: Nullable<Float32Array>;
  15104. /**
  15105. * The linearAcceleration of the device, values in array are [x,y,z].
  15106. */
  15107. readonly linearAcceleration: Nullable<Float32Array>;
  15108. /**
  15109. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15110. */
  15111. readonly orientation: Nullable<Float32Array>;
  15112. /**
  15113. * The angularVelocity of the device, values in array are [x,y,z].
  15114. */
  15115. readonly angularVelocity: Nullable<Float32Array>;
  15116. /**
  15117. * The angularAcceleration of the device, values in array are [x,y,z].
  15118. */
  15119. readonly angularAcceleration: Nullable<Float32Array>;
  15120. }
  15121. /**
  15122. * Interface representing a pose controlled object in Babylon.
  15123. * A pose controlled object has both regular pose values as well as pose values
  15124. * from an external device such as a VR head mounted display
  15125. */
  15126. export interface PoseControlled {
  15127. /**
  15128. * The position of the object in babylon space.
  15129. */
  15130. position: Vector3;
  15131. /**
  15132. * The rotation quaternion of the object in babylon space.
  15133. */
  15134. rotationQuaternion: Quaternion;
  15135. /**
  15136. * The position of the device in babylon space.
  15137. */
  15138. devicePosition?: Vector3;
  15139. /**
  15140. * The rotation quaternion of the device in babylon space.
  15141. */
  15142. deviceRotationQuaternion: Quaternion;
  15143. /**
  15144. * The raw pose coming from the device.
  15145. */
  15146. rawPose: Nullable<DevicePose>;
  15147. /**
  15148. * The scale of the device to be used when translating from device space to babylon space.
  15149. */
  15150. deviceScaleFactor: number;
  15151. /**
  15152. * Updates the poseControlled values based on the input device pose.
  15153. * @param poseData the pose data to update the object with
  15154. */
  15155. updateFromDevice(poseData: DevicePose): void;
  15156. }
  15157. /**
  15158. * Set of options to customize the webVRCamera
  15159. */
  15160. export interface WebVROptions {
  15161. /**
  15162. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15163. */
  15164. trackPosition?: boolean;
  15165. /**
  15166. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15167. */
  15168. positionScale?: number;
  15169. /**
  15170. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15171. */
  15172. displayName?: string;
  15173. /**
  15174. * Should the native controller meshes be initialized. (default: true)
  15175. */
  15176. controllerMeshes?: boolean;
  15177. /**
  15178. * Creating a default HemiLight only on controllers. (default: true)
  15179. */
  15180. defaultLightingOnControllers?: boolean;
  15181. /**
  15182. * If you don't want to use the default VR button of the helper. (default: false)
  15183. */
  15184. useCustomVRButton?: boolean;
  15185. /**
  15186. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15187. */
  15188. customVRButton?: HTMLButtonElement;
  15189. /**
  15190. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15191. */
  15192. rayLength?: number;
  15193. /**
  15194. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15195. */
  15196. defaultHeight?: number;
  15197. /**
  15198. * If multiview should be used if availible (default: false)
  15199. */
  15200. useMultiview?: boolean;
  15201. }
  15202. /**
  15203. * This represents a WebVR camera.
  15204. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15205. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15206. */
  15207. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15208. private webVROptions;
  15209. /**
  15210. * @hidden
  15211. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15212. */
  15213. _vrDevice: any;
  15214. /**
  15215. * The rawPose of the vrDevice.
  15216. */
  15217. rawPose: Nullable<DevicePose>;
  15218. private _onVREnabled;
  15219. private _specsVersion;
  15220. private _attached;
  15221. private _frameData;
  15222. protected _descendants: Array<Node>;
  15223. private _deviceRoomPosition;
  15224. /** @hidden */
  15225. _deviceRoomRotationQuaternion: Quaternion;
  15226. private _standingMatrix;
  15227. /**
  15228. * Represents device position in babylon space.
  15229. */
  15230. devicePosition: Vector3;
  15231. /**
  15232. * Represents device rotation in babylon space.
  15233. */
  15234. deviceRotationQuaternion: Quaternion;
  15235. /**
  15236. * The scale of the device to be used when translating from device space to babylon space.
  15237. */
  15238. deviceScaleFactor: number;
  15239. private _deviceToWorld;
  15240. private _worldToDevice;
  15241. /**
  15242. * References to the webVR controllers for the vrDevice.
  15243. */
  15244. controllers: Array<WebVRController>;
  15245. /**
  15246. * Emits an event when a controller is attached.
  15247. */
  15248. onControllersAttachedObservable: Observable<WebVRController[]>;
  15249. /**
  15250. * Emits an event when a controller's mesh has been loaded;
  15251. */
  15252. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15253. /**
  15254. * Emits an event when the HMD's pose has been updated.
  15255. */
  15256. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15257. private _poseSet;
  15258. /**
  15259. * If the rig cameras be used as parent instead of this camera.
  15260. */
  15261. rigParenting: boolean;
  15262. private _lightOnControllers;
  15263. private _defaultHeight?;
  15264. /**
  15265. * Instantiates a WebVRFreeCamera.
  15266. * @param name The name of the WebVRFreeCamera
  15267. * @param position The starting anchor position for the camera
  15268. * @param scene The scene the camera belongs to
  15269. * @param webVROptions a set of customizable options for the webVRCamera
  15270. */
  15271. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15272. /**
  15273. * Gets the device distance from the ground in meters.
  15274. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  15275. */
  15276. deviceDistanceToRoomGround(): number;
  15277. /**
  15278. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15279. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15280. */
  15281. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15282. /**
  15283. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15284. * @returns A promise with a boolean set to if the standing matrix is supported.
  15285. */
  15286. useStandingMatrixAsync(): Promise<boolean>;
  15287. /**
  15288. * Disposes the camera
  15289. */
  15290. dispose(): void;
  15291. /**
  15292. * Gets a vrController by name.
  15293. * @param name The name of the controller to retreive
  15294. * @returns the controller matching the name specified or null if not found
  15295. */
  15296. getControllerByName(name: string): Nullable<WebVRController>;
  15297. private _leftController;
  15298. /**
  15299. * The controller corresponding to the users left hand.
  15300. */
  15301. readonly leftController: Nullable<WebVRController>;
  15302. private _rightController;
  15303. /**
  15304. * The controller corresponding to the users right hand.
  15305. */
  15306. readonly rightController: Nullable<WebVRController>;
  15307. /**
  15308. * Casts a ray forward from the vrCamera's gaze.
  15309. * @param length Length of the ray (default: 100)
  15310. * @returns the ray corresponding to the gaze
  15311. */
  15312. getForwardRay(length?: number): Ray;
  15313. /**
  15314. * @hidden
  15315. * Updates the camera based on device's frame data
  15316. */
  15317. _checkInputs(): void;
  15318. /**
  15319. * Updates the poseControlled values based on the input device pose.
  15320. * @param poseData Pose coming from the device
  15321. */
  15322. updateFromDevice(poseData: DevicePose): void;
  15323. private _htmlElementAttached;
  15324. private _detachIfAttached;
  15325. /**
  15326. * WebVR's attach control will start broadcasting frames to the device.
  15327. * Note that in certain browsers (chrome for example) this function must be called
  15328. * within a user-interaction callback. Example:
  15329. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15330. *
  15331. * @param element html element to attach the vrDevice to
  15332. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15333. */
  15334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15335. /**
  15336. * Detaches the camera from the html element and disables VR
  15337. *
  15338. * @param element html element to detach from
  15339. */
  15340. detachControl(element: HTMLElement): void;
  15341. /**
  15342. * @returns the name of this class
  15343. */
  15344. getClassName(): string;
  15345. /**
  15346. * Calls resetPose on the vrDisplay
  15347. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15348. */
  15349. resetToCurrentRotation(): void;
  15350. /**
  15351. * @hidden
  15352. * Updates the rig cameras (left and right eye)
  15353. */
  15354. _updateRigCameras(): void;
  15355. private _workingVector;
  15356. private _oneVector;
  15357. private _workingMatrix;
  15358. private updateCacheCalled;
  15359. private _correctPositionIfNotTrackPosition;
  15360. /**
  15361. * @hidden
  15362. * Updates the cached values of the camera
  15363. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15364. */
  15365. _updateCache(ignoreParentClass?: boolean): void;
  15366. /**
  15367. * @hidden
  15368. * Get current device position in babylon world
  15369. */
  15370. _computeDevicePosition(): void;
  15371. /**
  15372. * Updates the current device position and rotation in the babylon world
  15373. */
  15374. update(): void;
  15375. /**
  15376. * @hidden
  15377. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15378. * @returns an identity matrix
  15379. */
  15380. _getViewMatrix(): Matrix;
  15381. private _tmpMatrix;
  15382. /**
  15383. * This function is called by the two RIG cameras.
  15384. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15385. * @hidden
  15386. */
  15387. _getWebVRViewMatrix(): Matrix;
  15388. /** @hidden */
  15389. _getWebVRProjectionMatrix(): Matrix;
  15390. private _onGamepadConnectedObserver;
  15391. private _onGamepadDisconnectedObserver;
  15392. private _updateCacheWhenTrackingDisabledObserver;
  15393. /**
  15394. * Initializes the controllers and their meshes
  15395. */
  15396. initControllers(): void;
  15397. }
  15398. }
  15399. declare module "babylonjs/PostProcesses/postProcess" {
  15400. import { Nullable } from "babylonjs/types";
  15401. import { SmartArray } from "babylonjs/Misc/smartArray";
  15402. import { Observable } from "babylonjs/Misc/observable";
  15403. import { Vector2 } from "babylonjs/Maths/math.vector";
  15404. import { Camera } from "babylonjs/Cameras/camera";
  15405. import { Effect } from "babylonjs/Materials/effect";
  15406. import "babylonjs/Shaders/postprocess.vertex";
  15407. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15408. import { Engine } from "babylonjs/Engines/engine";
  15409. import { Color4 } from "babylonjs/Maths/math.color";
  15410. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15411. /**
  15412. * Size options for a post process
  15413. */
  15414. export type PostProcessOptions = {
  15415. width: number;
  15416. height: number;
  15417. };
  15418. /**
  15419. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15420. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15421. */
  15422. export class PostProcess {
  15423. /** Name of the PostProcess. */
  15424. name: string;
  15425. /**
  15426. * Gets or sets the unique id of the post process
  15427. */
  15428. uniqueId: number;
  15429. /**
  15430. * Width of the texture to apply the post process on
  15431. */
  15432. width: number;
  15433. /**
  15434. * Height of the texture to apply the post process on
  15435. */
  15436. height: number;
  15437. /**
  15438. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15439. * @hidden
  15440. */
  15441. _outputTexture: Nullable<InternalTexture>;
  15442. /**
  15443. * Sampling mode used by the shader
  15444. * See https://doc.babylonjs.com/classes/3.1/texture
  15445. */
  15446. renderTargetSamplingMode: number;
  15447. /**
  15448. * Clear color to use when screen clearing
  15449. */
  15450. clearColor: Color4;
  15451. /**
  15452. * If the buffer needs to be cleared before applying the post process. (default: true)
  15453. * Should be set to false if shader will overwrite all previous pixels.
  15454. */
  15455. autoClear: boolean;
  15456. /**
  15457. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15458. */
  15459. alphaMode: number;
  15460. /**
  15461. * Sets the setAlphaBlendConstants of the babylon engine
  15462. */
  15463. alphaConstants: Color4;
  15464. /**
  15465. * Animations to be used for the post processing
  15466. */
  15467. animations: import("babylonjs/Animations/animation").Animation[];
  15468. /**
  15469. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15470. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15471. */
  15472. enablePixelPerfectMode: boolean;
  15473. /**
  15474. * Force the postprocess to be applied without taking in account viewport
  15475. */
  15476. forceFullscreenViewport: boolean;
  15477. /**
  15478. * List of inspectable custom properties (used by the Inspector)
  15479. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15480. */
  15481. inspectableCustomProperties: IInspectable[];
  15482. /**
  15483. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15484. *
  15485. * | Value | Type | Description |
  15486. * | ----- | ----------------------------------- | ----------- |
  15487. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15488. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15489. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15490. *
  15491. */
  15492. scaleMode: number;
  15493. /**
  15494. * Force textures to be a power of two (default: false)
  15495. */
  15496. alwaysForcePOT: boolean;
  15497. private _samples;
  15498. /**
  15499. * Number of sample textures (default: 1)
  15500. */
  15501. samples: number;
  15502. /**
  15503. * Modify the scale of the post process to be the same as the viewport (default: false)
  15504. */
  15505. adaptScaleToCurrentViewport: boolean;
  15506. private _camera;
  15507. private _scene;
  15508. private _engine;
  15509. private _options;
  15510. private _reusable;
  15511. private _textureType;
  15512. /**
  15513. * Smart array of input and output textures for the post process.
  15514. * @hidden
  15515. */
  15516. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15517. /**
  15518. * The index in _textures that corresponds to the output texture.
  15519. * @hidden
  15520. */
  15521. _currentRenderTextureInd: number;
  15522. private _effect;
  15523. private _samplers;
  15524. private _fragmentUrl;
  15525. private _vertexUrl;
  15526. private _parameters;
  15527. private _scaleRatio;
  15528. protected _indexParameters: any;
  15529. private _shareOutputWithPostProcess;
  15530. private _texelSize;
  15531. private _forcedOutputTexture;
  15532. /**
  15533. * Returns the fragment url or shader name used in the post process.
  15534. * @returns the fragment url or name in the shader store.
  15535. */
  15536. getEffectName(): string;
  15537. /**
  15538. * An event triggered when the postprocess is activated.
  15539. */
  15540. onActivateObservable: Observable<Camera>;
  15541. private _onActivateObserver;
  15542. /**
  15543. * A function that is added to the onActivateObservable
  15544. */
  15545. onActivate: Nullable<(camera: Camera) => void>;
  15546. /**
  15547. * An event triggered when the postprocess changes its size.
  15548. */
  15549. onSizeChangedObservable: Observable<PostProcess>;
  15550. private _onSizeChangedObserver;
  15551. /**
  15552. * A function that is added to the onSizeChangedObservable
  15553. */
  15554. onSizeChanged: (postProcess: PostProcess) => void;
  15555. /**
  15556. * An event triggered when the postprocess applies its effect.
  15557. */
  15558. onApplyObservable: Observable<Effect>;
  15559. private _onApplyObserver;
  15560. /**
  15561. * A function that is added to the onApplyObservable
  15562. */
  15563. onApply: (effect: Effect) => void;
  15564. /**
  15565. * An event triggered before rendering the postprocess
  15566. */
  15567. onBeforeRenderObservable: Observable<Effect>;
  15568. private _onBeforeRenderObserver;
  15569. /**
  15570. * A function that is added to the onBeforeRenderObservable
  15571. */
  15572. onBeforeRender: (effect: Effect) => void;
  15573. /**
  15574. * An event triggered after rendering the postprocess
  15575. */
  15576. onAfterRenderObservable: Observable<Effect>;
  15577. private _onAfterRenderObserver;
  15578. /**
  15579. * A function that is added to the onAfterRenderObservable
  15580. */
  15581. onAfterRender: (efect: Effect) => void;
  15582. /**
  15583. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  15584. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15585. */
  15586. inputTexture: InternalTexture;
  15587. /**
  15588. * Gets the camera which post process is applied to.
  15589. * @returns The camera the post process is applied to.
  15590. */
  15591. getCamera(): Camera;
  15592. /**
  15593. * Gets the texel size of the postprocess.
  15594. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15595. */
  15596. readonly texelSize: Vector2;
  15597. /**
  15598. * Creates a new instance PostProcess
  15599. * @param name The name of the PostProcess.
  15600. * @param fragmentUrl The url of the fragment shader to be used.
  15601. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15602. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15603. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15604. * @param camera The camera to apply the render pass to.
  15605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15606. * @param engine The engine which the post process will be applied. (default: current engine)
  15607. * @param reusable If the post process can be reused on the same frame. (default: false)
  15608. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15609. * @param textureType Type of textures used when performing the post process. (default: 0)
  15610. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15611. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15612. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15613. */
  15614. constructor(
  15615. /** Name of the PostProcess. */
  15616. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  15617. /**
  15618. * Gets a string idenfifying the name of the class
  15619. * @returns "PostProcess" string
  15620. */
  15621. getClassName(): string;
  15622. /**
  15623. * Gets the engine which this post process belongs to.
  15624. * @returns The engine the post process was enabled with.
  15625. */
  15626. getEngine(): Engine;
  15627. /**
  15628. * The effect that is created when initializing the post process.
  15629. * @returns The created effect corresponding the the postprocess.
  15630. */
  15631. getEffect(): Effect;
  15632. /**
  15633. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15634. * @param postProcess The post process to share the output with.
  15635. * @returns This post process.
  15636. */
  15637. shareOutputWith(postProcess: PostProcess): PostProcess;
  15638. /**
  15639. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15640. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15641. */
  15642. useOwnOutput(): void;
  15643. /**
  15644. * Updates the effect with the current post process compile time values and recompiles the shader.
  15645. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15646. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15647. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15648. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15649. * @param onCompiled Called when the shader has been compiled.
  15650. * @param onError Called if there is an error when compiling a shader.
  15651. */
  15652. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15653. /**
  15654. * The post process is reusable if it can be used multiple times within one frame.
  15655. * @returns If the post process is reusable
  15656. */
  15657. isReusable(): boolean;
  15658. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15659. markTextureDirty(): void;
  15660. /**
  15661. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15662. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  15663. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15664. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15665. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15666. * @returns The target texture that was bound to be written to.
  15667. */
  15668. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15669. /**
  15670. * If the post process is supported.
  15671. */
  15672. readonly isSupported: boolean;
  15673. /**
  15674. * The aspect ratio of the output texture.
  15675. */
  15676. readonly aspectRatio: number;
  15677. /**
  15678. * Get a value indicating if the post-process is ready to be used
  15679. * @returns true if the post-process is ready (shader is compiled)
  15680. */
  15681. isReady(): boolean;
  15682. /**
  15683. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15684. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15685. */
  15686. apply(): Nullable<Effect>;
  15687. private _disposeTextures;
  15688. /**
  15689. * Disposes the post process.
  15690. * @param camera The camera to dispose the post process on.
  15691. */
  15692. dispose(camera?: Camera): void;
  15693. }
  15694. }
  15695. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15696. /** @hidden */
  15697. export var kernelBlurVaryingDeclaration: {
  15698. name: string;
  15699. shader: string;
  15700. };
  15701. }
  15702. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15703. /** @hidden */
  15704. export var kernelBlurFragment: {
  15705. name: string;
  15706. shader: string;
  15707. };
  15708. }
  15709. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15710. /** @hidden */
  15711. export var kernelBlurFragment2: {
  15712. name: string;
  15713. shader: string;
  15714. };
  15715. }
  15716. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15717. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15718. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15719. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15720. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15721. /** @hidden */
  15722. export var kernelBlurPixelShader: {
  15723. name: string;
  15724. shader: string;
  15725. };
  15726. }
  15727. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15728. /** @hidden */
  15729. export var kernelBlurVertex: {
  15730. name: string;
  15731. shader: string;
  15732. };
  15733. }
  15734. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15735. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15736. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15737. /** @hidden */
  15738. export var kernelBlurVertexShader: {
  15739. name: string;
  15740. shader: string;
  15741. };
  15742. }
  15743. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15744. import { Vector2 } from "babylonjs/Maths/math.vector";
  15745. import { Nullable } from "babylonjs/types";
  15746. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15747. import { Camera } from "babylonjs/Cameras/camera";
  15748. import { Effect } from "babylonjs/Materials/effect";
  15749. import { Engine } from "babylonjs/Engines/engine";
  15750. import "babylonjs/Shaders/kernelBlur.fragment";
  15751. import "babylonjs/Shaders/kernelBlur.vertex";
  15752. /**
  15753. * The Blur Post Process which blurs an image based on a kernel and direction.
  15754. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15755. */
  15756. export class BlurPostProcess extends PostProcess {
  15757. /** The direction in which to blur the image. */
  15758. direction: Vector2;
  15759. private blockCompilation;
  15760. protected _kernel: number;
  15761. protected _idealKernel: number;
  15762. protected _packedFloat: boolean;
  15763. private _staticDefines;
  15764. /**
  15765. * Sets the length in pixels of the blur sample region
  15766. */
  15767. /**
  15768. * Gets the length in pixels of the blur sample region
  15769. */
  15770. kernel: number;
  15771. /**
  15772. * Sets wether or not the blur needs to unpack/repack floats
  15773. */
  15774. /**
  15775. * Gets wether or not the blur is unpacking/repacking floats
  15776. */
  15777. packedFloat: boolean;
  15778. /**
  15779. * Creates a new instance BlurPostProcess
  15780. * @param name The name of the effect.
  15781. * @param direction The direction in which to blur the image.
  15782. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  15783. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15784. * @param camera The camera to apply the render pass to.
  15785. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15786. * @param engine The engine which the post process will be applied. (default: current engine)
  15787. * @param reusable If the post process can be reused on the same frame. (default: false)
  15788. * @param textureType Type of textures used when performing the post process. (default: 0)
  15789. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  15790. */
  15791. constructor(name: string,
  15792. /** The direction in which to blur the image. */
  15793. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15794. /**
  15795. * Updates the effect with the current post process compile time values and recompiles the shader.
  15796. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15797. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15798. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15799. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15800. * @param onCompiled Called when the shader has been compiled.
  15801. * @param onError Called if there is an error when compiling a shader.
  15802. */
  15803. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15804. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15805. /**
  15806. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15807. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15808. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15809. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15810. * The gaps between physical kernels are compensated for in the weighting of the samples
  15811. * @param idealKernel Ideal blur kernel.
  15812. * @return Nearest best kernel.
  15813. */
  15814. protected _nearestBestKernel(idealKernel: number): number;
  15815. /**
  15816. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15817. * @param x The point on the Gaussian distribution to sample.
  15818. * @return the value of the Gaussian function at x.
  15819. */
  15820. protected _gaussianWeight(x: number): number;
  15821. /**
  15822. * Generates a string that can be used as a floating point number in GLSL.
  15823. * @param x Value to print.
  15824. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15825. * @return GLSL float string.
  15826. */
  15827. protected _glslFloat(x: number, decimalFigures?: number): string;
  15828. }
  15829. }
  15830. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15831. import { Scene } from "babylonjs/scene";
  15832. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15833. import { Plane } from "babylonjs/Maths/math.plane";
  15834. /**
  15835. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15836. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15837. * You can then easily use it as a reflectionTexture on a flat surface.
  15838. * In case the surface is not a plane, please consider relying on reflection probes.
  15839. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15840. */
  15841. export class MirrorTexture extends RenderTargetTexture {
  15842. private scene;
  15843. /**
  15844. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15845. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  15846. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15847. */
  15848. mirrorPlane: Plane;
  15849. /**
  15850. * Define the blur ratio used to blur the reflection if needed.
  15851. */
  15852. blurRatio: number;
  15853. /**
  15854. * Define the adaptive blur kernel used to blur the reflection if needed.
  15855. * This will autocompute the closest best match for the `blurKernel`
  15856. */
  15857. adaptiveBlurKernel: number;
  15858. /**
  15859. * Define the blur kernel used to blur the reflection if needed.
  15860. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15861. */
  15862. blurKernel: number;
  15863. /**
  15864. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15865. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15866. */
  15867. blurKernelX: number;
  15868. /**
  15869. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15870. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15871. */
  15872. blurKernelY: number;
  15873. private _autoComputeBlurKernel;
  15874. protected _onRatioRescale(): void;
  15875. private _updateGammaSpace;
  15876. private _imageProcessingConfigChangeObserver;
  15877. private _transformMatrix;
  15878. private _mirrorMatrix;
  15879. private _savedViewMatrix;
  15880. private _blurX;
  15881. private _blurY;
  15882. private _adaptiveBlurKernel;
  15883. private _blurKernelX;
  15884. private _blurKernelY;
  15885. private _blurRatio;
  15886. /**
  15887. * Instantiates a Mirror Texture.
  15888. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15889. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15890. * You can then easily use it as a reflectionTexture on a flat surface.
  15891. * In case the surface is not a plane, please consider relying on reflection probes.
  15892. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15893. * @param name
  15894. * @param size
  15895. * @param scene
  15896. * @param generateMipMaps
  15897. * @param type
  15898. * @param samplingMode
  15899. * @param generateDepthBuffer
  15900. */
  15901. constructor(name: string, size: number | {
  15902. width: number;
  15903. height: number;
  15904. } | {
  15905. ratio: number;
  15906. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15907. private _preparePostProcesses;
  15908. /**
  15909. * Clone the mirror texture.
  15910. * @returns the cloned texture
  15911. */
  15912. clone(): MirrorTexture;
  15913. /**
  15914. * Serialize the texture to a JSON representation you could use in Parse later on
  15915. * @returns the serialized JSON representation
  15916. */
  15917. serialize(): any;
  15918. /**
  15919. * Dispose the texture and release its associated resources.
  15920. */
  15921. dispose(): void;
  15922. }
  15923. }
  15924. declare module "babylonjs/Materials/Textures/texture" {
  15925. import { Observable } from "babylonjs/Misc/observable";
  15926. import { Nullable } from "babylonjs/types";
  15927. import { Scene } from "babylonjs/scene";
  15928. import { Matrix } from "babylonjs/Maths/math.vector";
  15929. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15930. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15931. import { Engine } from "babylonjs/Engines/engine";
  15932. /**
  15933. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15934. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15935. */
  15936. export class Texture extends BaseTexture {
  15937. /**
  15938. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15939. */
  15940. static SerializeBuffers: boolean;
  15941. /** @hidden */
  15942. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15943. /** @hidden */
  15944. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15945. /** @hidden */
  15946. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15947. /** nearest is mag = nearest and min = nearest and mip = linear */
  15948. static readonly NEAREST_SAMPLINGMODE: number;
  15949. /** nearest is mag = nearest and min = nearest and mip = linear */
  15950. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15951. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15952. static readonly BILINEAR_SAMPLINGMODE: number;
  15953. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15954. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15955. /** Trilinear is mag = linear and min = linear and mip = linear */
  15956. static readonly TRILINEAR_SAMPLINGMODE: number;
  15957. /** Trilinear is mag = linear and min = linear and mip = linear */
  15958. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15959. /** mag = nearest and min = nearest and mip = nearest */
  15960. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15961. /** mag = nearest and min = linear and mip = nearest */
  15962. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15963. /** mag = nearest and min = linear and mip = linear */
  15964. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15965. /** mag = nearest and min = linear and mip = none */
  15966. static readonly NEAREST_LINEAR: number;
  15967. /** mag = nearest and min = nearest and mip = none */
  15968. static readonly NEAREST_NEAREST: number;
  15969. /** mag = linear and min = nearest and mip = nearest */
  15970. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15971. /** mag = linear and min = nearest and mip = linear */
  15972. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15973. /** mag = linear and min = linear and mip = none */
  15974. static readonly LINEAR_LINEAR: number;
  15975. /** mag = linear and min = nearest and mip = none */
  15976. static readonly LINEAR_NEAREST: number;
  15977. /** Explicit coordinates mode */
  15978. static readonly EXPLICIT_MODE: number;
  15979. /** Spherical coordinates mode */
  15980. static readonly SPHERICAL_MODE: number;
  15981. /** Planar coordinates mode */
  15982. static readonly PLANAR_MODE: number;
  15983. /** Cubic coordinates mode */
  15984. static readonly CUBIC_MODE: number;
  15985. /** Projection coordinates mode */
  15986. static readonly PROJECTION_MODE: number;
  15987. /** Inverse Cubic coordinates mode */
  15988. static readonly SKYBOX_MODE: number;
  15989. /** Inverse Cubic coordinates mode */
  15990. static readonly INVCUBIC_MODE: number;
  15991. /** Equirectangular coordinates mode */
  15992. static readonly EQUIRECTANGULAR_MODE: number;
  15993. /** Equirectangular Fixed coordinates mode */
  15994. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15995. /** Equirectangular Fixed Mirrored coordinates mode */
  15996. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15997. /** Texture is not repeating outside of 0..1 UVs */
  15998. static readonly CLAMP_ADDRESSMODE: number;
  15999. /** Texture is repeating outside of 0..1 UVs */
  16000. static readonly WRAP_ADDRESSMODE: number;
  16001. /** Texture is repeating and mirrored */
  16002. static readonly MIRROR_ADDRESSMODE: number;
  16003. /**
  16004. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  16005. */
  16006. static UseSerializedUrlIfAny: boolean;
  16007. /**
  16008. * Define the url of the texture.
  16009. */
  16010. url: Nullable<string>;
  16011. /**
  16012. * Define an offset on the texture to offset the u coordinates of the UVs
  16013. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16014. */
  16015. uOffset: number;
  16016. /**
  16017. * Define an offset on the texture to offset the v coordinates of the UVs
  16018. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16019. */
  16020. vOffset: number;
  16021. /**
  16022. * Define an offset on the texture to scale the u coordinates of the UVs
  16023. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16024. */
  16025. uScale: number;
  16026. /**
  16027. * Define an offset on the texture to scale the v coordinates of the UVs
  16028. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16029. */
  16030. vScale: number;
  16031. /**
  16032. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16033. * @see http://doc.babylonjs.com/how_to/more_materials
  16034. */
  16035. uAng: number;
  16036. /**
  16037. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16038. * @see http://doc.babylonjs.com/how_to/more_materials
  16039. */
  16040. vAng: number;
  16041. /**
  16042. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16043. * @see http://doc.babylonjs.com/how_to/more_materials
  16044. */
  16045. wAng: number;
  16046. /**
  16047. * Defines the center of rotation (U)
  16048. */
  16049. uRotationCenter: number;
  16050. /**
  16051. * Defines the center of rotation (V)
  16052. */
  16053. vRotationCenter: number;
  16054. /**
  16055. * Defines the center of rotation (W)
  16056. */
  16057. wRotationCenter: number;
  16058. /**
  16059. * Are mip maps generated for this texture or not.
  16060. */
  16061. readonly noMipmap: boolean;
  16062. /**
  16063. * List of inspectable custom properties (used by the Inspector)
  16064. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16065. */
  16066. inspectableCustomProperties: Nullable<IInspectable[]>;
  16067. private _noMipmap;
  16068. /** @hidden */
  16069. _invertY: boolean;
  16070. private _rowGenerationMatrix;
  16071. private _cachedTextureMatrix;
  16072. private _projectionModeMatrix;
  16073. private _t0;
  16074. private _t1;
  16075. private _t2;
  16076. private _cachedUOffset;
  16077. private _cachedVOffset;
  16078. private _cachedUScale;
  16079. private _cachedVScale;
  16080. private _cachedUAng;
  16081. private _cachedVAng;
  16082. private _cachedWAng;
  16083. private _cachedProjectionMatrixId;
  16084. private _cachedCoordinatesMode;
  16085. /** @hidden */
  16086. protected _initialSamplingMode: number;
  16087. /** @hidden */
  16088. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16089. private _deleteBuffer;
  16090. protected _format: Nullable<number>;
  16091. private _delayedOnLoad;
  16092. private _delayedOnError;
  16093. /**
  16094. * Observable triggered once the texture has been loaded.
  16095. */
  16096. onLoadObservable: Observable<Texture>;
  16097. protected _isBlocking: boolean;
  16098. /**
  16099. * Is the texture preventing material to render while loading.
  16100. * If false, a default texture will be used instead of the loading one during the preparation step.
  16101. */
  16102. isBlocking: boolean;
  16103. /**
  16104. * Get the current sampling mode associated with the texture.
  16105. */
  16106. readonly samplingMode: number;
  16107. /**
  16108. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16109. */
  16110. readonly invertY: boolean;
  16111. /**
  16112. * Instantiates a new texture.
  16113. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16114. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16115. * @param url define the url of the picture to load as a texture
  16116. * @param scene define the scene or engine the texture will belong to
  16117. * @param noMipmap define if the texture will require mip maps or not
  16118. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16119. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16120. * @param onLoad define a callback triggered when the texture has been loaded
  16121. * @param onError define a callback triggered when an error occurred during the loading session
  16122. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16123. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16124. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16125. */
  16126. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16127. /**
  16128. * Update the url (and optional buffer) of this texture if url was null during construction.
  16129. * @param url the url of the texture
  16130. * @param buffer the buffer of the texture (defaults to null)
  16131. * @param onLoad callback called when the texture is loaded (defaults to null)
  16132. */
  16133. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16134. /**
  16135. * Finish the loading sequence of a texture flagged as delayed load.
  16136. * @hidden
  16137. */
  16138. delayLoad(): void;
  16139. private _prepareRowForTextureGeneration;
  16140. /**
  16141. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16142. * @returns the transform matrix of the texture.
  16143. */
  16144. getTextureMatrix(): Matrix;
  16145. /**
  16146. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16147. * @returns The reflection texture transform
  16148. */
  16149. getReflectionTextureMatrix(): Matrix;
  16150. /**
  16151. * Clones the texture.
  16152. * @returns the cloned texture
  16153. */
  16154. clone(): Texture;
  16155. /**
  16156. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16157. * @returns The JSON representation of the texture
  16158. */
  16159. serialize(): any;
  16160. /**
  16161. * Get the current class name of the texture useful for serialization or dynamic coding.
  16162. * @returns "Texture"
  16163. */
  16164. getClassName(): string;
  16165. /**
  16166. * Dispose the texture and release its associated resources.
  16167. */
  16168. dispose(): void;
  16169. /**
  16170. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16171. * @param parsedTexture Define the JSON representation of the texture
  16172. * @param scene Define the scene the parsed texture should be instantiated in
  16173. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16174. * @returns The parsed texture if successful
  16175. */
  16176. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16177. /**
  16178. * Creates a texture from its base 64 representation.
  16179. * @param data Define the base64 payload without the data: prefix
  16180. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16181. * @param scene Define the scene the texture should belong to
  16182. * @param noMipmap Forces the texture to not create mip map information if true
  16183. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16184. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16185. * @param onLoad define a callback triggered when the texture has been loaded
  16186. * @param onError define a callback triggered when an error occurred during the loading session
  16187. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16188. * @returns the created texture
  16189. */
  16190. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16191. /**
  16192. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16193. * @param data Define the base64 payload without the data: prefix
  16194. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16195. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16196. * @param scene Define the scene the texture should belong to
  16197. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16198. * @param noMipmap Forces the texture to not create mip map information if true
  16199. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16200. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16201. * @param onLoad define a callback triggered when the texture has been loaded
  16202. * @param onError define a callback triggered when an error occurred during the loading session
  16203. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16204. * @returns the created texture
  16205. */
  16206. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  16207. }
  16208. }
  16209. declare module "babylonjs/PostProcesses/postProcessManager" {
  16210. import { Nullable } from "babylonjs/types";
  16211. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16212. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16213. import { Scene } from "babylonjs/scene";
  16214. /**
  16215. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16216. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16217. */
  16218. export class PostProcessManager {
  16219. private _scene;
  16220. private _indexBuffer;
  16221. private _vertexBuffers;
  16222. /**
  16223. * Creates a new instance PostProcess
  16224. * @param scene The scene that the post process is associated with.
  16225. */
  16226. constructor(scene: Scene);
  16227. private _prepareBuffers;
  16228. private _buildIndexBuffer;
  16229. /**
  16230. * Rebuilds the vertex buffers of the manager.
  16231. * @hidden
  16232. */
  16233. _rebuild(): void;
  16234. /**
  16235. * Prepares a frame to be run through a post process.
  16236. * @param sourceTexture The input texture to the post procesess. (default: null)
  16237. * @param postProcesses An array of post processes to be run. (default: null)
  16238. * @returns True if the post processes were able to be run.
  16239. * @hidden
  16240. */
  16241. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16242. /**
  16243. * Manually render a set of post processes to a texture.
  16244. * @param postProcesses An array of post processes to be run.
  16245. * @param targetTexture The target texture to render to.
  16246. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16247. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16248. * @param lodLevel defines which lod of the texture to render to
  16249. */
  16250. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16251. /**
  16252. * Finalize the result of the output of the postprocesses.
  16253. * @param doNotPresent If true the result will not be displayed to the screen.
  16254. * @param targetTexture The target texture to render to.
  16255. * @param faceIndex The index of the face to bind the target texture to.
  16256. * @param postProcesses The array of post processes to render.
  16257. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16258. * @hidden
  16259. */
  16260. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16261. /**
  16262. * Disposes of the post process manager.
  16263. */
  16264. dispose(): void;
  16265. }
  16266. }
  16267. declare module "babylonjs/Misc/gradients" {
  16268. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16269. /** Interface used by value gradients (color, factor, ...) */
  16270. export interface IValueGradient {
  16271. /**
  16272. * Gets or sets the gradient value (between 0 and 1)
  16273. */
  16274. gradient: number;
  16275. }
  16276. /** Class used to store color4 gradient */
  16277. export class ColorGradient implements IValueGradient {
  16278. /**
  16279. * Gets or sets the gradient value (between 0 and 1)
  16280. */
  16281. gradient: number;
  16282. /**
  16283. * Gets or sets first associated color
  16284. */
  16285. color1: Color4;
  16286. /**
  16287. * Gets or sets second associated color
  16288. */
  16289. color2?: Color4;
  16290. /**
  16291. * Will get a color picked randomly between color1 and color2.
  16292. * If color2 is undefined then color1 will be used
  16293. * @param result defines the target Color4 to store the result in
  16294. */
  16295. getColorToRef(result: Color4): void;
  16296. }
  16297. /** Class used to store color 3 gradient */
  16298. export class Color3Gradient implements IValueGradient {
  16299. /**
  16300. * Gets or sets the gradient value (between 0 and 1)
  16301. */
  16302. gradient: number;
  16303. /**
  16304. * Gets or sets the associated color
  16305. */
  16306. color: Color3;
  16307. }
  16308. /** Class used to store factor gradient */
  16309. export class FactorGradient implements IValueGradient {
  16310. /**
  16311. * Gets or sets the gradient value (between 0 and 1)
  16312. */
  16313. gradient: number;
  16314. /**
  16315. * Gets or sets first associated factor
  16316. */
  16317. factor1: number;
  16318. /**
  16319. * Gets or sets second associated factor
  16320. */
  16321. factor2?: number;
  16322. /**
  16323. * Will get a number picked randomly between factor1 and factor2.
  16324. * If factor2 is undefined then factor1 will be used
  16325. * @returns the picked number
  16326. */
  16327. getFactor(): number;
  16328. }
  16329. /**
  16330. * Helper used to simplify some generic gradient tasks
  16331. */
  16332. export class GradientHelper {
  16333. /**
  16334. * Gets the current gradient from an array of IValueGradient
  16335. * @param ratio defines the current ratio to get
  16336. * @param gradients defines the array of IValueGradient
  16337. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16338. */
  16339. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16340. }
  16341. }
  16342. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16343. import { Scene } from "babylonjs/scene";
  16344. import { Texture } from "babylonjs/Materials/Textures/texture";
  16345. /**
  16346. * A class extending Texture allowing drawing on a texture
  16347. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16348. */
  16349. export class DynamicTexture extends Texture {
  16350. private _generateMipMaps;
  16351. private _canvas;
  16352. private _context;
  16353. private _engine;
  16354. /**
  16355. * Creates a DynamicTexture
  16356. * @param name defines the name of the texture
  16357. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  16358. * @param scene defines the scene where you want the texture
  16359. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16360. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16361. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16362. */
  16363. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16364. /**
  16365. * Get the current class name of the texture useful for serialization or dynamic coding.
  16366. * @returns "DynamicTexture"
  16367. */
  16368. getClassName(): string;
  16369. /**
  16370. * Gets the current state of canRescale
  16371. */
  16372. readonly canRescale: boolean;
  16373. private _recreate;
  16374. /**
  16375. * Scales the texture
  16376. * @param ratio the scale factor to apply to both width and height
  16377. */
  16378. scale(ratio: number): void;
  16379. /**
  16380. * Resizes the texture
  16381. * @param width the new width
  16382. * @param height the new height
  16383. */
  16384. scaleTo(width: number, height: number): void;
  16385. /**
  16386. * Gets the context of the canvas used by the texture
  16387. * @returns the canvas context of the dynamic texture
  16388. */
  16389. getContext(): CanvasRenderingContext2D;
  16390. /**
  16391. * Clears the texture
  16392. */
  16393. clear(): void;
  16394. /**
  16395. * Updates the texture
  16396. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16397. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16398. */
  16399. update(invertY?: boolean, premulAlpha?: boolean): void;
  16400. /**
  16401. * Draws text onto the texture
  16402. * @param text defines the text to be drawn
  16403. * @param x defines the placement of the text from the left
  16404. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16405. * @param font defines the font to be used with font-style, font-size, font-name
  16406. * @param color defines the color used for the text
  16407. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16408. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16409. * @param update defines whether texture is immediately update (default is true)
  16410. */
  16411. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16412. /**
  16413. * Clones the texture
  16414. * @returns the clone of the texture.
  16415. */
  16416. clone(): DynamicTexture;
  16417. /**
  16418. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16419. * @returns a serialized dynamic texture object
  16420. */
  16421. serialize(): any;
  16422. /** @hidden */
  16423. _rebuild(): void;
  16424. }
  16425. }
  16426. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16427. import { Scene } from "babylonjs/scene";
  16428. import { ISceneComponent } from "babylonjs/sceneComponent";
  16429. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16430. module "babylonjs/abstractScene" {
  16431. interface AbstractScene {
  16432. /**
  16433. * The list of procedural textures added to the scene
  16434. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16435. */
  16436. proceduralTextures: Array<ProceduralTexture>;
  16437. }
  16438. }
  16439. /**
  16440. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16441. * in a given scene.
  16442. */
  16443. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16444. /**
  16445. * The component name helpfull to identify the component in the list of scene components.
  16446. */
  16447. readonly name: string;
  16448. /**
  16449. * The scene the component belongs to.
  16450. */
  16451. scene: Scene;
  16452. /**
  16453. * Creates a new instance of the component for the given scene
  16454. * @param scene Defines the scene to register the component in
  16455. */
  16456. constructor(scene: Scene);
  16457. /**
  16458. * Registers the component in a given scene
  16459. */
  16460. register(): void;
  16461. /**
  16462. * Rebuilds the elements related to this component in case of
  16463. * context lost for instance.
  16464. */
  16465. rebuild(): void;
  16466. /**
  16467. * Disposes the component and the associated ressources.
  16468. */
  16469. dispose(): void;
  16470. private _beforeClear;
  16471. }
  16472. }
  16473. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16474. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16475. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16476. module "babylonjs/Engines/engine" {
  16477. interface Engine {
  16478. /**
  16479. * Creates a new render target cube texture
  16480. * @param size defines the size of the texture
  16481. * @param options defines the options used to create the texture
  16482. * @returns a new render target cube texture stored in an InternalTexture
  16483. */
  16484. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16485. }
  16486. }
  16487. }
  16488. declare module "babylonjs/Shaders/procedural.vertex" {
  16489. /** @hidden */
  16490. export var proceduralVertexShader: {
  16491. name: string;
  16492. shader: string;
  16493. };
  16494. }
  16495. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16496. import { Observable } from "babylonjs/Misc/observable";
  16497. import { Nullable } from "babylonjs/types";
  16498. import { Scene } from "babylonjs/scene";
  16499. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16500. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16501. import { Effect } from "babylonjs/Materials/effect";
  16502. import { Texture } from "babylonjs/Materials/Textures/texture";
  16503. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16504. import "babylonjs/Shaders/procedural.vertex";
  16505. /**
  16506. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  16507. * This is the base class of any Procedural texture and contains most of the shareable code.
  16508. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16509. */
  16510. export class ProceduralTexture extends Texture {
  16511. isCube: boolean;
  16512. /**
  16513. * Define if the texture is enabled or not (disabled texture will not render)
  16514. */
  16515. isEnabled: boolean;
  16516. /**
  16517. * Define if the texture must be cleared before rendering (default is true)
  16518. */
  16519. autoClear: boolean;
  16520. /**
  16521. * Callback called when the texture is generated
  16522. */
  16523. onGenerated: () => void;
  16524. /**
  16525. * Event raised when the texture is generated
  16526. */
  16527. onGeneratedObservable: Observable<ProceduralTexture>;
  16528. /** @hidden */
  16529. _generateMipMaps: boolean;
  16530. /** @hidden **/
  16531. _effect: Effect;
  16532. /** @hidden */
  16533. _textures: {
  16534. [key: string]: Texture;
  16535. };
  16536. private _size;
  16537. private _currentRefreshId;
  16538. private _refreshRate;
  16539. private _vertexBuffers;
  16540. private _indexBuffer;
  16541. private _uniforms;
  16542. private _samplers;
  16543. private _fragment;
  16544. private _floats;
  16545. private _ints;
  16546. private _floatsArrays;
  16547. private _colors3;
  16548. private _colors4;
  16549. private _vectors2;
  16550. private _vectors3;
  16551. private _matrices;
  16552. private _fallbackTexture;
  16553. private _fallbackTextureUsed;
  16554. private _engine;
  16555. private _cachedDefines;
  16556. private _contentUpdateId;
  16557. private _contentData;
  16558. /**
  16559. * Instantiates a new procedural texture.
  16560. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  16561. * This is the base class of any Procedural texture and contains most of the shareable code.
  16562. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16563. * @param name Define the name of the texture
  16564. * @param size Define the size of the texture to create
  16565. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16566. * @param scene Define the scene the texture belongs to
  16567. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16568. * @param generateMipMaps Define if the texture should creates mip maps or not
  16569. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16570. */
  16571. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16572. /**
  16573. * The effect that is created when initializing the post process.
  16574. * @returns The created effect corresponding the the postprocess.
  16575. */
  16576. getEffect(): Effect;
  16577. /**
  16578. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16579. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16580. */
  16581. getContent(): Nullable<ArrayBufferView>;
  16582. private _createIndexBuffer;
  16583. /** @hidden */
  16584. _rebuild(): void;
  16585. /**
  16586. * Resets the texture in order to recreate its associated resources.
  16587. * This can be called in case of context loss
  16588. */
  16589. reset(): void;
  16590. protected _getDefines(): string;
  16591. /**
  16592. * Is the texture ready to be used ? (rendered at least once)
  16593. * @returns true if ready, otherwise, false.
  16594. */
  16595. isReady(): boolean;
  16596. /**
  16597. * Resets the refresh counter of the texture and start bak from scratch.
  16598. * Could be useful to regenerate the texture if it is setup to render only once.
  16599. */
  16600. resetRefreshCounter(): void;
  16601. /**
  16602. * Set the fragment shader to use in order to render the texture.
  16603. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16604. */
  16605. setFragment(fragment: any): void;
  16606. /**
  16607. * Define the refresh rate of the texture or the rendering frequency.
  16608. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16609. */
  16610. refreshRate: number;
  16611. /** @hidden */
  16612. _shouldRender(): boolean;
  16613. /**
  16614. * Get the size the texture is rendering at.
  16615. * @returns the size (texture is always squared)
  16616. */
  16617. getRenderSize(): number;
  16618. /**
  16619. * Resize the texture to new value.
  16620. * @param size Define the new size the texture should have
  16621. * @param generateMipMaps Define whether the new texture should create mip maps
  16622. */
  16623. resize(size: number, generateMipMaps: boolean): void;
  16624. private _checkUniform;
  16625. /**
  16626. * Set a texture in the shader program used to render.
  16627. * @param name Define the name of the uniform samplers as defined in the shader
  16628. * @param texture Define the texture to bind to this sampler
  16629. * @return the texture itself allowing "fluent" like uniform updates
  16630. */
  16631. setTexture(name: string, texture: Texture): ProceduralTexture;
  16632. /**
  16633. * Set a float in the shader.
  16634. * @param name Define the name of the uniform as defined in the shader
  16635. * @param value Define the value to give to the uniform
  16636. * @return the texture itself allowing "fluent" like uniform updates
  16637. */
  16638. setFloat(name: string, value: number): ProceduralTexture;
  16639. /**
  16640. * Set a int in the shader.
  16641. * @param name Define the name of the uniform as defined in the shader
  16642. * @param value Define the value to give to the uniform
  16643. * @return the texture itself allowing "fluent" like uniform updates
  16644. */
  16645. setInt(name: string, value: number): ProceduralTexture;
  16646. /**
  16647. * Set an array of floats in the shader.
  16648. * @param name Define the name of the uniform as defined in the shader
  16649. * @param value Define the value to give to the uniform
  16650. * @return the texture itself allowing "fluent" like uniform updates
  16651. */
  16652. setFloats(name: string, value: number[]): ProceduralTexture;
  16653. /**
  16654. * Set a vec3 in the shader from a Color3.
  16655. * @param name Define the name of the uniform as defined in the shader
  16656. * @param value Define the value to give to the uniform
  16657. * @return the texture itself allowing "fluent" like uniform updates
  16658. */
  16659. setColor3(name: string, value: Color3): ProceduralTexture;
  16660. /**
  16661. * Set a vec4 in the shader from a Color4.
  16662. * @param name Define the name of the uniform as defined in the shader
  16663. * @param value Define the value to give to the uniform
  16664. * @return the texture itself allowing "fluent" like uniform updates
  16665. */
  16666. setColor4(name: string, value: Color4): ProceduralTexture;
  16667. /**
  16668. * Set a vec2 in the shader from a Vector2.
  16669. * @param name Define the name of the uniform as defined in the shader
  16670. * @param value Define the value to give to the uniform
  16671. * @return the texture itself allowing "fluent" like uniform updates
  16672. */
  16673. setVector2(name: string, value: Vector2): ProceduralTexture;
  16674. /**
  16675. * Set a vec3 in the shader from a Vector3.
  16676. * @param name Define the name of the uniform as defined in the shader
  16677. * @param value Define the value to give to the uniform
  16678. * @return the texture itself allowing "fluent" like uniform updates
  16679. */
  16680. setVector3(name: string, value: Vector3): ProceduralTexture;
  16681. /**
  16682. * Set a mat4 in the shader from a MAtrix.
  16683. * @param name Define the name of the uniform as defined in the shader
  16684. * @param value Define the value to give to the uniform
  16685. * @return the texture itself allowing "fluent" like uniform updates
  16686. */
  16687. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16688. /**
  16689. * Render the texture to its associated render target.
  16690. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16691. */
  16692. render(useCameraPostProcess?: boolean): void;
  16693. /**
  16694. * Clone the texture.
  16695. * @returns the cloned texture
  16696. */
  16697. clone(): ProceduralTexture;
  16698. /**
  16699. * Dispose the texture and release its asoociated resources.
  16700. */
  16701. dispose(): void;
  16702. }
  16703. }
  16704. declare module "babylonjs/Particles/baseParticleSystem" {
  16705. import { Nullable } from "babylonjs/types";
  16706. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16708. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16709. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16710. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16711. import { Scene } from "babylonjs/scene";
  16712. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16713. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16714. import { Texture } from "babylonjs/Materials/Textures/texture";
  16715. import { Color4 } from "babylonjs/Maths/math.color";
  16716. import { Animation } from "babylonjs/Animations/animation";
  16717. /**
  16718. * This represents the base class for particle system in Babylon.
  16719. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16720. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16721. * @example https://doc.babylonjs.com/babylon101/particles
  16722. */
  16723. export class BaseParticleSystem {
  16724. /**
  16725. * Source color is added to the destination color without alpha affecting the result
  16726. */
  16727. static BLENDMODE_ONEONE: number;
  16728. /**
  16729. * Blend current color and particle color using particle’s alpha
  16730. */
  16731. static BLENDMODE_STANDARD: number;
  16732. /**
  16733. * Add current color and particle color multiplied by particle’s alpha
  16734. */
  16735. static BLENDMODE_ADD: number;
  16736. /**
  16737. * Multiply current color with particle color
  16738. */
  16739. static BLENDMODE_MULTIPLY: number;
  16740. /**
  16741. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16742. */
  16743. static BLENDMODE_MULTIPLYADD: number;
  16744. /**
  16745. * List of animations used by the particle system.
  16746. */
  16747. animations: Animation[];
  16748. /**
  16749. * The id of the Particle system.
  16750. */
  16751. id: string;
  16752. /**
  16753. * The friendly name of the Particle system.
  16754. */
  16755. name: string;
  16756. /**
  16757. * The rendering group used by the Particle system to chose when to render.
  16758. */
  16759. renderingGroupId: number;
  16760. /**
  16761. * The emitter represents the Mesh or position we are attaching the particle system to.
  16762. */
  16763. emitter: Nullable<AbstractMesh | Vector3>;
  16764. /**
  16765. * The maximum number of particles to emit per frame
  16766. */
  16767. emitRate: number;
  16768. /**
  16769. * If you want to launch only a few particles at once, that can be done, as well.
  16770. */
  16771. manualEmitCount: number;
  16772. /**
  16773. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16774. */
  16775. updateSpeed: number;
  16776. /**
  16777. * The amount of time the particle system is running (depends of the overall update speed).
  16778. */
  16779. targetStopDuration: number;
  16780. /**
  16781. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16782. */
  16783. disposeOnStop: boolean;
  16784. /**
  16785. * Minimum power of emitting particles.
  16786. */
  16787. minEmitPower: number;
  16788. /**
  16789. * Maximum power of emitting particles.
  16790. */
  16791. maxEmitPower: number;
  16792. /**
  16793. * Minimum life time of emitting particles.
  16794. */
  16795. minLifeTime: number;
  16796. /**
  16797. * Maximum life time of emitting particles.
  16798. */
  16799. maxLifeTime: number;
  16800. /**
  16801. * Minimum Size of emitting particles.
  16802. */
  16803. minSize: number;
  16804. /**
  16805. * Maximum Size of emitting particles.
  16806. */
  16807. maxSize: number;
  16808. /**
  16809. * Minimum scale of emitting particles on X axis.
  16810. */
  16811. minScaleX: number;
  16812. /**
  16813. * Maximum scale of emitting particles on X axis.
  16814. */
  16815. maxScaleX: number;
  16816. /**
  16817. * Minimum scale of emitting particles on Y axis.
  16818. */
  16819. minScaleY: number;
  16820. /**
  16821. * Maximum scale of emitting particles on Y axis.
  16822. */
  16823. maxScaleY: number;
  16824. /**
  16825. * Gets or sets the minimal initial rotation in radians.
  16826. */
  16827. minInitialRotation: number;
  16828. /**
  16829. * Gets or sets the maximal initial rotation in radians.
  16830. */
  16831. maxInitialRotation: number;
  16832. /**
  16833. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16834. */
  16835. minAngularSpeed: number;
  16836. /**
  16837. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16838. */
  16839. maxAngularSpeed: number;
  16840. /**
  16841. * The texture used to render each particle. (this can be a spritesheet)
  16842. */
  16843. particleTexture: Nullable<Texture>;
  16844. /**
  16845. * The layer mask we are rendering the particles through.
  16846. */
  16847. layerMask: number;
  16848. /**
  16849. * This can help using your own shader to render the particle system.
  16850. * The according effect will be created
  16851. */
  16852. customShader: any;
  16853. /**
  16854. * By default particle system starts as soon as they are created. This prevents the
  16855. * automatic start to happen and let you decide when to start emitting particles.
  16856. */
  16857. preventAutoStart: boolean;
  16858. private _noiseTexture;
  16859. /**
  16860. * Gets or sets a texture used to add random noise to particle positions
  16861. */
  16862. noiseTexture: Nullable<ProceduralTexture>;
  16863. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16864. noiseStrength: Vector3;
  16865. /**
  16866. * Callback triggered when the particle animation is ending.
  16867. */
  16868. onAnimationEnd: Nullable<() => void>;
  16869. /**
  16870. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16871. */
  16872. blendMode: number;
  16873. /**
  16874. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16875. * to override the particles.
  16876. */
  16877. forceDepthWrite: boolean;
  16878. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  16879. preWarmCycles: number;
  16880. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16881. preWarmStepOffset: number;
  16882. /**
  16883. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  16884. */
  16885. spriteCellChangeSpeed: number;
  16886. /**
  16887. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16888. */
  16889. startSpriteCellID: number;
  16890. /**
  16891. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16892. */
  16893. endSpriteCellID: number;
  16894. /**
  16895. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16896. */
  16897. spriteCellWidth: number;
  16898. /**
  16899. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16900. */
  16901. spriteCellHeight: number;
  16902. /**
  16903. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16904. */
  16905. spriteRandomStartCell: boolean;
  16906. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16907. translationPivot: Vector2;
  16908. /** @hidden */
  16909. protected _isAnimationSheetEnabled: boolean;
  16910. /**
  16911. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16912. */
  16913. beginAnimationOnStart: boolean;
  16914. /**
  16915. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16916. */
  16917. beginAnimationFrom: number;
  16918. /**
  16919. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16920. */
  16921. beginAnimationTo: number;
  16922. /**
  16923. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16924. */
  16925. beginAnimationLoop: boolean;
  16926. /**
  16927. * Gets or sets a world offset applied to all particles
  16928. */
  16929. worldOffset: Vector3;
  16930. /**
  16931. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16932. */
  16933. isAnimationSheetEnabled: boolean;
  16934. /**
  16935. * Get hosting scene
  16936. * @returns the scene
  16937. */
  16938. getScene(): Scene;
  16939. /**
  16940. * You can use gravity if you want to give an orientation to your particles.
  16941. */
  16942. gravity: Vector3;
  16943. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16944. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16945. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16946. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16947. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16948. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16949. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16950. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16951. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16952. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16953. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16954. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16955. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16956. /**
  16957. * Defines the delay in milliseconds before starting the system (0 by default)
  16958. */
  16959. startDelay: number;
  16960. /**
  16961. * Gets the current list of drag gradients.
  16962. * You must use addDragGradient and removeDragGradient to udpate this list
  16963. * @returns the list of drag gradients
  16964. */
  16965. getDragGradients(): Nullable<Array<FactorGradient>>;
  16966. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16967. limitVelocityDamping: number;
  16968. /**
  16969. * Gets the current list of limit velocity gradients.
  16970. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16971. * @returns the list of limit velocity gradients
  16972. */
  16973. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16974. /**
  16975. * Gets the current list of color gradients.
  16976. * You must use addColorGradient and removeColorGradient to udpate this list
  16977. * @returns the list of color gradients
  16978. */
  16979. getColorGradients(): Nullable<Array<ColorGradient>>;
  16980. /**
  16981. * Gets the current list of size gradients.
  16982. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16983. * @returns the list of size gradients
  16984. */
  16985. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16986. /**
  16987. * Gets the current list of color remap gradients.
  16988. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16989. * @returns the list of color remap gradients
  16990. */
  16991. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16992. /**
  16993. * Gets the current list of alpha remap gradients.
  16994. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16995. * @returns the list of alpha remap gradients
  16996. */
  16997. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16998. /**
  16999. * Gets the current list of life time gradients.
  17000. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17001. * @returns the list of life time gradients
  17002. */
  17003. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17004. /**
  17005. * Gets the current list of angular speed gradients.
  17006. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17007. * @returns the list of angular speed gradients
  17008. */
  17009. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17010. /**
  17011. * Gets the current list of velocity gradients.
  17012. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17013. * @returns the list of velocity gradients
  17014. */
  17015. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17016. /**
  17017. * Gets the current list of start size gradients.
  17018. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17019. * @returns the list of start size gradients
  17020. */
  17021. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17022. /**
  17023. * Gets the current list of emit rate gradients.
  17024. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17025. * @returns the list of emit rate gradients
  17026. */
  17027. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17028. /**
  17029. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17030. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17031. */
  17032. direction1: Vector3;
  17033. /**
  17034. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17035. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17036. */
  17037. direction2: Vector3;
  17038. /**
  17039. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17040. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17041. */
  17042. minEmitBox: Vector3;
  17043. /**
  17044. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17045. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17046. */
  17047. maxEmitBox: Vector3;
  17048. /**
  17049. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17050. */
  17051. color1: Color4;
  17052. /**
  17053. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17054. */
  17055. color2: Color4;
  17056. /**
  17057. * Color the particle will have at the end of its lifetime
  17058. */
  17059. colorDead: Color4;
  17060. /**
  17061. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17062. */
  17063. textureMask: Color4;
  17064. /**
  17065. * The particle emitter type defines the emitter used by the particle system.
  17066. * It can be for example box, sphere, or cone...
  17067. */
  17068. particleEmitterType: IParticleEmitterType;
  17069. /** @hidden */
  17070. _isSubEmitter: boolean;
  17071. /**
  17072. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17073. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17074. */
  17075. billboardMode: number;
  17076. protected _isBillboardBased: boolean;
  17077. /**
  17078. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17079. */
  17080. isBillboardBased: boolean;
  17081. /**
  17082. * The scene the particle system belongs to.
  17083. */
  17084. protected _scene: Scene;
  17085. /**
  17086. * Local cache of defines for image processing.
  17087. */
  17088. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17089. /**
  17090. * Default configuration related to image processing available in the standard Material.
  17091. */
  17092. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17093. /**
  17094. * Gets the image processing configuration used either in this material.
  17095. */
  17096. /**
  17097. * Sets the Default image processing configuration used either in the this material.
  17098. *
  17099. * If sets to null, the scene one is in use.
  17100. */
  17101. imageProcessingConfiguration: ImageProcessingConfiguration;
  17102. /**
  17103. * Attaches a new image processing configuration to the Standard Material.
  17104. * @param configuration
  17105. */
  17106. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17107. /** @hidden */
  17108. protected _reset(): void;
  17109. /** @hidden */
  17110. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17111. /**
  17112. * Instantiates a particle system.
  17113. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17114. * @param name The name of the particle system
  17115. */
  17116. constructor(name: string);
  17117. /**
  17118. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17119. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17120. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17121. * @returns the emitter
  17122. */
  17123. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17124. /**
  17125. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17126. * @param radius The radius of the hemisphere to emit from
  17127. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17128. * @returns the emitter
  17129. */
  17130. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17131. /**
  17132. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17133. * @param radius The radius of the sphere to emit from
  17134. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17135. * @returns the emitter
  17136. */
  17137. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17138. /**
  17139. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17140. * @param radius The radius of the sphere to emit from
  17141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17143. * @returns the emitter
  17144. */
  17145. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17146. /**
  17147. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17148. * @param radius The radius of the emission cylinder
  17149. * @param height The height of the emission cylinder
  17150. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17151. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17152. * @returns the emitter
  17153. */
  17154. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17155. /**
  17156. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17157. * @param radius The radius of the cylinder to emit from
  17158. * @param height The height of the emission cylinder
  17159. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17160. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17161. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17162. * @returns the emitter
  17163. */
  17164. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17165. /**
  17166. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17167. * @param radius The radius of the cone to emit from
  17168. * @param angle The base angle of the cone
  17169. * @returns the emitter
  17170. */
  17171. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17172. /**
  17173. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17174. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17175. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17176. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17177. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17178. * @returns the emitter
  17179. */
  17180. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17181. }
  17182. }
  17183. declare module "babylonjs/Particles/subEmitter" {
  17184. import { Scene } from "babylonjs/scene";
  17185. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17186. /**
  17187. * Type of sub emitter
  17188. */
  17189. export enum SubEmitterType {
  17190. /**
  17191. * Attached to the particle over it's lifetime
  17192. */
  17193. ATTACHED = 0,
  17194. /**
  17195. * Created when the particle dies
  17196. */
  17197. END = 1
  17198. }
  17199. /**
  17200. * Sub emitter class used to emit particles from an existing particle
  17201. */
  17202. export class SubEmitter {
  17203. /**
  17204. * the particle system to be used by the sub emitter
  17205. */
  17206. particleSystem: ParticleSystem;
  17207. /**
  17208. * Type of the submitter (Default: END)
  17209. */
  17210. type: SubEmitterType;
  17211. /**
  17212. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  17213. * Note: This only is supported when using an emitter of type Mesh
  17214. */
  17215. inheritDirection: boolean;
  17216. /**
  17217. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17218. */
  17219. inheritedVelocityAmount: number;
  17220. /**
  17221. * Creates a sub emitter
  17222. * @param particleSystem the particle system to be used by the sub emitter
  17223. */
  17224. constructor(
  17225. /**
  17226. * the particle system to be used by the sub emitter
  17227. */
  17228. particleSystem: ParticleSystem);
  17229. /**
  17230. * Clones the sub emitter
  17231. * @returns the cloned sub emitter
  17232. */
  17233. clone(): SubEmitter;
  17234. /**
  17235. * Serialize current object to a JSON object
  17236. * @returns the serialized object
  17237. */
  17238. serialize(): any;
  17239. /** @hidden */
  17240. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17241. /**
  17242. * Creates a new SubEmitter from a serialized JSON version
  17243. * @param serializationObject defines the JSON object to read from
  17244. * @param scene defines the hosting scene
  17245. * @param rootUrl defines the rootUrl for data loading
  17246. * @returns a new SubEmitter
  17247. */
  17248. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17249. /** Release associated resources */
  17250. dispose(): void;
  17251. }
  17252. }
  17253. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17254. /** @hidden */
  17255. export var clipPlaneFragmentDeclaration: {
  17256. name: string;
  17257. shader: string;
  17258. };
  17259. }
  17260. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17261. /** @hidden */
  17262. export var imageProcessingDeclaration: {
  17263. name: string;
  17264. shader: string;
  17265. };
  17266. }
  17267. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17268. /** @hidden */
  17269. export var imageProcessingFunctions: {
  17270. name: string;
  17271. shader: string;
  17272. };
  17273. }
  17274. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17275. /** @hidden */
  17276. export var clipPlaneFragment: {
  17277. name: string;
  17278. shader: string;
  17279. };
  17280. }
  17281. declare module "babylonjs/Shaders/particles.fragment" {
  17282. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17283. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17284. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17285. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17286. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17287. /** @hidden */
  17288. export var particlesPixelShader: {
  17289. name: string;
  17290. shader: string;
  17291. };
  17292. }
  17293. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17294. /** @hidden */
  17295. export var clipPlaneVertexDeclaration: {
  17296. name: string;
  17297. shader: string;
  17298. };
  17299. }
  17300. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17301. /** @hidden */
  17302. export var clipPlaneVertex: {
  17303. name: string;
  17304. shader: string;
  17305. };
  17306. }
  17307. declare module "babylonjs/Shaders/particles.vertex" {
  17308. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17309. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17310. /** @hidden */
  17311. export var particlesVertexShader: {
  17312. name: string;
  17313. shader: string;
  17314. };
  17315. }
  17316. declare module "babylonjs/Particles/particleSystem" {
  17317. import { Nullable } from "babylonjs/types";
  17318. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17319. import { Observable } from "babylonjs/Misc/observable";
  17320. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17321. import { Effect } from "babylonjs/Materials/effect";
  17322. import { Scene, IDisposable } from "babylonjs/scene";
  17323. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17324. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17325. import { Particle } from "babylonjs/Particles/particle";
  17326. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17327. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17328. import "babylonjs/Shaders/particles.fragment";
  17329. import "babylonjs/Shaders/particles.vertex";
  17330. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17331. /**
  17332. * This represents a particle system in Babylon.
  17333. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17334. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17335. * @example https://doc.babylonjs.com/babylon101/particles
  17336. */
  17337. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17338. /**
  17339. * Billboard mode will only apply to Y axis
  17340. */
  17341. static readonly BILLBOARDMODE_Y: number;
  17342. /**
  17343. * Billboard mode will apply to all axes
  17344. */
  17345. static readonly BILLBOARDMODE_ALL: number;
  17346. /**
  17347. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17348. */
  17349. static readonly BILLBOARDMODE_STRETCHED: number;
  17350. /**
  17351. * This function can be defined to provide custom update for active particles.
  17352. * This function will be called instead of regular update (age, position, color, etc.).
  17353. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17354. */
  17355. updateFunction: (particles: Particle[]) => void;
  17356. private _emitterWorldMatrix;
  17357. /**
  17358. * This function can be defined to specify initial direction for every new particle.
  17359. * It by default use the emitterType defined function
  17360. */
  17361. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17362. /**
  17363. * This function can be defined to specify initial position for every new particle.
  17364. * It by default use the emitterType defined function
  17365. */
  17366. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17367. /**
  17368. * @hidden
  17369. */
  17370. _inheritedVelocityOffset: Vector3;
  17371. /**
  17372. * An event triggered when the system is disposed
  17373. */
  17374. onDisposeObservable: Observable<ParticleSystem>;
  17375. private _onDisposeObserver;
  17376. /**
  17377. * Sets a callback that will be triggered when the system is disposed
  17378. */
  17379. onDispose: () => void;
  17380. private _particles;
  17381. private _epsilon;
  17382. private _capacity;
  17383. private _stockParticles;
  17384. private _newPartsExcess;
  17385. private _vertexData;
  17386. private _vertexBuffer;
  17387. private _vertexBuffers;
  17388. private _spriteBuffer;
  17389. private _indexBuffer;
  17390. private _effect;
  17391. private _customEffect;
  17392. private _cachedDefines;
  17393. private _scaledColorStep;
  17394. private _colorDiff;
  17395. private _scaledDirection;
  17396. private _scaledGravity;
  17397. private _currentRenderId;
  17398. private _alive;
  17399. private _useInstancing;
  17400. private _started;
  17401. private _stopped;
  17402. private _actualFrame;
  17403. private _scaledUpdateSpeed;
  17404. private _vertexBufferSize;
  17405. /** @hidden */
  17406. _currentEmitRateGradient: Nullable<FactorGradient>;
  17407. /** @hidden */
  17408. _currentEmitRate1: number;
  17409. /** @hidden */
  17410. _currentEmitRate2: number;
  17411. /** @hidden */
  17412. _currentStartSizeGradient: Nullable<FactorGradient>;
  17413. /** @hidden */
  17414. _currentStartSize1: number;
  17415. /** @hidden */
  17416. _currentStartSize2: number;
  17417. private readonly _rawTextureWidth;
  17418. private _rampGradientsTexture;
  17419. private _useRampGradients;
  17420. /** Gets or sets a boolean indicating that ramp gradients must be used
  17421. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17422. */
  17423. useRampGradients: boolean;
  17424. /**
  17425. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  17426. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  17427. */
  17428. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17429. private _subEmitters;
  17430. /**
  17431. * @hidden
  17432. * If the particle systems emitter should be disposed when the particle system is disposed
  17433. */
  17434. _disposeEmitterOnDispose: boolean;
  17435. /**
  17436. * The current active Sub-systems, this property is used by the root particle system only.
  17437. */
  17438. activeSubSystems: Array<ParticleSystem>;
  17439. private _rootParticleSystem;
  17440. /**
  17441. * Gets the current list of active particles
  17442. */
  17443. readonly particles: Particle[];
  17444. /**
  17445. * Returns the string "ParticleSystem"
  17446. * @returns a string containing the class name
  17447. */
  17448. getClassName(): string;
  17449. /**
  17450. * Instantiates a particle system.
  17451. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17452. * @param name The name of the particle system
  17453. * @param capacity The max number of particles alive at the same time
  17454. * @param scene The scene the particle system belongs to
  17455. * @param customEffect a custom effect used to change the way particles are rendered by default
  17456. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17457. * @param epsilon Offset used to render the particles
  17458. */
  17459. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17460. private _addFactorGradient;
  17461. private _removeFactorGradient;
  17462. /**
  17463. * Adds a new life time gradient
  17464. * @param gradient defines the gradient to use (between 0 and 1)
  17465. * @param factor defines the life time factor to affect to the specified gradient
  17466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17467. * @returns the current particle system
  17468. */
  17469. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17470. /**
  17471. * Remove a specific life time gradient
  17472. * @param gradient defines the gradient to remove
  17473. * @returns the current particle system
  17474. */
  17475. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17476. /**
  17477. * Adds a new size gradient
  17478. * @param gradient defines the gradient to use (between 0 and 1)
  17479. * @param factor defines the size factor to affect to the specified gradient
  17480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17481. * @returns the current particle system
  17482. */
  17483. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17484. /**
  17485. * Remove a specific size gradient
  17486. * @param gradient defines the gradient to remove
  17487. * @returns the current particle system
  17488. */
  17489. removeSizeGradient(gradient: number): IParticleSystem;
  17490. /**
  17491. * Adds a new color remap gradient
  17492. * @param gradient defines the gradient to use (between 0 and 1)
  17493. * @param min defines the color remap minimal range
  17494. * @param max defines the color remap maximal range
  17495. * @returns the current particle system
  17496. */
  17497. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17498. /**
  17499. * Remove a specific color remap gradient
  17500. * @param gradient defines the gradient to remove
  17501. * @returns the current particle system
  17502. */
  17503. removeColorRemapGradient(gradient: number): IParticleSystem;
  17504. /**
  17505. * Adds a new alpha remap gradient
  17506. * @param gradient defines the gradient to use (between 0 and 1)
  17507. * @param min defines the alpha remap minimal range
  17508. * @param max defines the alpha remap maximal range
  17509. * @returns the current particle system
  17510. */
  17511. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17512. /**
  17513. * Remove a specific alpha remap gradient
  17514. * @param gradient defines the gradient to remove
  17515. * @returns the current particle system
  17516. */
  17517. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17518. /**
  17519. * Adds a new angular speed gradient
  17520. * @param gradient defines the gradient to use (between 0 and 1)
  17521. * @param factor defines the angular speed to affect to the specified gradient
  17522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17523. * @returns the current particle system
  17524. */
  17525. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17526. /**
  17527. * Remove a specific angular speed gradient
  17528. * @param gradient defines the gradient to remove
  17529. * @returns the current particle system
  17530. */
  17531. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17532. /**
  17533. * Adds a new velocity gradient
  17534. * @param gradient defines the gradient to use (between 0 and 1)
  17535. * @param factor defines the velocity to affect to the specified gradient
  17536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17537. * @returns the current particle system
  17538. */
  17539. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17540. /**
  17541. * Remove a specific velocity gradient
  17542. * @param gradient defines the gradient to remove
  17543. * @returns the current particle system
  17544. */
  17545. removeVelocityGradient(gradient: number): IParticleSystem;
  17546. /**
  17547. * Adds a new limit velocity gradient
  17548. * @param gradient defines the gradient to use (between 0 and 1)
  17549. * @param factor defines the limit velocity value to affect to the specified gradient
  17550. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17551. * @returns the current particle system
  17552. */
  17553. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17554. /**
  17555. * Remove a specific limit velocity gradient
  17556. * @param gradient defines the gradient to remove
  17557. * @returns the current particle system
  17558. */
  17559. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17560. /**
  17561. * Adds a new drag gradient
  17562. * @param gradient defines the gradient to use (between 0 and 1)
  17563. * @param factor defines the drag value to affect to the specified gradient
  17564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17565. * @returns the current particle system
  17566. */
  17567. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17568. /**
  17569. * Remove a specific drag gradient
  17570. * @param gradient defines the gradient to remove
  17571. * @returns the current particle system
  17572. */
  17573. removeDragGradient(gradient: number): IParticleSystem;
  17574. /**
  17575. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17576. * @param gradient defines the gradient to use (between 0 and 1)
  17577. * @param factor defines the emit rate value to affect to the specified gradient
  17578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17579. * @returns the current particle system
  17580. */
  17581. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17582. /**
  17583. * Remove a specific emit rate gradient
  17584. * @param gradient defines the gradient to remove
  17585. * @returns the current particle system
  17586. */
  17587. removeEmitRateGradient(gradient: number): IParticleSystem;
  17588. /**
  17589. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17590. * @param gradient defines the gradient to use (between 0 and 1)
  17591. * @param factor defines the start size value to affect to the specified gradient
  17592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17593. * @returns the current particle system
  17594. */
  17595. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17596. /**
  17597. * Remove a specific start size gradient
  17598. * @param gradient defines the gradient to remove
  17599. * @returns the current particle system
  17600. */
  17601. removeStartSizeGradient(gradient: number): IParticleSystem;
  17602. private _createRampGradientTexture;
  17603. /**
  17604. * Gets the current list of ramp gradients.
  17605. * You must use addRampGradient and removeRampGradient to udpate this list
  17606. * @returns the list of ramp gradients
  17607. */
  17608. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17609. /**
  17610. * Adds a new ramp gradient used to remap particle colors
  17611. * @param gradient defines the gradient to use (between 0 and 1)
  17612. * @param color defines the color to affect to the specified gradient
  17613. * @returns the current particle system
  17614. */
  17615. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17616. /**
  17617. * Remove a specific ramp gradient
  17618. * @param gradient defines the gradient to remove
  17619. * @returns the current particle system
  17620. */
  17621. removeRampGradient(gradient: number): ParticleSystem;
  17622. /**
  17623. * Adds a new color gradient
  17624. * @param gradient defines the gradient to use (between 0 and 1)
  17625. * @param color1 defines the color to affect to the specified gradient
  17626. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17627. * @returns this particle system
  17628. */
  17629. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17630. /**
  17631. * Remove a specific color gradient
  17632. * @param gradient defines the gradient to remove
  17633. * @returns this particle system
  17634. */
  17635. removeColorGradient(gradient: number): IParticleSystem;
  17636. private _fetchR;
  17637. protected _reset(): void;
  17638. private _resetEffect;
  17639. private _createVertexBuffers;
  17640. private _createIndexBuffer;
  17641. /**
  17642. * Gets the maximum number of particles active at the same time.
  17643. * @returns The max number of active particles.
  17644. */
  17645. getCapacity(): number;
  17646. /**
  17647. * Gets whether there are still active particles in the system.
  17648. * @returns True if it is alive, otherwise false.
  17649. */
  17650. isAlive(): boolean;
  17651. /**
  17652. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17653. * @returns True if it has been started, otherwise false.
  17654. */
  17655. isStarted(): boolean;
  17656. private _prepareSubEmitterInternalArray;
  17657. /**
  17658. * Starts the particle system and begins to emit
  17659. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17660. */
  17661. start(delay?: number): void;
  17662. /**
  17663. * Stops the particle system.
  17664. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  17665. */
  17666. stop(stopSubEmitters?: boolean): void;
  17667. /**
  17668. * Remove all active particles
  17669. */
  17670. reset(): void;
  17671. /**
  17672. * @hidden (for internal use only)
  17673. */
  17674. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17675. /**
  17676. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17677. * Its lifetime will start back at 0.
  17678. */
  17679. recycleParticle: (particle: Particle) => void;
  17680. private _stopSubEmitters;
  17681. private _createParticle;
  17682. private _removeFromRoot;
  17683. private _emitFromParticle;
  17684. private _update;
  17685. /** @hidden */
  17686. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17687. /** @hidden */
  17688. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17689. /** @hidden */
  17690. private _getEffect;
  17691. /**
  17692. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17693. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17694. */
  17695. animate(preWarmOnly?: boolean): void;
  17696. private _appendParticleVertices;
  17697. /**
  17698. * Rebuilds the particle system.
  17699. */
  17700. rebuild(): void;
  17701. /**
  17702. * Is this system ready to be used/rendered
  17703. * @return true if the system is ready
  17704. */
  17705. isReady(): boolean;
  17706. private _render;
  17707. /**
  17708. * Renders the particle system in its current state.
  17709. * @returns the current number of particles
  17710. */
  17711. render(): number;
  17712. /**
  17713. * Disposes the particle system and free the associated resources
  17714. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17715. */
  17716. dispose(disposeTexture?: boolean): void;
  17717. /**
  17718. * Clones the particle system.
  17719. * @param name The name of the cloned object
  17720. * @param newEmitter The new emitter to use
  17721. * @returns the cloned particle system
  17722. */
  17723. clone(name: string, newEmitter: any): ParticleSystem;
  17724. /**
  17725. * Serializes the particle system to a JSON object.
  17726. * @returns the JSON object
  17727. */
  17728. serialize(): any;
  17729. /** @hidden */
  17730. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17731. /** @hidden */
  17732. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17733. /**
  17734. * Parses a JSON object to create a particle system.
  17735. * @param parsedParticleSystem The JSON object to parse
  17736. * @param scene The scene to create the particle system in
  17737. * @param rootUrl The root url to use to load external dependencies like texture
  17738. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17739. * @returns the Parsed particle system
  17740. */
  17741. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17742. }
  17743. }
  17744. declare module "babylonjs/Particles/particle" {
  17745. import { Nullable } from "babylonjs/types";
  17746. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17747. import { Color4 } from "babylonjs/Maths/math.color";
  17748. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17749. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17750. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17751. /**
  17752. * A particle represents one of the element emitted by a particle system.
  17753. * This is mainly define by its coordinates, direction, velocity and age.
  17754. */
  17755. export class Particle {
  17756. /**
  17757. * The particle system the particle belongs to.
  17758. */
  17759. particleSystem: ParticleSystem;
  17760. private static _Count;
  17761. /**
  17762. * Unique ID of the particle
  17763. */
  17764. id: number;
  17765. /**
  17766. * The world position of the particle in the scene.
  17767. */
  17768. position: Vector3;
  17769. /**
  17770. * The world direction of the particle in the scene.
  17771. */
  17772. direction: Vector3;
  17773. /**
  17774. * The color of the particle.
  17775. */
  17776. color: Color4;
  17777. /**
  17778. * The color change of the particle per step.
  17779. */
  17780. colorStep: Color4;
  17781. /**
  17782. * Defines how long will the life of the particle be.
  17783. */
  17784. lifeTime: number;
  17785. /**
  17786. * The current age of the particle.
  17787. */
  17788. age: number;
  17789. /**
  17790. * The current size of the particle.
  17791. */
  17792. size: number;
  17793. /**
  17794. * The current scale of the particle.
  17795. */
  17796. scale: Vector2;
  17797. /**
  17798. * The current angle of the particle.
  17799. */
  17800. angle: number;
  17801. /**
  17802. * Defines how fast is the angle changing.
  17803. */
  17804. angularSpeed: number;
  17805. /**
  17806. * Defines the cell index used by the particle to be rendered from a sprite.
  17807. */
  17808. cellIndex: number;
  17809. /**
  17810. * The information required to support color remapping
  17811. */
  17812. remapData: Vector4;
  17813. /** @hidden */
  17814. _randomCellOffset?: number;
  17815. /** @hidden */
  17816. _initialDirection: Nullable<Vector3>;
  17817. /** @hidden */
  17818. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17819. /** @hidden */
  17820. _initialStartSpriteCellID: number;
  17821. /** @hidden */
  17822. _initialEndSpriteCellID: number;
  17823. /** @hidden */
  17824. _currentColorGradient: Nullable<ColorGradient>;
  17825. /** @hidden */
  17826. _currentColor1: Color4;
  17827. /** @hidden */
  17828. _currentColor2: Color4;
  17829. /** @hidden */
  17830. _currentSizeGradient: Nullable<FactorGradient>;
  17831. /** @hidden */
  17832. _currentSize1: number;
  17833. /** @hidden */
  17834. _currentSize2: number;
  17835. /** @hidden */
  17836. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17837. /** @hidden */
  17838. _currentAngularSpeed1: number;
  17839. /** @hidden */
  17840. _currentAngularSpeed2: number;
  17841. /** @hidden */
  17842. _currentVelocityGradient: Nullable<FactorGradient>;
  17843. /** @hidden */
  17844. _currentVelocity1: number;
  17845. /** @hidden */
  17846. _currentVelocity2: number;
  17847. /** @hidden */
  17848. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17849. /** @hidden */
  17850. _currentLimitVelocity1: number;
  17851. /** @hidden */
  17852. _currentLimitVelocity2: number;
  17853. /** @hidden */
  17854. _currentDragGradient: Nullable<FactorGradient>;
  17855. /** @hidden */
  17856. _currentDrag1: number;
  17857. /** @hidden */
  17858. _currentDrag2: number;
  17859. /** @hidden */
  17860. _randomNoiseCoordinates1: Vector3;
  17861. /** @hidden */
  17862. _randomNoiseCoordinates2: Vector3;
  17863. /**
  17864. * Creates a new instance Particle
  17865. * @param particleSystem the particle system the particle belongs to
  17866. */
  17867. constructor(
  17868. /**
  17869. * The particle system the particle belongs to.
  17870. */
  17871. particleSystem: ParticleSystem);
  17872. private updateCellInfoFromSystem;
  17873. /**
  17874. * Defines how the sprite cell index is updated for the particle
  17875. */
  17876. updateCellIndex(): void;
  17877. /** @hidden */
  17878. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17879. /** @hidden */
  17880. _inheritParticleInfoToSubEmitters(): void;
  17881. /** @hidden */
  17882. _reset(): void;
  17883. /**
  17884. * Copy the properties of particle to another one.
  17885. * @param other the particle to copy the information to.
  17886. */
  17887. copyTo(other: Particle): void;
  17888. }
  17889. }
  17890. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17891. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17892. import { Effect } from "babylonjs/Materials/effect";
  17893. import { Particle } from "babylonjs/Particles/particle";
  17894. /**
  17895. * Particle emitter represents a volume emitting particles.
  17896. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17897. */
  17898. export interface IParticleEmitterType {
  17899. /**
  17900. * Called by the particle System when the direction is computed for the created particle.
  17901. * @param worldMatrix is the world matrix of the particle system
  17902. * @param directionToUpdate is the direction vector to update with the result
  17903. * @param particle is the particle we are computed the direction for
  17904. */
  17905. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17906. /**
  17907. * Called by the particle System when the position is computed for the created particle.
  17908. * @param worldMatrix is the world matrix of the particle system
  17909. * @param positionToUpdate is the position vector to update with the result
  17910. * @param particle is the particle we are computed the position for
  17911. */
  17912. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17913. /**
  17914. * Clones the current emitter and returns a copy of it
  17915. * @returns the new emitter
  17916. */
  17917. clone(): IParticleEmitterType;
  17918. /**
  17919. * Called by the GPUParticleSystem to setup the update shader
  17920. * @param effect defines the update shader
  17921. */
  17922. applyToShader(effect: Effect): void;
  17923. /**
  17924. * Returns a string to use to update the GPU particles update shader
  17925. * @returns the effect defines string
  17926. */
  17927. getEffectDefines(): string;
  17928. /**
  17929. * Returns a string representing the class name
  17930. * @returns a string containing the class name
  17931. */
  17932. getClassName(): string;
  17933. /**
  17934. * Serializes the particle system to a JSON object.
  17935. * @returns the JSON object
  17936. */
  17937. serialize(): any;
  17938. /**
  17939. * Parse properties from a JSON object
  17940. * @param serializationObject defines the JSON object
  17941. */
  17942. parse(serializationObject: any): void;
  17943. }
  17944. }
  17945. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17946. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17947. import { Effect } from "babylonjs/Materials/effect";
  17948. import { Particle } from "babylonjs/Particles/particle";
  17949. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17950. /**
  17951. * Particle emitter emitting particles from the inside of a box.
  17952. * It emits the particles randomly between 2 given directions.
  17953. */
  17954. export class BoxParticleEmitter implements IParticleEmitterType {
  17955. /**
  17956. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17957. */
  17958. direction1: Vector3;
  17959. /**
  17960. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17961. */
  17962. direction2: Vector3;
  17963. /**
  17964. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17965. */
  17966. minEmitBox: Vector3;
  17967. /**
  17968. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17969. */
  17970. maxEmitBox: Vector3;
  17971. /**
  17972. * Creates a new instance BoxParticleEmitter
  17973. */
  17974. constructor();
  17975. /**
  17976. * Called by the particle System when the direction is computed for the created particle.
  17977. * @param worldMatrix is the world matrix of the particle system
  17978. * @param directionToUpdate is the direction vector to update with the result
  17979. * @param particle is the particle we are computed the direction for
  17980. */
  17981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17982. /**
  17983. * Called by the particle System when the position is computed for the created particle.
  17984. * @param worldMatrix is the world matrix of the particle system
  17985. * @param positionToUpdate is the position vector to update with the result
  17986. * @param particle is the particle we are computed the position for
  17987. */
  17988. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17989. /**
  17990. * Clones the current emitter and returns a copy of it
  17991. * @returns the new emitter
  17992. */
  17993. clone(): BoxParticleEmitter;
  17994. /**
  17995. * Called by the GPUParticleSystem to setup the update shader
  17996. * @param effect defines the update shader
  17997. */
  17998. applyToShader(effect: Effect): void;
  17999. /**
  18000. * Returns a string to use to update the GPU particles update shader
  18001. * @returns a string containng the defines string
  18002. */
  18003. getEffectDefines(): string;
  18004. /**
  18005. * Returns the string "BoxParticleEmitter"
  18006. * @returns a string containing the class name
  18007. */
  18008. getClassName(): string;
  18009. /**
  18010. * Serializes the particle system to a JSON object.
  18011. * @returns the JSON object
  18012. */
  18013. serialize(): any;
  18014. /**
  18015. * Parse properties from a JSON object
  18016. * @param serializationObject defines the JSON object
  18017. */
  18018. parse(serializationObject: any): void;
  18019. }
  18020. }
  18021. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18022. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18023. import { Effect } from "babylonjs/Materials/effect";
  18024. import { Particle } from "babylonjs/Particles/particle";
  18025. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18026. /**
  18027. * Particle emitter emitting particles from the inside of a cone.
  18028. * It emits the particles alongside the cone volume from the base to the particle.
  18029. * The emission direction might be randomized.
  18030. */
  18031. export class ConeParticleEmitter implements IParticleEmitterType {
  18032. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18033. directionRandomizer: number;
  18034. private _radius;
  18035. private _angle;
  18036. private _height;
  18037. /**
  18038. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18039. */
  18040. radiusRange: number;
  18041. /**
  18042. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18043. */
  18044. heightRange: number;
  18045. /**
  18046. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18047. */
  18048. emitFromSpawnPointOnly: boolean;
  18049. /**
  18050. * Gets or sets the radius of the emission cone
  18051. */
  18052. radius: number;
  18053. /**
  18054. * Gets or sets the angle of the emission cone
  18055. */
  18056. angle: number;
  18057. private _buildHeight;
  18058. /**
  18059. * Creates a new instance ConeParticleEmitter
  18060. * @param radius the radius of the emission cone (1 by default)
  18061. * @param angle the cone base angle (PI by default)
  18062. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18063. */
  18064. constructor(radius?: number, angle?: number,
  18065. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18066. directionRandomizer?: number);
  18067. /**
  18068. * Called by the particle System when the direction is computed for the created particle.
  18069. * @param worldMatrix is the world matrix of the particle system
  18070. * @param directionToUpdate is the direction vector to update with the result
  18071. * @param particle is the particle we are computed the direction for
  18072. */
  18073. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18074. /**
  18075. * Called by the particle System when the position is computed for the created particle.
  18076. * @param worldMatrix is the world matrix of the particle system
  18077. * @param positionToUpdate is the position vector to update with the result
  18078. * @param particle is the particle we are computed the position for
  18079. */
  18080. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18081. /**
  18082. * Clones the current emitter and returns a copy of it
  18083. * @returns the new emitter
  18084. */
  18085. clone(): ConeParticleEmitter;
  18086. /**
  18087. * Called by the GPUParticleSystem to setup the update shader
  18088. * @param effect defines the update shader
  18089. */
  18090. applyToShader(effect: Effect): void;
  18091. /**
  18092. * Returns a string to use to update the GPU particles update shader
  18093. * @returns a string containng the defines string
  18094. */
  18095. getEffectDefines(): string;
  18096. /**
  18097. * Returns the string "ConeParticleEmitter"
  18098. * @returns a string containing the class name
  18099. */
  18100. getClassName(): string;
  18101. /**
  18102. * Serializes the particle system to a JSON object.
  18103. * @returns the JSON object
  18104. */
  18105. serialize(): any;
  18106. /**
  18107. * Parse properties from a JSON object
  18108. * @param serializationObject defines the JSON object
  18109. */
  18110. parse(serializationObject: any): void;
  18111. }
  18112. }
  18113. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18114. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18115. import { Effect } from "babylonjs/Materials/effect";
  18116. import { Particle } from "babylonjs/Particles/particle";
  18117. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18118. /**
  18119. * Particle emitter emitting particles from the inside of a cylinder.
  18120. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18121. */
  18122. export class CylinderParticleEmitter implements IParticleEmitterType {
  18123. /**
  18124. * The radius of the emission cylinder.
  18125. */
  18126. radius: number;
  18127. /**
  18128. * The height of the emission cylinder.
  18129. */
  18130. height: number;
  18131. /**
  18132. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18133. */
  18134. radiusRange: number;
  18135. /**
  18136. * How much to randomize the particle direction [0-1].
  18137. */
  18138. directionRandomizer: number;
  18139. /**
  18140. * Creates a new instance CylinderParticleEmitter
  18141. * @param radius the radius of the emission cylinder (1 by default)
  18142. * @param height the height of the emission cylinder (1 by default)
  18143. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18144. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18145. */
  18146. constructor(
  18147. /**
  18148. * The radius of the emission cylinder.
  18149. */
  18150. radius?: number,
  18151. /**
  18152. * The height of the emission cylinder.
  18153. */
  18154. height?: number,
  18155. /**
  18156. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18157. */
  18158. radiusRange?: number,
  18159. /**
  18160. * How much to randomize the particle direction [0-1].
  18161. */
  18162. directionRandomizer?: number);
  18163. /**
  18164. * Called by the particle System when the direction is computed for the created particle.
  18165. * @param worldMatrix is the world matrix of the particle system
  18166. * @param directionToUpdate is the direction vector to update with the result
  18167. * @param particle is the particle we are computed the direction for
  18168. */
  18169. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18170. /**
  18171. * Called by the particle System when the position is computed for the created particle.
  18172. * @param worldMatrix is the world matrix of the particle system
  18173. * @param positionToUpdate is the position vector to update with the result
  18174. * @param particle is the particle we are computed the position for
  18175. */
  18176. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18177. /**
  18178. * Clones the current emitter and returns a copy of it
  18179. * @returns the new emitter
  18180. */
  18181. clone(): CylinderParticleEmitter;
  18182. /**
  18183. * Called by the GPUParticleSystem to setup the update shader
  18184. * @param effect defines the update shader
  18185. */
  18186. applyToShader(effect: Effect): void;
  18187. /**
  18188. * Returns a string to use to update the GPU particles update shader
  18189. * @returns a string containng the defines string
  18190. */
  18191. getEffectDefines(): string;
  18192. /**
  18193. * Returns the string "CylinderParticleEmitter"
  18194. * @returns a string containing the class name
  18195. */
  18196. getClassName(): string;
  18197. /**
  18198. * Serializes the particle system to a JSON object.
  18199. * @returns the JSON object
  18200. */
  18201. serialize(): any;
  18202. /**
  18203. * Parse properties from a JSON object
  18204. * @param serializationObject defines the JSON object
  18205. */
  18206. parse(serializationObject: any): void;
  18207. }
  18208. /**
  18209. * Particle emitter emitting particles from the inside of a cylinder.
  18210. * It emits the particles randomly between two vectors.
  18211. */
  18212. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18213. /**
  18214. * The min limit of the emission direction.
  18215. */
  18216. direction1: Vector3;
  18217. /**
  18218. * The max limit of the emission direction.
  18219. */
  18220. direction2: Vector3;
  18221. /**
  18222. * Creates a new instance CylinderDirectedParticleEmitter
  18223. * @param radius the radius of the emission cylinder (1 by default)
  18224. * @param height the height of the emission cylinder (1 by default)
  18225. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18226. * @param direction1 the min limit of the emission direction (up vector by default)
  18227. * @param direction2 the max limit of the emission direction (up vector by default)
  18228. */
  18229. constructor(radius?: number, height?: number, radiusRange?: number,
  18230. /**
  18231. * The min limit of the emission direction.
  18232. */
  18233. direction1?: Vector3,
  18234. /**
  18235. * The max limit of the emission direction.
  18236. */
  18237. direction2?: Vector3);
  18238. /**
  18239. * Called by the particle System when the direction is computed for the created particle.
  18240. * @param worldMatrix is the world matrix of the particle system
  18241. * @param directionToUpdate is the direction vector to update with the result
  18242. * @param particle is the particle we are computed the direction for
  18243. */
  18244. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18245. /**
  18246. * Clones the current emitter and returns a copy of it
  18247. * @returns the new emitter
  18248. */
  18249. clone(): CylinderDirectedParticleEmitter;
  18250. /**
  18251. * Called by the GPUParticleSystem to setup the update shader
  18252. * @param effect defines the update shader
  18253. */
  18254. applyToShader(effect: Effect): void;
  18255. /**
  18256. * Returns a string to use to update the GPU particles update shader
  18257. * @returns a string containng the defines string
  18258. */
  18259. getEffectDefines(): string;
  18260. /**
  18261. * Returns the string "CylinderDirectedParticleEmitter"
  18262. * @returns a string containing the class name
  18263. */
  18264. getClassName(): string;
  18265. /**
  18266. * Serializes the particle system to a JSON object.
  18267. * @returns the JSON object
  18268. */
  18269. serialize(): any;
  18270. /**
  18271. * Parse properties from a JSON object
  18272. * @param serializationObject defines the JSON object
  18273. */
  18274. parse(serializationObject: any): void;
  18275. }
  18276. }
  18277. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18278. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18279. import { Effect } from "babylonjs/Materials/effect";
  18280. import { Particle } from "babylonjs/Particles/particle";
  18281. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18282. /**
  18283. * Particle emitter emitting particles from the inside of a hemisphere.
  18284. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18285. */
  18286. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18287. /**
  18288. * The radius of the emission hemisphere.
  18289. */
  18290. radius: number;
  18291. /**
  18292. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18293. */
  18294. radiusRange: number;
  18295. /**
  18296. * How much to randomize the particle direction [0-1].
  18297. */
  18298. directionRandomizer: number;
  18299. /**
  18300. * Creates a new instance HemisphericParticleEmitter
  18301. * @param radius the radius of the emission hemisphere (1 by default)
  18302. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18304. */
  18305. constructor(
  18306. /**
  18307. * The radius of the emission hemisphere.
  18308. */
  18309. radius?: number,
  18310. /**
  18311. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18312. */
  18313. radiusRange?: number,
  18314. /**
  18315. * How much to randomize the particle direction [0-1].
  18316. */
  18317. directionRandomizer?: number);
  18318. /**
  18319. * Called by the particle System when the direction is computed for the created particle.
  18320. * @param worldMatrix is the world matrix of the particle system
  18321. * @param directionToUpdate is the direction vector to update with the result
  18322. * @param particle is the particle we are computed the direction for
  18323. */
  18324. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18325. /**
  18326. * Called by the particle System when the position is computed for the created particle.
  18327. * @param worldMatrix is the world matrix of the particle system
  18328. * @param positionToUpdate is the position vector to update with the result
  18329. * @param particle is the particle we are computed the position for
  18330. */
  18331. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18332. /**
  18333. * Clones the current emitter and returns a copy of it
  18334. * @returns the new emitter
  18335. */
  18336. clone(): HemisphericParticleEmitter;
  18337. /**
  18338. * Called by the GPUParticleSystem to setup the update shader
  18339. * @param effect defines the update shader
  18340. */
  18341. applyToShader(effect: Effect): void;
  18342. /**
  18343. * Returns a string to use to update the GPU particles update shader
  18344. * @returns a string containng the defines string
  18345. */
  18346. getEffectDefines(): string;
  18347. /**
  18348. * Returns the string "HemisphericParticleEmitter"
  18349. * @returns a string containing the class name
  18350. */
  18351. getClassName(): string;
  18352. /**
  18353. * Serializes the particle system to a JSON object.
  18354. * @returns the JSON object
  18355. */
  18356. serialize(): any;
  18357. /**
  18358. * Parse properties from a JSON object
  18359. * @param serializationObject defines the JSON object
  18360. */
  18361. parse(serializationObject: any): void;
  18362. }
  18363. }
  18364. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18365. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18366. import { Effect } from "babylonjs/Materials/effect";
  18367. import { Particle } from "babylonjs/Particles/particle";
  18368. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18369. /**
  18370. * Particle emitter emitting particles from a point.
  18371. * It emits the particles randomly between 2 given directions.
  18372. */
  18373. export class PointParticleEmitter implements IParticleEmitterType {
  18374. /**
  18375. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18376. */
  18377. direction1: Vector3;
  18378. /**
  18379. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18380. */
  18381. direction2: Vector3;
  18382. /**
  18383. * Creates a new instance PointParticleEmitter
  18384. */
  18385. constructor();
  18386. /**
  18387. * Called by the particle System when the direction is computed for the created particle.
  18388. * @param worldMatrix is the world matrix of the particle system
  18389. * @param directionToUpdate is the direction vector to update with the result
  18390. * @param particle is the particle we are computed the direction for
  18391. */
  18392. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18393. /**
  18394. * Called by the particle System when the position is computed for the created particle.
  18395. * @param worldMatrix is the world matrix of the particle system
  18396. * @param positionToUpdate is the position vector to update with the result
  18397. * @param particle is the particle we are computed the position for
  18398. */
  18399. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18400. /**
  18401. * Clones the current emitter and returns a copy of it
  18402. * @returns the new emitter
  18403. */
  18404. clone(): PointParticleEmitter;
  18405. /**
  18406. * Called by the GPUParticleSystem to setup the update shader
  18407. * @param effect defines the update shader
  18408. */
  18409. applyToShader(effect: Effect): void;
  18410. /**
  18411. * Returns a string to use to update the GPU particles update shader
  18412. * @returns a string containng the defines string
  18413. */
  18414. getEffectDefines(): string;
  18415. /**
  18416. * Returns the string "PointParticleEmitter"
  18417. * @returns a string containing the class name
  18418. */
  18419. getClassName(): string;
  18420. /**
  18421. * Serializes the particle system to a JSON object.
  18422. * @returns the JSON object
  18423. */
  18424. serialize(): any;
  18425. /**
  18426. * Parse properties from a JSON object
  18427. * @param serializationObject defines the JSON object
  18428. */
  18429. parse(serializationObject: any): void;
  18430. }
  18431. }
  18432. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18433. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18434. import { Effect } from "babylonjs/Materials/effect";
  18435. import { Particle } from "babylonjs/Particles/particle";
  18436. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18437. /**
  18438. * Particle emitter emitting particles from the inside of a sphere.
  18439. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18440. */
  18441. export class SphereParticleEmitter implements IParticleEmitterType {
  18442. /**
  18443. * The radius of the emission sphere.
  18444. */
  18445. radius: number;
  18446. /**
  18447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18448. */
  18449. radiusRange: number;
  18450. /**
  18451. * How much to randomize the particle direction [0-1].
  18452. */
  18453. directionRandomizer: number;
  18454. /**
  18455. * Creates a new instance SphereParticleEmitter
  18456. * @param radius the radius of the emission sphere (1 by default)
  18457. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18458. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18459. */
  18460. constructor(
  18461. /**
  18462. * The radius of the emission sphere.
  18463. */
  18464. radius?: number,
  18465. /**
  18466. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18467. */
  18468. radiusRange?: number,
  18469. /**
  18470. * How much to randomize the particle direction [0-1].
  18471. */
  18472. directionRandomizer?: number);
  18473. /**
  18474. * Called by the particle System when the direction is computed for the created particle.
  18475. * @param worldMatrix is the world matrix of the particle system
  18476. * @param directionToUpdate is the direction vector to update with the result
  18477. * @param particle is the particle we are computed the direction for
  18478. */
  18479. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18480. /**
  18481. * Called by the particle System when the position is computed for the created particle.
  18482. * @param worldMatrix is the world matrix of the particle system
  18483. * @param positionToUpdate is the position vector to update with the result
  18484. * @param particle is the particle we are computed the position for
  18485. */
  18486. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18487. /**
  18488. * Clones the current emitter and returns a copy of it
  18489. * @returns the new emitter
  18490. */
  18491. clone(): SphereParticleEmitter;
  18492. /**
  18493. * Called by the GPUParticleSystem to setup the update shader
  18494. * @param effect defines the update shader
  18495. */
  18496. applyToShader(effect: Effect): void;
  18497. /**
  18498. * Returns a string to use to update the GPU particles update shader
  18499. * @returns a string containng the defines string
  18500. */
  18501. getEffectDefines(): string;
  18502. /**
  18503. * Returns the string "SphereParticleEmitter"
  18504. * @returns a string containing the class name
  18505. */
  18506. getClassName(): string;
  18507. /**
  18508. * Serializes the particle system to a JSON object.
  18509. * @returns the JSON object
  18510. */
  18511. serialize(): any;
  18512. /**
  18513. * Parse properties from a JSON object
  18514. * @param serializationObject defines the JSON object
  18515. */
  18516. parse(serializationObject: any): void;
  18517. }
  18518. /**
  18519. * Particle emitter emitting particles from the inside of a sphere.
  18520. * It emits the particles randomly between two vectors.
  18521. */
  18522. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18523. /**
  18524. * The min limit of the emission direction.
  18525. */
  18526. direction1: Vector3;
  18527. /**
  18528. * The max limit of the emission direction.
  18529. */
  18530. direction2: Vector3;
  18531. /**
  18532. * Creates a new instance SphereDirectedParticleEmitter
  18533. * @param radius the radius of the emission sphere (1 by default)
  18534. * @param direction1 the min limit of the emission direction (up vector by default)
  18535. * @param direction2 the max limit of the emission direction (up vector by default)
  18536. */
  18537. constructor(radius?: number,
  18538. /**
  18539. * The min limit of the emission direction.
  18540. */
  18541. direction1?: Vector3,
  18542. /**
  18543. * The max limit of the emission direction.
  18544. */
  18545. direction2?: Vector3);
  18546. /**
  18547. * Called by the particle System when the direction is computed for the created particle.
  18548. * @param worldMatrix is the world matrix of the particle system
  18549. * @param directionToUpdate is the direction vector to update with the result
  18550. * @param particle is the particle we are computed the direction for
  18551. */
  18552. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18553. /**
  18554. * Clones the current emitter and returns a copy of it
  18555. * @returns the new emitter
  18556. */
  18557. clone(): SphereDirectedParticleEmitter;
  18558. /**
  18559. * Called by the GPUParticleSystem to setup the update shader
  18560. * @param effect defines the update shader
  18561. */
  18562. applyToShader(effect: Effect): void;
  18563. /**
  18564. * Returns a string to use to update the GPU particles update shader
  18565. * @returns a string containng the defines string
  18566. */
  18567. getEffectDefines(): string;
  18568. /**
  18569. * Returns the string "SphereDirectedParticleEmitter"
  18570. * @returns a string containing the class name
  18571. */
  18572. getClassName(): string;
  18573. /**
  18574. * Serializes the particle system to a JSON object.
  18575. * @returns the JSON object
  18576. */
  18577. serialize(): any;
  18578. /**
  18579. * Parse properties from a JSON object
  18580. * @param serializationObject defines the JSON object
  18581. */
  18582. parse(serializationObject: any): void;
  18583. }
  18584. }
  18585. declare module "babylonjs/Particles/EmitterTypes/index" {
  18586. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18587. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18588. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18589. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18590. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18591. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18592. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18593. }
  18594. declare module "babylonjs/Particles/IParticleSystem" {
  18595. import { Nullable } from "babylonjs/types";
  18596. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18597. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18600. import { Texture } from "babylonjs/Materials/Textures/texture";
  18601. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18602. import { Scene } from "babylonjs/scene";
  18603. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18604. import { Animation } from "babylonjs/Animations/animation";
  18605. /**
  18606. * Interface representing a particle system in Babylon.js.
  18607. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18608. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18609. */
  18610. export interface IParticleSystem {
  18611. /**
  18612. * List of animations used by the particle system.
  18613. */
  18614. animations: Animation[];
  18615. /**
  18616. * The id of the Particle system.
  18617. */
  18618. id: string;
  18619. /**
  18620. * The name of the Particle system.
  18621. */
  18622. name: string;
  18623. /**
  18624. * The emitter represents the Mesh or position we are attaching the particle system to.
  18625. */
  18626. emitter: Nullable<AbstractMesh | Vector3>;
  18627. /**
  18628. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18629. */
  18630. isBillboardBased: boolean;
  18631. /**
  18632. * The rendering group used by the Particle system to chose when to render.
  18633. */
  18634. renderingGroupId: number;
  18635. /**
  18636. * The layer mask we are rendering the particles through.
  18637. */
  18638. layerMask: number;
  18639. /**
  18640. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18641. */
  18642. updateSpeed: number;
  18643. /**
  18644. * The amount of time the particle system is running (depends of the overall update speed).
  18645. */
  18646. targetStopDuration: number;
  18647. /**
  18648. * The texture used to render each particle. (this can be a spritesheet)
  18649. */
  18650. particleTexture: Nullable<Texture>;
  18651. /**
  18652. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18653. */
  18654. blendMode: number;
  18655. /**
  18656. * Minimum life time of emitting particles.
  18657. */
  18658. minLifeTime: number;
  18659. /**
  18660. * Maximum life time of emitting particles.
  18661. */
  18662. maxLifeTime: number;
  18663. /**
  18664. * Minimum Size of emitting particles.
  18665. */
  18666. minSize: number;
  18667. /**
  18668. * Maximum Size of emitting particles.
  18669. */
  18670. maxSize: number;
  18671. /**
  18672. * Minimum scale of emitting particles on X axis.
  18673. */
  18674. minScaleX: number;
  18675. /**
  18676. * Maximum scale of emitting particles on X axis.
  18677. */
  18678. maxScaleX: number;
  18679. /**
  18680. * Minimum scale of emitting particles on Y axis.
  18681. */
  18682. minScaleY: number;
  18683. /**
  18684. * Maximum scale of emitting particles on Y axis.
  18685. */
  18686. maxScaleY: number;
  18687. /**
  18688. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18689. */
  18690. color1: Color4;
  18691. /**
  18692. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18693. */
  18694. color2: Color4;
  18695. /**
  18696. * Color the particle will have at the end of its lifetime.
  18697. */
  18698. colorDead: Color4;
  18699. /**
  18700. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18701. */
  18702. emitRate: number;
  18703. /**
  18704. * You can use gravity if you want to give an orientation to your particles.
  18705. */
  18706. gravity: Vector3;
  18707. /**
  18708. * Minimum power of emitting particles.
  18709. */
  18710. minEmitPower: number;
  18711. /**
  18712. * Maximum power of emitting particles.
  18713. */
  18714. maxEmitPower: number;
  18715. /**
  18716. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18717. */
  18718. minAngularSpeed: number;
  18719. /**
  18720. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18721. */
  18722. maxAngularSpeed: number;
  18723. /**
  18724. * Gets or sets the minimal initial rotation in radians.
  18725. */
  18726. minInitialRotation: number;
  18727. /**
  18728. * Gets or sets the maximal initial rotation in radians.
  18729. */
  18730. maxInitialRotation: number;
  18731. /**
  18732. * The particle emitter type defines the emitter used by the particle system.
  18733. * It can be for example box, sphere, or cone...
  18734. */
  18735. particleEmitterType: Nullable<IParticleEmitterType>;
  18736. /**
  18737. * Defines the delay in milliseconds before starting the system (0 by default)
  18738. */
  18739. startDelay: number;
  18740. /**
  18741. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  18742. */
  18743. preWarmCycles: number;
  18744. /**
  18745. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18746. */
  18747. preWarmStepOffset: number;
  18748. /**
  18749. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  18750. */
  18751. spriteCellChangeSpeed: number;
  18752. /**
  18753. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18754. */
  18755. startSpriteCellID: number;
  18756. /**
  18757. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18758. */
  18759. endSpriteCellID: number;
  18760. /**
  18761. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18762. */
  18763. spriteCellWidth: number;
  18764. /**
  18765. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18766. */
  18767. spriteCellHeight: number;
  18768. /**
  18769. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18770. */
  18771. spriteRandomStartCell: boolean;
  18772. /**
  18773. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18774. */
  18775. isAnimationSheetEnabled: boolean;
  18776. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18777. translationPivot: Vector2;
  18778. /**
  18779. * Gets or sets a texture used to add random noise to particle positions
  18780. */
  18781. noiseTexture: Nullable<BaseTexture>;
  18782. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18783. noiseStrength: Vector3;
  18784. /**
  18785. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18786. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18787. */
  18788. billboardMode: number;
  18789. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18790. limitVelocityDamping: number;
  18791. /**
  18792. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18793. */
  18794. beginAnimationOnStart: boolean;
  18795. /**
  18796. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18797. */
  18798. beginAnimationFrom: number;
  18799. /**
  18800. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18801. */
  18802. beginAnimationTo: number;
  18803. /**
  18804. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18805. */
  18806. beginAnimationLoop: boolean;
  18807. /**
  18808. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18809. */
  18810. disposeOnStop: boolean;
  18811. /**
  18812. * Gets the maximum number of particles active at the same time.
  18813. * @returns The max number of active particles.
  18814. */
  18815. getCapacity(): number;
  18816. /**
  18817. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18818. * @returns True if it has been started, otherwise false.
  18819. */
  18820. isStarted(): boolean;
  18821. /**
  18822. * Animates the particle system for this frame.
  18823. */
  18824. animate(): void;
  18825. /**
  18826. * Renders the particle system in its current state.
  18827. * @returns the current number of particles
  18828. */
  18829. render(): number;
  18830. /**
  18831. * Dispose the particle system and frees its associated resources.
  18832. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18833. */
  18834. dispose(disposeTexture?: boolean): void;
  18835. /**
  18836. * Clones the particle system.
  18837. * @param name The name of the cloned object
  18838. * @param newEmitter The new emitter to use
  18839. * @returns the cloned particle system
  18840. */
  18841. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18842. /**
  18843. * Serializes the particle system to a JSON object.
  18844. * @returns the JSON object
  18845. */
  18846. serialize(): any;
  18847. /**
  18848. * Rebuild the particle system
  18849. */
  18850. rebuild(): void;
  18851. /**
  18852. * Starts the particle system and begins to emit
  18853. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18854. */
  18855. start(delay?: number): void;
  18856. /**
  18857. * Stops the particle system.
  18858. */
  18859. stop(): void;
  18860. /**
  18861. * Remove all active particles
  18862. */
  18863. reset(): void;
  18864. /**
  18865. * Is this system ready to be used/rendered
  18866. * @return true if the system is ready
  18867. */
  18868. isReady(): boolean;
  18869. /**
  18870. * Adds a new color gradient
  18871. * @param gradient defines the gradient to use (between 0 and 1)
  18872. * @param color1 defines the color to affect to the specified gradient
  18873. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18874. * @returns the current particle system
  18875. */
  18876. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18877. /**
  18878. * Remove a specific color gradient
  18879. * @param gradient defines the gradient to remove
  18880. * @returns the current particle system
  18881. */
  18882. removeColorGradient(gradient: number): IParticleSystem;
  18883. /**
  18884. * Adds a new size gradient
  18885. * @param gradient defines the gradient to use (between 0 and 1)
  18886. * @param factor defines the size factor to affect to the specified gradient
  18887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18888. * @returns the current particle system
  18889. */
  18890. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18891. /**
  18892. * Remove a specific size gradient
  18893. * @param gradient defines the gradient to remove
  18894. * @returns the current particle system
  18895. */
  18896. removeSizeGradient(gradient: number): IParticleSystem;
  18897. /**
  18898. * Gets the current list of color gradients.
  18899. * You must use addColorGradient and removeColorGradient to udpate this list
  18900. * @returns the list of color gradients
  18901. */
  18902. getColorGradients(): Nullable<Array<ColorGradient>>;
  18903. /**
  18904. * Gets the current list of size gradients.
  18905. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18906. * @returns the list of size gradients
  18907. */
  18908. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18909. /**
  18910. * Gets the current list of angular speed gradients.
  18911. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18912. * @returns the list of angular speed gradients
  18913. */
  18914. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18915. /**
  18916. * Adds a new angular speed gradient
  18917. * @param gradient defines the gradient to use (between 0 and 1)
  18918. * @param factor defines the angular speed to affect to the specified gradient
  18919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18920. * @returns the current particle system
  18921. */
  18922. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18923. /**
  18924. * Remove a specific angular speed gradient
  18925. * @param gradient defines the gradient to remove
  18926. * @returns the current particle system
  18927. */
  18928. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18929. /**
  18930. * Gets the current list of velocity gradients.
  18931. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18932. * @returns the list of velocity gradients
  18933. */
  18934. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18935. /**
  18936. * Adds a new velocity gradient
  18937. * @param gradient defines the gradient to use (between 0 and 1)
  18938. * @param factor defines the velocity to affect to the specified gradient
  18939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18940. * @returns the current particle system
  18941. */
  18942. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18943. /**
  18944. * Remove a specific velocity gradient
  18945. * @param gradient defines the gradient to remove
  18946. * @returns the current particle system
  18947. */
  18948. removeVelocityGradient(gradient: number): IParticleSystem;
  18949. /**
  18950. * Gets the current list of limit velocity gradients.
  18951. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18952. * @returns the list of limit velocity gradients
  18953. */
  18954. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18955. /**
  18956. * Adds a new limit velocity gradient
  18957. * @param gradient defines the gradient to use (between 0 and 1)
  18958. * @param factor defines the limit velocity to affect to the specified gradient
  18959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18960. * @returns the current particle system
  18961. */
  18962. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18963. /**
  18964. * Remove a specific limit velocity gradient
  18965. * @param gradient defines the gradient to remove
  18966. * @returns the current particle system
  18967. */
  18968. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18969. /**
  18970. * Adds a new drag gradient
  18971. * @param gradient defines the gradient to use (between 0 and 1)
  18972. * @param factor defines the drag to affect to the specified gradient
  18973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18974. * @returns the current particle system
  18975. */
  18976. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18977. /**
  18978. * Remove a specific drag gradient
  18979. * @param gradient defines the gradient to remove
  18980. * @returns the current particle system
  18981. */
  18982. removeDragGradient(gradient: number): IParticleSystem;
  18983. /**
  18984. * Gets the current list of drag gradients.
  18985. * You must use addDragGradient and removeDragGradient to udpate this list
  18986. * @returns the list of drag gradients
  18987. */
  18988. getDragGradients(): Nullable<Array<FactorGradient>>;
  18989. /**
  18990. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18991. * @param gradient defines the gradient to use (between 0 and 1)
  18992. * @param factor defines the emit rate to affect to the specified gradient
  18993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18994. * @returns the current particle system
  18995. */
  18996. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18997. /**
  18998. * Remove a specific emit rate gradient
  18999. * @param gradient defines the gradient to remove
  19000. * @returns the current particle system
  19001. */
  19002. removeEmitRateGradient(gradient: number): IParticleSystem;
  19003. /**
  19004. * Gets the current list of emit rate gradients.
  19005. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19006. * @returns the list of emit rate gradients
  19007. */
  19008. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19009. /**
  19010. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19011. * @param gradient defines the gradient to use (between 0 and 1)
  19012. * @param factor defines the start size to affect to the specified gradient
  19013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19014. * @returns the current particle system
  19015. */
  19016. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19017. /**
  19018. * Remove a specific start size gradient
  19019. * @param gradient defines the gradient to remove
  19020. * @returns the current particle system
  19021. */
  19022. removeStartSizeGradient(gradient: number): IParticleSystem;
  19023. /**
  19024. * Gets the current list of start size gradients.
  19025. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19026. * @returns the list of start size gradients
  19027. */
  19028. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19029. /**
  19030. * Adds a new life time gradient
  19031. * @param gradient defines the gradient to use (between 0 and 1)
  19032. * @param factor defines the life time factor to affect to the specified gradient
  19033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19034. * @returns the current particle system
  19035. */
  19036. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19037. /**
  19038. * Remove a specific life time gradient
  19039. * @param gradient defines the gradient to remove
  19040. * @returns the current particle system
  19041. */
  19042. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19043. /**
  19044. * Gets the current list of life time gradients.
  19045. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19046. * @returns the list of life time gradients
  19047. */
  19048. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19049. /**
  19050. * Gets the current list of color gradients.
  19051. * You must use addColorGradient and removeColorGradient to udpate this list
  19052. * @returns the list of color gradients
  19053. */
  19054. getColorGradients(): Nullable<Array<ColorGradient>>;
  19055. /**
  19056. * Adds a new ramp gradient used to remap particle colors
  19057. * @param gradient defines the gradient to use (between 0 and 1)
  19058. * @param color defines the color to affect to the specified gradient
  19059. * @returns the current particle system
  19060. */
  19061. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19062. /**
  19063. * Gets the current list of ramp gradients.
  19064. * You must use addRampGradient and removeRampGradient to udpate this list
  19065. * @returns the list of ramp gradients
  19066. */
  19067. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19068. /** Gets or sets a boolean indicating that ramp gradients must be used
  19069. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19070. */
  19071. useRampGradients: boolean;
  19072. /**
  19073. * Adds a new color remap gradient
  19074. * @param gradient defines the gradient to use (between 0 and 1)
  19075. * @param min defines the color remap minimal range
  19076. * @param max defines the color remap maximal range
  19077. * @returns the current particle system
  19078. */
  19079. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19080. /**
  19081. * Gets the current list of color remap gradients.
  19082. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19083. * @returns the list of color remap gradients
  19084. */
  19085. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19086. /**
  19087. * Adds a new alpha remap gradient
  19088. * @param gradient defines the gradient to use (between 0 and 1)
  19089. * @param min defines the alpha remap minimal range
  19090. * @param max defines the alpha remap maximal range
  19091. * @returns the current particle system
  19092. */
  19093. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19094. /**
  19095. * Gets the current list of alpha remap gradients.
  19096. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19097. * @returns the list of alpha remap gradients
  19098. */
  19099. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19100. /**
  19101. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19102. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19103. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19104. * @returns the emitter
  19105. */
  19106. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19107. /**
  19108. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19109. * @param radius The radius of the hemisphere to emit from
  19110. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19111. * @returns the emitter
  19112. */
  19113. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19114. /**
  19115. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19116. * @param radius The radius of the sphere to emit from
  19117. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19118. * @returns the emitter
  19119. */
  19120. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19121. /**
  19122. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19123. * @param radius The radius of the sphere to emit from
  19124. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19125. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19126. * @returns the emitter
  19127. */
  19128. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19129. /**
  19130. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19131. * @param radius The radius of the emission cylinder
  19132. * @param height The height of the emission cylinder
  19133. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19134. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19135. * @returns the emitter
  19136. */
  19137. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19138. /**
  19139. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19140. * @param radius The radius of the cylinder to emit from
  19141. * @param height The height of the emission cylinder
  19142. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19143. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19144. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19145. * @returns the emitter
  19146. */
  19147. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19148. /**
  19149. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19150. * @param radius The radius of the cone to emit from
  19151. * @param angle The base angle of the cone
  19152. * @returns the emitter
  19153. */
  19154. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19155. /**
  19156. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19157. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19158. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19159. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19160. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19161. * @returns the emitter
  19162. */
  19163. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19164. /**
  19165. * Get hosting scene
  19166. * @returns the scene
  19167. */
  19168. getScene(): Scene;
  19169. }
  19170. }
  19171. declare module "babylonjs/Meshes/instancedMesh" {
  19172. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19173. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19174. import { Camera } from "babylonjs/Cameras/camera";
  19175. import { Node } from "babylonjs/node";
  19176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19177. import { Mesh } from "babylonjs/Meshes/mesh";
  19178. import { Material } from "babylonjs/Materials/material";
  19179. import { Skeleton } from "babylonjs/Bones/skeleton";
  19180. import { Light } from "babylonjs/Lights/light";
  19181. /**
  19182. * Creates an instance based on a source mesh.
  19183. */
  19184. export class InstancedMesh extends AbstractMesh {
  19185. private _sourceMesh;
  19186. private _currentLOD;
  19187. /** @hidden */
  19188. _indexInSourceMeshInstanceArray: number;
  19189. constructor(name: string, source: Mesh);
  19190. /**
  19191. * Returns the string "InstancedMesh".
  19192. */
  19193. getClassName(): string;
  19194. /** Gets the list of lights affecting that mesh */
  19195. readonly lightSources: Light[];
  19196. _resyncLightSources(): void;
  19197. _resyncLighSource(light: Light): void;
  19198. _removeLightSource(light: Light, dispose: boolean): void;
  19199. /**
  19200. * If the source mesh receives shadows
  19201. */
  19202. readonly receiveShadows: boolean;
  19203. /**
  19204. * The material of the source mesh
  19205. */
  19206. readonly material: Nullable<Material>;
  19207. /**
  19208. * Visibility of the source mesh
  19209. */
  19210. readonly visibility: number;
  19211. /**
  19212. * Skeleton of the source mesh
  19213. */
  19214. readonly skeleton: Nullable<Skeleton>;
  19215. /**
  19216. * Rendering ground id of the source mesh
  19217. */
  19218. renderingGroupId: number;
  19219. /**
  19220. * Returns the total number of vertices (integer).
  19221. */
  19222. getTotalVertices(): number;
  19223. /**
  19224. * Returns a positive integer : the total number of indices in this mesh geometry.
  19225. * @returns the numner of indices or zero if the mesh has no geometry.
  19226. */
  19227. getTotalIndices(): number;
  19228. /**
  19229. * The source mesh of the instance
  19230. */
  19231. readonly sourceMesh: Mesh;
  19232. /**
  19233. * Is this node ready to be used/rendered
  19234. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19235. * @return {boolean} is it ready
  19236. */
  19237. isReady(completeCheck?: boolean): boolean;
  19238. /**
  19239. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19240. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19241. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  19242. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19243. */
  19244. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19245. /**
  19246. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19247. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19248. * The `data` are either a numeric array either a Float32Array.
  19249. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19250. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  19251. * Note that a new underlying VertexBuffer object is created each call.
  19252. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19253. *
  19254. * Possible `kind` values :
  19255. * - VertexBuffer.PositionKind
  19256. * - VertexBuffer.UVKind
  19257. * - VertexBuffer.UV2Kind
  19258. * - VertexBuffer.UV3Kind
  19259. * - VertexBuffer.UV4Kind
  19260. * - VertexBuffer.UV5Kind
  19261. * - VertexBuffer.UV6Kind
  19262. * - VertexBuffer.ColorKind
  19263. * - VertexBuffer.MatricesIndicesKind
  19264. * - VertexBuffer.MatricesIndicesExtraKind
  19265. * - VertexBuffer.MatricesWeightsKind
  19266. * - VertexBuffer.MatricesWeightsExtraKind
  19267. *
  19268. * Returns the Mesh.
  19269. */
  19270. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19271. /**
  19272. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19273. * If the mesh has no geometry, it is simply returned as it is.
  19274. * The `data` are either a numeric array either a Float32Array.
  19275. * No new underlying VertexBuffer object is created.
  19276. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19277. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19278. *
  19279. * Possible `kind` values :
  19280. * - VertexBuffer.PositionKind
  19281. * - VertexBuffer.UVKind
  19282. * - VertexBuffer.UV2Kind
  19283. * - VertexBuffer.UV3Kind
  19284. * - VertexBuffer.UV4Kind
  19285. * - VertexBuffer.UV5Kind
  19286. * - VertexBuffer.UV6Kind
  19287. * - VertexBuffer.ColorKind
  19288. * - VertexBuffer.MatricesIndicesKind
  19289. * - VertexBuffer.MatricesIndicesExtraKind
  19290. * - VertexBuffer.MatricesWeightsKind
  19291. * - VertexBuffer.MatricesWeightsExtraKind
  19292. *
  19293. * Returns the Mesh.
  19294. */
  19295. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19296. /**
  19297. * Sets the mesh indices.
  19298. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19299. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19300. * This method creates a new index buffer each call.
  19301. * Returns the Mesh.
  19302. */
  19303. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19304. /**
  19305. * Boolean : True if the mesh owns the requested kind of data.
  19306. */
  19307. isVerticesDataPresent(kind: string): boolean;
  19308. /**
  19309. * Returns an array of indices (IndicesArray).
  19310. */
  19311. getIndices(): Nullable<IndicesArray>;
  19312. readonly _positions: Nullable<Vector3[]>;
  19313. /**
  19314. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19315. * This means the mesh underlying bounding box and sphere are recomputed.
  19316. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19317. * @returns the current mesh
  19318. */
  19319. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19320. /** @hidden */
  19321. _preActivate(): InstancedMesh;
  19322. /** @hidden */
  19323. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19324. /** @hidden */
  19325. _postActivate(): void;
  19326. getWorldMatrix(): Matrix;
  19327. readonly isAnInstance: boolean;
  19328. /**
  19329. * Returns the current associated LOD AbstractMesh.
  19330. */
  19331. getLOD(camera: Camera): AbstractMesh;
  19332. /** @hidden */
  19333. _syncSubMeshes(): InstancedMesh;
  19334. /** @hidden */
  19335. _generatePointsArray(): boolean;
  19336. /**
  19337. * Creates a new InstancedMesh from the current mesh.
  19338. * - name (string) : the cloned mesh name
  19339. * - newParent (optional Node) : the optional Node to parent the clone to.
  19340. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19341. *
  19342. * Returns the clone.
  19343. */
  19344. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19345. /**
  19346. * Disposes the InstancedMesh.
  19347. * Returns nothing.
  19348. */
  19349. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19350. }
  19351. }
  19352. declare module "babylonjs/Materials/shaderMaterial" {
  19353. import { Scene } from "babylonjs/scene";
  19354. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19356. import { Mesh } from "babylonjs/Meshes/mesh";
  19357. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19359. import { Texture } from "babylonjs/Materials/Textures/texture";
  19360. import { Material } from "babylonjs/Materials/material";
  19361. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19362. /**
  19363. * Defines the options associated with the creation of a shader material.
  19364. */
  19365. export interface IShaderMaterialOptions {
  19366. /**
  19367. * Does the material work in alpha blend mode
  19368. */
  19369. needAlphaBlending: boolean;
  19370. /**
  19371. * Does the material work in alpha test mode
  19372. */
  19373. needAlphaTesting: boolean;
  19374. /**
  19375. * The list of attribute names used in the shader
  19376. */
  19377. attributes: string[];
  19378. /**
  19379. * The list of unifrom names used in the shader
  19380. */
  19381. uniforms: string[];
  19382. /**
  19383. * The list of UBO names used in the shader
  19384. */
  19385. uniformBuffers: string[];
  19386. /**
  19387. * The list of sampler names used in the shader
  19388. */
  19389. samplers: string[];
  19390. /**
  19391. * The list of defines used in the shader
  19392. */
  19393. defines: string[];
  19394. }
  19395. /**
  19396. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19397. *
  19398. * This returned material effects how the mesh will look based on the code in the shaders.
  19399. *
  19400. * @see http://doc.babylonjs.com/how_to/shader_material
  19401. */
  19402. export class ShaderMaterial extends Material {
  19403. private _shaderPath;
  19404. private _options;
  19405. private _textures;
  19406. private _textureArrays;
  19407. private _floats;
  19408. private _ints;
  19409. private _floatsArrays;
  19410. private _colors3;
  19411. private _colors3Arrays;
  19412. private _colors4;
  19413. private _colors4Arrays;
  19414. private _vectors2;
  19415. private _vectors3;
  19416. private _vectors4;
  19417. private _matrices;
  19418. private _matrices3x3;
  19419. private _matrices2x2;
  19420. private _vectors2Arrays;
  19421. private _vectors3Arrays;
  19422. private _vectors4Arrays;
  19423. private _cachedWorldViewMatrix;
  19424. private _cachedWorldViewProjectionMatrix;
  19425. private _renderId;
  19426. /**
  19427. * Instantiate a new shader material.
  19428. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19429. * This returned material effects how the mesh will look based on the code in the shaders.
  19430. * @see http://doc.babylonjs.com/how_to/shader_material
  19431. * @param name Define the name of the material in the scene
  19432. * @param scene Define the scene the material belongs to
  19433. * @param shaderPath Defines the route to the shader code in one of three ways:
  19434. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19435. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19436. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19437. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19438. * @param options Define the options used to create the shader
  19439. */
  19440. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19441. /**
  19442. * Gets the options used to compile the shader.
  19443. * They can be modified to trigger a new compilation
  19444. */
  19445. readonly options: IShaderMaterialOptions;
  19446. /**
  19447. * Gets the current class name of the material e.g. "ShaderMaterial"
  19448. * Mainly use in serialization.
  19449. * @returns the class name
  19450. */
  19451. getClassName(): string;
  19452. /**
  19453. * Specifies if the material will require alpha blending
  19454. * @returns a boolean specifying if alpha blending is needed
  19455. */
  19456. needAlphaBlending(): boolean;
  19457. /**
  19458. * Specifies if this material should be rendered in alpha test mode
  19459. * @returns a boolean specifying if an alpha test is needed.
  19460. */
  19461. needAlphaTesting(): boolean;
  19462. private _checkUniform;
  19463. /**
  19464. * Set a texture in the shader.
  19465. * @param name Define the name of the uniform samplers as defined in the shader
  19466. * @param texture Define the texture to bind to this sampler
  19467. * @return the material itself allowing "fluent" like uniform updates
  19468. */
  19469. setTexture(name: string, texture: Texture): ShaderMaterial;
  19470. /**
  19471. * Set a texture array in the shader.
  19472. * @param name Define the name of the uniform sampler array as defined in the shader
  19473. * @param textures Define the list of textures to bind to this sampler
  19474. * @return the material itself allowing "fluent" like uniform updates
  19475. */
  19476. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19477. /**
  19478. * Set a float in the shader.
  19479. * @param name Define the name of the uniform as defined in the shader
  19480. * @param value Define the value to give to the uniform
  19481. * @return the material itself allowing "fluent" like uniform updates
  19482. */
  19483. setFloat(name: string, value: number): ShaderMaterial;
  19484. /**
  19485. * Set a int in the shader.
  19486. * @param name Define the name of the uniform as defined in the shader
  19487. * @param value Define the value to give to the uniform
  19488. * @return the material itself allowing "fluent" like uniform updates
  19489. */
  19490. setInt(name: string, value: number): ShaderMaterial;
  19491. /**
  19492. * Set an array of floats in the shader.
  19493. * @param name Define the name of the uniform as defined in the shader
  19494. * @param value Define the value to give to the uniform
  19495. * @return the material itself allowing "fluent" like uniform updates
  19496. */
  19497. setFloats(name: string, value: number[]): ShaderMaterial;
  19498. /**
  19499. * Set a vec3 in the shader from a Color3.
  19500. * @param name Define the name of the uniform as defined in the shader
  19501. * @param value Define the value to give to the uniform
  19502. * @return the material itself allowing "fluent" like uniform updates
  19503. */
  19504. setColor3(name: string, value: Color3): ShaderMaterial;
  19505. /**
  19506. * Set a vec3 array in the shader from a Color3 array.
  19507. * @param name Define the name of the uniform as defined in the shader
  19508. * @param value Define the value to give to the uniform
  19509. * @return the material itself allowing "fluent" like uniform updates
  19510. */
  19511. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19512. /**
  19513. * Set a vec4 in the shader from a Color4.
  19514. * @param name Define the name of the uniform as defined in the shader
  19515. * @param value Define the value to give to the uniform
  19516. * @return the material itself allowing "fluent" like uniform updates
  19517. */
  19518. setColor4(name: string, value: Color4): ShaderMaterial;
  19519. /**
  19520. * Set a vec4 array in the shader from a Color4 array.
  19521. * @param name Define the name of the uniform as defined in the shader
  19522. * @param value Define the value to give to the uniform
  19523. * @return the material itself allowing "fluent" like uniform updates
  19524. */
  19525. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19526. /**
  19527. * Set a vec2 in the shader from a Vector2.
  19528. * @param name Define the name of the uniform as defined in the shader
  19529. * @param value Define the value to give to the uniform
  19530. * @return the material itself allowing "fluent" like uniform updates
  19531. */
  19532. setVector2(name: string, value: Vector2): ShaderMaterial;
  19533. /**
  19534. * Set a vec3 in the shader from a Vector3.
  19535. * @param name Define the name of the uniform as defined in the shader
  19536. * @param value Define the value to give to the uniform
  19537. * @return the material itself allowing "fluent" like uniform updates
  19538. */
  19539. setVector3(name: string, value: Vector3): ShaderMaterial;
  19540. /**
  19541. * Set a vec4 in the shader from a Vector4.
  19542. * @param name Define the name of the uniform as defined in the shader
  19543. * @param value Define the value to give to the uniform
  19544. * @return the material itself allowing "fluent" like uniform updates
  19545. */
  19546. setVector4(name: string, value: Vector4): ShaderMaterial;
  19547. /**
  19548. * Set a mat4 in the shader from a Matrix.
  19549. * @param name Define the name of the uniform as defined in the shader
  19550. * @param value Define the value to give to the uniform
  19551. * @return the material itself allowing "fluent" like uniform updates
  19552. */
  19553. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19554. /**
  19555. * Set a mat3 in the shader from a Float32Array.
  19556. * @param name Define the name of the uniform as defined in the shader
  19557. * @param value Define the value to give to the uniform
  19558. * @return the material itself allowing "fluent" like uniform updates
  19559. */
  19560. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19561. /**
  19562. * Set a mat2 in the shader from a Float32Array.
  19563. * @param name Define the name of the uniform as defined in the shader
  19564. * @param value Define the value to give to the uniform
  19565. * @return the material itself allowing "fluent" like uniform updates
  19566. */
  19567. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19568. /**
  19569. * Set a vec2 array in the shader from a number array.
  19570. * @param name Define the name of the uniform as defined in the shader
  19571. * @param value Define the value to give to the uniform
  19572. * @return the material itself allowing "fluent" like uniform updates
  19573. */
  19574. setArray2(name: string, value: number[]): ShaderMaterial;
  19575. /**
  19576. * Set a vec3 array in the shader from a number array.
  19577. * @param name Define the name of the uniform as defined in the shader
  19578. * @param value Define the value to give to the uniform
  19579. * @return the material itself allowing "fluent" like uniform updates
  19580. */
  19581. setArray3(name: string, value: number[]): ShaderMaterial;
  19582. /**
  19583. * Set a vec4 array in the shader from a number array.
  19584. * @param name Define the name of the uniform as defined in the shader
  19585. * @param value Define the value to give to the uniform
  19586. * @return the material itself allowing "fluent" like uniform updates
  19587. */
  19588. setArray4(name: string, value: number[]): ShaderMaterial;
  19589. private _checkCache;
  19590. /**
  19591. * Specifies that the submesh is ready to be used
  19592. * @param mesh defines the mesh to check
  19593. * @param subMesh defines which submesh to check
  19594. * @param useInstances specifies that instances should be used
  19595. * @returns a boolean indicating that the submesh is ready or not
  19596. */
  19597. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19598. /**
  19599. * Checks if the material is ready to render the requested mesh
  19600. * @param mesh Define the mesh to render
  19601. * @param useInstances Define whether or not the material is used with instances
  19602. * @returns true if ready, otherwise false
  19603. */
  19604. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19605. /**
  19606. * Binds the world matrix to the material
  19607. * @param world defines the world transformation matrix
  19608. */
  19609. bindOnlyWorldMatrix(world: Matrix): void;
  19610. /**
  19611. * Binds the material to the mesh
  19612. * @param world defines the world transformation matrix
  19613. * @param mesh defines the mesh to bind the material to
  19614. */
  19615. bind(world: Matrix, mesh?: Mesh): void;
  19616. /**
  19617. * Gets the active textures from the material
  19618. * @returns an array of textures
  19619. */
  19620. getActiveTextures(): BaseTexture[];
  19621. /**
  19622. * Specifies if the material uses a texture
  19623. * @param texture defines the texture to check against the material
  19624. * @returns a boolean specifying if the material uses the texture
  19625. */
  19626. hasTexture(texture: BaseTexture): boolean;
  19627. /**
  19628. * Makes a duplicate of the material, and gives it a new name
  19629. * @param name defines the new name for the duplicated material
  19630. * @returns the cloned material
  19631. */
  19632. clone(name: string): ShaderMaterial;
  19633. /**
  19634. * Disposes the material
  19635. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19636. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19637. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19638. */
  19639. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19640. /**
  19641. * Serializes this material in a JSON representation
  19642. * @returns the serialized material object
  19643. */
  19644. serialize(): any;
  19645. /**
  19646. * Creates a shader material from parsed shader material data
  19647. * @param source defines the JSON represnetation of the material
  19648. * @param scene defines the hosting scene
  19649. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19650. * @returns a new material
  19651. */
  19652. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19653. }
  19654. }
  19655. declare module "babylonjs/Shaders/color.fragment" {
  19656. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19657. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19658. /** @hidden */
  19659. export var colorPixelShader: {
  19660. name: string;
  19661. shader: string;
  19662. };
  19663. }
  19664. declare module "babylonjs/Shaders/color.vertex" {
  19665. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19666. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19667. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19668. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19669. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19670. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19671. /** @hidden */
  19672. export var colorVertexShader: {
  19673. name: string;
  19674. shader: string;
  19675. };
  19676. }
  19677. declare module "babylonjs/Meshes/linesMesh" {
  19678. import { Nullable } from "babylonjs/types";
  19679. import { Scene } from "babylonjs/scene";
  19680. import { Color3 } from "babylonjs/Maths/math.color";
  19681. import { Node } from "babylonjs/node";
  19682. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19683. import { Mesh } from "babylonjs/Meshes/mesh";
  19684. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19685. import { Effect } from "babylonjs/Materials/effect";
  19686. import { Material } from "babylonjs/Materials/material";
  19687. import "babylonjs/Shaders/color.fragment";
  19688. import "babylonjs/Shaders/color.vertex";
  19689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19690. /**
  19691. * Line mesh
  19692. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19693. */
  19694. export class LinesMesh extends Mesh {
  19695. /**
  19696. * If vertex color should be applied to the mesh
  19697. */
  19698. readonly useVertexColor?: boolean | undefined;
  19699. /**
  19700. * If vertex alpha should be applied to the mesh
  19701. */
  19702. readonly useVertexAlpha?: boolean | undefined;
  19703. /**
  19704. * Color of the line (Default: White)
  19705. */
  19706. color: Color3;
  19707. /**
  19708. * Alpha of the line (Default: 1)
  19709. */
  19710. alpha: number;
  19711. /**
  19712. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19713. * This margin is expressed in world space coordinates, so its value may vary.
  19714. * Default value is 0.1
  19715. */
  19716. intersectionThreshold: number;
  19717. private _colorShader;
  19718. private color4;
  19719. /**
  19720. * Creates a new LinesMesh
  19721. * @param name defines the name
  19722. * @param scene defines the hosting scene
  19723. * @param parent defines the parent mesh if any
  19724. * @param source defines the optional source LinesMesh used to clone data from
  19725. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19726. * When false, achieved by calling a clone(), also passing False.
  19727. * This will make creation of children, recursive.
  19728. * @param useVertexColor defines if this LinesMesh supports vertex color
  19729. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19730. */
  19731. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19732. /**
  19733. * If vertex color should be applied to the mesh
  19734. */
  19735. useVertexColor?: boolean | undefined,
  19736. /**
  19737. * If vertex alpha should be applied to the mesh
  19738. */
  19739. useVertexAlpha?: boolean | undefined);
  19740. private _addClipPlaneDefine;
  19741. private _removeClipPlaneDefine;
  19742. isReady(): boolean;
  19743. /**
  19744. * Returns the string "LineMesh"
  19745. */
  19746. getClassName(): string;
  19747. /**
  19748. * @hidden
  19749. */
  19750. /**
  19751. * @hidden
  19752. */
  19753. material: Material;
  19754. /**
  19755. * @hidden
  19756. */
  19757. readonly checkCollisions: boolean;
  19758. /** @hidden */
  19759. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19760. /** @hidden */
  19761. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19762. /**
  19763. * Disposes of the line mesh
  19764. * @param doNotRecurse If children should be disposed
  19765. */
  19766. dispose(doNotRecurse?: boolean): void;
  19767. /**
  19768. * Returns a new LineMesh object cloned from the current one.
  19769. */
  19770. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19771. /**
  19772. * Creates a new InstancedLinesMesh object from the mesh model.
  19773. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19774. * @param name defines the name of the new instance
  19775. * @returns a new InstancedLinesMesh
  19776. */
  19777. createInstance(name: string): InstancedLinesMesh;
  19778. }
  19779. /**
  19780. * Creates an instance based on a source LinesMesh
  19781. */
  19782. export class InstancedLinesMesh extends InstancedMesh {
  19783. /**
  19784. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19785. * This margin is expressed in world space coordinates, so its value may vary.
  19786. * Initilized with the intersectionThreshold value of the source LinesMesh
  19787. */
  19788. intersectionThreshold: number;
  19789. constructor(name: string, source: LinesMesh);
  19790. /**
  19791. * Returns the string "InstancedLinesMesh".
  19792. */
  19793. getClassName(): string;
  19794. }
  19795. }
  19796. declare module "babylonjs/Shaders/line.fragment" {
  19797. /** @hidden */
  19798. export var linePixelShader: {
  19799. name: string;
  19800. shader: string;
  19801. };
  19802. }
  19803. declare module "babylonjs/Shaders/line.vertex" {
  19804. /** @hidden */
  19805. export var lineVertexShader: {
  19806. name: string;
  19807. shader: string;
  19808. };
  19809. }
  19810. declare module "babylonjs/Rendering/edgesRenderer" {
  19811. import { Nullable } from "babylonjs/types";
  19812. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19814. import { Vector3 } from "babylonjs/Maths/math.vector";
  19815. import { IDisposable } from "babylonjs/scene";
  19816. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19817. import "babylonjs/Shaders/line.fragment";
  19818. import "babylonjs/Shaders/line.vertex";
  19819. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19820. module "babylonjs/Meshes/abstractMesh" {
  19821. interface AbstractMesh {
  19822. /**
  19823. * Gets the edgesRenderer associated with the mesh
  19824. */
  19825. edgesRenderer: Nullable<EdgesRenderer>;
  19826. }
  19827. }
  19828. module "babylonjs/Meshes/linesMesh" {
  19829. interface LinesMesh {
  19830. /**
  19831. * Enables the edge rendering mode on the mesh.
  19832. * This mode makes the mesh edges visible
  19833. * @param epsilon defines the maximal distance between two angles to detect a face
  19834. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19835. * @returns the currentAbstractMesh
  19836. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19837. */
  19838. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19839. }
  19840. }
  19841. module "babylonjs/Meshes/linesMesh" {
  19842. interface InstancedLinesMesh {
  19843. /**
  19844. * Enables the edge rendering mode on the mesh.
  19845. * This mode makes the mesh edges visible
  19846. * @param epsilon defines the maximal distance between two angles to detect a face
  19847. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19848. * @returns the current InstancedLinesMesh
  19849. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19850. */
  19851. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19852. }
  19853. }
  19854. /**
  19855. * Defines the minimum contract an Edges renderer should follow.
  19856. */
  19857. export interface IEdgesRenderer extends IDisposable {
  19858. /**
  19859. * Gets or sets a boolean indicating if the edgesRenderer is active
  19860. */
  19861. isEnabled: boolean;
  19862. /**
  19863. * Renders the edges of the attached mesh,
  19864. */
  19865. render(): void;
  19866. /**
  19867. * Checks wether or not the edges renderer is ready to render.
  19868. * @return true if ready, otherwise false.
  19869. */
  19870. isReady(): boolean;
  19871. }
  19872. /**
  19873. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19874. */
  19875. export class EdgesRenderer implements IEdgesRenderer {
  19876. /**
  19877. * Define the size of the edges with an orthographic camera
  19878. */
  19879. edgesWidthScalerForOrthographic: number;
  19880. /**
  19881. * Define the size of the edges with a perspective camera
  19882. */
  19883. edgesWidthScalerForPerspective: number;
  19884. protected _source: AbstractMesh;
  19885. protected _linesPositions: number[];
  19886. protected _linesNormals: number[];
  19887. protected _linesIndices: number[];
  19888. protected _epsilon: number;
  19889. protected _indicesCount: number;
  19890. protected _lineShader: ShaderMaterial;
  19891. protected _ib: DataBuffer;
  19892. protected _buffers: {
  19893. [key: string]: Nullable<VertexBuffer>;
  19894. };
  19895. protected _checkVerticesInsteadOfIndices: boolean;
  19896. private _meshRebuildObserver;
  19897. private _meshDisposeObserver;
  19898. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19899. isEnabled: boolean;
  19900. /**
  19901. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19902. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19903. * @param source Mesh used to create edges
  19904. * @param epsilon sum of angles in adjacency to check for edge
  19905. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19906. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19907. */
  19908. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19909. protected _prepareRessources(): void;
  19910. /** @hidden */
  19911. _rebuild(): void;
  19912. /**
  19913. * Releases the required resources for the edges renderer
  19914. */
  19915. dispose(): void;
  19916. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19917. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19918. /**
  19919. * Checks if the pair of p0 and p1 is en edge
  19920. * @param faceIndex
  19921. * @param edge
  19922. * @param faceNormals
  19923. * @param p0
  19924. * @param p1
  19925. * @private
  19926. */
  19927. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19928. /**
  19929. * push line into the position, normal and index buffer
  19930. * @protected
  19931. */
  19932. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19933. /**
  19934. * Generates lines edges from adjacencjes
  19935. * @private
  19936. */
  19937. _generateEdgesLines(): void;
  19938. /**
  19939. * Checks wether or not the edges renderer is ready to render.
  19940. * @return true if ready, otherwise false.
  19941. */
  19942. isReady(): boolean;
  19943. /**
  19944. * Renders the edges of the attached mesh,
  19945. */
  19946. render(): void;
  19947. }
  19948. /**
  19949. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19950. */
  19951. export class LineEdgesRenderer extends EdgesRenderer {
  19952. /**
  19953. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19954. * @param source LineMesh used to generate edges
  19955. * @param epsilon not important (specified angle for edge detection)
  19956. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19957. */
  19958. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19959. /**
  19960. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19961. */
  19962. _generateEdgesLines(): void;
  19963. }
  19964. }
  19965. declare module "babylonjs/Rendering/renderingGroup" {
  19966. import { SmartArray } from "babylonjs/Misc/smartArray";
  19967. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19969. import { Nullable } from "babylonjs/types";
  19970. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19971. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19972. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19973. import { Material } from "babylonjs/Materials/material";
  19974. import { Scene } from "babylonjs/scene";
  19975. /**
  19976. * This represents the object necessary to create a rendering group.
  19977. * This is exclusively used and created by the rendering manager.
  19978. * To modify the behavior, you use the available helpers in your scene or meshes.
  19979. * @hidden
  19980. */
  19981. export class RenderingGroup {
  19982. index: number;
  19983. private static _zeroVector;
  19984. private _scene;
  19985. private _opaqueSubMeshes;
  19986. private _transparentSubMeshes;
  19987. private _alphaTestSubMeshes;
  19988. private _depthOnlySubMeshes;
  19989. private _particleSystems;
  19990. private _spriteManagers;
  19991. private _opaqueSortCompareFn;
  19992. private _alphaTestSortCompareFn;
  19993. private _transparentSortCompareFn;
  19994. private _renderOpaque;
  19995. private _renderAlphaTest;
  19996. private _renderTransparent;
  19997. /** @hidden */
  19998. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19999. onBeforeTransparentRendering: () => void;
  20000. /**
  20001. * Set the opaque sort comparison function.
  20002. * If null the sub meshes will be render in the order they were created
  20003. */
  20004. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20005. /**
  20006. * Set the alpha test sort comparison function.
  20007. * If null the sub meshes will be render in the order they were created
  20008. */
  20009. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20010. /**
  20011. * Set the transparent sort comparison function.
  20012. * If null the sub meshes will be render in the order they were created
  20013. */
  20014. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20015. /**
  20016. * Creates a new rendering group.
  20017. * @param index The rendering group index
  20018. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20019. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20020. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20021. */
  20022. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20023. /**
  20024. * Render all the sub meshes contained in the group.
  20025. * @param customRenderFunction Used to override the default render behaviour of the group.
  20026. * @returns true if rendered some submeshes.
  20027. */
  20028. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20029. /**
  20030. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20031. * @param subMeshes The submeshes to render
  20032. */
  20033. private renderOpaqueSorted;
  20034. /**
  20035. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20036. * @param subMeshes The submeshes to render
  20037. */
  20038. private renderAlphaTestSorted;
  20039. /**
  20040. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20041. * @param subMeshes The submeshes to render
  20042. */
  20043. private renderTransparentSorted;
  20044. /**
  20045. * Renders the submeshes in a specified order.
  20046. * @param subMeshes The submeshes to sort before render
  20047. * @param sortCompareFn The comparison function use to sort
  20048. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20049. * @param transparent Specifies to activate blending if true
  20050. */
  20051. private static renderSorted;
  20052. /**
  20053. * Renders the submeshes in the order they were dispatched (no sort applied).
  20054. * @param subMeshes The submeshes to render
  20055. */
  20056. private static renderUnsorted;
  20057. /**
  20058. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20059. * are rendered back to front if in the same alpha index.
  20060. *
  20061. * @param a The first submesh
  20062. * @param b The second submesh
  20063. * @returns The result of the comparison
  20064. */
  20065. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20066. /**
  20067. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20068. * are rendered back to front.
  20069. *
  20070. * @param a The first submesh
  20071. * @param b The second submesh
  20072. * @returns The result of the comparison
  20073. */
  20074. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20075. /**
  20076. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20077. * are rendered front to back (prevent overdraw).
  20078. *
  20079. * @param a The first submesh
  20080. * @param b The second submesh
  20081. * @returns The result of the comparison
  20082. */
  20083. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20084. /**
  20085. * Resets the different lists of submeshes to prepare a new frame.
  20086. */
  20087. prepare(): void;
  20088. dispose(): void;
  20089. /**
  20090. * Inserts the submesh in its correct queue depending on its material.
  20091. * @param subMesh The submesh to dispatch
  20092. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20093. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20094. */
  20095. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20096. dispatchSprites(spriteManager: ISpriteManager): void;
  20097. dispatchParticles(particleSystem: IParticleSystem): void;
  20098. private _renderParticles;
  20099. private _renderSprites;
  20100. }
  20101. }
  20102. declare module "babylonjs/Rendering/renderingManager" {
  20103. import { Nullable } from "babylonjs/types";
  20104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20105. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20106. import { SmartArray } from "babylonjs/Misc/smartArray";
  20107. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20108. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20109. import { Material } from "babylonjs/Materials/material";
  20110. import { Scene } from "babylonjs/scene";
  20111. import { Camera } from "babylonjs/Cameras/camera";
  20112. /**
  20113. * Interface describing the different options available in the rendering manager
  20114. * regarding Auto Clear between groups.
  20115. */
  20116. export interface IRenderingManagerAutoClearSetup {
  20117. /**
  20118. * Defines whether or not autoclear is enable.
  20119. */
  20120. autoClear: boolean;
  20121. /**
  20122. * Defines whether or not to autoclear the depth buffer.
  20123. */
  20124. depth: boolean;
  20125. /**
  20126. * Defines whether or not to autoclear the stencil buffer.
  20127. */
  20128. stencil: boolean;
  20129. }
  20130. /**
  20131. * This class is used by the onRenderingGroupObservable
  20132. */
  20133. export class RenderingGroupInfo {
  20134. /**
  20135. * The Scene that being rendered
  20136. */
  20137. scene: Scene;
  20138. /**
  20139. * The camera currently used for the rendering pass
  20140. */
  20141. camera: Nullable<Camera>;
  20142. /**
  20143. * The ID of the renderingGroup being processed
  20144. */
  20145. renderingGroupId: number;
  20146. }
  20147. /**
  20148. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20149. * It is enable to manage the different groups as well as the different necessary sort functions.
  20150. * This should not be used directly aside of the few static configurations
  20151. */
  20152. export class RenderingManager {
  20153. /**
  20154. * The max id used for rendering groups (not included)
  20155. */
  20156. static MAX_RENDERINGGROUPS: number;
  20157. /**
  20158. * The min id used for rendering groups (included)
  20159. */
  20160. static MIN_RENDERINGGROUPS: number;
  20161. /**
  20162. * Used to globally prevent autoclearing scenes.
  20163. */
  20164. static AUTOCLEAR: boolean;
  20165. /**
  20166. * @hidden
  20167. */
  20168. _useSceneAutoClearSetup: boolean;
  20169. private _scene;
  20170. private _renderingGroups;
  20171. private _depthStencilBufferAlreadyCleaned;
  20172. private _autoClearDepthStencil;
  20173. private _customOpaqueSortCompareFn;
  20174. private _customAlphaTestSortCompareFn;
  20175. private _customTransparentSortCompareFn;
  20176. private _renderingGroupInfo;
  20177. /**
  20178. * Instantiates a new rendering group for a particular scene
  20179. * @param scene Defines the scene the groups belongs to
  20180. */
  20181. constructor(scene: Scene);
  20182. private _clearDepthStencilBuffer;
  20183. /**
  20184. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20185. * @hidden
  20186. */
  20187. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20188. /**
  20189. * Resets the different information of the group to prepare a new frame
  20190. * @hidden
  20191. */
  20192. reset(): void;
  20193. /**
  20194. * Dispose and release the group and its associated resources.
  20195. * @hidden
  20196. */
  20197. dispose(): void;
  20198. /**
  20199. * Clear the info related to rendering groups preventing retention points during dispose.
  20200. */
  20201. freeRenderingGroups(): void;
  20202. private _prepareRenderingGroup;
  20203. /**
  20204. * Add a sprite manager to the rendering manager in order to render it this frame.
  20205. * @param spriteManager Define the sprite manager to render
  20206. */
  20207. dispatchSprites(spriteManager: ISpriteManager): void;
  20208. /**
  20209. * Add a particle system to the rendering manager in order to render it this frame.
  20210. * @param particleSystem Define the particle system to render
  20211. */
  20212. dispatchParticles(particleSystem: IParticleSystem): void;
  20213. /**
  20214. * Add a submesh to the manager in order to render it this frame
  20215. * @param subMesh The submesh to dispatch
  20216. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20217. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20218. */
  20219. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20220. /**
  20221. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20222. * This allowed control for front to back rendering or reversly depending of the special needs.
  20223. *
  20224. * @param renderingGroupId The rendering group id corresponding to its index
  20225. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20226. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20227. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20228. */
  20229. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20230. /**
  20231. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20232. *
  20233. * @param renderingGroupId The rendering group id corresponding to its index
  20234. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20235. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20236. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20237. */
  20238. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20239. /**
  20240. * Gets the current auto clear configuration for one rendering group of the rendering
  20241. * manager.
  20242. * @param index the rendering group index to get the information for
  20243. * @returns The auto clear setup for the requested rendering group
  20244. */
  20245. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20246. }
  20247. }
  20248. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20249. import { Observable } from "babylonjs/Misc/observable";
  20250. import { SmartArray } from "babylonjs/Misc/smartArray";
  20251. import { Nullable } from "babylonjs/types";
  20252. import { Camera } from "babylonjs/Cameras/camera";
  20253. import { Scene } from "babylonjs/scene";
  20254. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20255. import { Color4 } from "babylonjs/Maths/math.color";
  20256. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20260. import { Texture } from "babylonjs/Materials/Textures/texture";
  20261. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20262. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20263. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20264. import { Engine } from "babylonjs/Engines/engine";
  20265. /**
  20266. * This Helps creating a texture that will be created from a camera in your scene.
  20267. * It is basically a dynamic texture that could be used to create special effects for instance.
  20268. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20269. */
  20270. export class RenderTargetTexture extends Texture {
  20271. isCube: boolean;
  20272. /**
  20273. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20274. */
  20275. static readonly REFRESHRATE_RENDER_ONCE: number;
  20276. /**
  20277. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20278. */
  20279. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20280. /**
  20281. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20282. * the central point of your effect and can save a lot of performances.
  20283. */
  20284. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20285. /**
  20286. * Use this predicate to dynamically define the list of mesh you want to render.
  20287. * If set, the renderList property will be overwritten.
  20288. */
  20289. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20290. private _renderList;
  20291. /**
  20292. * Use this list to define the list of mesh you want to render.
  20293. */
  20294. renderList: Nullable<Array<AbstractMesh>>;
  20295. private _hookArray;
  20296. /**
  20297. * Define if particles should be rendered in your texture.
  20298. */
  20299. renderParticles: boolean;
  20300. /**
  20301. * Define if sprites should be rendered in your texture.
  20302. */
  20303. renderSprites: boolean;
  20304. /**
  20305. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20306. */
  20307. coordinatesMode: number;
  20308. /**
  20309. * Define the camera used to render the texture.
  20310. */
  20311. activeCamera: Nullable<Camera>;
  20312. /**
  20313. * Override the render function of the texture with your own one.
  20314. */
  20315. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20316. /**
  20317. * Define if camera post processes should be use while rendering the texture.
  20318. */
  20319. useCameraPostProcesses: boolean;
  20320. /**
  20321. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20322. */
  20323. ignoreCameraViewport: boolean;
  20324. private _postProcessManager;
  20325. private _postProcesses;
  20326. private _resizeObserver;
  20327. /**
  20328. * An event triggered when the texture is unbind.
  20329. */
  20330. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20331. /**
  20332. * An event triggered when the texture is unbind.
  20333. */
  20334. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20335. private _onAfterUnbindObserver;
  20336. /**
  20337. * Set a after unbind callback in the texture.
  20338. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20339. */
  20340. onAfterUnbind: () => void;
  20341. /**
  20342. * An event triggered before rendering the texture
  20343. */
  20344. onBeforeRenderObservable: Observable<number>;
  20345. private _onBeforeRenderObserver;
  20346. /**
  20347. * Set a before render callback in the texture.
  20348. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20349. */
  20350. onBeforeRender: (faceIndex: number) => void;
  20351. /**
  20352. * An event triggered after rendering the texture
  20353. */
  20354. onAfterRenderObservable: Observable<number>;
  20355. private _onAfterRenderObserver;
  20356. /**
  20357. * Set a after render callback in the texture.
  20358. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20359. */
  20360. onAfterRender: (faceIndex: number) => void;
  20361. /**
  20362. * An event triggered after the texture clear
  20363. */
  20364. onClearObservable: Observable<Engine>;
  20365. private _onClearObserver;
  20366. /**
  20367. * Set a clear callback in the texture.
  20368. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20369. */
  20370. onClear: (Engine: Engine) => void;
  20371. /**
  20372. * An event triggered when the texture is resized.
  20373. */
  20374. onResizeObservable: Observable<RenderTargetTexture>;
  20375. /**
  20376. * Define the clear color of the Render Target if it should be different from the scene.
  20377. */
  20378. clearColor: Color4;
  20379. protected _size: number | {
  20380. width: number;
  20381. height: number;
  20382. };
  20383. protected _initialSizeParameter: number | {
  20384. width: number;
  20385. height: number;
  20386. } | {
  20387. ratio: number;
  20388. };
  20389. protected _sizeRatio: Nullable<number>;
  20390. /** @hidden */
  20391. _generateMipMaps: boolean;
  20392. protected _renderingManager: RenderingManager;
  20393. /** @hidden */
  20394. _waitingRenderList: string[];
  20395. protected _doNotChangeAspectRatio: boolean;
  20396. protected _currentRefreshId: number;
  20397. protected _refreshRate: number;
  20398. protected _textureMatrix: Matrix;
  20399. protected _samples: number;
  20400. protected _renderTargetOptions: RenderTargetCreationOptions;
  20401. /**
  20402. * Gets render target creation options that were used.
  20403. */
  20404. readonly renderTargetOptions: RenderTargetCreationOptions;
  20405. protected _engine: Engine;
  20406. protected _onRatioRescale(): void;
  20407. /**
  20408. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20409. * It must define where the camera used to render the texture is set
  20410. */
  20411. boundingBoxPosition: Vector3;
  20412. private _boundingBoxSize;
  20413. /**
  20414. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20415. * When defined, the cubemap will switch to local mode
  20416. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20417. * @example https://www.babylonjs-playground.com/#RNASML
  20418. */
  20419. boundingBoxSize: Vector3;
  20420. /**
  20421. * In case the RTT has been created with a depth texture, get the associated
  20422. * depth texture.
  20423. * Otherwise, return null.
  20424. */
  20425. depthStencilTexture: Nullable<InternalTexture>;
  20426. /**
  20427. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20428. * or used a shadow, depth texture...
  20429. * @param name The friendly name of the texture
  20430. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  20431. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20432. * @param generateMipMaps True if mip maps need to be generated after render.
  20433. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20434. * @param type The type of the buffer in the RTT (int, half float, float...)
  20435. * @param isCube True if a cube texture needs to be created
  20436. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20437. * @param generateDepthBuffer True to generate a depth buffer
  20438. * @param generateStencilBuffer True to generate a stencil buffer
  20439. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20440. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20441. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20442. */
  20443. constructor(name: string, size: number | {
  20444. width: number;
  20445. height: number;
  20446. } | {
  20447. ratio: number;
  20448. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20449. /**
  20450. * Creates a depth stencil texture.
  20451. * This is only available in WebGL 2 or with the depth texture extension available.
  20452. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20453. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20454. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20455. */
  20456. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20457. private _processSizeParameter;
  20458. /**
  20459. * Define the number of samples to use in case of MSAA.
  20460. * It defaults to one meaning no MSAA has been enabled.
  20461. */
  20462. samples: number;
  20463. /**
  20464. * Resets the refresh counter of the texture and start bak from scratch.
  20465. * Could be useful to regenerate the texture if it is setup to render only once.
  20466. */
  20467. resetRefreshCounter(): void;
  20468. /**
  20469. * Define the refresh rate of the texture or the rendering frequency.
  20470. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20471. */
  20472. refreshRate: number;
  20473. /**
  20474. * Adds a post process to the render target rendering passes.
  20475. * @param postProcess define the post process to add
  20476. */
  20477. addPostProcess(postProcess: PostProcess): void;
  20478. /**
  20479. * Clear all the post processes attached to the render target
  20480. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20481. */
  20482. clearPostProcesses(dispose?: boolean): void;
  20483. /**
  20484. * Remove one of the post process from the list of attached post processes to the texture
  20485. * @param postProcess define the post process to remove from the list
  20486. */
  20487. removePostProcess(postProcess: PostProcess): void;
  20488. /** @hidden */
  20489. _shouldRender(): boolean;
  20490. /**
  20491. * Gets the actual render size of the texture.
  20492. * @returns the width of the render size
  20493. */
  20494. getRenderSize(): number;
  20495. /**
  20496. * Gets the actual render width of the texture.
  20497. * @returns the width of the render size
  20498. */
  20499. getRenderWidth(): number;
  20500. /**
  20501. * Gets the actual render height of the texture.
  20502. * @returns the height of the render size
  20503. */
  20504. getRenderHeight(): number;
  20505. /**
  20506. * Get if the texture can be rescaled or not.
  20507. */
  20508. readonly canRescale: boolean;
  20509. /**
  20510. * Resize the texture using a ratio.
  20511. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20512. */
  20513. scale(ratio: number): void;
  20514. /**
  20515. * Get the texture reflection matrix used to rotate/transform the reflection.
  20516. * @returns the reflection matrix
  20517. */
  20518. getReflectionTextureMatrix(): Matrix;
  20519. /**
  20520. * Resize the texture to a new desired size.
  20521. * Be carrefull as it will recreate all the data in the new texture.
  20522. * @param size Define the new size. It can be:
  20523. * - a number for squared texture,
  20524. * - an object containing { width: number, height: number }
  20525. * - or an object containing a ratio { ratio: number }
  20526. */
  20527. resize(size: number | {
  20528. width: number;
  20529. height: number;
  20530. } | {
  20531. ratio: number;
  20532. }): void;
  20533. /**
  20534. * Renders all the objects from the render list into the texture.
  20535. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20536. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20537. */
  20538. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20539. private _bestReflectionRenderTargetDimension;
  20540. /**
  20541. * @hidden
  20542. * @param faceIndex face index to bind to if this is a cubetexture
  20543. */
  20544. _bindFrameBuffer(faceIndex?: number): void;
  20545. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20546. private renderToTarget;
  20547. /**
  20548. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20549. * This allowed control for front to back rendering or reversly depending of the special needs.
  20550. *
  20551. * @param renderingGroupId The rendering group id corresponding to its index
  20552. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20553. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20554. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20555. */
  20556. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20557. /**
  20558. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20559. *
  20560. * @param renderingGroupId The rendering group id corresponding to its index
  20561. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20562. */
  20563. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20564. /**
  20565. * Clones the texture.
  20566. * @returns the cloned texture
  20567. */
  20568. clone(): RenderTargetTexture;
  20569. /**
  20570. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20571. * @returns The JSON representation of the texture
  20572. */
  20573. serialize(): any;
  20574. /**
  20575. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20576. */
  20577. disposeFramebufferObjects(): void;
  20578. /**
  20579. * Dispose the texture and release its associated resources.
  20580. */
  20581. dispose(): void;
  20582. /** @hidden */
  20583. _rebuild(): void;
  20584. /**
  20585. * Clear the info related to rendering groups preventing retention point in material dispose.
  20586. */
  20587. freeRenderingGroups(): void;
  20588. /**
  20589. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20590. * @returns the view count
  20591. */
  20592. getViewCount(): number;
  20593. }
  20594. }
  20595. declare module "babylonjs/Materials/material" {
  20596. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20597. import { SmartArray } from "babylonjs/Misc/smartArray";
  20598. import { Observable } from "babylonjs/Misc/observable";
  20599. import { Nullable } from "babylonjs/types";
  20600. import { Scene } from "babylonjs/scene";
  20601. import { Matrix } from "babylonjs/Maths/math.vector";
  20602. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20604. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20605. import { Effect } from "babylonjs/Materials/effect";
  20606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20608. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20609. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20610. import { Mesh } from "babylonjs/Meshes/mesh";
  20611. import { Animation } from "babylonjs/Animations/animation";
  20612. /**
  20613. * Base class for the main features of a material in Babylon.js
  20614. */
  20615. export class Material implements IAnimatable {
  20616. /**
  20617. * Returns the triangle fill mode
  20618. */
  20619. static readonly TriangleFillMode: number;
  20620. /**
  20621. * Returns the wireframe mode
  20622. */
  20623. static readonly WireFrameFillMode: number;
  20624. /**
  20625. * Returns the point fill mode
  20626. */
  20627. static readonly PointFillMode: number;
  20628. /**
  20629. * Returns the point list draw mode
  20630. */
  20631. static readonly PointListDrawMode: number;
  20632. /**
  20633. * Returns the line list draw mode
  20634. */
  20635. static readonly LineListDrawMode: number;
  20636. /**
  20637. * Returns the line loop draw mode
  20638. */
  20639. static readonly LineLoopDrawMode: number;
  20640. /**
  20641. * Returns the line strip draw mode
  20642. */
  20643. static readonly LineStripDrawMode: number;
  20644. /**
  20645. * Returns the triangle strip draw mode
  20646. */
  20647. static readonly TriangleStripDrawMode: number;
  20648. /**
  20649. * Returns the triangle fan draw mode
  20650. */
  20651. static readonly TriangleFanDrawMode: number;
  20652. /**
  20653. * Stores the clock-wise side orientation
  20654. */
  20655. static readonly ClockWiseSideOrientation: number;
  20656. /**
  20657. * Stores the counter clock-wise side orientation
  20658. */
  20659. static readonly CounterClockWiseSideOrientation: number;
  20660. /**
  20661. * The dirty texture flag value
  20662. */
  20663. static readonly TextureDirtyFlag: number;
  20664. /**
  20665. * The dirty light flag value
  20666. */
  20667. static readonly LightDirtyFlag: number;
  20668. /**
  20669. * The dirty fresnel flag value
  20670. */
  20671. static readonly FresnelDirtyFlag: number;
  20672. /**
  20673. * The dirty attribute flag value
  20674. */
  20675. static readonly AttributesDirtyFlag: number;
  20676. /**
  20677. * The dirty misc flag value
  20678. */
  20679. static readonly MiscDirtyFlag: number;
  20680. /**
  20681. * The all dirty flag value
  20682. */
  20683. static readonly AllDirtyFlag: number;
  20684. /**
  20685. * The ID of the material
  20686. */
  20687. id: string;
  20688. /**
  20689. * Gets or sets the unique id of the material
  20690. */
  20691. uniqueId: number;
  20692. /**
  20693. * The name of the material
  20694. */
  20695. name: string;
  20696. /**
  20697. * Gets or sets user defined metadata
  20698. */
  20699. metadata: any;
  20700. /**
  20701. * For internal use only. Please do not use.
  20702. */
  20703. reservedDataStore: any;
  20704. /**
  20705. * Specifies if the ready state should be checked on each call
  20706. */
  20707. checkReadyOnEveryCall: boolean;
  20708. /**
  20709. * Specifies if the ready state should be checked once
  20710. */
  20711. checkReadyOnlyOnce: boolean;
  20712. /**
  20713. * The state of the material
  20714. */
  20715. state: string;
  20716. /**
  20717. * The alpha value of the material
  20718. */
  20719. protected _alpha: number;
  20720. /**
  20721. * List of inspectable custom properties (used by the Inspector)
  20722. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20723. */
  20724. inspectableCustomProperties: IInspectable[];
  20725. /**
  20726. * Sets the alpha value of the material
  20727. */
  20728. /**
  20729. * Gets the alpha value of the material
  20730. */
  20731. alpha: number;
  20732. /**
  20733. * Specifies if back face culling is enabled
  20734. */
  20735. protected _backFaceCulling: boolean;
  20736. /**
  20737. * Sets the back-face culling state
  20738. */
  20739. /**
  20740. * Gets the back-face culling state
  20741. */
  20742. backFaceCulling: boolean;
  20743. /**
  20744. * Stores the value for side orientation
  20745. */
  20746. sideOrientation: number;
  20747. /**
  20748. * Callback triggered when the material is compiled
  20749. */
  20750. onCompiled: Nullable<(effect: Effect) => void>;
  20751. /**
  20752. * Callback triggered when an error occurs
  20753. */
  20754. onError: Nullable<(effect: Effect, errors: string) => void>;
  20755. /**
  20756. * Callback triggered to get the render target textures
  20757. */
  20758. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20759. /**
  20760. * Gets a boolean indicating that current material needs to register RTT
  20761. */
  20762. readonly hasRenderTargetTextures: boolean;
  20763. /**
  20764. * Specifies if the material should be serialized
  20765. */
  20766. doNotSerialize: boolean;
  20767. /**
  20768. * @hidden
  20769. */
  20770. _storeEffectOnSubMeshes: boolean;
  20771. /**
  20772. * Stores the animations for the material
  20773. */
  20774. animations: Nullable<Array<Animation>>;
  20775. /**
  20776. * An event triggered when the material is disposed
  20777. */
  20778. onDisposeObservable: Observable<Material>;
  20779. /**
  20780. * An observer which watches for dispose events
  20781. */
  20782. private _onDisposeObserver;
  20783. private _onUnBindObservable;
  20784. /**
  20785. * Called during a dispose event
  20786. */
  20787. onDispose: () => void;
  20788. private _onBindObservable;
  20789. /**
  20790. * An event triggered when the material is bound
  20791. */
  20792. readonly onBindObservable: Observable<AbstractMesh>;
  20793. /**
  20794. * An observer which watches for bind events
  20795. */
  20796. private _onBindObserver;
  20797. /**
  20798. * Called during a bind event
  20799. */
  20800. onBind: (Mesh: AbstractMesh) => void;
  20801. /**
  20802. * An event triggered when the material is unbound
  20803. */
  20804. readonly onUnBindObservable: Observable<Material>;
  20805. /**
  20806. * Stores the value of the alpha mode
  20807. */
  20808. private _alphaMode;
  20809. /**
  20810. * Sets the value of the alpha mode.
  20811. *
  20812. * | Value | Type | Description |
  20813. * | --- | --- | --- |
  20814. * | 0 | ALPHA_DISABLE | |
  20815. * | 1 | ALPHA_ADD | |
  20816. * | 2 | ALPHA_COMBINE | |
  20817. * | 3 | ALPHA_SUBTRACT | |
  20818. * | 4 | ALPHA_MULTIPLY | |
  20819. * | 5 | ALPHA_MAXIMIZED | |
  20820. * | 6 | ALPHA_ONEONE | |
  20821. * | 7 | ALPHA_PREMULTIPLIED | |
  20822. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20823. * | 9 | ALPHA_INTERPOLATE | |
  20824. * | 10 | ALPHA_SCREENMODE | |
  20825. *
  20826. */
  20827. /**
  20828. * Gets the value of the alpha mode
  20829. */
  20830. alphaMode: number;
  20831. /**
  20832. * Stores the state of the need depth pre-pass value
  20833. */
  20834. private _needDepthPrePass;
  20835. /**
  20836. * Sets the need depth pre-pass value
  20837. */
  20838. /**
  20839. * Gets the depth pre-pass value
  20840. */
  20841. needDepthPrePass: boolean;
  20842. /**
  20843. * Specifies if depth writing should be disabled
  20844. */
  20845. disableDepthWrite: boolean;
  20846. /**
  20847. * Specifies if depth writing should be forced
  20848. */
  20849. forceDepthWrite: boolean;
  20850. /**
  20851. * Specifies if there should be a separate pass for culling
  20852. */
  20853. separateCullingPass: boolean;
  20854. /**
  20855. * Stores the state specifing if fog should be enabled
  20856. */
  20857. private _fogEnabled;
  20858. /**
  20859. * Sets the state for enabling fog
  20860. */
  20861. /**
  20862. * Gets the value of the fog enabled state
  20863. */
  20864. fogEnabled: boolean;
  20865. /**
  20866. * Stores the size of points
  20867. */
  20868. pointSize: number;
  20869. /**
  20870. * Stores the z offset value
  20871. */
  20872. zOffset: number;
  20873. /**
  20874. * Gets a value specifying if wireframe mode is enabled
  20875. */
  20876. /**
  20877. * Sets the state of wireframe mode
  20878. */
  20879. wireframe: boolean;
  20880. /**
  20881. * Gets the value specifying if point clouds are enabled
  20882. */
  20883. /**
  20884. * Sets the state of point cloud mode
  20885. */
  20886. pointsCloud: boolean;
  20887. /**
  20888. * Gets the material fill mode
  20889. */
  20890. /**
  20891. * Sets the material fill mode
  20892. */
  20893. fillMode: number;
  20894. /**
  20895. * @hidden
  20896. * Stores the effects for the material
  20897. */
  20898. _effect: Nullable<Effect>;
  20899. /**
  20900. * @hidden
  20901. * Specifies if the material was previously ready
  20902. */
  20903. _wasPreviouslyReady: boolean;
  20904. /**
  20905. * Specifies if uniform buffers should be used
  20906. */
  20907. private _useUBO;
  20908. /**
  20909. * Stores a reference to the scene
  20910. */
  20911. private _scene;
  20912. /**
  20913. * Stores the fill mode state
  20914. */
  20915. private _fillMode;
  20916. /**
  20917. * Specifies if the depth write state should be cached
  20918. */
  20919. private _cachedDepthWriteState;
  20920. /**
  20921. * Stores the uniform buffer
  20922. */
  20923. protected _uniformBuffer: UniformBuffer;
  20924. /** @hidden */
  20925. _indexInSceneMaterialArray: number;
  20926. /** @hidden */
  20927. meshMap: Nullable<{
  20928. [id: string]: AbstractMesh | undefined;
  20929. }>;
  20930. /**
  20931. * Creates a material instance
  20932. * @param name defines the name of the material
  20933. * @param scene defines the scene to reference
  20934. * @param doNotAdd specifies if the material should be added to the scene
  20935. */
  20936. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20937. /**
  20938. * Returns a string representation of the current material
  20939. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20940. * @returns a string with material information
  20941. */
  20942. toString(fullDetails?: boolean): string;
  20943. /**
  20944. * Gets the class name of the material
  20945. * @returns a string with the class name of the material
  20946. */
  20947. getClassName(): string;
  20948. /**
  20949. * Specifies if updates for the material been locked
  20950. */
  20951. readonly isFrozen: boolean;
  20952. /**
  20953. * Locks updates for the material
  20954. */
  20955. freeze(): void;
  20956. /**
  20957. * Unlocks updates for the material
  20958. */
  20959. unfreeze(): void;
  20960. /**
  20961. * Specifies if the material is ready to be used
  20962. * @param mesh defines the mesh to check
  20963. * @param useInstances specifies if instances should be used
  20964. * @returns a boolean indicating if the material is ready to be used
  20965. */
  20966. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20967. /**
  20968. * Specifies that the submesh is ready to be used
  20969. * @param mesh defines the mesh to check
  20970. * @param subMesh defines which submesh to check
  20971. * @param useInstances specifies that instances should be used
  20972. * @returns a boolean indicating that the submesh is ready or not
  20973. */
  20974. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20975. /**
  20976. * Returns the material effect
  20977. * @returns the effect associated with the material
  20978. */
  20979. getEffect(): Nullable<Effect>;
  20980. /**
  20981. * Returns the current scene
  20982. * @returns a Scene
  20983. */
  20984. getScene(): Scene;
  20985. /**
  20986. * Specifies if the material will require alpha blending
  20987. * @returns a boolean specifying if alpha blending is needed
  20988. */
  20989. needAlphaBlending(): boolean;
  20990. /**
  20991. * Specifies if the mesh will require alpha blending
  20992. * @param mesh defines the mesh to check
  20993. * @returns a boolean specifying if alpha blending is needed for the mesh
  20994. */
  20995. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20996. /**
  20997. * Specifies if this material should be rendered in alpha test mode
  20998. * @returns a boolean specifying if an alpha test is needed.
  20999. */
  21000. needAlphaTesting(): boolean;
  21001. /**
  21002. * Gets the texture used for the alpha test
  21003. * @returns the texture to use for alpha testing
  21004. */
  21005. getAlphaTestTexture(): Nullable<BaseTexture>;
  21006. /**
  21007. * Marks the material to indicate that it needs to be re-calculated
  21008. */
  21009. markDirty(): void;
  21010. /** @hidden */
  21011. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21012. /**
  21013. * Binds the material to the mesh
  21014. * @param world defines the world transformation matrix
  21015. * @param mesh defines the mesh to bind the material to
  21016. */
  21017. bind(world: Matrix, mesh?: Mesh): void;
  21018. /**
  21019. * Binds the submesh to the material
  21020. * @param world defines the world transformation matrix
  21021. * @param mesh defines the mesh containing the submesh
  21022. * @param subMesh defines the submesh to bind the material to
  21023. */
  21024. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21025. /**
  21026. * Binds the world matrix to the material
  21027. * @param world defines the world transformation matrix
  21028. */
  21029. bindOnlyWorldMatrix(world: Matrix): void;
  21030. /**
  21031. * Binds the scene's uniform buffer to the effect.
  21032. * @param effect defines the effect to bind to the scene uniform buffer
  21033. * @param sceneUbo defines the uniform buffer storing scene data
  21034. */
  21035. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21036. /**
  21037. * Binds the view matrix to the effect
  21038. * @param effect defines the effect to bind the view matrix to
  21039. */
  21040. bindView(effect: Effect): void;
  21041. /**
  21042. * Binds the view projection matrix to the effect
  21043. * @param effect defines the effect to bind the view projection matrix to
  21044. */
  21045. bindViewProjection(effect: Effect): void;
  21046. /**
  21047. * Specifies if material alpha testing should be turned on for the mesh
  21048. * @param mesh defines the mesh to check
  21049. */
  21050. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21051. /**
  21052. * Processes to execute after binding the material to a mesh
  21053. * @param mesh defines the rendered mesh
  21054. */
  21055. protected _afterBind(mesh?: Mesh): void;
  21056. /**
  21057. * Unbinds the material from the mesh
  21058. */
  21059. unbind(): void;
  21060. /**
  21061. * Gets the active textures from the material
  21062. * @returns an array of textures
  21063. */
  21064. getActiveTextures(): BaseTexture[];
  21065. /**
  21066. * Specifies if the material uses a texture
  21067. * @param texture defines the texture to check against the material
  21068. * @returns a boolean specifying if the material uses the texture
  21069. */
  21070. hasTexture(texture: BaseTexture): boolean;
  21071. /**
  21072. * Makes a duplicate of the material, and gives it a new name
  21073. * @param name defines the new name for the duplicated material
  21074. * @returns the cloned material
  21075. */
  21076. clone(name: string): Nullable<Material>;
  21077. /**
  21078. * Gets the meshes bound to the material
  21079. * @returns an array of meshes bound to the material
  21080. */
  21081. getBindedMeshes(): AbstractMesh[];
  21082. /**
  21083. * Force shader compilation
  21084. * @param mesh defines the mesh associated with this material
  21085. * @param onCompiled defines a function to execute once the material is compiled
  21086. * @param options defines the options to configure the compilation
  21087. */
  21088. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21089. clipPlane: boolean;
  21090. }>): void;
  21091. /**
  21092. * Force shader compilation
  21093. * @param mesh defines the mesh that will use this material
  21094. * @param options defines additional options for compiling the shaders
  21095. * @returns a promise that resolves when the compilation completes
  21096. */
  21097. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21098. clipPlane: boolean;
  21099. }>): Promise<void>;
  21100. private static readonly _AllDirtyCallBack;
  21101. private static readonly _ImageProcessingDirtyCallBack;
  21102. private static readonly _TextureDirtyCallBack;
  21103. private static readonly _FresnelDirtyCallBack;
  21104. private static readonly _MiscDirtyCallBack;
  21105. private static readonly _LightsDirtyCallBack;
  21106. private static readonly _AttributeDirtyCallBack;
  21107. private static _FresnelAndMiscDirtyCallBack;
  21108. private static _TextureAndMiscDirtyCallBack;
  21109. private static readonly _DirtyCallbackArray;
  21110. private static readonly _RunDirtyCallBacks;
  21111. /**
  21112. * Marks a define in the material to indicate that it needs to be re-computed
  21113. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21114. */
  21115. markAsDirty(flag: number): void;
  21116. /**
  21117. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21118. * @param func defines a function which checks material defines against the submeshes
  21119. */
  21120. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21121. /**
  21122. * Indicates that we need to re-calculated for all submeshes
  21123. */
  21124. protected _markAllSubMeshesAsAllDirty(): void;
  21125. /**
  21126. * Indicates that image processing needs to be re-calculated for all submeshes
  21127. */
  21128. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21129. /**
  21130. * Indicates that textures need to be re-calculated for all submeshes
  21131. */
  21132. protected _markAllSubMeshesAsTexturesDirty(): void;
  21133. /**
  21134. * Indicates that fresnel needs to be re-calculated for all submeshes
  21135. */
  21136. protected _markAllSubMeshesAsFresnelDirty(): void;
  21137. /**
  21138. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21139. */
  21140. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21141. /**
  21142. * Indicates that lights need to be re-calculated for all submeshes
  21143. */
  21144. protected _markAllSubMeshesAsLightsDirty(): void;
  21145. /**
  21146. * Indicates that attributes need to be re-calculated for all submeshes
  21147. */
  21148. protected _markAllSubMeshesAsAttributesDirty(): void;
  21149. /**
  21150. * Indicates that misc needs to be re-calculated for all submeshes
  21151. */
  21152. protected _markAllSubMeshesAsMiscDirty(): void;
  21153. /**
  21154. * Indicates that textures and misc need to be re-calculated for all submeshes
  21155. */
  21156. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21157. /**
  21158. * Disposes the material
  21159. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21160. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21161. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21162. */
  21163. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21164. /** @hidden */
  21165. private releaseVertexArrayObject;
  21166. /**
  21167. * Serializes this material
  21168. * @returns the serialized material object
  21169. */
  21170. serialize(): any;
  21171. /**
  21172. * Creates a material from parsed material data
  21173. * @param parsedMaterial defines parsed material data
  21174. * @param scene defines the hosting scene
  21175. * @param rootUrl defines the root URL to use to load textures
  21176. * @returns a new material
  21177. */
  21178. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21179. }
  21180. }
  21181. declare module "babylonjs/Materials/multiMaterial" {
  21182. import { Nullable } from "babylonjs/types";
  21183. import { Scene } from "babylonjs/scene";
  21184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21185. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21187. import { Material } from "babylonjs/Materials/material";
  21188. /**
  21189. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21190. * separate meshes. This can be use to improve performances.
  21191. * @see http://doc.babylonjs.com/how_to/multi_materials
  21192. */
  21193. export class MultiMaterial extends Material {
  21194. private _subMaterials;
  21195. /**
  21196. * Gets or Sets the list of Materials used within the multi material.
  21197. * They need to be ordered according to the submeshes order in the associated mesh
  21198. */
  21199. subMaterials: Nullable<Material>[];
  21200. /**
  21201. * Function used to align with Node.getChildren()
  21202. * @returns the list of Materials used within the multi material
  21203. */
  21204. getChildren(): Nullable<Material>[];
  21205. /**
  21206. * Instantiates a new Multi Material
  21207. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21208. * separate meshes. This can be use to improve performances.
  21209. * @see http://doc.babylonjs.com/how_to/multi_materials
  21210. * @param name Define the name in the scene
  21211. * @param scene Define the scene the material belongs to
  21212. */
  21213. constructor(name: string, scene: Scene);
  21214. private _hookArray;
  21215. /**
  21216. * Get one of the submaterial by its index in the submaterials array
  21217. * @param index The index to look the sub material at
  21218. * @returns The Material if the index has been defined
  21219. */
  21220. getSubMaterial(index: number): Nullable<Material>;
  21221. /**
  21222. * Get the list of active textures for the whole sub materials list.
  21223. * @returns All the textures that will be used during the rendering
  21224. */
  21225. getActiveTextures(): BaseTexture[];
  21226. /**
  21227. * Gets the current class name of the material e.g. "MultiMaterial"
  21228. * Mainly use in serialization.
  21229. * @returns the class name
  21230. */
  21231. getClassName(): string;
  21232. /**
  21233. * Checks if the material is ready to render the requested sub mesh
  21234. * @param mesh Define the mesh the submesh belongs to
  21235. * @param subMesh Define the sub mesh to look readyness for
  21236. * @param useInstances Define whether or not the material is used with instances
  21237. * @returns true if ready, otherwise false
  21238. */
  21239. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21240. /**
  21241. * Clones the current material and its related sub materials
  21242. * @param name Define the name of the newly cloned material
  21243. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21244. * @returns the cloned material
  21245. */
  21246. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21247. /**
  21248. * Serializes the materials into a JSON representation.
  21249. * @returns the JSON representation
  21250. */
  21251. serialize(): any;
  21252. /**
  21253. * Dispose the material and release its associated resources
  21254. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  21255. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  21256. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  21257. */
  21258. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21259. /**
  21260. * Creates a MultiMaterial from parsed MultiMaterial data.
  21261. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21262. * @param scene defines the hosting scene
  21263. * @returns a new MultiMaterial
  21264. */
  21265. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21266. }
  21267. }
  21268. declare module "babylonjs/Meshes/subMesh" {
  21269. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21270. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21271. import { Engine } from "babylonjs/Engines/engine";
  21272. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21273. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21274. import { Effect } from "babylonjs/Materials/effect";
  21275. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21276. import { Plane } from "babylonjs/Maths/math.plane";
  21277. import { Collider } from "babylonjs/Collisions/collider";
  21278. import { Material } from "babylonjs/Materials/material";
  21279. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21281. import { Mesh } from "babylonjs/Meshes/mesh";
  21282. import { Ray } from "babylonjs/Culling/ray";
  21283. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21284. /**
  21285. * Base class for submeshes
  21286. */
  21287. export class BaseSubMesh {
  21288. /** @hidden */
  21289. _materialDefines: Nullable<MaterialDefines>;
  21290. /** @hidden */
  21291. _materialEffect: Nullable<Effect>;
  21292. /**
  21293. * Gets associated effect
  21294. */
  21295. readonly effect: Nullable<Effect>;
  21296. /**
  21297. * Sets associated effect (effect used to render this submesh)
  21298. * @param effect defines the effect to associate with
  21299. * @param defines defines the set of defines used to compile this effect
  21300. */
  21301. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21302. }
  21303. /**
  21304. * Defines a subdivision inside a mesh
  21305. */
  21306. export class SubMesh extends BaseSubMesh implements ICullable {
  21307. /** the material index to use */
  21308. materialIndex: number;
  21309. /** vertex index start */
  21310. verticesStart: number;
  21311. /** vertices count */
  21312. verticesCount: number;
  21313. /** index start */
  21314. indexStart: number;
  21315. /** indices count */
  21316. indexCount: number;
  21317. /** @hidden */
  21318. _linesIndexCount: number;
  21319. private _mesh;
  21320. private _renderingMesh;
  21321. private _boundingInfo;
  21322. private _linesIndexBuffer;
  21323. /** @hidden */
  21324. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21325. /** @hidden */
  21326. _trianglePlanes: Plane[];
  21327. /** @hidden */
  21328. _lastColliderTransformMatrix: Nullable<Matrix>;
  21329. /** @hidden */
  21330. _renderId: number;
  21331. /** @hidden */
  21332. _alphaIndex: number;
  21333. /** @hidden */
  21334. _distanceToCamera: number;
  21335. /** @hidden */
  21336. _id: number;
  21337. private _currentMaterial;
  21338. /**
  21339. * Add a new submesh to a mesh
  21340. * @param materialIndex defines the material index to use
  21341. * @param verticesStart defines vertex index start
  21342. * @param verticesCount defines vertices count
  21343. * @param indexStart defines index start
  21344. * @param indexCount defines indices count
  21345. * @param mesh defines the parent mesh
  21346. * @param renderingMesh defines an optional rendering mesh
  21347. * @param createBoundingBox defines if bounding box should be created for this submesh
  21348. * @returns the new submesh
  21349. */
  21350. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21351. /**
  21352. * Creates a new submesh
  21353. * @param materialIndex defines the material index to use
  21354. * @param verticesStart defines vertex index start
  21355. * @param verticesCount defines vertices count
  21356. * @param indexStart defines index start
  21357. * @param indexCount defines indices count
  21358. * @param mesh defines the parent mesh
  21359. * @param renderingMesh defines an optional rendering mesh
  21360. * @param createBoundingBox defines if bounding box should be created for this submesh
  21361. */
  21362. constructor(
  21363. /** the material index to use */
  21364. materialIndex: number,
  21365. /** vertex index start */
  21366. verticesStart: number,
  21367. /** vertices count */
  21368. verticesCount: number,
  21369. /** index start */
  21370. indexStart: number,
  21371. /** indices count */
  21372. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21373. /**
  21374. * Returns true if this submesh covers the entire parent mesh
  21375. * @ignorenaming
  21376. */
  21377. readonly IsGlobal: boolean;
  21378. /**
  21379. * Returns the submesh BoudingInfo object
  21380. * @returns current bounding info (or mesh's one if the submesh is global)
  21381. */
  21382. getBoundingInfo(): BoundingInfo;
  21383. /**
  21384. * Sets the submesh BoundingInfo
  21385. * @param boundingInfo defines the new bounding info to use
  21386. * @returns the SubMesh
  21387. */
  21388. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21389. /**
  21390. * Returns the mesh of the current submesh
  21391. * @return the parent mesh
  21392. */
  21393. getMesh(): AbstractMesh;
  21394. /**
  21395. * Returns the rendering mesh of the submesh
  21396. * @returns the rendering mesh (could be different from parent mesh)
  21397. */
  21398. getRenderingMesh(): Mesh;
  21399. /**
  21400. * Returns the submesh material
  21401. * @returns null or the current material
  21402. */
  21403. getMaterial(): Nullable<Material>;
  21404. /**
  21405. * Sets a new updated BoundingInfo object to the submesh
  21406. * @param data defines an optional position array to use to determine the bounding info
  21407. * @returns the SubMesh
  21408. */
  21409. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21410. /** @hidden */
  21411. _checkCollision(collider: Collider): boolean;
  21412. /**
  21413. * Updates the submesh BoundingInfo
  21414. * @param world defines the world matrix to use to update the bounding info
  21415. * @returns the submesh
  21416. */
  21417. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21418. /**
  21419. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21420. * @param frustumPlanes defines the frustum planes
  21421. * @returns true if the submesh is intersecting with the frustum
  21422. */
  21423. isInFrustum(frustumPlanes: Plane[]): boolean;
  21424. /**
  21425. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21426. * @param frustumPlanes defines the frustum planes
  21427. * @returns true if the submesh is inside the frustum
  21428. */
  21429. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21430. /**
  21431. * Renders the submesh
  21432. * @param enableAlphaMode defines if alpha needs to be used
  21433. * @returns the submesh
  21434. */
  21435. render(enableAlphaMode: boolean): SubMesh;
  21436. /**
  21437. * @hidden
  21438. */
  21439. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21440. /**
  21441. * Checks if the submesh intersects with a ray
  21442. * @param ray defines the ray to test
  21443. * @returns true is the passed ray intersects the submesh bounding box
  21444. */
  21445. canIntersects(ray: Ray): boolean;
  21446. /**
  21447. * Intersects current submesh with a ray
  21448. * @param ray defines the ray to test
  21449. * @param positions defines mesh's positions array
  21450. * @param indices defines mesh's indices array
  21451. * @param fastCheck defines if only bounding info should be used
  21452. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21453. * @returns intersection info or null if no intersection
  21454. */
  21455. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21456. /** @hidden */
  21457. private _intersectLines;
  21458. /** @hidden */
  21459. private _intersectUnIndexedLines;
  21460. /** @hidden */
  21461. private _intersectTriangles;
  21462. /** @hidden */
  21463. private _intersectUnIndexedTriangles;
  21464. /** @hidden */
  21465. _rebuild(): void;
  21466. /**
  21467. * Creates a new submesh from the passed mesh
  21468. * @param newMesh defines the new hosting mesh
  21469. * @param newRenderingMesh defines an optional rendering mesh
  21470. * @returns the new submesh
  21471. */
  21472. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21473. /**
  21474. * Release associated resources
  21475. */
  21476. dispose(): void;
  21477. /**
  21478. * Gets the class name
  21479. * @returns the string "SubMesh".
  21480. */
  21481. getClassName(): string;
  21482. /**
  21483. * Creates a new submesh from indices data
  21484. * @param materialIndex the index of the main mesh material
  21485. * @param startIndex the index where to start the copy in the mesh indices array
  21486. * @param indexCount the number of indices to copy then from the startIndex
  21487. * @param mesh the main mesh to create the submesh from
  21488. * @param renderingMesh the optional rendering mesh
  21489. * @returns a new submesh
  21490. */
  21491. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21492. }
  21493. }
  21494. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21495. /**
  21496. * Class used to represent data loading progression
  21497. */
  21498. export class SceneLoaderFlags {
  21499. private static _ForceFullSceneLoadingForIncremental;
  21500. private static _ShowLoadingScreen;
  21501. private static _CleanBoneMatrixWeights;
  21502. private static _loggingLevel;
  21503. /**
  21504. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21505. */
  21506. static ForceFullSceneLoadingForIncremental: boolean;
  21507. /**
  21508. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21509. */
  21510. static ShowLoadingScreen: boolean;
  21511. /**
  21512. * Defines the current logging level (while loading the scene)
  21513. * @ignorenaming
  21514. */
  21515. static loggingLevel: number;
  21516. /**
  21517. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21518. */
  21519. static CleanBoneMatrixWeights: boolean;
  21520. }
  21521. }
  21522. declare module "babylonjs/Meshes/geometry" {
  21523. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21524. import { Scene } from "babylonjs/scene";
  21525. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21526. import { Engine } from "babylonjs/Engines/engine";
  21527. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21528. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21529. import { Effect } from "babylonjs/Materials/effect";
  21530. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21531. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21532. import { Mesh } from "babylonjs/Meshes/mesh";
  21533. /**
  21534. * Class used to store geometry data (vertex buffers + index buffer)
  21535. */
  21536. export class Geometry implements IGetSetVerticesData {
  21537. /**
  21538. * Gets or sets the ID of the geometry
  21539. */
  21540. id: string;
  21541. /**
  21542. * Gets or sets the unique ID of the geometry
  21543. */
  21544. uniqueId: number;
  21545. /**
  21546. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21547. */
  21548. delayLoadState: number;
  21549. /**
  21550. * Gets the file containing the data to load when running in delay load state
  21551. */
  21552. delayLoadingFile: Nullable<string>;
  21553. /**
  21554. * Callback called when the geometry is updated
  21555. */
  21556. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21557. private _scene;
  21558. private _engine;
  21559. private _meshes;
  21560. private _totalVertices;
  21561. /** @hidden */
  21562. _indices: IndicesArray;
  21563. /** @hidden */
  21564. _vertexBuffers: {
  21565. [key: string]: VertexBuffer;
  21566. };
  21567. private _isDisposed;
  21568. private _extend;
  21569. private _boundingBias;
  21570. /** @hidden */
  21571. _delayInfo: Array<string>;
  21572. private _indexBuffer;
  21573. private _indexBufferIsUpdatable;
  21574. /** @hidden */
  21575. _boundingInfo: Nullable<BoundingInfo>;
  21576. /** @hidden */
  21577. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21578. /** @hidden */
  21579. _softwareSkinningFrameId: number;
  21580. private _vertexArrayObjects;
  21581. private _updatable;
  21582. /** @hidden */
  21583. _positions: Nullable<Vector3[]>;
  21584. /**
  21585. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21586. */
  21587. /**
  21588. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21589. */
  21590. boundingBias: Vector2;
  21591. /**
  21592. * Static function used to attach a new empty geometry to a mesh
  21593. * @param mesh defines the mesh to attach the geometry to
  21594. * @returns the new Geometry
  21595. */
  21596. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21597. /**
  21598. * Creates a new geometry
  21599. * @param id defines the unique ID
  21600. * @param scene defines the hosting scene
  21601. * @param vertexData defines the VertexData used to get geometry data
  21602. * @param updatable defines if geometry must be updatable (false by default)
  21603. * @param mesh defines the mesh that will be associated with the geometry
  21604. */
  21605. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21606. /**
  21607. * Gets the current extend of the geometry
  21608. */
  21609. readonly extend: {
  21610. minimum: Vector3;
  21611. maximum: Vector3;
  21612. };
  21613. /**
  21614. * Gets the hosting scene
  21615. * @returns the hosting Scene
  21616. */
  21617. getScene(): Scene;
  21618. /**
  21619. * Gets the hosting engine
  21620. * @returns the hosting Engine
  21621. */
  21622. getEngine(): Engine;
  21623. /**
  21624. * Defines if the geometry is ready to use
  21625. * @returns true if the geometry is ready to be used
  21626. */
  21627. isReady(): boolean;
  21628. /**
  21629. * Gets a value indicating that the geometry should not be serialized
  21630. */
  21631. readonly doNotSerialize: boolean;
  21632. /** @hidden */
  21633. _rebuild(): void;
  21634. /**
  21635. * Affects all geometry data in one call
  21636. * @param vertexData defines the geometry data
  21637. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21638. */
  21639. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21640. /**
  21641. * Set specific vertex data
  21642. * @param kind defines the data kind (Position, normal, etc...)
  21643. * @param data defines the vertex data to use
  21644. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21645. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21646. */
  21647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21648. /**
  21649. * Removes a specific vertex data
  21650. * @param kind defines the data kind (Position, normal, etc...)
  21651. */
  21652. removeVerticesData(kind: string): void;
  21653. /**
  21654. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21655. * @param buffer defines the vertex buffer to use
  21656. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21657. */
  21658. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21659. /**
  21660. * Update a specific vertex buffer
  21661. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21662. * It will do nothing if the buffer is not updatable
  21663. * @param kind defines the data kind (Position, normal, etc...)
  21664. * @param data defines the data to use
  21665. * @param offset defines the offset in the target buffer where to store the data
  21666. * @param useBytes set to true if the offset is in bytes
  21667. */
  21668. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21669. /**
  21670. * Update a specific vertex buffer
  21671. * This function will create a new buffer if the current one is not updatable
  21672. * @param kind defines the data kind (Position, normal, etc...)
  21673. * @param data defines the data to use
  21674. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21675. */
  21676. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21677. private _updateBoundingInfo;
  21678. /** @hidden */
  21679. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21680. /**
  21681. * Gets total number of vertices
  21682. * @returns the total number of vertices
  21683. */
  21684. getTotalVertices(): number;
  21685. /**
  21686. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21687. * @param kind defines the data kind (Position, normal, etc...)
  21688. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21689. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21690. * @returns a float array containing vertex data
  21691. */
  21692. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21693. /**
  21694. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21695. * @param kind defines the data kind (Position, normal, etc...)
  21696. * @returns true if the vertex buffer with the specified kind is updatable
  21697. */
  21698. isVertexBufferUpdatable(kind: string): boolean;
  21699. /**
  21700. * Gets a specific vertex buffer
  21701. * @param kind defines the data kind (Position, normal, etc...)
  21702. * @returns a VertexBuffer
  21703. */
  21704. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21705. /**
  21706. * Returns all vertex buffers
  21707. * @return an object holding all vertex buffers indexed by kind
  21708. */
  21709. getVertexBuffers(): Nullable<{
  21710. [key: string]: VertexBuffer;
  21711. }>;
  21712. /**
  21713. * Gets a boolean indicating if specific vertex buffer is present
  21714. * @param kind defines the data kind (Position, normal, etc...)
  21715. * @returns true if data is present
  21716. */
  21717. isVerticesDataPresent(kind: string): boolean;
  21718. /**
  21719. * Gets a list of all attached data kinds (Position, normal, etc...)
  21720. * @returns a list of string containing all kinds
  21721. */
  21722. getVerticesDataKinds(): string[];
  21723. /**
  21724. * Update index buffer
  21725. * @param indices defines the indices to store in the index buffer
  21726. * @param offset defines the offset in the target buffer where to store the data
  21727. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  21728. */
  21729. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21730. /**
  21731. * Creates a new index buffer
  21732. * @param indices defines the indices to store in the index buffer
  21733. * @param totalVertices defines the total number of vertices (could be null)
  21734. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21735. */
  21736. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21737. /**
  21738. * Return the total number of indices
  21739. * @returns the total number of indices
  21740. */
  21741. getTotalIndices(): number;
  21742. /**
  21743. * Gets the index buffer array
  21744. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21745. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21746. * @returns the index buffer array
  21747. */
  21748. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21749. /**
  21750. * Gets the index buffer
  21751. * @return the index buffer
  21752. */
  21753. getIndexBuffer(): Nullable<DataBuffer>;
  21754. /** @hidden */
  21755. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21756. /**
  21757. * Release the associated resources for a specific mesh
  21758. * @param mesh defines the source mesh
  21759. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21760. */
  21761. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21762. /**
  21763. * Apply current geometry to a given mesh
  21764. * @param mesh defines the mesh to apply geometry to
  21765. */
  21766. applyToMesh(mesh: Mesh): void;
  21767. private _updateExtend;
  21768. private _applyToMesh;
  21769. private notifyUpdate;
  21770. /**
  21771. * Load the geometry if it was flagged as delay loaded
  21772. * @param scene defines the hosting scene
  21773. * @param onLoaded defines a callback called when the geometry is loaded
  21774. */
  21775. load(scene: Scene, onLoaded?: () => void): void;
  21776. private _queueLoad;
  21777. /**
  21778. * Invert the geometry to move from a right handed system to a left handed one.
  21779. */
  21780. toLeftHanded(): void;
  21781. /** @hidden */
  21782. _resetPointsArrayCache(): void;
  21783. /** @hidden */
  21784. _generatePointsArray(): boolean;
  21785. /**
  21786. * Gets a value indicating if the geometry is disposed
  21787. * @returns true if the geometry was disposed
  21788. */
  21789. isDisposed(): boolean;
  21790. private _disposeVertexArrayObjects;
  21791. /**
  21792. * Free all associated resources
  21793. */
  21794. dispose(): void;
  21795. /**
  21796. * Clone the current geometry into a new geometry
  21797. * @param id defines the unique ID of the new geometry
  21798. * @returns a new geometry object
  21799. */
  21800. copy(id: string): Geometry;
  21801. /**
  21802. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21803. * @return a JSON representation of the current geometry data (without the vertices data)
  21804. */
  21805. serialize(): any;
  21806. private toNumberArray;
  21807. /**
  21808. * Serialize all vertices data into a JSON oject
  21809. * @returns a JSON representation of the current geometry data
  21810. */
  21811. serializeVerticeData(): any;
  21812. /**
  21813. * Extracts a clone of a mesh geometry
  21814. * @param mesh defines the source mesh
  21815. * @param id defines the unique ID of the new geometry object
  21816. * @returns the new geometry object
  21817. */
  21818. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21819. /**
  21820. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21821. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21822. * Be aware Math.random() could cause collisions, but:
  21823. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  21824. * @returns a string containing a new GUID
  21825. */
  21826. static RandomId(): string;
  21827. /** @hidden */
  21828. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21829. private static _CleanMatricesWeights;
  21830. /**
  21831. * Create a new geometry from persisted data (Using .babylon file format)
  21832. * @param parsedVertexData defines the persisted data
  21833. * @param scene defines the hosting scene
  21834. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21835. * @returns the new geometry object
  21836. */
  21837. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21838. }
  21839. }
  21840. declare module "babylonjs/Meshes/mesh.vertexData" {
  21841. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21842. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21843. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21844. import { Geometry } from "babylonjs/Meshes/geometry";
  21845. import { Mesh } from "babylonjs/Meshes/mesh";
  21846. /**
  21847. * Define an interface for all classes that will get and set the data on vertices
  21848. */
  21849. export interface IGetSetVerticesData {
  21850. /**
  21851. * Gets a boolean indicating if specific vertex data is present
  21852. * @param kind defines the vertex data kind to use
  21853. * @returns true is data kind is present
  21854. */
  21855. isVerticesDataPresent(kind: string): boolean;
  21856. /**
  21857. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21858. * @param kind defines the data kind (Position, normal, etc...)
  21859. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21860. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21861. * @returns a float array containing vertex data
  21862. */
  21863. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21864. /**
  21865. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21866. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  21867. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21868. * @returns the indices array or an empty array if the mesh has no geometry
  21869. */
  21870. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21871. /**
  21872. * Set specific vertex data
  21873. * @param kind defines the data kind (Position, normal, etc...)
  21874. * @param data defines the vertex data to use
  21875. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21876. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21877. */
  21878. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21879. /**
  21880. * Update a specific associated vertex buffer
  21881. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21882. * - VertexBuffer.PositionKind
  21883. * - VertexBuffer.UVKind
  21884. * - VertexBuffer.UV2Kind
  21885. * - VertexBuffer.UV3Kind
  21886. * - VertexBuffer.UV4Kind
  21887. * - VertexBuffer.UV5Kind
  21888. * - VertexBuffer.UV6Kind
  21889. * - VertexBuffer.ColorKind
  21890. * - VertexBuffer.MatricesIndicesKind
  21891. * - VertexBuffer.MatricesIndicesExtraKind
  21892. * - VertexBuffer.MatricesWeightsKind
  21893. * - VertexBuffer.MatricesWeightsExtraKind
  21894. * @param data defines the data source
  21895. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21896. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  21897. */
  21898. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21899. /**
  21900. * Creates a new index buffer
  21901. * @param indices defines the indices to store in the index buffer
  21902. * @param totalVertices defines the total number of vertices (could be null)
  21903. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21904. */
  21905. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21906. }
  21907. /**
  21908. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21909. */
  21910. export class VertexData {
  21911. /**
  21912. * Mesh side orientation : usually the external or front surface
  21913. */
  21914. static readonly FRONTSIDE: number;
  21915. /**
  21916. * Mesh side orientation : usually the internal or back surface
  21917. */
  21918. static readonly BACKSIDE: number;
  21919. /**
  21920. * Mesh side orientation : both internal and external or front and back surfaces
  21921. */
  21922. static readonly DOUBLESIDE: number;
  21923. /**
  21924. * Mesh side orientation : by default, `FRONTSIDE`
  21925. */
  21926. static readonly DEFAULTSIDE: number;
  21927. /**
  21928. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21929. */
  21930. positions: Nullable<FloatArray>;
  21931. /**
  21932. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21933. */
  21934. normals: Nullable<FloatArray>;
  21935. /**
  21936. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21937. */
  21938. tangents: Nullable<FloatArray>;
  21939. /**
  21940. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21941. */
  21942. uvs: Nullable<FloatArray>;
  21943. /**
  21944. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21945. */
  21946. uvs2: Nullable<FloatArray>;
  21947. /**
  21948. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21949. */
  21950. uvs3: Nullable<FloatArray>;
  21951. /**
  21952. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21953. */
  21954. uvs4: Nullable<FloatArray>;
  21955. /**
  21956. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21957. */
  21958. uvs5: Nullable<FloatArray>;
  21959. /**
  21960. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21961. */
  21962. uvs6: Nullable<FloatArray>;
  21963. /**
  21964. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21965. */
  21966. colors: Nullable<FloatArray>;
  21967. /**
  21968. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  21969. */
  21970. matricesIndices: Nullable<FloatArray>;
  21971. /**
  21972. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21973. */
  21974. matricesWeights: Nullable<FloatArray>;
  21975. /**
  21976. * An array extending the number of possible indices
  21977. */
  21978. matricesIndicesExtra: Nullable<FloatArray>;
  21979. /**
  21980. * An array extending the number of possible weights when the number of indices is extended
  21981. */
  21982. matricesWeightsExtra: Nullable<FloatArray>;
  21983. /**
  21984. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21985. */
  21986. indices: Nullable<IndicesArray>;
  21987. /**
  21988. * Uses the passed data array to set the set the values for the specified kind of data
  21989. * @param data a linear array of floating numbers
  21990. * @param kind the type of data that is being set, eg positions, colors etc
  21991. */
  21992. set(data: FloatArray, kind: string): void;
  21993. /**
  21994. * Associates the vertexData to the passed Mesh.
  21995. * Sets it as updatable or not (default `false`)
  21996. * @param mesh the mesh the vertexData is applied to
  21997. * @param updatable when used and having the value true allows new data to update the vertexData
  21998. * @returns the VertexData
  21999. */
  22000. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22001. /**
  22002. * Associates the vertexData to the passed Geometry.
  22003. * Sets it as updatable or not (default `false`)
  22004. * @param geometry the geometry the vertexData is applied to
  22005. * @param updatable when used and having the value true allows new data to update the vertexData
  22006. * @returns VertexData
  22007. */
  22008. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22009. /**
  22010. * Updates the associated mesh
  22011. * @param mesh the mesh to be updated
  22012. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22013. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22014. * @returns VertexData
  22015. */
  22016. updateMesh(mesh: Mesh): VertexData;
  22017. /**
  22018. * Updates the associated geometry
  22019. * @param geometry the geometry to be updated
  22020. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22021. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22022. * @returns VertexData.
  22023. */
  22024. updateGeometry(geometry: Geometry): VertexData;
  22025. private _applyTo;
  22026. private _update;
  22027. /**
  22028. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22029. * @param matrix the transforming matrix
  22030. * @returns the VertexData
  22031. */
  22032. transform(matrix: Matrix): VertexData;
  22033. /**
  22034. * Merges the passed VertexData into the current one
  22035. * @param other the VertexData to be merged into the current one
  22036. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22037. * @returns the modified VertexData
  22038. */
  22039. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22040. private _mergeElement;
  22041. private _validate;
  22042. /**
  22043. * Serializes the VertexData
  22044. * @returns a serialized object
  22045. */
  22046. serialize(): any;
  22047. /**
  22048. * Extracts the vertexData from a mesh
  22049. * @param mesh the mesh from which to extract the VertexData
  22050. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22051. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22052. * @returns the object VertexData associated to the passed mesh
  22053. */
  22054. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22055. /**
  22056. * Extracts the vertexData from the geometry
  22057. * @param geometry the geometry from which to extract the VertexData
  22058. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22059. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22060. * @returns the object VertexData associated to the passed mesh
  22061. */
  22062. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22063. private static _ExtractFrom;
  22064. /**
  22065. * Creates the VertexData for a Ribbon
  22066. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22067. * * pathArray array of paths, each of which an array of successive Vector3
  22068. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22069. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22070. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  22071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22072. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22073. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22074. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22075. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22076. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22077. * @returns the VertexData of the ribbon
  22078. */
  22079. static CreateRibbon(options: {
  22080. pathArray: Vector3[][];
  22081. closeArray?: boolean;
  22082. closePath?: boolean;
  22083. offset?: number;
  22084. sideOrientation?: number;
  22085. frontUVs?: Vector4;
  22086. backUVs?: Vector4;
  22087. invertUV?: boolean;
  22088. uvs?: Vector2[];
  22089. colors?: Color4[];
  22090. }): VertexData;
  22091. /**
  22092. * Creates the VertexData for a box
  22093. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22094. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22095. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22096. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22097. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22098. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22099. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22100. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22101. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22102. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22103. * @returns the VertexData of the box
  22104. */
  22105. static CreateBox(options: {
  22106. size?: number;
  22107. width?: number;
  22108. height?: number;
  22109. depth?: number;
  22110. faceUV?: Vector4[];
  22111. faceColors?: Color4[];
  22112. sideOrientation?: number;
  22113. frontUVs?: Vector4;
  22114. backUVs?: Vector4;
  22115. }): VertexData;
  22116. /**
  22117. * Creates the VertexData for a tiled box
  22118. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22119. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22120. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22121. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22122. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22123. * @returns the VertexData of the box
  22124. */
  22125. static CreateTiledBox(options: {
  22126. pattern?: number;
  22127. width?: number;
  22128. height?: number;
  22129. depth?: number;
  22130. tileSize?: number;
  22131. tileWidth?: number;
  22132. tileHeight?: number;
  22133. alignHorizontal?: number;
  22134. alignVertical?: number;
  22135. faceUV?: Vector4[];
  22136. faceColors?: Color4[];
  22137. sideOrientation?: number;
  22138. }): VertexData;
  22139. /**
  22140. * Creates the VertexData for a tiled plane
  22141. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22142. * * pattern a limited pattern arrangement depending on the number
  22143. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22144. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22145. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22147. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22148. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22149. * @returns the VertexData of the tiled plane
  22150. */
  22151. static CreateTiledPlane(options: {
  22152. pattern?: number;
  22153. tileSize?: number;
  22154. tileWidth?: number;
  22155. tileHeight?: number;
  22156. size?: number;
  22157. width?: number;
  22158. height?: number;
  22159. alignHorizontal?: number;
  22160. alignVertical?: number;
  22161. sideOrientation?: number;
  22162. frontUVs?: Vector4;
  22163. backUVs?: Vector4;
  22164. }): VertexData;
  22165. /**
  22166. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22167. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22168. * * segments sets the number of horizontal strips optional, default 32
  22169. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22170. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22171. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22172. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22173. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  22174. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  22175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22176. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22177. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22178. * @returns the VertexData of the ellipsoid
  22179. */
  22180. static CreateSphere(options: {
  22181. segments?: number;
  22182. diameter?: number;
  22183. diameterX?: number;
  22184. diameterY?: number;
  22185. diameterZ?: number;
  22186. arc?: number;
  22187. slice?: number;
  22188. sideOrientation?: number;
  22189. frontUVs?: Vector4;
  22190. backUVs?: Vector4;
  22191. }): VertexData;
  22192. /**
  22193. * Creates the VertexData for a cylinder, cone or prism
  22194. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22195. * * height sets the height (y direction) of the cylinder, optional, default 2
  22196. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22197. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22198. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22199. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22200. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22201. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  22202. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22203. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22204. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22205. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22207. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22208. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22209. * @returns the VertexData of the cylinder, cone or prism
  22210. */
  22211. static CreateCylinder(options: {
  22212. height?: number;
  22213. diameterTop?: number;
  22214. diameterBottom?: number;
  22215. diameter?: number;
  22216. tessellation?: number;
  22217. subdivisions?: number;
  22218. arc?: number;
  22219. faceColors?: Color4[];
  22220. faceUV?: Vector4[];
  22221. hasRings?: boolean;
  22222. enclose?: boolean;
  22223. sideOrientation?: number;
  22224. frontUVs?: Vector4;
  22225. backUVs?: Vector4;
  22226. }): VertexData;
  22227. /**
  22228. * Creates the VertexData for a torus
  22229. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22230. * * diameter the diameter of the torus, optional default 1
  22231. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22232. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22234. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22235. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22236. * @returns the VertexData of the torus
  22237. */
  22238. static CreateTorus(options: {
  22239. diameter?: number;
  22240. thickness?: number;
  22241. tessellation?: number;
  22242. sideOrientation?: number;
  22243. frontUVs?: Vector4;
  22244. backUVs?: Vector4;
  22245. }): VertexData;
  22246. /**
  22247. * Creates the VertexData of the LineSystem
  22248. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22249. * - lines an array of lines, each line being an array of successive Vector3
  22250. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22251. * @returns the VertexData of the LineSystem
  22252. */
  22253. static CreateLineSystem(options: {
  22254. lines: Vector3[][];
  22255. colors?: Nullable<Color4[][]>;
  22256. }): VertexData;
  22257. /**
  22258. * Create the VertexData for a DashedLines
  22259. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22260. * - points an array successive Vector3
  22261. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22262. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22263. * - dashNb the intended total number of dashes, optional, default 200
  22264. * @returns the VertexData for the DashedLines
  22265. */
  22266. static CreateDashedLines(options: {
  22267. points: Vector3[];
  22268. dashSize?: number;
  22269. gapSize?: number;
  22270. dashNb?: number;
  22271. }): VertexData;
  22272. /**
  22273. * Creates the VertexData for a Ground
  22274. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22275. * - width the width (x direction) of the ground, optional, default 1
  22276. * - height the height (z direction) of the ground, optional, default 1
  22277. * - subdivisions the number of subdivisions per side, optional, default 1
  22278. * @returns the VertexData of the Ground
  22279. */
  22280. static CreateGround(options: {
  22281. width?: number;
  22282. height?: number;
  22283. subdivisions?: number;
  22284. subdivisionsX?: number;
  22285. subdivisionsY?: number;
  22286. }): VertexData;
  22287. /**
  22288. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22289. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22290. * * xmin the ground minimum X coordinate, optional, default -1
  22291. * * zmin the ground minimum Z coordinate, optional, default -1
  22292. * * xmax the ground maximum X coordinate, optional, default 1
  22293. * * zmax the ground maximum Z coordinate, optional, default 1
  22294. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  22295. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  22296. * @returns the VertexData of the TiledGround
  22297. */
  22298. static CreateTiledGround(options: {
  22299. xmin: number;
  22300. zmin: number;
  22301. xmax: number;
  22302. zmax: number;
  22303. subdivisions?: {
  22304. w: number;
  22305. h: number;
  22306. };
  22307. precision?: {
  22308. w: number;
  22309. h: number;
  22310. };
  22311. }): VertexData;
  22312. /**
  22313. * Creates the VertexData of the Ground designed from a heightmap
  22314. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22315. * * width the width (x direction) of the ground
  22316. * * height the height (z direction) of the ground
  22317. * * subdivisions the number of subdivisions per side
  22318. * * minHeight the minimum altitude on the ground, optional, default 0
  22319. * * maxHeight the maximum altitude on the ground, optional default 1
  22320. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22321. * * buffer the array holding the image color data
  22322. * * bufferWidth the width of image
  22323. * * bufferHeight the height of image
  22324. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22325. * @returns the VertexData of the Ground designed from a heightmap
  22326. */
  22327. static CreateGroundFromHeightMap(options: {
  22328. width: number;
  22329. height: number;
  22330. subdivisions: number;
  22331. minHeight: number;
  22332. maxHeight: number;
  22333. colorFilter: Color3;
  22334. buffer: Uint8Array;
  22335. bufferWidth: number;
  22336. bufferHeight: number;
  22337. alphaFilter: number;
  22338. }): VertexData;
  22339. /**
  22340. * Creates the VertexData for a Plane
  22341. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22342. * * size sets the width and height of the plane to the value of size, optional default 1
  22343. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22344. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22346. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22347. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22348. * @returns the VertexData of the box
  22349. */
  22350. static CreatePlane(options: {
  22351. size?: number;
  22352. width?: number;
  22353. height?: number;
  22354. sideOrientation?: number;
  22355. frontUVs?: Vector4;
  22356. backUVs?: Vector4;
  22357. }): VertexData;
  22358. /**
  22359. * Creates the VertexData of the Disc or regular Polygon
  22360. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22361. * * radius the radius of the disc, optional default 0.5
  22362. * * tessellation the number of polygon sides, optional, default 64
  22363. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  22364. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22365. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22366. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22367. * @returns the VertexData of the box
  22368. */
  22369. static CreateDisc(options: {
  22370. radius?: number;
  22371. tessellation?: number;
  22372. arc?: number;
  22373. sideOrientation?: number;
  22374. frontUVs?: Vector4;
  22375. backUVs?: Vector4;
  22376. }): VertexData;
  22377. /**
  22378. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22379. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22380. * @param polygon a mesh built from polygonTriangulation.build()
  22381. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22382. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22383. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22384. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22385. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22386. * @returns the VertexData of the Polygon
  22387. */
  22388. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22389. /**
  22390. * Creates the VertexData of the IcoSphere
  22391. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22392. * * radius the radius of the IcoSphere, optional default 1
  22393. * * radiusX allows stretching in the x direction, optional, default radius
  22394. * * radiusY allows stretching in the y direction, optional, default radius
  22395. * * radiusZ allows stretching in the z direction, optional, default radius
  22396. * * flat when true creates a flat shaded mesh, optional, default true
  22397. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22399. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22400. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22401. * @returns the VertexData of the IcoSphere
  22402. */
  22403. static CreateIcoSphere(options: {
  22404. radius?: number;
  22405. radiusX?: number;
  22406. radiusY?: number;
  22407. radiusZ?: number;
  22408. flat?: boolean;
  22409. subdivisions?: number;
  22410. sideOrientation?: number;
  22411. frontUVs?: Vector4;
  22412. backUVs?: Vector4;
  22413. }): VertexData;
  22414. /**
  22415. * Creates the VertexData for a Polyhedron
  22416. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22417. * * type provided types are:
  22418. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22419. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  22420. * * size the size of the IcoSphere, optional default 1
  22421. * * sizeX allows stretching in the x direction, optional, default size
  22422. * * sizeY allows stretching in the y direction, optional, default size
  22423. * * sizeZ allows stretching in the z direction, optional, default size
  22424. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  22425. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22426. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22427. * * flat when true creates a flat shaded mesh, optional, default true
  22428. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22430. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22431. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22432. * @returns the VertexData of the Polyhedron
  22433. */
  22434. static CreatePolyhedron(options: {
  22435. type?: number;
  22436. size?: number;
  22437. sizeX?: number;
  22438. sizeY?: number;
  22439. sizeZ?: number;
  22440. custom?: any;
  22441. faceUV?: Vector4[];
  22442. faceColors?: Color4[];
  22443. flat?: boolean;
  22444. sideOrientation?: number;
  22445. frontUVs?: Vector4;
  22446. backUVs?: Vector4;
  22447. }): VertexData;
  22448. /**
  22449. * Creates the VertexData for a TorusKnot
  22450. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22451. * * radius the radius of the torus knot, optional, default 2
  22452. * * tube the thickness of the tube, optional, default 0.5
  22453. * * radialSegments the number of sides on each tube segments, optional, default 32
  22454. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22455. * * p the number of windings around the z axis, optional, default 2
  22456. * * q the number of windings around the x axis, optional, default 3
  22457. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22458. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22459. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22460. * @returns the VertexData of the Torus Knot
  22461. */
  22462. static CreateTorusKnot(options: {
  22463. radius?: number;
  22464. tube?: number;
  22465. radialSegments?: number;
  22466. tubularSegments?: number;
  22467. p?: number;
  22468. q?: number;
  22469. sideOrientation?: number;
  22470. frontUVs?: Vector4;
  22471. backUVs?: Vector4;
  22472. }): VertexData;
  22473. /**
  22474. * Compute normals for given positions and indices
  22475. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22476. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22477. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22478. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22479. * * facetNormals : optional array of facet normals (vector3)
  22480. * * facetPositions : optional array of facet positions (vector3)
  22481. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22482. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22483. * * bInfo : optional bounding info, required for facetPartitioning computation
  22484. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22485. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22486. * * useRightHandedSystem: optional boolean to for right handed system computation
  22487. * * depthSort : optional boolean to enable the facet depth sort computation
  22488. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22489. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22490. */
  22491. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22492. facetNormals?: any;
  22493. facetPositions?: any;
  22494. facetPartitioning?: any;
  22495. ratio?: number;
  22496. bInfo?: any;
  22497. bbSize?: Vector3;
  22498. subDiv?: any;
  22499. useRightHandedSystem?: boolean;
  22500. depthSort?: boolean;
  22501. distanceTo?: Vector3;
  22502. depthSortedFacets?: any;
  22503. }): void;
  22504. /** @hidden */
  22505. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22506. /**
  22507. * Applies VertexData created from the imported parameters to the geometry
  22508. * @param parsedVertexData the parsed data from an imported file
  22509. * @param geometry the geometry to apply the VertexData to
  22510. */
  22511. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22512. }
  22513. }
  22514. declare module "babylonjs/Morph/morphTarget" {
  22515. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22516. import { Observable } from "babylonjs/Misc/observable";
  22517. import { Nullable, FloatArray } from "babylonjs/types";
  22518. import { Scene } from "babylonjs/scene";
  22519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22520. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22521. /**
  22522. * Defines a target to use with MorphTargetManager
  22523. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22524. */
  22525. export class MorphTarget implements IAnimatable {
  22526. /** defines the name of the target */
  22527. name: string;
  22528. /**
  22529. * Gets or sets the list of animations
  22530. */
  22531. animations: import("babylonjs/Animations/animation").Animation[];
  22532. private _scene;
  22533. private _positions;
  22534. private _normals;
  22535. private _tangents;
  22536. private _uvs;
  22537. private _influence;
  22538. /**
  22539. * Observable raised when the influence changes
  22540. */
  22541. onInfluenceChanged: Observable<boolean>;
  22542. /** @hidden */
  22543. _onDataLayoutChanged: Observable<void>;
  22544. /**
  22545. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22546. */
  22547. influence: number;
  22548. /**
  22549. * Gets or sets the id of the morph Target
  22550. */
  22551. id: string;
  22552. private _animationPropertiesOverride;
  22553. /**
  22554. * Gets or sets the animation properties override
  22555. */
  22556. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22557. /**
  22558. * Creates a new MorphTarget
  22559. * @param name defines the name of the target
  22560. * @param influence defines the influence to use
  22561. * @param scene defines the scene the morphtarget belongs to
  22562. */
  22563. constructor(
  22564. /** defines the name of the target */
  22565. name: string, influence?: number, scene?: Nullable<Scene>);
  22566. /**
  22567. * Gets a boolean defining if the target contains position data
  22568. */
  22569. readonly hasPositions: boolean;
  22570. /**
  22571. * Gets a boolean defining if the target contains normal data
  22572. */
  22573. readonly hasNormals: boolean;
  22574. /**
  22575. * Gets a boolean defining if the target contains tangent data
  22576. */
  22577. readonly hasTangents: boolean;
  22578. /**
  22579. * Gets a boolean defining if the target contains texture coordinates data
  22580. */
  22581. readonly hasUVs: boolean;
  22582. /**
  22583. * Affects position data to this target
  22584. * @param data defines the position data to use
  22585. */
  22586. setPositions(data: Nullable<FloatArray>): void;
  22587. /**
  22588. * Gets the position data stored in this target
  22589. * @returns a FloatArray containing the position data (or null if not present)
  22590. */
  22591. getPositions(): Nullable<FloatArray>;
  22592. /**
  22593. * Affects normal data to this target
  22594. * @param data defines the normal data to use
  22595. */
  22596. setNormals(data: Nullable<FloatArray>): void;
  22597. /**
  22598. * Gets the normal data stored in this target
  22599. * @returns a FloatArray containing the normal data (or null if not present)
  22600. */
  22601. getNormals(): Nullable<FloatArray>;
  22602. /**
  22603. * Affects tangent data to this target
  22604. * @param data defines the tangent data to use
  22605. */
  22606. setTangents(data: Nullable<FloatArray>): void;
  22607. /**
  22608. * Gets the tangent data stored in this target
  22609. * @returns a FloatArray containing the tangent data (or null if not present)
  22610. */
  22611. getTangents(): Nullable<FloatArray>;
  22612. /**
  22613. * Affects texture coordinates data to this target
  22614. * @param data defines the texture coordinates data to use
  22615. */
  22616. setUVs(data: Nullable<FloatArray>): void;
  22617. /**
  22618. * Gets the texture coordinates data stored in this target
  22619. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22620. */
  22621. getUVs(): Nullable<FloatArray>;
  22622. /**
  22623. * Serializes the current target into a Serialization object
  22624. * @returns the serialized object
  22625. */
  22626. serialize(): any;
  22627. /**
  22628. * Returns the string "MorphTarget"
  22629. * @returns "MorphTarget"
  22630. */
  22631. getClassName(): string;
  22632. /**
  22633. * Creates a new target from serialized data
  22634. * @param serializationObject defines the serialized data to use
  22635. * @returns a new MorphTarget
  22636. */
  22637. static Parse(serializationObject: any): MorphTarget;
  22638. /**
  22639. * Creates a MorphTarget from mesh data
  22640. * @param mesh defines the source mesh
  22641. * @param name defines the name to use for the new target
  22642. * @param influence defines the influence to attach to the target
  22643. * @returns a new MorphTarget
  22644. */
  22645. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22646. }
  22647. }
  22648. declare module "babylonjs/Morph/morphTargetManager" {
  22649. import { Nullable } from "babylonjs/types";
  22650. import { Scene } from "babylonjs/scene";
  22651. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22652. /**
  22653. * This class is used to deform meshes using morphing between different targets
  22654. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22655. */
  22656. export class MorphTargetManager {
  22657. private _targets;
  22658. private _targetInfluenceChangedObservers;
  22659. private _targetDataLayoutChangedObservers;
  22660. private _activeTargets;
  22661. private _scene;
  22662. private _influences;
  22663. private _supportsNormals;
  22664. private _supportsTangents;
  22665. private _supportsUVs;
  22666. private _vertexCount;
  22667. private _uniqueId;
  22668. private _tempInfluences;
  22669. /**
  22670. * Gets or sets a boolean indicating if normals must be morphed
  22671. */
  22672. enableNormalMorphing: boolean;
  22673. /**
  22674. * Gets or sets a boolean indicating if tangents must be morphed
  22675. */
  22676. enableTangentMorphing: boolean;
  22677. /**
  22678. * Gets or sets a boolean indicating if UV must be morphed
  22679. */
  22680. enableUVMorphing: boolean;
  22681. /**
  22682. * Creates a new MorphTargetManager
  22683. * @param scene defines the current scene
  22684. */
  22685. constructor(scene?: Nullable<Scene>);
  22686. /**
  22687. * Gets the unique ID of this manager
  22688. */
  22689. readonly uniqueId: number;
  22690. /**
  22691. * Gets the number of vertices handled by this manager
  22692. */
  22693. readonly vertexCount: number;
  22694. /**
  22695. * Gets a boolean indicating if this manager supports morphing of normals
  22696. */
  22697. readonly supportsNormals: boolean;
  22698. /**
  22699. * Gets a boolean indicating if this manager supports morphing of tangents
  22700. */
  22701. readonly supportsTangents: boolean;
  22702. /**
  22703. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22704. */
  22705. readonly supportsUVs: boolean;
  22706. /**
  22707. * Gets the number of targets stored in this manager
  22708. */
  22709. readonly numTargets: number;
  22710. /**
  22711. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22712. */
  22713. readonly numInfluencers: number;
  22714. /**
  22715. * Gets the list of influences (one per target)
  22716. */
  22717. readonly influences: Float32Array;
  22718. /**
  22719. * Gets the active target at specified index. An active target is a target with an influence > 0
  22720. * @param index defines the index to check
  22721. * @returns the requested target
  22722. */
  22723. getActiveTarget(index: number): MorphTarget;
  22724. /**
  22725. * Gets the target at specified index
  22726. * @param index defines the index to check
  22727. * @returns the requested target
  22728. */
  22729. getTarget(index: number): MorphTarget;
  22730. /**
  22731. * Add a new target to this manager
  22732. * @param target defines the target to add
  22733. */
  22734. addTarget(target: MorphTarget): void;
  22735. /**
  22736. * Removes a target from the manager
  22737. * @param target defines the target to remove
  22738. */
  22739. removeTarget(target: MorphTarget): void;
  22740. /**
  22741. * Serializes the current manager into a Serialization object
  22742. * @returns the serialized object
  22743. */
  22744. serialize(): any;
  22745. private _syncActiveTargets;
  22746. /**
  22747. * Syncrhonize the targets with all the meshes using this morph target manager
  22748. */
  22749. synchronize(): void;
  22750. /**
  22751. * Creates a new MorphTargetManager from serialized data
  22752. * @param serializationObject defines the serialized data
  22753. * @param scene defines the hosting scene
  22754. * @returns the new MorphTargetManager
  22755. */
  22756. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22757. }
  22758. }
  22759. declare module "babylonjs/Meshes/meshLODLevel" {
  22760. import { Mesh } from "babylonjs/Meshes/mesh";
  22761. import { Nullable } from "babylonjs/types";
  22762. /**
  22763. * Class used to represent a specific level of detail of a mesh
  22764. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22765. */
  22766. export class MeshLODLevel {
  22767. /** Defines the distance where this level should start being displayed */
  22768. distance: number;
  22769. /** Defines the mesh to use to render this level */
  22770. mesh: Nullable<Mesh>;
  22771. /**
  22772. * Creates a new LOD level
  22773. * @param distance defines the distance where this level should star being displayed
  22774. * @param mesh defines the mesh to use to render this level
  22775. */
  22776. constructor(
  22777. /** Defines the distance where this level should start being displayed */
  22778. distance: number,
  22779. /** Defines the mesh to use to render this level */
  22780. mesh: Nullable<Mesh>);
  22781. }
  22782. }
  22783. declare module "babylonjs/Meshes/groundMesh" {
  22784. import { Scene } from "babylonjs/scene";
  22785. import { Vector3 } from "babylonjs/Maths/math.vector";
  22786. import { Mesh } from "babylonjs/Meshes/mesh";
  22787. /**
  22788. * Mesh representing the gorund
  22789. */
  22790. export class GroundMesh extends Mesh {
  22791. /** If octree should be generated */
  22792. generateOctree: boolean;
  22793. private _heightQuads;
  22794. /** @hidden */
  22795. _subdivisionsX: number;
  22796. /** @hidden */
  22797. _subdivisionsY: number;
  22798. /** @hidden */
  22799. _width: number;
  22800. /** @hidden */
  22801. _height: number;
  22802. /** @hidden */
  22803. _minX: number;
  22804. /** @hidden */
  22805. _maxX: number;
  22806. /** @hidden */
  22807. _minZ: number;
  22808. /** @hidden */
  22809. _maxZ: number;
  22810. constructor(name: string, scene: Scene);
  22811. /**
  22812. * "GroundMesh"
  22813. * @returns "GroundMesh"
  22814. */
  22815. getClassName(): string;
  22816. /**
  22817. * The minimum of x and y subdivisions
  22818. */
  22819. readonly subdivisions: number;
  22820. /**
  22821. * X subdivisions
  22822. */
  22823. readonly subdivisionsX: number;
  22824. /**
  22825. * Y subdivisions
  22826. */
  22827. readonly subdivisionsY: number;
  22828. /**
  22829. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22830. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22831. * @param chunksCount the number of subdivisions for x and y
  22832. * @param octreeBlocksSize (Default: 32)
  22833. */
  22834. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22835. /**
  22836. * Returns a height (y) value in the Worl system :
  22837. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22838. * @param x x coordinate
  22839. * @param z z coordinate
  22840. * @returns the ground y position if (x, z) are outside the ground surface.
  22841. */
  22842. getHeightAtCoordinates(x: number, z: number): number;
  22843. /**
  22844. * Returns a normalized vector (Vector3) orthogonal to the ground
  22845. * at the ground coordinates (x, z) expressed in the World system.
  22846. * @param x x coordinate
  22847. * @param z z coordinate
  22848. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22849. */
  22850. getNormalAtCoordinates(x: number, z: number): Vector3;
  22851. /**
  22852. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22853. * at the ground coordinates (x, z) expressed in the World system.
  22854. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22855. * @param x x coordinate
  22856. * @param z z coordinate
  22857. * @param ref vector to store the result
  22858. * @returns the GroundMesh.
  22859. */
  22860. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22861. /**
  22862. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22863. * if the ground has been updated.
  22864. * This can be used in the render loop.
  22865. * @returns the GroundMesh.
  22866. */
  22867. updateCoordinateHeights(): GroundMesh;
  22868. private _getFacetAt;
  22869. private _initHeightQuads;
  22870. private _computeHeightQuads;
  22871. /**
  22872. * Serializes this ground mesh
  22873. * @param serializationObject object to write serialization to
  22874. */
  22875. serialize(serializationObject: any): void;
  22876. /**
  22877. * Parses a serialized ground mesh
  22878. * @param parsedMesh the serialized mesh
  22879. * @param scene the scene to create the ground mesh in
  22880. * @returns the created ground mesh
  22881. */
  22882. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22883. }
  22884. }
  22885. declare module "babylonjs/Physics/physicsJoint" {
  22886. import { Vector3 } from "babylonjs/Maths/math.vector";
  22887. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22888. /**
  22889. * Interface for Physics-Joint data
  22890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22891. */
  22892. export interface PhysicsJointData {
  22893. /**
  22894. * The main pivot of the joint
  22895. */
  22896. mainPivot?: Vector3;
  22897. /**
  22898. * The connected pivot of the joint
  22899. */
  22900. connectedPivot?: Vector3;
  22901. /**
  22902. * The main axis of the joint
  22903. */
  22904. mainAxis?: Vector3;
  22905. /**
  22906. * The connected axis of the joint
  22907. */
  22908. connectedAxis?: Vector3;
  22909. /**
  22910. * The collision of the joint
  22911. */
  22912. collision?: boolean;
  22913. /**
  22914. * Native Oimo/Cannon/Energy data
  22915. */
  22916. nativeParams?: any;
  22917. }
  22918. /**
  22919. * This is a holder class for the physics joint created by the physics plugin
  22920. * It holds a set of functions to control the underlying joint
  22921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22922. */
  22923. export class PhysicsJoint {
  22924. /**
  22925. * The type of the physics joint
  22926. */
  22927. type: number;
  22928. /**
  22929. * The data for the physics joint
  22930. */
  22931. jointData: PhysicsJointData;
  22932. private _physicsJoint;
  22933. protected _physicsPlugin: IPhysicsEnginePlugin;
  22934. /**
  22935. * Initializes the physics joint
  22936. * @param type The type of the physics joint
  22937. * @param jointData The data for the physics joint
  22938. */
  22939. constructor(
  22940. /**
  22941. * The type of the physics joint
  22942. */
  22943. type: number,
  22944. /**
  22945. * The data for the physics joint
  22946. */
  22947. jointData: PhysicsJointData);
  22948. /**
  22949. * Gets the physics joint
  22950. */
  22951. /**
  22952. * Sets the physics joint
  22953. */
  22954. physicsJoint: any;
  22955. /**
  22956. * Sets the physics plugin
  22957. */
  22958. physicsPlugin: IPhysicsEnginePlugin;
  22959. /**
  22960. * Execute a function that is physics-plugin specific.
  22961. * @param {Function} func the function that will be executed.
  22962. * It accepts two parameters: the physics world and the physics joint
  22963. */
  22964. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22965. /**
  22966. * Distance-Joint type
  22967. */
  22968. static DistanceJoint: number;
  22969. /**
  22970. * Hinge-Joint type
  22971. */
  22972. static HingeJoint: number;
  22973. /**
  22974. * Ball-and-Socket joint type
  22975. */
  22976. static BallAndSocketJoint: number;
  22977. /**
  22978. * Wheel-Joint type
  22979. */
  22980. static WheelJoint: number;
  22981. /**
  22982. * Slider-Joint type
  22983. */
  22984. static SliderJoint: number;
  22985. /**
  22986. * Prismatic-Joint type
  22987. */
  22988. static PrismaticJoint: number;
  22989. /**
  22990. * Universal-Joint type
  22991. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22992. */
  22993. static UniversalJoint: number;
  22994. /**
  22995. * Hinge-Joint 2 type
  22996. */
  22997. static Hinge2Joint: number;
  22998. /**
  22999. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23000. */
  23001. static PointToPointJoint: number;
  23002. /**
  23003. * Spring-Joint type
  23004. */
  23005. static SpringJoint: number;
  23006. /**
  23007. * Lock-Joint type
  23008. */
  23009. static LockJoint: number;
  23010. }
  23011. /**
  23012. * A class representing a physics distance joint
  23013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23014. */
  23015. export class DistanceJoint extends PhysicsJoint {
  23016. /**
  23017. *
  23018. * @param jointData The data for the Distance-Joint
  23019. */
  23020. constructor(jointData: DistanceJointData);
  23021. /**
  23022. * Update the predefined distance.
  23023. * @param maxDistance The maximum preferred distance
  23024. * @param minDistance The minimum preferred distance
  23025. */
  23026. updateDistance(maxDistance: number, minDistance?: number): void;
  23027. }
  23028. /**
  23029. * Represents a Motor-Enabled Joint
  23030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23031. */
  23032. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23033. /**
  23034. * Initializes the Motor-Enabled Joint
  23035. * @param type The type of the joint
  23036. * @param jointData The physica joint data for the joint
  23037. */
  23038. constructor(type: number, jointData: PhysicsJointData);
  23039. /**
  23040. * Set the motor values.
  23041. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23042. * @param force the force to apply
  23043. * @param maxForce max force for this motor.
  23044. */
  23045. setMotor(force?: number, maxForce?: number): void;
  23046. /**
  23047. * Set the motor's limits.
  23048. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23049. * @param upperLimit The upper limit of the motor
  23050. * @param lowerLimit The lower limit of the motor
  23051. */
  23052. setLimit(upperLimit: number, lowerLimit?: number): void;
  23053. }
  23054. /**
  23055. * This class represents a single physics Hinge-Joint
  23056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23057. */
  23058. export class HingeJoint extends MotorEnabledJoint {
  23059. /**
  23060. * Initializes the Hinge-Joint
  23061. * @param jointData The joint data for the Hinge-Joint
  23062. */
  23063. constructor(jointData: PhysicsJointData);
  23064. /**
  23065. * Set the motor values.
  23066. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23067. * @param {number} force the force to apply
  23068. * @param {number} maxForce max force for this motor.
  23069. */
  23070. setMotor(force?: number, maxForce?: number): void;
  23071. /**
  23072. * Set the motor's limits.
  23073. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23074. * @param upperLimit The upper limit of the motor
  23075. * @param lowerLimit The lower limit of the motor
  23076. */
  23077. setLimit(upperLimit: number, lowerLimit?: number): void;
  23078. }
  23079. /**
  23080. * This class represents a dual hinge physics joint (same as wheel joint)
  23081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23082. */
  23083. export class Hinge2Joint extends MotorEnabledJoint {
  23084. /**
  23085. * Initializes the Hinge2-Joint
  23086. * @param jointData The joint data for the Hinge2-Joint
  23087. */
  23088. constructor(jointData: PhysicsJointData);
  23089. /**
  23090. * Set the motor values.
  23091. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23092. * @param {number} targetSpeed the speed the motor is to reach
  23093. * @param {number} maxForce max force for this motor.
  23094. * @param {motorIndex} the motor's index, 0 or 1.
  23095. */
  23096. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23097. /**
  23098. * Set the motor limits.
  23099. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23100. * @param {number} upperLimit the upper limit
  23101. * @param {number} lowerLimit lower limit
  23102. * @param {motorIndex} the motor's index, 0 or 1.
  23103. */
  23104. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23105. }
  23106. /**
  23107. * Interface for a motor enabled joint
  23108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23109. */
  23110. export interface IMotorEnabledJoint {
  23111. /**
  23112. * Physics joint
  23113. */
  23114. physicsJoint: any;
  23115. /**
  23116. * Sets the motor of the motor-enabled joint
  23117. * @param force The force of the motor
  23118. * @param maxForce The maximum force of the motor
  23119. * @param motorIndex The index of the motor
  23120. */
  23121. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23122. /**
  23123. * Sets the limit of the motor
  23124. * @param upperLimit The upper limit of the motor
  23125. * @param lowerLimit The lower limit of the motor
  23126. * @param motorIndex The index of the motor
  23127. */
  23128. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23129. }
  23130. /**
  23131. * Joint data for a Distance-Joint
  23132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23133. */
  23134. export interface DistanceJointData extends PhysicsJointData {
  23135. /**
  23136. * Max distance the 2 joint objects can be apart
  23137. */
  23138. maxDistance: number;
  23139. }
  23140. /**
  23141. * Joint data from a spring joint
  23142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23143. */
  23144. export interface SpringJointData extends PhysicsJointData {
  23145. /**
  23146. * Length of the spring
  23147. */
  23148. length: number;
  23149. /**
  23150. * Stiffness of the spring
  23151. */
  23152. stiffness: number;
  23153. /**
  23154. * Damping of the spring
  23155. */
  23156. damping: number;
  23157. /** this callback will be called when applying the force to the impostors. */
  23158. forceApplicationCallback: () => void;
  23159. }
  23160. }
  23161. declare module "babylonjs/Physics/physicsRaycastResult" {
  23162. import { Vector3 } from "babylonjs/Maths/math.vector";
  23163. /**
  23164. * Holds the data for the raycast result
  23165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23166. */
  23167. export class PhysicsRaycastResult {
  23168. private _hasHit;
  23169. private _hitDistance;
  23170. private _hitNormalWorld;
  23171. private _hitPointWorld;
  23172. private _rayFromWorld;
  23173. private _rayToWorld;
  23174. /**
  23175. * Gets if there was a hit
  23176. */
  23177. readonly hasHit: boolean;
  23178. /**
  23179. * Gets the distance from the hit
  23180. */
  23181. readonly hitDistance: number;
  23182. /**
  23183. * Gets the hit normal/direction in the world
  23184. */
  23185. readonly hitNormalWorld: Vector3;
  23186. /**
  23187. * Gets the hit point in the world
  23188. */
  23189. readonly hitPointWorld: Vector3;
  23190. /**
  23191. * Gets the ray "start point" of the ray in the world
  23192. */
  23193. readonly rayFromWorld: Vector3;
  23194. /**
  23195. * Gets the ray "end point" of the ray in the world
  23196. */
  23197. readonly rayToWorld: Vector3;
  23198. /**
  23199. * Sets the hit data (normal & point in world space)
  23200. * @param hitNormalWorld defines the normal in world space
  23201. * @param hitPointWorld defines the point in world space
  23202. */
  23203. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23204. /**
  23205. * Sets the distance from the start point to the hit point
  23206. * @param distance
  23207. */
  23208. setHitDistance(distance: number): void;
  23209. /**
  23210. * Calculates the distance manually
  23211. */
  23212. calculateHitDistance(): void;
  23213. /**
  23214. * Resets all the values to default
  23215. * @param from The from point on world space
  23216. * @param to The to point on world space
  23217. */
  23218. reset(from?: Vector3, to?: Vector3): void;
  23219. }
  23220. /**
  23221. * Interface for the size containing width and height
  23222. */
  23223. interface IXYZ {
  23224. /**
  23225. * X
  23226. */
  23227. x: number;
  23228. /**
  23229. * Y
  23230. */
  23231. y: number;
  23232. /**
  23233. * Z
  23234. */
  23235. z: number;
  23236. }
  23237. }
  23238. declare module "babylonjs/Physics/IPhysicsEngine" {
  23239. import { Nullable } from "babylonjs/types";
  23240. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23242. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23243. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23244. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23245. /**
  23246. * Interface used to describe a physics joint
  23247. */
  23248. export interface PhysicsImpostorJoint {
  23249. /** Defines the main impostor to which the joint is linked */
  23250. mainImpostor: PhysicsImpostor;
  23251. /** Defines the impostor that is connected to the main impostor using this joint */
  23252. connectedImpostor: PhysicsImpostor;
  23253. /** Defines the joint itself */
  23254. joint: PhysicsJoint;
  23255. }
  23256. /** @hidden */
  23257. export interface IPhysicsEnginePlugin {
  23258. world: any;
  23259. name: string;
  23260. setGravity(gravity: Vector3): void;
  23261. setTimeStep(timeStep: number): void;
  23262. getTimeStep(): number;
  23263. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23264. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23265. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23266. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23267. removePhysicsBody(impostor: PhysicsImpostor): void;
  23268. generateJoint(joint: PhysicsImpostorJoint): void;
  23269. removeJoint(joint: PhysicsImpostorJoint): void;
  23270. isSupported(): boolean;
  23271. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23272. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23273. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23274. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23275. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23276. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23277. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23278. getBodyMass(impostor: PhysicsImpostor): number;
  23279. getBodyFriction(impostor: PhysicsImpostor): number;
  23280. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23281. getBodyRestitution(impostor: PhysicsImpostor): number;
  23282. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23283. getBodyPressure?(impostor: PhysicsImpostor): number;
  23284. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23285. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23286. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23287. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23288. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23289. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23290. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23291. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23292. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23293. sleepBody(impostor: PhysicsImpostor): void;
  23294. wakeUpBody(impostor: PhysicsImpostor): void;
  23295. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23296. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23297. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23298. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23299. getRadius(impostor: PhysicsImpostor): number;
  23300. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23301. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23302. dispose(): void;
  23303. }
  23304. /**
  23305. * Interface used to define a physics engine
  23306. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23307. */
  23308. export interface IPhysicsEngine {
  23309. /**
  23310. * Gets the gravity vector used by the simulation
  23311. */
  23312. gravity: Vector3;
  23313. /**
  23314. * Sets the gravity vector used by the simulation
  23315. * @param gravity defines the gravity vector to use
  23316. */
  23317. setGravity(gravity: Vector3): void;
  23318. /**
  23319. * Set the time step of the physics engine.
  23320. * Default is 1/60.
  23321. * To slow it down, enter 1/600 for example.
  23322. * To speed it up, 1/30
  23323. * @param newTimeStep the new timestep to apply to this world.
  23324. */
  23325. setTimeStep(newTimeStep: number): void;
  23326. /**
  23327. * Get the time step of the physics engine.
  23328. * @returns the current time step
  23329. */
  23330. getTimeStep(): number;
  23331. /**
  23332. * Release all resources
  23333. */
  23334. dispose(): void;
  23335. /**
  23336. * Gets the name of the current physics plugin
  23337. * @returns the name of the plugin
  23338. */
  23339. getPhysicsPluginName(): string;
  23340. /**
  23341. * Adding a new impostor for the impostor tracking.
  23342. * This will be done by the impostor itself.
  23343. * @param impostor the impostor to add
  23344. */
  23345. addImpostor(impostor: PhysicsImpostor): void;
  23346. /**
  23347. * Remove an impostor from the engine.
  23348. * This impostor and its mesh will not longer be updated by the physics engine.
  23349. * @param impostor the impostor to remove
  23350. */
  23351. removeImpostor(impostor: PhysicsImpostor): void;
  23352. /**
  23353. * Add a joint to the physics engine
  23354. * @param mainImpostor defines the main impostor to which the joint is added.
  23355. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23356. * @param joint defines the joint that will connect both impostors.
  23357. */
  23358. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23359. /**
  23360. * Removes a joint from the simulation
  23361. * @param mainImpostor defines the impostor used with the joint
  23362. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23363. * @param joint defines the joint to remove
  23364. */
  23365. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23366. /**
  23367. * Gets the current plugin used to run the simulation
  23368. * @returns current plugin
  23369. */
  23370. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23371. /**
  23372. * Gets the list of physic impostors
  23373. * @returns an array of PhysicsImpostor
  23374. */
  23375. getImpostors(): Array<PhysicsImpostor>;
  23376. /**
  23377. * Gets the impostor for a physics enabled object
  23378. * @param object defines the object impersonated by the impostor
  23379. * @returns the PhysicsImpostor or null if not found
  23380. */
  23381. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23382. /**
  23383. * Gets the impostor for a physics body object
  23384. * @param body defines physics body used by the impostor
  23385. * @returns the PhysicsImpostor or null if not found
  23386. */
  23387. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23388. /**
  23389. * Does a raycast in the physics world
  23390. * @param from when should the ray start?
  23391. * @param to when should the ray end?
  23392. * @returns PhysicsRaycastResult
  23393. */
  23394. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23395. /**
  23396. * Called by the scene. No need to call it.
  23397. * @param delta defines the timespam between frames
  23398. */
  23399. _step(delta: number): void;
  23400. }
  23401. }
  23402. declare module "babylonjs/Physics/physicsImpostor" {
  23403. import { Nullable, IndicesArray } from "babylonjs/types";
  23404. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23405. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23407. import { Scene } from "babylonjs/scene";
  23408. import { Bone } from "babylonjs/Bones/bone";
  23409. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23410. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23411. import { Space } from "babylonjs/Maths/math.axis";
  23412. /**
  23413. * The interface for the physics imposter parameters
  23414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23415. */
  23416. export interface PhysicsImpostorParameters {
  23417. /**
  23418. * The mass of the physics imposter
  23419. */
  23420. mass: number;
  23421. /**
  23422. * The friction of the physics imposter
  23423. */
  23424. friction?: number;
  23425. /**
  23426. * The coefficient of restitution of the physics imposter
  23427. */
  23428. restitution?: number;
  23429. /**
  23430. * The native options of the physics imposter
  23431. */
  23432. nativeOptions?: any;
  23433. /**
  23434. * Specifies if the parent should be ignored
  23435. */
  23436. ignoreParent?: boolean;
  23437. /**
  23438. * Specifies if bi-directional transformations should be disabled
  23439. */
  23440. disableBidirectionalTransformation?: boolean;
  23441. /**
  23442. * The pressure inside the physics imposter, soft object only
  23443. */
  23444. pressure?: number;
  23445. /**
  23446. * The stiffness the physics imposter, soft object only
  23447. */
  23448. stiffness?: number;
  23449. /**
  23450. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23451. */
  23452. velocityIterations?: number;
  23453. /**
  23454. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23455. */
  23456. positionIterations?: number;
  23457. /**
  23458. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23459. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23460. * Add to fix multiple points
  23461. */
  23462. fixedPoints?: number;
  23463. /**
  23464. * The collision margin around a soft object
  23465. */
  23466. margin?: number;
  23467. /**
  23468. * The collision margin around a soft object
  23469. */
  23470. damping?: number;
  23471. /**
  23472. * The path for a rope based on an extrusion
  23473. */
  23474. path?: any;
  23475. /**
  23476. * The shape of an extrusion used for a rope based on an extrusion
  23477. */
  23478. shape?: any;
  23479. }
  23480. /**
  23481. * Interface for a physics-enabled object
  23482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23483. */
  23484. export interface IPhysicsEnabledObject {
  23485. /**
  23486. * The position of the physics-enabled object
  23487. */
  23488. position: Vector3;
  23489. /**
  23490. * The rotation of the physics-enabled object
  23491. */
  23492. rotationQuaternion: Nullable<Quaternion>;
  23493. /**
  23494. * The scale of the physics-enabled object
  23495. */
  23496. scaling: Vector3;
  23497. /**
  23498. * The rotation of the physics-enabled object
  23499. */
  23500. rotation?: Vector3;
  23501. /**
  23502. * The parent of the physics-enabled object
  23503. */
  23504. parent?: any;
  23505. /**
  23506. * The bounding info of the physics-enabled object
  23507. * @returns The bounding info of the physics-enabled object
  23508. */
  23509. getBoundingInfo(): BoundingInfo;
  23510. /**
  23511. * Computes the world matrix
  23512. * @param force Specifies if the world matrix should be computed by force
  23513. * @returns A world matrix
  23514. */
  23515. computeWorldMatrix(force: boolean): Matrix;
  23516. /**
  23517. * Gets the world matrix
  23518. * @returns A world matrix
  23519. */
  23520. getWorldMatrix?(): Matrix;
  23521. /**
  23522. * Gets the child meshes
  23523. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23524. * @returns An array of abstract meshes
  23525. */
  23526. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23527. /**
  23528. * Gets the vertex data
  23529. * @param kind The type of vertex data
  23530. * @returns A nullable array of numbers, or a float32 array
  23531. */
  23532. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23533. /**
  23534. * Gets the indices from the mesh
  23535. * @returns A nullable array of index arrays
  23536. */
  23537. getIndices?(): Nullable<IndicesArray>;
  23538. /**
  23539. * Gets the scene from the mesh
  23540. * @returns the indices array or null
  23541. */
  23542. getScene?(): Scene;
  23543. /**
  23544. * Gets the absolute position from the mesh
  23545. * @returns the absolute position
  23546. */
  23547. getAbsolutePosition(): Vector3;
  23548. /**
  23549. * Gets the absolute pivot point from the mesh
  23550. * @returns the absolute pivot point
  23551. */
  23552. getAbsolutePivotPoint(): Vector3;
  23553. /**
  23554. * Rotates the mesh
  23555. * @param axis The axis of rotation
  23556. * @param amount The amount of rotation
  23557. * @param space The space of the rotation
  23558. * @returns The rotation transform node
  23559. */
  23560. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23561. /**
  23562. * Translates the mesh
  23563. * @param axis The axis of translation
  23564. * @param distance The distance of translation
  23565. * @param space The space of the translation
  23566. * @returns The transform node
  23567. */
  23568. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23569. /**
  23570. * Sets the absolute position of the mesh
  23571. * @param absolutePosition The absolute position of the mesh
  23572. * @returns The transform node
  23573. */
  23574. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23575. /**
  23576. * Gets the class name of the mesh
  23577. * @returns The class name
  23578. */
  23579. getClassName(): string;
  23580. }
  23581. /**
  23582. * Represents a physics imposter
  23583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23584. */
  23585. export class PhysicsImpostor {
  23586. /**
  23587. * The physics-enabled object used as the physics imposter
  23588. */
  23589. object: IPhysicsEnabledObject;
  23590. /**
  23591. * The type of the physics imposter
  23592. */
  23593. type: number;
  23594. private _options;
  23595. private _scene?;
  23596. /**
  23597. * The default object size of the imposter
  23598. */
  23599. static DEFAULT_OBJECT_SIZE: Vector3;
  23600. /**
  23601. * The identity quaternion of the imposter
  23602. */
  23603. static IDENTITY_QUATERNION: Quaternion;
  23604. /** @hidden */
  23605. _pluginData: any;
  23606. private _physicsEngine;
  23607. private _physicsBody;
  23608. private _bodyUpdateRequired;
  23609. private _onBeforePhysicsStepCallbacks;
  23610. private _onAfterPhysicsStepCallbacks;
  23611. /** @hidden */
  23612. _onPhysicsCollideCallbacks: Array<{
  23613. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23614. otherImpostors: Array<PhysicsImpostor>;
  23615. }>;
  23616. private _deltaPosition;
  23617. private _deltaRotation;
  23618. private _deltaRotationConjugated;
  23619. /** @hidden */
  23620. _isFromLine: boolean;
  23621. private _parent;
  23622. private _isDisposed;
  23623. private static _tmpVecs;
  23624. private static _tmpQuat;
  23625. /**
  23626. * Specifies if the physics imposter is disposed
  23627. */
  23628. readonly isDisposed: boolean;
  23629. /**
  23630. * Gets the mass of the physics imposter
  23631. */
  23632. mass: number;
  23633. /**
  23634. * Gets the coefficient of friction
  23635. */
  23636. /**
  23637. * Sets the coefficient of friction
  23638. */
  23639. friction: number;
  23640. /**
  23641. * Gets the coefficient of restitution
  23642. */
  23643. /**
  23644. * Sets the coefficient of restitution
  23645. */
  23646. restitution: number;
  23647. /**
  23648. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23649. */
  23650. /**
  23651. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23652. */
  23653. pressure: number;
  23654. /**
  23655. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23656. */
  23657. /**
  23658. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23659. */
  23660. stiffness: number;
  23661. /**
  23662. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23663. */
  23664. /**
  23665. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23666. */
  23667. velocityIterations: number;
  23668. /**
  23669. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23670. */
  23671. /**
  23672. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23673. */
  23674. positionIterations: number;
  23675. /**
  23676. * The unique id of the physics imposter
  23677. * set by the physics engine when adding this impostor to the array
  23678. */
  23679. uniqueId: number;
  23680. /**
  23681. * @hidden
  23682. */
  23683. soft: boolean;
  23684. /**
  23685. * @hidden
  23686. */
  23687. segments: number;
  23688. private _joints;
  23689. /**
  23690. * Initializes the physics imposter
  23691. * @param object The physics-enabled object used as the physics imposter
  23692. * @param type The type of the physics imposter
  23693. * @param _options The options for the physics imposter
  23694. * @param _scene The Babylon scene
  23695. */
  23696. constructor(
  23697. /**
  23698. * The physics-enabled object used as the physics imposter
  23699. */
  23700. object: IPhysicsEnabledObject,
  23701. /**
  23702. * The type of the physics imposter
  23703. */
  23704. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23705. /**
  23706. * This function will completly initialize this impostor.
  23707. * It will create a new body - but only if this mesh has no parent.
  23708. * If it has, this impostor will not be used other than to define the impostor
  23709. * of the child mesh.
  23710. * @hidden
  23711. */
  23712. _init(): void;
  23713. private _getPhysicsParent;
  23714. /**
  23715. * Should a new body be generated.
  23716. * @returns boolean specifying if body initialization is required
  23717. */
  23718. isBodyInitRequired(): boolean;
  23719. /**
  23720. * Sets the updated scaling
  23721. * @param updated Specifies if the scaling is updated
  23722. */
  23723. setScalingUpdated(): void;
  23724. /**
  23725. * Force a regeneration of this or the parent's impostor's body.
  23726. * Use under cautious - This will remove all joints already implemented.
  23727. */
  23728. forceUpdate(): void;
  23729. /**
  23730. * Gets the body that holds this impostor. Either its own, or its parent.
  23731. */
  23732. /**
  23733. * Set the physics body. Used mainly by the physics engine/plugin
  23734. */
  23735. physicsBody: any;
  23736. /**
  23737. * Get the parent of the physics imposter
  23738. * @returns Physics imposter or null
  23739. */
  23740. /**
  23741. * Sets the parent of the physics imposter
  23742. */
  23743. parent: Nullable<PhysicsImpostor>;
  23744. /**
  23745. * Resets the update flags
  23746. */
  23747. resetUpdateFlags(): void;
  23748. /**
  23749. * Gets the object extend size
  23750. * @returns the object extend size
  23751. */
  23752. getObjectExtendSize(): Vector3;
  23753. /**
  23754. * Gets the object center
  23755. * @returns The object center
  23756. */
  23757. getObjectCenter(): Vector3;
  23758. /**
  23759. * Get a specific parametes from the options parameter
  23760. * @param paramName The object parameter name
  23761. * @returns The object parameter
  23762. */
  23763. getParam(paramName: string): any;
  23764. /**
  23765. * Sets a specific parameter in the options given to the physics plugin
  23766. * @param paramName The parameter name
  23767. * @param value The value of the parameter
  23768. */
  23769. setParam(paramName: string, value: number): void;
  23770. /**
  23771. * Specifically change the body's mass option. Won't recreate the physics body object
  23772. * @param mass The mass of the physics imposter
  23773. */
  23774. setMass(mass: number): void;
  23775. /**
  23776. * Gets the linear velocity
  23777. * @returns linear velocity or null
  23778. */
  23779. getLinearVelocity(): Nullable<Vector3>;
  23780. /**
  23781. * Sets the linear velocity
  23782. * @param velocity linear velocity or null
  23783. */
  23784. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23785. /**
  23786. * Gets the angular velocity
  23787. * @returns angular velocity or null
  23788. */
  23789. getAngularVelocity(): Nullable<Vector3>;
  23790. /**
  23791. * Sets the angular velocity
  23792. * @param velocity The velocity or null
  23793. */
  23794. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23795. /**
  23796. * Execute a function with the physics plugin native code
  23797. * Provide a function the will have two variables - the world object and the physics body object
  23798. * @param func The function to execute with the physics plugin native code
  23799. */
  23800. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23801. /**
  23802. * Register a function that will be executed before the physics world is stepping forward
  23803. * @param func The function to execute before the physics world is stepped forward
  23804. */
  23805. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23806. /**
  23807. * Unregister a function that will be executed before the physics world is stepping forward
  23808. * @param func The function to execute before the physics world is stepped forward
  23809. */
  23810. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23811. /**
  23812. * Register a function that will be executed after the physics step
  23813. * @param func The function to execute after physics step
  23814. */
  23815. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23816. /**
  23817. * Unregisters a function that will be executed after the physics step
  23818. * @param func The function to execute after physics step
  23819. */
  23820. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23821. /**
  23822. * register a function that will be executed when this impostor collides against a different body
  23823. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23824. * @param func Callback that is executed on collision
  23825. */
  23826. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23827. /**
  23828. * Unregisters the physics imposter on contact
  23829. * @param collideAgainst The physics object to collide against
  23830. * @param func Callback to execute on collision
  23831. */
  23832. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23833. private _tmpQuat;
  23834. private _tmpQuat2;
  23835. /**
  23836. * Get the parent rotation
  23837. * @returns The parent rotation
  23838. */
  23839. getParentsRotation(): Quaternion;
  23840. /**
  23841. * this function is executed by the physics engine.
  23842. */
  23843. beforeStep: () => void;
  23844. /**
  23845. * this function is executed by the physics engine
  23846. */
  23847. afterStep: () => void;
  23848. /**
  23849. * Legacy collision detection event support
  23850. */
  23851. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23852. /**
  23853. * event and body object due to cannon's event-based architecture.
  23854. */
  23855. onCollide: (e: {
  23856. body: any;
  23857. }) => void;
  23858. /**
  23859. * Apply a force
  23860. * @param force The force to apply
  23861. * @param contactPoint The contact point for the force
  23862. * @returns The physics imposter
  23863. */
  23864. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23865. /**
  23866. * Apply an impulse
  23867. * @param force The impulse force
  23868. * @param contactPoint The contact point for the impulse force
  23869. * @returns The physics imposter
  23870. */
  23871. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23872. /**
  23873. * A help function to create a joint
  23874. * @param otherImpostor A physics imposter used to create a joint
  23875. * @param jointType The type of joint
  23876. * @param jointData The data for the joint
  23877. * @returns The physics imposter
  23878. */
  23879. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23880. /**
  23881. * Add a joint to this impostor with a different impostor
  23882. * @param otherImpostor A physics imposter used to add a joint
  23883. * @param joint The joint to add
  23884. * @returns The physics imposter
  23885. */
  23886. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23887. /**
  23888. * Add an anchor to a cloth impostor
  23889. * @param otherImpostor rigid impostor to anchor to
  23890. * @param width ratio across width from 0 to 1
  23891. * @param height ratio up height from 0 to 1
  23892. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23893. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23894. * @returns impostor the soft imposter
  23895. */
  23896. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23897. /**
  23898. * Add a hook to a rope impostor
  23899. * @param otherImpostor rigid impostor to anchor to
  23900. * @param length ratio across rope from 0 to 1
  23901. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23902. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23903. * @returns impostor the rope imposter
  23904. */
  23905. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23906. /**
  23907. * Will keep this body still, in a sleep mode.
  23908. * @returns the physics imposter
  23909. */
  23910. sleep(): PhysicsImpostor;
  23911. /**
  23912. * Wake the body up.
  23913. * @returns The physics imposter
  23914. */
  23915. wakeUp(): PhysicsImpostor;
  23916. /**
  23917. * Clones the physics imposter
  23918. * @param newObject The physics imposter clones to this physics-enabled object
  23919. * @returns A nullable physics imposter
  23920. */
  23921. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23922. /**
  23923. * Disposes the physics imposter
  23924. */
  23925. dispose(): void;
  23926. /**
  23927. * Sets the delta position
  23928. * @param position The delta position amount
  23929. */
  23930. setDeltaPosition(position: Vector3): void;
  23931. /**
  23932. * Sets the delta rotation
  23933. * @param rotation The delta rotation amount
  23934. */
  23935. setDeltaRotation(rotation: Quaternion): void;
  23936. /**
  23937. * Gets the box size of the physics imposter and stores the result in the input parameter
  23938. * @param result Stores the box size
  23939. * @returns The physics imposter
  23940. */
  23941. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23942. /**
  23943. * Gets the radius of the physics imposter
  23944. * @returns Radius of the physics imposter
  23945. */
  23946. getRadius(): number;
  23947. /**
  23948. * Sync a bone with this impostor
  23949. * @param bone The bone to sync to the impostor.
  23950. * @param boneMesh The mesh that the bone is influencing.
  23951. * @param jointPivot The pivot of the joint / bone in local space.
  23952. * @param distToJoint Optional distance from the impostor to the joint.
  23953. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23954. */
  23955. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23956. /**
  23957. * Sync impostor to a bone
  23958. * @param bone The bone that the impostor will be synced to.
  23959. * @param boneMesh The mesh that the bone is influencing.
  23960. * @param jointPivot The pivot of the joint / bone in local space.
  23961. * @param distToJoint Optional distance from the impostor to the joint.
  23962. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23963. * @param boneAxis Optional vector3 axis the bone is aligned with
  23964. */
  23965. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23966. /**
  23967. * No-Imposter type
  23968. */
  23969. static NoImpostor: number;
  23970. /**
  23971. * Sphere-Imposter type
  23972. */
  23973. static SphereImpostor: number;
  23974. /**
  23975. * Box-Imposter type
  23976. */
  23977. static BoxImpostor: number;
  23978. /**
  23979. * Plane-Imposter type
  23980. */
  23981. static PlaneImpostor: number;
  23982. /**
  23983. * Mesh-imposter type
  23984. */
  23985. static MeshImpostor: number;
  23986. /**
  23987. * Capsule-Impostor type (Ammo.js plugin only)
  23988. */
  23989. static CapsuleImpostor: number;
  23990. /**
  23991. * Cylinder-Imposter type
  23992. */
  23993. static CylinderImpostor: number;
  23994. /**
  23995. * Particle-Imposter type
  23996. */
  23997. static ParticleImpostor: number;
  23998. /**
  23999. * Heightmap-Imposter type
  24000. */
  24001. static HeightmapImpostor: number;
  24002. /**
  24003. * ConvexHull-Impostor type (Ammo.js plugin only)
  24004. */
  24005. static ConvexHullImpostor: number;
  24006. /**
  24007. * Rope-Imposter type
  24008. */
  24009. static RopeImpostor: number;
  24010. /**
  24011. * Cloth-Imposter type
  24012. */
  24013. static ClothImpostor: number;
  24014. /**
  24015. * Softbody-Imposter type
  24016. */
  24017. static SoftbodyImpostor: number;
  24018. }
  24019. }
  24020. declare module "babylonjs/Meshes/mesh" {
  24021. import { Observable } from "babylonjs/Misc/observable";
  24022. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24023. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24024. import { Camera } from "babylonjs/Cameras/camera";
  24025. import { Scene } from "babylonjs/scene";
  24026. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24027. import { Color4 } from "babylonjs/Maths/math.color";
  24028. import { Engine } from "babylonjs/Engines/engine";
  24029. import { Node } from "babylonjs/node";
  24030. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24031. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24032. import { Buffer } from "babylonjs/Meshes/buffer";
  24033. import { Geometry } from "babylonjs/Meshes/geometry";
  24034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24035. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24036. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24037. import { Effect } from "babylonjs/Materials/effect";
  24038. import { Material } from "babylonjs/Materials/material";
  24039. import { Skeleton } from "babylonjs/Bones/skeleton";
  24040. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24041. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24042. import { Path3D } from "babylonjs/Maths/math.path";
  24043. import { Plane } from "babylonjs/Maths/math.plane";
  24044. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24045. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24046. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24047. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24048. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24049. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24050. /**
  24051. * @hidden
  24052. **/
  24053. export class _CreationDataStorage {
  24054. closePath?: boolean;
  24055. closeArray?: boolean;
  24056. idx: number[];
  24057. dashSize: number;
  24058. gapSize: number;
  24059. path3D: Path3D;
  24060. pathArray: Vector3[][];
  24061. arc: number;
  24062. radius: number;
  24063. cap: number;
  24064. tessellation: number;
  24065. }
  24066. /**
  24067. * @hidden
  24068. **/
  24069. class _InstanceDataStorage {
  24070. visibleInstances: any;
  24071. batchCache: _InstancesBatch;
  24072. instancesBufferSize: number;
  24073. instancesBuffer: Nullable<Buffer>;
  24074. instancesData: Float32Array;
  24075. overridenInstanceCount: number;
  24076. isFrozen: boolean;
  24077. previousBatch: Nullable<_InstancesBatch>;
  24078. hardwareInstancedRendering: boolean;
  24079. sideOrientation: number;
  24080. }
  24081. /**
  24082. * @hidden
  24083. **/
  24084. export class _InstancesBatch {
  24085. mustReturn: boolean;
  24086. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24087. renderSelf: boolean[];
  24088. hardwareInstancedRendering: boolean[];
  24089. }
  24090. /**
  24091. * Class used to represent renderable models
  24092. */
  24093. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24094. /**
  24095. * Mesh side orientation : usually the external or front surface
  24096. */
  24097. static readonly FRONTSIDE: number;
  24098. /**
  24099. * Mesh side orientation : usually the internal or back surface
  24100. */
  24101. static readonly BACKSIDE: number;
  24102. /**
  24103. * Mesh side orientation : both internal and external or front and back surfaces
  24104. */
  24105. static readonly DOUBLESIDE: number;
  24106. /**
  24107. * Mesh side orientation : by default, `FRONTSIDE`
  24108. */
  24109. static readonly DEFAULTSIDE: number;
  24110. /**
  24111. * Mesh cap setting : no cap
  24112. */
  24113. static readonly NO_CAP: number;
  24114. /**
  24115. * Mesh cap setting : one cap at the beginning of the mesh
  24116. */
  24117. static readonly CAP_START: number;
  24118. /**
  24119. * Mesh cap setting : one cap at the end of the mesh
  24120. */
  24121. static readonly CAP_END: number;
  24122. /**
  24123. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24124. */
  24125. static readonly CAP_ALL: number;
  24126. /**
  24127. * Mesh pattern setting : no flip or rotate
  24128. */
  24129. static readonly NO_FLIP: number;
  24130. /**
  24131. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24132. */
  24133. static readonly FLIP_TILE: number;
  24134. /**
  24135. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24136. */
  24137. static readonly ROTATE_TILE: number;
  24138. /**
  24139. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24140. */
  24141. static readonly FLIP_ROW: number;
  24142. /**
  24143. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24144. */
  24145. static readonly ROTATE_ROW: number;
  24146. /**
  24147. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24148. */
  24149. static readonly FLIP_N_ROTATE_TILE: number;
  24150. /**
  24151. * Mesh pattern setting : rotate pattern and rotate
  24152. */
  24153. static readonly FLIP_N_ROTATE_ROW: number;
  24154. /**
  24155. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24156. */
  24157. static readonly CENTER: number;
  24158. /**
  24159. * Mesh tile positioning : part tiles on left
  24160. */
  24161. static readonly LEFT: number;
  24162. /**
  24163. * Mesh tile positioning : part tiles on right
  24164. */
  24165. static readonly RIGHT: number;
  24166. /**
  24167. * Mesh tile positioning : part tiles on top
  24168. */
  24169. static readonly TOP: number;
  24170. /**
  24171. * Mesh tile positioning : part tiles on bottom
  24172. */
  24173. static readonly BOTTOM: number;
  24174. /**
  24175. * Gets the default side orientation.
  24176. * @param orientation the orientation to value to attempt to get
  24177. * @returns the default orientation
  24178. * @hidden
  24179. */
  24180. static _GetDefaultSideOrientation(orientation?: number): number;
  24181. private _internalMeshDataInfo;
  24182. /**
  24183. * An event triggered before rendering the mesh
  24184. */
  24185. readonly onBeforeRenderObservable: Observable<Mesh>;
  24186. /**
  24187. * An event triggered before binding the mesh
  24188. */
  24189. readonly onBeforeBindObservable: Observable<Mesh>;
  24190. /**
  24191. * An event triggered after rendering the mesh
  24192. */
  24193. readonly onAfterRenderObservable: Observable<Mesh>;
  24194. /**
  24195. * An event triggered before drawing the mesh
  24196. */
  24197. readonly onBeforeDrawObservable: Observable<Mesh>;
  24198. private _onBeforeDrawObserver;
  24199. /**
  24200. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24201. */
  24202. onBeforeDraw: () => void;
  24203. readonly hasInstances: boolean;
  24204. /**
  24205. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24206. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24207. */
  24208. delayLoadState: number;
  24209. /**
  24210. * Gets the list of instances created from this mesh
  24211. * it is not supposed to be modified manually.
  24212. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24213. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24214. */
  24215. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24216. /**
  24217. * Gets the file containing delay loading data for this mesh
  24218. */
  24219. delayLoadingFile: string;
  24220. /** @hidden */
  24221. _binaryInfo: any;
  24222. /**
  24223. * User defined function used to change how LOD level selection is done
  24224. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24225. */
  24226. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24227. /**
  24228. * Gets or sets the morph target manager
  24229. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24230. */
  24231. morphTargetManager: Nullable<MorphTargetManager>;
  24232. /** @hidden */
  24233. _creationDataStorage: Nullable<_CreationDataStorage>;
  24234. /** @hidden */
  24235. _geometry: Nullable<Geometry>;
  24236. /** @hidden */
  24237. _delayInfo: Array<string>;
  24238. /** @hidden */
  24239. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24240. /** @hidden */
  24241. _instanceDataStorage: _InstanceDataStorage;
  24242. private _effectiveMaterial;
  24243. /** @hidden */
  24244. _shouldGenerateFlatShading: boolean;
  24245. /** @hidden */
  24246. _originalBuilderSideOrientation: number;
  24247. /**
  24248. * Use this property to change the original side orientation defined at construction time
  24249. */
  24250. overrideMaterialSideOrientation: Nullable<number>;
  24251. /**
  24252. * Gets the source mesh (the one used to clone this one from)
  24253. */
  24254. readonly source: Nullable<Mesh>;
  24255. /**
  24256. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24257. */
  24258. isUnIndexed: boolean;
  24259. /**
  24260. * @constructor
  24261. * @param name The value used by scene.getMeshByName() to do a lookup.
  24262. * @param scene The scene to add this mesh to.
  24263. * @param parent The parent of this mesh, if it has one
  24264. * @param source An optional Mesh from which geometry is shared, cloned.
  24265. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24266. * When false, achieved by calling a clone(), also passing False.
  24267. * This will make creation of children, recursive.
  24268. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24269. */
  24270. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24271. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24272. /**
  24273. * Gets the class name
  24274. * @returns the string "Mesh".
  24275. */
  24276. getClassName(): string;
  24277. /** @hidden */
  24278. readonly _isMesh: boolean;
  24279. /**
  24280. * Returns a description of this mesh
  24281. * @param fullDetails define if full details about this mesh must be used
  24282. * @returns a descriptive string representing this mesh
  24283. */
  24284. toString(fullDetails?: boolean): string;
  24285. /** @hidden */
  24286. _unBindEffect(): void;
  24287. /**
  24288. * Gets a boolean indicating if this mesh has LOD
  24289. */
  24290. readonly hasLODLevels: boolean;
  24291. /**
  24292. * Gets the list of MeshLODLevel associated with the current mesh
  24293. * @returns an array of MeshLODLevel
  24294. */
  24295. getLODLevels(): MeshLODLevel[];
  24296. private _sortLODLevels;
  24297. /**
  24298. * Add a mesh as LOD level triggered at the given distance.
  24299. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24300. * @param distance The distance from the center of the object to show this level
  24301. * @param mesh The mesh to be added as LOD level (can be null)
  24302. * @return This mesh (for chaining)
  24303. */
  24304. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24305. /**
  24306. * Returns the LOD level mesh at the passed distance or null if not found.
  24307. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24308. * @param distance The distance from the center of the object to show this level
  24309. * @returns a Mesh or `null`
  24310. */
  24311. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24312. /**
  24313. * Remove a mesh from the LOD array
  24314. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24315. * @param mesh defines the mesh to be removed
  24316. * @return This mesh (for chaining)
  24317. */
  24318. removeLODLevel(mesh: Mesh): Mesh;
  24319. /**
  24320. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24321. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24322. * @param camera defines the camera to use to compute distance
  24323. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24324. * @return This mesh (for chaining)
  24325. */
  24326. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24327. /**
  24328. * Gets the mesh internal Geometry object
  24329. */
  24330. readonly geometry: Nullable<Geometry>;
  24331. /**
  24332. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24333. * @returns the total number of vertices
  24334. */
  24335. getTotalVertices(): number;
  24336. /**
  24337. * Returns the content of an associated vertex buffer
  24338. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24339. * - VertexBuffer.PositionKind
  24340. * - VertexBuffer.UVKind
  24341. * - VertexBuffer.UV2Kind
  24342. * - VertexBuffer.UV3Kind
  24343. * - VertexBuffer.UV4Kind
  24344. * - VertexBuffer.UV5Kind
  24345. * - VertexBuffer.UV6Kind
  24346. * - VertexBuffer.ColorKind
  24347. * - VertexBuffer.MatricesIndicesKind
  24348. * - VertexBuffer.MatricesIndicesExtraKind
  24349. * - VertexBuffer.MatricesWeightsKind
  24350. * - VertexBuffer.MatricesWeightsExtraKind
  24351. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  24352. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24353. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24354. */
  24355. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24356. /**
  24357. * Returns the mesh VertexBuffer object from the requested `kind`
  24358. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24359. * - VertexBuffer.PositionKind
  24360. * - VertexBuffer.NormalKind
  24361. * - VertexBuffer.UVKind
  24362. * - VertexBuffer.UV2Kind
  24363. * - VertexBuffer.UV3Kind
  24364. * - VertexBuffer.UV4Kind
  24365. * - VertexBuffer.UV5Kind
  24366. * - VertexBuffer.UV6Kind
  24367. * - VertexBuffer.ColorKind
  24368. * - VertexBuffer.MatricesIndicesKind
  24369. * - VertexBuffer.MatricesIndicesExtraKind
  24370. * - VertexBuffer.MatricesWeightsKind
  24371. * - VertexBuffer.MatricesWeightsExtraKind
  24372. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24373. */
  24374. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24375. /**
  24376. * Tests if a specific vertex buffer is associated with this mesh
  24377. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24378. * - VertexBuffer.PositionKind
  24379. * - VertexBuffer.NormalKind
  24380. * - VertexBuffer.UVKind
  24381. * - VertexBuffer.UV2Kind
  24382. * - VertexBuffer.UV3Kind
  24383. * - VertexBuffer.UV4Kind
  24384. * - VertexBuffer.UV5Kind
  24385. * - VertexBuffer.UV6Kind
  24386. * - VertexBuffer.ColorKind
  24387. * - VertexBuffer.MatricesIndicesKind
  24388. * - VertexBuffer.MatricesIndicesExtraKind
  24389. * - VertexBuffer.MatricesWeightsKind
  24390. * - VertexBuffer.MatricesWeightsExtraKind
  24391. * @returns a boolean
  24392. */
  24393. isVerticesDataPresent(kind: string): boolean;
  24394. /**
  24395. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24396. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24397. * - VertexBuffer.PositionKind
  24398. * - VertexBuffer.UVKind
  24399. * - VertexBuffer.UV2Kind
  24400. * - VertexBuffer.UV3Kind
  24401. * - VertexBuffer.UV4Kind
  24402. * - VertexBuffer.UV5Kind
  24403. * - VertexBuffer.UV6Kind
  24404. * - VertexBuffer.ColorKind
  24405. * - VertexBuffer.MatricesIndicesKind
  24406. * - VertexBuffer.MatricesIndicesExtraKind
  24407. * - VertexBuffer.MatricesWeightsKind
  24408. * - VertexBuffer.MatricesWeightsExtraKind
  24409. * @returns a boolean
  24410. */
  24411. isVertexBufferUpdatable(kind: string): boolean;
  24412. /**
  24413. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24414. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24415. * - VertexBuffer.PositionKind
  24416. * - VertexBuffer.NormalKind
  24417. * - VertexBuffer.UVKind
  24418. * - VertexBuffer.UV2Kind
  24419. * - VertexBuffer.UV3Kind
  24420. * - VertexBuffer.UV4Kind
  24421. * - VertexBuffer.UV5Kind
  24422. * - VertexBuffer.UV6Kind
  24423. * - VertexBuffer.ColorKind
  24424. * - VertexBuffer.MatricesIndicesKind
  24425. * - VertexBuffer.MatricesIndicesExtraKind
  24426. * - VertexBuffer.MatricesWeightsKind
  24427. * - VertexBuffer.MatricesWeightsExtraKind
  24428. * @returns an array of strings
  24429. */
  24430. getVerticesDataKinds(): string[];
  24431. /**
  24432. * Returns a positive integer : the total number of indices in this mesh geometry.
  24433. * @returns the numner of indices or zero if the mesh has no geometry.
  24434. */
  24435. getTotalIndices(): number;
  24436. /**
  24437. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24438. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  24439. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24440. * @returns the indices array or an empty array if the mesh has no geometry
  24441. */
  24442. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24443. readonly isBlocked: boolean;
  24444. /**
  24445. * Determine if the current mesh is ready to be rendered
  24446. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24447. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24448. * @returns true if all associated assets are ready (material, textures, shaders)
  24449. */
  24450. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24451. /**
  24452. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  24453. */
  24454. readonly areNormalsFrozen: boolean;
  24455. /**
  24456. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  24457. * @returns the current mesh
  24458. */
  24459. freezeNormals(): Mesh;
  24460. /**
  24461. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  24462. * @returns the current mesh
  24463. */
  24464. unfreezeNormals(): Mesh;
  24465. /**
  24466. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24467. */
  24468. overridenInstanceCount: number;
  24469. /** @hidden */
  24470. _preActivate(): Mesh;
  24471. /** @hidden */
  24472. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24473. /** @hidden */
  24474. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24475. /**
  24476. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24477. * This means the mesh underlying bounding box and sphere are recomputed.
  24478. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24479. * @returns the current mesh
  24480. */
  24481. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24482. /** @hidden */
  24483. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24484. /**
  24485. * This function will subdivide the mesh into multiple submeshes
  24486. * @param count defines the expected number of submeshes
  24487. */
  24488. subdivide(count: number): void;
  24489. /**
  24490. * Copy a FloatArray into a specific associated vertex buffer
  24491. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24492. * - VertexBuffer.PositionKind
  24493. * - VertexBuffer.UVKind
  24494. * - VertexBuffer.UV2Kind
  24495. * - VertexBuffer.UV3Kind
  24496. * - VertexBuffer.UV4Kind
  24497. * - VertexBuffer.UV5Kind
  24498. * - VertexBuffer.UV6Kind
  24499. * - VertexBuffer.ColorKind
  24500. * - VertexBuffer.MatricesIndicesKind
  24501. * - VertexBuffer.MatricesIndicesExtraKind
  24502. * - VertexBuffer.MatricesWeightsKind
  24503. * - VertexBuffer.MatricesWeightsExtraKind
  24504. * @param data defines the data source
  24505. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24506. * @param stride defines the data stride size (can be null)
  24507. * @returns the current mesh
  24508. */
  24509. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24510. /**
  24511. * Flags an associated vertex buffer as updatable
  24512. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24513. * - VertexBuffer.PositionKind
  24514. * - VertexBuffer.UVKind
  24515. * - VertexBuffer.UV2Kind
  24516. * - VertexBuffer.UV3Kind
  24517. * - VertexBuffer.UV4Kind
  24518. * - VertexBuffer.UV5Kind
  24519. * - VertexBuffer.UV6Kind
  24520. * - VertexBuffer.ColorKind
  24521. * - VertexBuffer.MatricesIndicesKind
  24522. * - VertexBuffer.MatricesIndicesExtraKind
  24523. * - VertexBuffer.MatricesWeightsKind
  24524. * - VertexBuffer.MatricesWeightsExtraKind
  24525. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24526. */
  24527. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24528. /**
  24529. * Sets the mesh global Vertex Buffer
  24530. * @param buffer defines the buffer to use
  24531. * @returns the current mesh
  24532. */
  24533. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24534. /**
  24535. * Update a specific associated vertex buffer
  24536. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24537. * - VertexBuffer.PositionKind
  24538. * - VertexBuffer.UVKind
  24539. * - VertexBuffer.UV2Kind
  24540. * - VertexBuffer.UV3Kind
  24541. * - VertexBuffer.UV4Kind
  24542. * - VertexBuffer.UV5Kind
  24543. * - VertexBuffer.UV6Kind
  24544. * - VertexBuffer.ColorKind
  24545. * - VertexBuffer.MatricesIndicesKind
  24546. * - VertexBuffer.MatricesIndicesExtraKind
  24547. * - VertexBuffer.MatricesWeightsKind
  24548. * - VertexBuffer.MatricesWeightsExtraKind
  24549. * @param data defines the data source
  24550. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24551. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  24552. * @returns the current mesh
  24553. */
  24554. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24555. /**
  24556. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24557. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24558. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24559. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24560. * @returns the current mesh
  24561. */
  24562. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24563. /**
  24564. * Creates a un-shared specific occurence of the geometry for the mesh.
  24565. * @returns the current mesh
  24566. */
  24567. makeGeometryUnique(): Mesh;
  24568. /**
  24569. * Set the index buffer of this mesh
  24570. * @param indices defines the source data
  24571. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24572. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24573. * @returns the current mesh
  24574. */
  24575. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24576. /**
  24577. * Update the current index buffer
  24578. * @param indices defines the source data
  24579. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24580. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24581. * @returns the current mesh
  24582. */
  24583. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24584. /**
  24585. * Invert the geometry to move from a right handed system to a left handed one.
  24586. * @returns the current mesh
  24587. */
  24588. toLeftHanded(): Mesh;
  24589. /** @hidden */
  24590. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24591. /** @hidden */
  24592. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24593. /**
  24594. * Registers for this mesh a javascript function called just before the rendering process
  24595. * @param func defines the function to call before rendering this mesh
  24596. * @returns the current mesh
  24597. */
  24598. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24599. /**
  24600. * Disposes a previously registered javascript function called before the rendering
  24601. * @param func defines the function to remove
  24602. * @returns the current mesh
  24603. */
  24604. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24605. /**
  24606. * Registers for this mesh a javascript function called just after the rendering is complete
  24607. * @param func defines the function to call after rendering this mesh
  24608. * @returns the current mesh
  24609. */
  24610. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24611. /**
  24612. * Disposes a previously registered javascript function called after the rendering.
  24613. * @param func defines the function to remove
  24614. * @returns the current mesh
  24615. */
  24616. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24617. /** @hidden */
  24618. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24619. /** @hidden */
  24620. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24621. /** @hidden */
  24622. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24623. /** @hidden */
  24624. _rebuild(): void;
  24625. /** @hidden */
  24626. _freeze(): void;
  24627. /** @hidden */
  24628. _unFreeze(): void;
  24629. /**
  24630. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  24631. * @param subMesh defines the subMesh to render
  24632. * @param enableAlphaMode defines if alpha mode can be changed
  24633. * @returns the current mesh
  24634. */
  24635. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24636. private _onBeforeDraw;
  24637. /**
  24638. * Renormalize the mesh and patch it up if there are no weights
  24639. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24640. * However in the case of zero weights then we set just a single influence to 1.
  24641. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24642. */
  24643. cleanMatrixWeights(): void;
  24644. private normalizeSkinFourWeights;
  24645. private normalizeSkinWeightsAndExtra;
  24646. /**
  24647. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24648. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24649. * the user know there was an issue with importing the mesh
  24650. * @returns a validation object with skinned, valid and report string
  24651. */
  24652. validateSkinning(): {
  24653. skinned: boolean;
  24654. valid: boolean;
  24655. report: string;
  24656. };
  24657. /** @hidden */
  24658. _checkDelayState(): Mesh;
  24659. private _queueLoad;
  24660. /**
  24661. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24662. * A mesh is in the frustum if its bounding box intersects the frustum
  24663. * @param frustumPlanes defines the frustum to test
  24664. * @returns true if the mesh is in the frustum planes
  24665. */
  24666. isInFrustum(frustumPlanes: Plane[]): boolean;
  24667. /**
  24668. * Sets the mesh material by the material or multiMaterial `id` property
  24669. * @param id is a string identifying the material or the multiMaterial
  24670. * @returns the current mesh
  24671. */
  24672. setMaterialByID(id: string): Mesh;
  24673. /**
  24674. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24675. * @returns an array of IAnimatable
  24676. */
  24677. getAnimatables(): IAnimatable[];
  24678. /**
  24679. * Modifies the mesh geometry according to the passed transformation matrix.
  24680. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24681. * The mesh normals are modified using the same transformation.
  24682. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24683. * @param transform defines the transform matrix to use
  24684. * @see http://doc.babylonjs.com/resources/baking_transformations
  24685. * @returns the current mesh
  24686. */
  24687. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24688. /**
  24689. * Modifies the mesh geometry according to its own current World Matrix.
  24690. * The mesh World Matrix is then reset.
  24691. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24692. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24693. * @see http://doc.babylonjs.com/resources/baking_transformations
  24694. * @returns the current mesh
  24695. */
  24696. bakeCurrentTransformIntoVertices(): Mesh;
  24697. /** @hidden */
  24698. readonly _positions: Nullable<Vector3[]>;
  24699. /** @hidden */
  24700. _resetPointsArrayCache(): Mesh;
  24701. /** @hidden */
  24702. _generatePointsArray(): boolean;
  24703. /**
  24704. * Returns a new Mesh object generated from the current mesh properties.
  24705. * This method must not get confused with createInstance()
  24706. * @param name is a string, the name given to the new mesh
  24707. * @param newParent can be any Node object (default `null`)
  24708. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24709. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24710. * @returns a new mesh
  24711. */
  24712. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24713. /**
  24714. * Releases resources associated with this mesh.
  24715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24717. */
  24718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24719. /**
  24720. * Modifies the mesh geometry according to a displacement map.
  24721. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  24722. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24723. * @param url is a string, the URL from the image file is to be downloaded.
  24724. * @param minHeight is the lower limit of the displacement.
  24725. * @param maxHeight is the upper limit of the displacement.
  24726. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  24727. * @param uvOffset is an optional vector2 used to offset UV.
  24728. * @param uvScale is an optional vector2 used to scale UV.
  24729. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  24730. * @returns the Mesh.
  24731. */
  24732. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24733. /**
  24734. * Modifies the mesh geometry according to a displacementMap buffer.
  24735. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  24736. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24737. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24738. * @param heightMapWidth is the width of the buffer image.
  24739. * @param heightMapHeight is the height of the buffer image.
  24740. * @param minHeight is the lower limit of the displacement.
  24741. * @param maxHeight is the upper limit of the displacement.
  24742. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  24743. * @param uvOffset is an optional vector2 used to offset UV.
  24744. * @param uvScale is an optional vector2 used to scale UV.
  24745. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  24746. * @returns the Mesh.
  24747. */
  24748. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24749. /**
  24750. * Modify the mesh to get a flat shading rendering.
  24751. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24752. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24753. * @returns current mesh
  24754. */
  24755. convertToFlatShadedMesh(): Mesh;
  24756. /**
  24757. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24758. * In other words, more vertices, no more indices and a single bigger VBO.
  24759. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24760. * @returns current mesh
  24761. */
  24762. convertToUnIndexedMesh(): Mesh;
  24763. /**
  24764. * Inverses facet orientations.
  24765. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24766. * @param flipNormals will also inverts the normals
  24767. * @returns current mesh
  24768. */
  24769. flipFaces(flipNormals?: boolean): Mesh;
  24770. /**
  24771. * Increase the number of facets and hence vertices in a mesh
  24772. * Vertex normals are interpolated from existing vertex normals
  24773. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24774. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24775. */
  24776. increaseVertices(numberPerEdge: number): void;
  24777. /**
  24778. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24779. * This will undo any application of covertToFlatShadedMesh
  24780. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24781. */
  24782. forceSharedVertices(): void;
  24783. /** @hidden */
  24784. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24785. /** @hidden */
  24786. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24787. /**
  24788. * Creates a new InstancedMesh object from the mesh model.
  24789. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24790. * @param name defines the name of the new instance
  24791. * @returns a new InstancedMesh
  24792. */
  24793. createInstance(name: string): InstancedMesh;
  24794. /**
  24795. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24796. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24797. * @returns the current mesh
  24798. */
  24799. synchronizeInstances(): Mesh;
  24800. /**
  24801. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24802. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24803. * This should be used together with the simplification to avoid disappearing triangles.
  24804. * @param successCallback an optional success callback to be called after the optimization finished.
  24805. * @returns the current mesh
  24806. */
  24807. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24808. /**
  24809. * Serialize current mesh
  24810. * @param serializationObject defines the object which will receive the serialization data
  24811. */
  24812. serialize(serializationObject: any): void;
  24813. /** @hidden */
  24814. _syncGeometryWithMorphTargetManager(): void;
  24815. /** @hidden */
  24816. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24817. /**
  24818. * Returns a new Mesh object parsed from the source provided.
  24819. * @param parsedMesh is the source
  24820. * @param scene defines the hosting scene
  24821. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24822. * @returns a new Mesh
  24823. */
  24824. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24825. /**
  24826. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24827. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24828. * @param name defines the name of the mesh to create
  24829. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24830. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24831. * @param closePath creates a seam between the first and the last points of each path of the path array
  24832. * @param offset is taken in account only if the `pathArray` is containing a single path
  24833. * @param scene defines the hosting scene
  24834. * @param updatable defines if the mesh must be flagged as updatable
  24835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24836. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  24837. * @returns a new Mesh
  24838. */
  24839. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24840. /**
  24841. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24842. * @param name defines the name of the mesh to create
  24843. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24844. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  24845. * @param scene defines the hosting scene
  24846. * @param updatable defines if the mesh must be flagged as updatable
  24847. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24848. * @returns a new Mesh
  24849. */
  24850. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24851. /**
  24852. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24853. * @param name defines the name of the mesh to create
  24854. * @param size sets the size (float) of each box side (default 1)
  24855. * @param scene defines the hosting scene
  24856. * @param updatable defines if the mesh must be flagged as updatable
  24857. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24858. * @returns a new Mesh
  24859. */
  24860. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24861. /**
  24862. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24863. * @param name defines the name of the mesh to create
  24864. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24865. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24866. * @param scene defines the hosting scene
  24867. * @param updatable defines if the mesh must be flagged as updatable
  24868. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24869. * @returns a new Mesh
  24870. */
  24871. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24872. /**
  24873. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24874. * @param name defines the name of the mesh to create
  24875. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24876. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24877. * @param scene defines the hosting scene
  24878. * @returns a new Mesh
  24879. */
  24880. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24881. /**
  24882. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24883. * @param name defines the name of the mesh to create
  24884. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24885. * @param diameterTop set the top cap diameter (floats, default 1)
  24886. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24887. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24888. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24889. * @param scene defines the hosting scene
  24890. * @param updatable defines if the mesh must be flagged as updatable
  24891. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24892. * @returns a new Mesh
  24893. */
  24894. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24895. /**
  24896. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24897. * @param name defines the name of the mesh to create
  24898. * @param diameter sets the diameter size (float) of the torus (default 1)
  24899. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24900. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24901. * @param scene defines the hosting scene
  24902. * @param updatable defines if the mesh must be flagged as updatable
  24903. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24904. * @returns a new Mesh
  24905. */
  24906. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24907. /**
  24908. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24909. * @param name defines the name of the mesh to create
  24910. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24911. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24912. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24913. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24914. * @param p the number of windings on X axis (positive integers, default 2)
  24915. * @param q the number of windings on Y axis (positive integers, default 3)
  24916. * @param scene defines the hosting scene
  24917. * @param updatable defines if the mesh must be flagged as updatable
  24918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24919. * @returns a new Mesh
  24920. */
  24921. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24922. /**
  24923. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24924. * @param name defines the name of the mesh to create
  24925. * @param points is an array successive Vector3
  24926. * @param scene defines the hosting scene
  24927. * @param updatable defines if the mesh must be flagged as updatable
  24928. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  24929. * @returns a new Mesh
  24930. */
  24931. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24932. /**
  24933. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24934. * @param name defines the name of the mesh to create
  24935. * @param points is an array successive Vector3
  24936. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24937. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24938. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24939. * @param scene defines the hosting scene
  24940. * @param updatable defines if the mesh must be flagged as updatable
  24941. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  24942. * @returns a new Mesh
  24943. */
  24944. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24945. /**
  24946. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24947. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24948. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  24949. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24950. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24951. * Remember you can only change the shape positions, not their number when updating a polygon.
  24952. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24953. * @param name defines the name of the mesh to create
  24954. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  24955. * @param scene defines the hosting scene
  24956. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24957. * @param updatable defines if the mesh must be flagged as updatable
  24958. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24959. * @param earcutInjection can be used to inject your own earcut reference
  24960. * @returns a new Mesh
  24961. */
  24962. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24963. /**
  24964. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24965. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24966. * @param name defines the name of the mesh to create
  24967. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  24968. * @param depth defines the height of extrusion
  24969. * @param scene defines the hosting scene
  24970. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24971. * @param updatable defines if the mesh must be flagged as updatable
  24972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24973. * @param earcutInjection can be used to inject your own earcut reference
  24974. * @returns a new Mesh
  24975. */
  24976. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24977. /**
  24978. * Creates an extruded shape mesh.
  24979. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  24980. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24981. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24982. * @param name defines the name of the mesh to create
  24983. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  24984. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24985. * @param scale is the value to scale the shape
  24986. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  24987. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24988. * @param scene defines the hosting scene
  24989. * @param updatable defines if the mesh must be flagged as updatable
  24990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24991. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  24992. * @returns a new Mesh
  24993. */
  24994. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24995. /**
  24996. * Creates an custom extruded shape mesh.
  24997. * The custom extrusion is a parametric shape.
  24998. * It has no predefined shape. Its final shape will depend on the input parameters.
  24999. * Please consider using the same method from the MeshBuilder class instead
  25000. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25001. * @param name defines the name of the mesh to create
  25002. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25003. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25004. * @param scaleFunction is a custom Javascript function called on each path point
  25005. * @param rotationFunction is a custom Javascript function called on each path point
  25006. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25007. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25008. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25009. * @param scene defines the hosting scene
  25010. * @param updatable defines if the mesh must be flagged as updatable
  25011. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25012. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  25013. * @returns a new Mesh
  25014. */
  25015. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25016. /**
  25017. * Creates lathe mesh.
  25018. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25019. * Please consider using the same method from the MeshBuilder class instead
  25020. * @param name defines the name of the mesh to create
  25021. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  25022. * @param radius is the radius value of the lathe
  25023. * @param tessellation is the side number of the lathe.
  25024. * @param scene defines the hosting scene
  25025. * @param updatable defines if the mesh must be flagged as updatable
  25026. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25027. * @returns a new Mesh
  25028. */
  25029. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25030. /**
  25031. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25032. * @param name defines the name of the mesh to create
  25033. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25034. * @param scene defines the hosting scene
  25035. * @param updatable defines if the mesh must be flagged as updatable
  25036. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25037. * @returns a new Mesh
  25038. */
  25039. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25040. /**
  25041. * Creates a ground mesh.
  25042. * Please consider using the same method from the MeshBuilder class instead
  25043. * @param name defines the name of the mesh to create
  25044. * @param width set the width of the ground
  25045. * @param height set the height of the ground
  25046. * @param subdivisions sets the number of subdivisions per side
  25047. * @param scene defines the hosting scene
  25048. * @param updatable defines if the mesh must be flagged as updatable
  25049. * @returns a new Mesh
  25050. */
  25051. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25052. /**
  25053. * Creates a tiled ground mesh.
  25054. * Please consider using the same method from the MeshBuilder class instead
  25055. * @param name defines the name of the mesh to create
  25056. * @param xmin set the ground minimum X coordinate
  25057. * @param zmin set the ground minimum Y coordinate
  25058. * @param xmax set the ground maximum X coordinate
  25059. * @param zmax set the ground maximum Z coordinate
  25060. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  25061. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  25062. * @param scene defines the hosting scene
  25063. * @param updatable defines if the mesh must be flagged as updatable
  25064. * @returns a new Mesh
  25065. */
  25066. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25067. w: number;
  25068. h: number;
  25069. }, precision: {
  25070. w: number;
  25071. h: number;
  25072. }, scene: Scene, updatable?: boolean): Mesh;
  25073. /**
  25074. * Creates a ground mesh from a height map.
  25075. * Please consider using the same method from the MeshBuilder class instead
  25076. * @see http://doc.babylonjs.com/babylon101/height_map
  25077. * @param name defines the name of the mesh to create
  25078. * @param url sets the URL of the height map image resource
  25079. * @param width set the ground width size
  25080. * @param height set the ground height size
  25081. * @param subdivisions sets the number of subdivision per side
  25082. * @param minHeight is the minimum altitude on the ground
  25083. * @param maxHeight is the maximum altitude on the ground
  25084. * @param scene defines the hosting scene
  25085. * @param updatable defines if the mesh must be flagged as updatable
  25086. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25087. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25088. * @returns a new Mesh
  25089. */
  25090. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  25091. /**
  25092. * Creates a tube mesh.
  25093. * The tube is a parametric shape.
  25094. * It has no predefined shape. Its final shape will depend on the input parameters.
  25095. * Please consider using the same method from the MeshBuilder class instead
  25096. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25097. * @param name defines the name of the mesh to create
  25098. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25099. * @param radius sets the tube radius size
  25100. * @param tessellation is the number of sides on the tubular surface
  25101. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  25102. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25103. * @param scene defines the hosting scene
  25104. * @param updatable defines if the mesh must be flagged as updatable
  25105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25106. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  25107. * @returns a new Mesh
  25108. */
  25109. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25110. (i: number, distance: number): number;
  25111. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25112. /**
  25113. * Creates a polyhedron mesh.
  25114. * Please consider using the same method from the MeshBuilder class instead.
  25115. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  25116. * * The parameter `size` (positive float, default 1) sets the polygon size
  25117. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25118. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  25119. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  25120. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  25121. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  25122. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  25123. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25126. * @param name defines the name of the mesh to create
  25127. * @param options defines the options used to create the mesh
  25128. * @param scene defines the hosting scene
  25129. * @returns a new Mesh
  25130. */
  25131. static CreatePolyhedron(name: string, options: {
  25132. type?: number;
  25133. size?: number;
  25134. sizeX?: number;
  25135. sizeY?: number;
  25136. sizeZ?: number;
  25137. custom?: any;
  25138. faceUV?: Vector4[];
  25139. faceColors?: Color4[];
  25140. updatable?: boolean;
  25141. sideOrientation?: number;
  25142. }, scene: Scene): Mesh;
  25143. /**
  25144. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25145. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25146. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  25147. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25148. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  25149. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25152. * @param name defines the name of the mesh
  25153. * @param options defines the options used to create the mesh
  25154. * @param scene defines the hosting scene
  25155. * @returns a new Mesh
  25156. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25157. */
  25158. static CreateIcoSphere(name: string, options: {
  25159. radius?: number;
  25160. flat?: boolean;
  25161. subdivisions?: number;
  25162. sideOrientation?: number;
  25163. updatable?: boolean;
  25164. }, scene: Scene): Mesh;
  25165. /**
  25166. * Creates a decal mesh.
  25167. * Please consider using the same method from the MeshBuilder class instead.
  25168. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25169. * @param name defines the name of the mesh
  25170. * @param sourceMesh defines the mesh receiving the decal
  25171. * @param position sets the position of the decal in world coordinates
  25172. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25173. * @param size sets the decal scaling
  25174. * @param angle sets the angle to rotate the decal
  25175. * @returns a new Mesh
  25176. */
  25177. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25178. /**
  25179. * Prepare internal position array for software CPU skinning
  25180. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25181. */
  25182. setPositionsForCPUSkinning(): Float32Array;
  25183. /**
  25184. * Prepare internal normal array for software CPU skinning
  25185. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25186. */
  25187. setNormalsForCPUSkinning(): Float32Array;
  25188. /**
  25189. * Updates the vertex buffer by applying transformation from the bones
  25190. * @param skeleton defines the skeleton to apply to current mesh
  25191. * @returns the current mesh
  25192. */
  25193. applySkeleton(skeleton: Skeleton): Mesh;
  25194. /**
  25195. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  25196. * @param meshes defines the list of meshes to scan
  25197. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25198. */
  25199. static MinMax(meshes: AbstractMesh[]): {
  25200. min: Vector3;
  25201. max: Vector3;
  25202. };
  25203. /**
  25204. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25205. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25206. * @returns a vector3
  25207. */
  25208. static Center(meshesOrMinMaxVector: {
  25209. min: Vector3;
  25210. max: Vector3;
  25211. } | AbstractMesh[]): Vector3;
  25212. /**
  25213. * Merge the array of meshes into a single mesh for performance reasons.
  25214. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25215. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25216. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25217. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25218. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25219. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25220. * @returns a new mesh
  25221. */
  25222. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25223. /** @hidden */
  25224. addInstance(instance: InstancedMesh): void;
  25225. /** @hidden */
  25226. removeInstance(instance: InstancedMesh): void;
  25227. }
  25228. }
  25229. declare module "babylonjs/Cameras/camera" {
  25230. import { SmartArray } from "babylonjs/Misc/smartArray";
  25231. import { Observable } from "babylonjs/Misc/observable";
  25232. import { Nullable } from "babylonjs/types";
  25233. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25234. import { Scene } from "babylonjs/scene";
  25235. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25236. import { Node } from "babylonjs/node";
  25237. import { Mesh } from "babylonjs/Meshes/mesh";
  25238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25239. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25240. import { Viewport } from "babylonjs/Maths/math.viewport";
  25241. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25242. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25243. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25244. import { Ray } from "babylonjs/Culling/ray";
  25245. /**
  25246. * This is the base class of all the camera used in the application.
  25247. * @see http://doc.babylonjs.com/features/cameras
  25248. */
  25249. export class Camera extends Node {
  25250. /** @hidden */
  25251. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25252. /**
  25253. * This is the default projection mode used by the cameras.
  25254. * It helps recreating a feeling of perspective and better appreciate depth.
  25255. * This is the best way to simulate real life cameras.
  25256. */
  25257. static readonly PERSPECTIVE_CAMERA: number;
  25258. /**
  25259. * This helps creating camera with an orthographic mode.
  25260. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  25261. */
  25262. static readonly ORTHOGRAPHIC_CAMERA: number;
  25263. /**
  25264. * This is the default FOV mode for perspective cameras.
  25265. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25266. */
  25267. static readonly FOVMODE_VERTICAL_FIXED: number;
  25268. /**
  25269. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25270. */
  25271. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25272. /**
  25273. * This specifies ther is no need for a camera rig.
  25274. * Basically only one eye is rendered corresponding to the camera.
  25275. */
  25276. static readonly RIG_MODE_NONE: number;
  25277. /**
  25278. * Simulates a camera Rig with one blue eye and one red eye.
  25279. * This can be use with 3d blue and red glasses.
  25280. */
  25281. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25282. /**
  25283. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25284. */
  25285. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25286. /**
  25287. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25288. */
  25289. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25290. /**
  25291. * Defines that both eyes of the camera will be rendered over under each other.
  25292. */
  25293. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25294. /**
  25295. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25296. */
  25297. static readonly RIG_MODE_VR: number;
  25298. /**
  25299. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25300. */
  25301. static readonly RIG_MODE_WEBVR: number;
  25302. /**
  25303. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25304. */
  25305. static readonly RIG_MODE_CUSTOM: number;
  25306. /**
  25307. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25308. */
  25309. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25310. /**
  25311. * Define the input manager associated with the camera.
  25312. */
  25313. inputs: CameraInputsManager<Camera>;
  25314. /** @hidden */
  25315. _position: Vector3;
  25316. /**
  25317. * Define the current local position of the camera in the scene
  25318. */
  25319. position: Vector3;
  25320. /**
  25321. * The vector the camera should consider as up.
  25322. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25323. */
  25324. upVector: Vector3;
  25325. /**
  25326. * Define the current limit on the left side for an orthographic camera
  25327. * In scene unit
  25328. */
  25329. orthoLeft: Nullable<number>;
  25330. /**
  25331. * Define the current limit on the right side for an orthographic camera
  25332. * In scene unit
  25333. */
  25334. orthoRight: Nullable<number>;
  25335. /**
  25336. * Define the current limit on the bottom side for an orthographic camera
  25337. * In scene unit
  25338. */
  25339. orthoBottom: Nullable<number>;
  25340. /**
  25341. * Define the current limit on the top side for an orthographic camera
  25342. * In scene unit
  25343. */
  25344. orthoTop: Nullable<number>;
  25345. /**
  25346. * Field Of View is set in Radians. (default is 0.8)
  25347. */
  25348. fov: number;
  25349. /**
  25350. * Define the minimum distance the camera can see from.
  25351. * This is important to note that the depth buffer are not infinite and the closer it starts
  25352. * the more your scene might encounter depth fighting issue.
  25353. */
  25354. minZ: number;
  25355. /**
  25356. * Define the maximum distance the camera can see to.
  25357. * This is important to note that the depth buffer are not infinite and the further it end
  25358. * the more your scene might encounter depth fighting issue.
  25359. */
  25360. maxZ: number;
  25361. /**
  25362. * Define the default inertia of the camera.
  25363. * This helps giving a smooth feeling to the camera movement.
  25364. */
  25365. inertia: number;
  25366. /**
  25367. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25368. */
  25369. mode: number;
  25370. /**
  25371. * Define wether the camera is intermediate.
  25372. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25373. */
  25374. isIntermediate: boolean;
  25375. /**
  25376. * Define the viewport of the camera.
  25377. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25378. */
  25379. viewport: Viewport;
  25380. /**
  25381. * Restricts the camera to viewing objects with the same layerMask.
  25382. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25383. */
  25384. layerMask: number;
  25385. /**
  25386. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25387. */
  25388. fovMode: number;
  25389. /**
  25390. * Rig mode of the camera.
  25391. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25392. * This is normally controlled byt the camera themselves as internal use.
  25393. */
  25394. cameraRigMode: number;
  25395. /**
  25396. * Defines the distance between both "eyes" in case of a RIG
  25397. */
  25398. interaxialDistance: number;
  25399. /**
  25400. * Defines if stereoscopic rendering is done side by side or over under.
  25401. */
  25402. isStereoscopicSideBySide: boolean;
  25403. /**
  25404. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  25405. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25406. * else in the scene. (Eg. security camera)
  25407. *
  25408. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25409. */
  25410. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25411. /**
  25412. * When set, the camera will render to this render target instead of the default canvas
  25413. *
  25414. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25415. */
  25416. outputRenderTarget: Nullable<RenderTargetTexture>;
  25417. /**
  25418. * Observable triggered when the camera view matrix has changed.
  25419. */
  25420. onViewMatrixChangedObservable: Observable<Camera>;
  25421. /**
  25422. * Observable triggered when the camera Projection matrix has changed.
  25423. */
  25424. onProjectionMatrixChangedObservable: Observable<Camera>;
  25425. /**
  25426. * Observable triggered when the inputs have been processed.
  25427. */
  25428. onAfterCheckInputsObservable: Observable<Camera>;
  25429. /**
  25430. * Observable triggered when reset has been called and applied to the camera.
  25431. */
  25432. onRestoreStateObservable: Observable<Camera>;
  25433. /** @hidden */
  25434. _cameraRigParams: any;
  25435. /** @hidden */
  25436. _rigCameras: Camera[];
  25437. /** @hidden */
  25438. _rigPostProcess: Nullable<PostProcess>;
  25439. protected _webvrViewMatrix: Matrix;
  25440. /** @hidden */
  25441. _skipRendering: boolean;
  25442. /** @hidden */
  25443. _projectionMatrix: Matrix;
  25444. /** @hidden */
  25445. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25446. /** @hidden */
  25447. _activeMeshes: SmartArray<AbstractMesh>;
  25448. protected _globalPosition: Vector3;
  25449. /** @hidden */
  25450. _computedViewMatrix: Matrix;
  25451. private _doNotComputeProjectionMatrix;
  25452. private _transformMatrix;
  25453. private _frustumPlanes;
  25454. private _refreshFrustumPlanes;
  25455. private _storedFov;
  25456. private _stateStored;
  25457. /**
  25458. * Instantiates a new camera object.
  25459. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25460. * @see http://doc.babylonjs.com/features/cameras
  25461. * @param name Defines the name of the camera in the scene
  25462. * @param position Defines the position of the camera
  25463. * @param scene Defines the scene the camera belongs too
  25464. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25465. */
  25466. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25467. /**
  25468. * Store current camera state (fov, position, etc..)
  25469. * @returns the camera
  25470. */
  25471. storeState(): Camera;
  25472. /**
  25473. * Restores the camera state values if it has been stored. You must call storeState() first
  25474. */
  25475. protected _restoreStateValues(): boolean;
  25476. /**
  25477. * Restored camera state. You must call storeState() first.
  25478. * @returns true if restored and false otherwise
  25479. */
  25480. restoreState(): boolean;
  25481. /**
  25482. * Gets the class name of the camera.
  25483. * @returns the class name
  25484. */
  25485. getClassName(): string;
  25486. /** @hidden */
  25487. readonly _isCamera: boolean;
  25488. /**
  25489. * Gets a string representation of the camera useful for debug purpose.
  25490. * @param fullDetails Defines that a more verboe level of logging is required
  25491. * @returns the string representation
  25492. */
  25493. toString(fullDetails?: boolean): string;
  25494. /**
  25495. * Gets the current world space position of the camera.
  25496. */
  25497. readonly globalPosition: Vector3;
  25498. /**
  25499. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25500. * @returns the active meshe list
  25501. */
  25502. getActiveMeshes(): SmartArray<AbstractMesh>;
  25503. /**
  25504. * Check wether a mesh is part of the current active mesh list of the camera
  25505. * @param mesh Defines the mesh to check
  25506. * @returns true if active, false otherwise
  25507. */
  25508. isActiveMesh(mesh: Mesh): boolean;
  25509. /**
  25510. * Is this camera ready to be used/rendered
  25511. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25512. * @return true if the camera is ready
  25513. */
  25514. isReady(completeCheck?: boolean): boolean;
  25515. /** @hidden */
  25516. _initCache(): void;
  25517. /** @hidden */
  25518. _updateCache(ignoreParentClass?: boolean): void;
  25519. /** @hidden */
  25520. _isSynchronized(): boolean;
  25521. /** @hidden */
  25522. _isSynchronizedViewMatrix(): boolean;
  25523. /** @hidden */
  25524. _isSynchronizedProjectionMatrix(): boolean;
  25525. /**
  25526. * Attach the input controls to a specific dom element to get the input from.
  25527. * @param element Defines the element the controls should be listened from
  25528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25529. */
  25530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25531. /**
  25532. * Detach the current controls from the specified dom element.
  25533. * @param element Defines the element to stop listening the inputs from
  25534. */
  25535. detachControl(element: HTMLElement): void;
  25536. /**
  25537. * Update the camera state according to the different inputs gathered during the frame.
  25538. */
  25539. update(): void;
  25540. /** @hidden */
  25541. _checkInputs(): void;
  25542. /** @hidden */
  25543. readonly rigCameras: Camera[];
  25544. /**
  25545. * Gets the post process used by the rig cameras
  25546. */
  25547. readonly rigPostProcess: Nullable<PostProcess>;
  25548. /**
  25549. * Internal, gets the first post proces.
  25550. * @returns the first post process to be run on this camera.
  25551. */
  25552. _getFirstPostProcess(): Nullable<PostProcess>;
  25553. private _cascadePostProcessesToRigCams;
  25554. /**
  25555. * Attach a post process to the camera.
  25556. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25557. * @param postProcess The post process to attach to the camera
  25558. * @param insertAt The position of the post process in case several of them are in use in the scene
  25559. * @returns the position the post process has been inserted at
  25560. */
  25561. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25562. /**
  25563. * Detach a post process to the camera.
  25564. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25565. * @param postProcess The post process to detach from the camera
  25566. */
  25567. detachPostProcess(postProcess: PostProcess): void;
  25568. /**
  25569. * Gets the current world matrix of the camera
  25570. */
  25571. getWorldMatrix(): Matrix;
  25572. /** @hidden */
  25573. _getViewMatrix(): Matrix;
  25574. /**
  25575. * Gets the current view matrix of the camera.
  25576. * @param force forces the camera to recompute the matrix without looking at the cached state
  25577. * @returns the view matrix
  25578. */
  25579. getViewMatrix(force?: boolean): Matrix;
  25580. /**
  25581. * Freeze the projection matrix.
  25582. * It will prevent the cache check of the camera projection compute and can speed up perf
  25583. * if no parameter of the camera are meant to change
  25584. * @param projection Defines manually a projection if necessary
  25585. */
  25586. freezeProjectionMatrix(projection?: Matrix): void;
  25587. /**
  25588. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25589. */
  25590. unfreezeProjectionMatrix(): void;
  25591. /**
  25592. * Gets the current projection matrix of the camera.
  25593. * @param force forces the camera to recompute the matrix without looking at the cached state
  25594. * @returns the projection matrix
  25595. */
  25596. getProjectionMatrix(force?: boolean): Matrix;
  25597. /**
  25598. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25599. * @returns a Matrix
  25600. */
  25601. getTransformationMatrix(): Matrix;
  25602. private _updateFrustumPlanes;
  25603. /**
  25604. * Checks if a cullable object (mesh...) is in the camera frustum
  25605. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25606. * @param target The object to check
  25607. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25608. * @returns true if the object is in frustum otherwise false
  25609. */
  25610. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25611. /**
  25612. * Checks if a cullable object (mesh...) is in the camera frustum
  25613. * Unlike isInFrustum this cheks the full bounding box
  25614. * @param target The object to check
  25615. * @returns true if the object is in frustum otherwise false
  25616. */
  25617. isCompletelyInFrustum(target: ICullable): boolean;
  25618. /**
  25619. * Gets a ray in the forward direction from the camera.
  25620. * @param length Defines the length of the ray to create
  25621. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25622. * @param origin Defines the start point of the ray which defaults to the camera position
  25623. * @returns the forward ray
  25624. */
  25625. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25626. /**
  25627. * Releases resources associated with this node.
  25628. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25629. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25630. */
  25631. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25632. /** @hidden */
  25633. _isLeftCamera: boolean;
  25634. /**
  25635. * Gets the left camera of a rig setup in case of Rigged Camera
  25636. */
  25637. readonly isLeftCamera: boolean;
  25638. /** @hidden */
  25639. _isRightCamera: boolean;
  25640. /**
  25641. * Gets the right camera of a rig setup in case of Rigged Camera
  25642. */
  25643. readonly isRightCamera: boolean;
  25644. /**
  25645. * Gets the left camera of a rig setup in case of Rigged Camera
  25646. */
  25647. readonly leftCamera: Nullable<FreeCamera>;
  25648. /**
  25649. * Gets the right camera of a rig setup in case of Rigged Camera
  25650. */
  25651. readonly rightCamera: Nullable<FreeCamera>;
  25652. /**
  25653. * Gets the left camera target of a rig setup in case of Rigged Camera
  25654. * @returns the target position
  25655. */
  25656. getLeftTarget(): Nullable<Vector3>;
  25657. /**
  25658. * Gets the right camera target of a rig setup in case of Rigged Camera
  25659. * @returns the target position
  25660. */
  25661. getRightTarget(): Nullable<Vector3>;
  25662. /**
  25663. * @hidden
  25664. */
  25665. setCameraRigMode(mode: number, rigParams: any): void;
  25666. /** @hidden */
  25667. static _setStereoscopicRigMode(camera: Camera): void;
  25668. /** @hidden */
  25669. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25670. /** @hidden */
  25671. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25672. /** @hidden */
  25673. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25674. /** @hidden */
  25675. _getVRProjectionMatrix(): Matrix;
  25676. protected _updateCameraRotationMatrix(): void;
  25677. protected _updateWebVRCameraRotationMatrix(): void;
  25678. /**
  25679. * This function MUST be overwritten by the different WebVR cameras available.
  25680. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25681. * @hidden
  25682. */
  25683. _getWebVRProjectionMatrix(): Matrix;
  25684. /**
  25685. * This function MUST be overwritten by the different WebVR cameras available.
  25686. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25687. * @hidden
  25688. */
  25689. _getWebVRViewMatrix(): Matrix;
  25690. /** @hidden */
  25691. setCameraRigParameter(name: string, value: any): void;
  25692. /**
  25693. * needs to be overridden by children so sub has required properties to be copied
  25694. * @hidden
  25695. */
  25696. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25697. /**
  25698. * May need to be overridden by children
  25699. * @hidden
  25700. */
  25701. _updateRigCameras(): void;
  25702. /** @hidden */
  25703. _setupInputs(): void;
  25704. /**
  25705. * Serialiaze the camera setup to a json represention
  25706. * @returns the JSON representation
  25707. */
  25708. serialize(): any;
  25709. /**
  25710. * Clones the current camera.
  25711. * @param name The cloned camera name
  25712. * @returns the cloned camera
  25713. */
  25714. clone(name: string): Camera;
  25715. /**
  25716. * Gets the direction of the camera relative to a given local axis.
  25717. * @param localAxis Defines the reference axis to provide a relative direction.
  25718. * @return the direction
  25719. */
  25720. getDirection(localAxis: Vector3): Vector3;
  25721. /**
  25722. * Returns the current camera absolute rotation
  25723. */
  25724. readonly absoluteRotation: Quaternion;
  25725. /**
  25726. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25727. * @param localAxis Defines the reference axis to provide a relative direction.
  25728. * @param result Defines the vector to store the result in
  25729. */
  25730. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25731. /**
  25732. * Gets a camera constructor for a given camera type
  25733. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25734. * @param name The name of the camera the result will be able to instantiate
  25735. * @param scene The scene the result will construct the camera in
  25736. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25737. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25738. * @returns a factory method to construc the camera
  25739. */
  25740. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25741. /**
  25742. * Compute the world matrix of the camera.
  25743. * @returns the camera workd matrix
  25744. */
  25745. computeWorldMatrix(): Matrix;
  25746. /**
  25747. * Parse a JSON and creates the camera from the parsed information
  25748. * @param parsedCamera The JSON to parse
  25749. * @param scene The scene to instantiate the camera in
  25750. * @returns the newly constructed camera
  25751. */
  25752. static Parse(parsedCamera: any, scene: Scene): Camera;
  25753. }
  25754. }
  25755. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25756. import { Nullable } from "babylonjs/types";
  25757. import { Scene } from "babylonjs/scene";
  25758. import { Vector4 } from "babylonjs/Maths/math.vector";
  25759. import { Mesh } from "babylonjs/Meshes/mesh";
  25760. /**
  25761. * Class containing static functions to help procedurally build meshes
  25762. */
  25763. export class DiscBuilder {
  25764. /**
  25765. * Creates a plane polygonal mesh. By default, this is a disc
  25766. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25767. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  25768. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  25769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25772. * @param name defines the name of the mesh
  25773. * @param options defines the options used to create the mesh
  25774. * @param scene defines the hosting scene
  25775. * @returns the plane polygonal mesh
  25776. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25777. */
  25778. static CreateDisc(name: string, options: {
  25779. radius?: number;
  25780. tessellation?: number;
  25781. arc?: number;
  25782. updatable?: boolean;
  25783. sideOrientation?: number;
  25784. frontUVs?: Vector4;
  25785. backUVs?: Vector4;
  25786. }, scene?: Nullable<Scene>): Mesh;
  25787. }
  25788. }
  25789. declare module "babylonjs/Particles/solidParticleSystem" {
  25790. import { Vector3 } from "babylonjs/Maths/math.vector";
  25791. import { Mesh } from "babylonjs/Meshes/mesh";
  25792. import { Scene, IDisposable } from "babylonjs/scene";
  25793. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25794. /**
  25795. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25796. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  25797. * The SPS is also a particle system. It provides some methods to manage the particles.
  25798. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25799. *
  25800. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25801. */
  25802. export class SolidParticleSystem implements IDisposable {
  25803. /**
  25804. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25805. * Example : var p = SPS.particles[i];
  25806. */
  25807. particles: SolidParticle[];
  25808. /**
  25809. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25810. */
  25811. nbParticles: number;
  25812. /**
  25813. * If the particles must ever face the camera (default false). Useful for planar particles.
  25814. */
  25815. billboard: boolean;
  25816. /**
  25817. * Recompute normals when adding a shape
  25818. */
  25819. recomputeNormals: boolean;
  25820. /**
  25821. * This a counter ofr your own usage. It's not set by any SPS functions.
  25822. */
  25823. counter: number;
  25824. /**
  25825. * The SPS name. This name is also given to the underlying mesh.
  25826. */
  25827. name: string;
  25828. /**
  25829. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25830. */
  25831. mesh: Mesh;
  25832. /**
  25833. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25834. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25835. */
  25836. vars: any;
  25837. /**
  25838. * This array is populated when the SPS is set as 'pickable'.
  25839. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25840. * Each element of this array is an object `{idx: int, faceId: int}`.
  25841. * `idx` is the picked particle index in the `SPS.particles` array
  25842. * `faceId` is the picked face index counted within this particle.
  25843. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25844. */
  25845. pickedParticles: {
  25846. idx: number;
  25847. faceId: number;
  25848. }[];
  25849. /**
  25850. * This array is populated when `enableDepthSort` is set to true.
  25851. * Each element of this array is an instance of the class DepthSortedParticle.
  25852. */
  25853. depthSortedParticles: DepthSortedParticle[];
  25854. /**
  25855. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25856. * @hidden
  25857. */
  25858. _bSphereOnly: boolean;
  25859. /**
  25860. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25861. * @hidden
  25862. */
  25863. _bSphereRadiusFactor: number;
  25864. private _scene;
  25865. private _positions;
  25866. private _indices;
  25867. private _normals;
  25868. private _colors;
  25869. private _uvs;
  25870. private _indices32;
  25871. private _positions32;
  25872. private _normals32;
  25873. private _fixedNormal32;
  25874. private _colors32;
  25875. private _uvs32;
  25876. private _index;
  25877. private _updatable;
  25878. private _pickable;
  25879. private _isVisibilityBoxLocked;
  25880. private _alwaysVisible;
  25881. private _depthSort;
  25882. private _shapeCounter;
  25883. private _copy;
  25884. private _color;
  25885. private _computeParticleColor;
  25886. private _computeParticleTexture;
  25887. private _computeParticleRotation;
  25888. private _computeParticleVertex;
  25889. private _computeBoundingBox;
  25890. private _depthSortParticles;
  25891. private _camera;
  25892. private _mustUnrotateFixedNormals;
  25893. private _particlesIntersect;
  25894. private _needs32Bits;
  25895. /**
  25896. * Creates a SPS (Solid Particle System) object.
  25897. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25898. * @param scene (Scene) is the scene in which the SPS is added.
  25899. * @param options defines the options of the sps e.g.
  25900. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25901. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25902. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25903. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25904. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25905. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25906. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25907. */
  25908. constructor(name: string, scene: Scene, options?: {
  25909. updatable?: boolean;
  25910. isPickable?: boolean;
  25911. enableDepthSort?: boolean;
  25912. particleIntersection?: boolean;
  25913. boundingSphereOnly?: boolean;
  25914. bSphereRadiusFactor?: number;
  25915. });
  25916. /**
  25917. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25918. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25919. * @returns the created mesh
  25920. */
  25921. buildMesh(): Mesh;
  25922. /**
  25923. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25924. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25925. * Thus the particles generated from `digest()` have their property `position` set yet.
  25926. * @param mesh ( Mesh ) is the mesh to be digested
  25927. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  25928. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25929. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25930. * @returns the current SPS
  25931. */
  25932. digest(mesh: Mesh, options?: {
  25933. facetNb?: number;
  25934. number?: number;
  25935. delta?: number;
  25936. }): SolidParticleSystem;
  25937. private _unrotateFixedNormals;
  25938. private _resetCopy;
  25939. private _meshBuilder;
  25940. private _posToShape;
  25941. private _uvsToShapeUV;
  25942. private _addParticle;
  25943. /**
  25944. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25945. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25946. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25947. * @param nb (positive integer) the number of particles to be created from this model
  25948. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25949. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25950. * @returns the number of shapes in the system
  25951. */
  25952. addShape(mesh: Mesh, nb: number, options?: {
  25953. positionFunction?: any;
  25954. vertexFunction?: any;
  25955. }): number;
  25956. private _rebuildParticle;
  25957. /**
  25958. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25959. * @returns the SPS.
  25960. */
  25961. rebuildMesh(): SolidParticleSystem;
  25962. /**
  25963. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25964. * This method calls `updateParticle()` for each particle of the SPS.
  25965. * For an animated SPS, it is usually called within the render loop.
  25966. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25967. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25968. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25969. * @returns the SPS.
  25970. */
  25971. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25972. /**
  25973. * Disposes the SPS.
  25974. */
  25975. dispose(): void;
  25976. /**
  25977. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25978. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25979. * @returns the SPS.
  25980. */
  25981. refreshVisibleSize(): SolidParticleSystem;
  25982. /**
  25983. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25984. * @param size the size (float) of the visibility box
  25985. * note : this doesn't lock the SPS mesh bounding box.
  25986. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25987. */
  25988. setVisibilityBox(size: number): void;
  25989. /**
  25990. * Gets whether the SPS as always visible or not
  25991. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25992. */
  25993. /**
  25994. * Sets the SPS as always visible or not
  25995. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25996. */
  25997. isAlwaysVisible: boolean;
  25998. /**
  25999. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26000. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26001. */
  26002. /**
  26003. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26004. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26005. */
  26006. isVisibilityBoxLocked: boolean;
  26007. /**
  26008. * Tells to `setParticles()` to compute the particle rotations or not.
  26009. * Default value : true. The SPS is faster when it's set to false.
  26010. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26011. */
  26012. /**
  26013. * Gets if `setParticles()` computes the particle rotations or not.
  26014. * Default value : true. The SPS is faster when it's set to false.
  26015. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26016. */
  26017. computeParticleRotation: boolean;
  26018. /**
  26019. * Tells to `setParticles()` to compute the particle colors or not.
  26020. * Default value : true. The SPS is faster when it's set to false.
  26021. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26022. */
  26023. /**
  26024. * Gets if `setParticles()` computes the particle colors or not.
  26025. * Default value : true. The SPS is faster when it's set to false.
  26026. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26027. */
  26028. computeParticleColor: boolean;
  26029. /**
  26030. * Gets if `setParticles()` computes the particle textures or not.
  26031. * Default value : true. The SPS is faster when it's set to false.
  26032. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26033. */
  26034. computeParticleTexture: boolean;
  26035. /**
  26036. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26037. * Default value : false. The SPS is faster when it's set to false.
  26038. * Note : the particle custom vertex positions aren't stored values.
  26039. */
  26040. /**
  26041. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26042. * Default value : false. The SPS is faster when it's set to false.
  26043. * Note : the particle custom vertex positions aren't stored values.
  26044. */
  26045. computeParticleVertex: boolean;
  26046. /**
  26047. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26048. */
  26049. /**
  26050. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26051. */
  26052. computeBoundingBox: boolean;
  26053. /**
  26054. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26055. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26056. * Default : `true`
  26057. */
  26058. /**
  26059. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26060. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26061. * Default : `true`
  26062. */
  26063. depthSortParticles: boolean;
  26064. /**
  26065. * This function does nothing. It may be overwritten to set all the particle first values.
  26066. * The SPS doesn't call this function, you may have to call it by your own.
  26067. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26068. */
  26069. initParticles(): void;
  26070. /**
  26071. * This function does nothing. It may be overwritten to recycle a particle.
  26072. * The SPS doesn't call this function, you may have to call it by your own.
  26073. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26074. * @param particle The particle to recycle
  26075. * @returns the recycled particle
  26076. */
  26077. recycleParticle(particle: SolidParticle): SolidParticle;
  26078. /**
  26079. * Updates a particle : this function should be overwritten by the user.
  26080. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26081. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26082. * @example : just set a particle position or velocity and recycle conditions
  26083. * @param particle The particle to update
  26084. * @returns the updated particle
  26085. */
  26086. updateParticle(particle: SolidParticle): SolidParticle;
  26087. /**
  26088. * Updates a vertex of a particle : it can be overwritten by the user.
  26089. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26090. * @param particle the current particle
  26091. * @param vertex the current index of the current particle
  26092. * @param pt the index of the current vertex in the particle shape
  26093. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26094. * @example : just set a vertex particle position
  26095. * @returns the updated vertex
  26096. */
  26097. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26098. /**
  26099. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26100. * This does nothing and may be overwritten by the user.
  26101. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26102. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26103. * @param update the boolean update value actually passed to setParticles()
  26104. */
  26105. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26106. /**
  26107. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26108. * This will be passed three parameters.
  26109. * This does nothing and may be overwritten by the user.
  26110. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26111. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26112. * @param update the boolean update value actually passed to setParticles()
  26113. */
  26114. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26115. }
  26116. }
  26117. declare module "babylonjs/Particles/solidParticle" {
  26118. import { Nullable } from "babylonjs/types";
  26119. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26120. import { Color4 } from "babylonjs/Maths/math.color";
  26121. import { Mesh } from "babylonjs/Meshes/mesh";
  26122. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26123. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26124. import { Plane } from "babylonjs/Maths/math.plane";
  26125. /**
  26126. * Represents one particle of a solid particle system.
  26127. */
  26128. export class SolidParticle {
  26129. /**
  26130. * particle global index
  26131. */
  26132. idx: number;
  26133. /**
  26134. * The color of the particle
  26135. */
  26136. color: Nullable<Color4>;
  26137. /**
  26138. * The world space position of the particle.
  26139. */
  26140. position: Vector3;
  26141. /**
  26142. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26143. */
  26144. rotation: Vector3;
  26145. /**
  26146. * The world space rotation quaternion of the particle.
  26147. */
  26148. rotationQuaternion: Nullable<Quaternion>;
  26149. /**
  26150. * The scaling of the particle.
  26151. */
  26152. scaling: Vector3;
  26153. /**
  26154. * The uvs of the particle.
  26155. */
  26156. uvs: Vector4;
  26157. /**
  26158. * The current speed of the particle.
  26159. */
  26160. velocity: Vector3;
  26161. /**
  26162. * The pivot point in the particle local space.
  26163. */
  26164. pivot: Vector3;
  26165. /**
  26166. * Must the particle be translated from its pivot point in its local space ?
  26167. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26168. * Default : false
  26169. */
  26170. translateFromPivot: boolean;
  26171. /**
  26172. * Is the particle active or not ?
  26173. */
  26174. alive: boolean;
  26175. /**
  26176. * Is the particle visible or not ?
  26177. */
  26178. isVisible: boolean;
  26179. /**
  26180. * Index of this particle in the global "positions" array (Internal use)
  26181. * @hidden
  26182. */
  26183. _pos: number;
  26184. /**
  26185. * @hidden Index of this particle in the global "indices" array (Internal use)
  26186. */
  26187. _ind: number;
  26188. /**
  26189. * @hidden ModelShape of this particle (Internal use)
  26190. */
  26191. _model: ModelShape;
  26192. /**
  26193. * ModelShape id of this particle
  26194. */
  26195. shapeId: number;
  26196. /**
  26197. * Index of the particle in its shape id
  26198. */
  26199. idxInShape: number;
  26200. /**
  26201. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26202. */
  26203. _modelBoundingInfo: BoundingInfo;
  26204. /**
  26205. * @hidden Particle BoundingInfo object (Internal use)
  26206. */
  26207. _boundingInfo: BoundingInfo;
  26208. /**
  26209. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26210. */
  26211. _sps: SolidParticleSystem;
  26212. /**
  26213. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26214. */
  26215. _stillInvisible: boolean;
  26216. /**
  26217. * @hidden Last computed particle rotation matrix
  26218. */
  26219. _rotationMatrix: number[];
  26220. /**
  26221. * Parent particle Id, if any.
  26222. * Default null.
  26223. */
  26224. parentId: Nullable<number>;
  26225. /**
  26226. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26227. * The possible values are :
  26228. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26229. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26230. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26231. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26232. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26233. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26234. * */
  26235. cullingStrategy: number;
  26236. /**
  26237. * @hidden Internal global position in the SPS.
  26238. */
  26239. _globalPosition: Vector3;
  26240. /**
  26241. * Creates a Solid Particle object.
  26242. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26243. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26244. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26245. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26246. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26247. * @param shapeId (integer) is the model shape identifier in the SPS.
  26248. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26249. * @param sps defines the sps it is associated to
  26250. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26251. */
  26252. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26253. /**
  26254. * Legacy support, changed scale to scaling
  26255. */
  26256. /**
  26257. * Legacy support, changed scale to scaling
  26258. */
  26259. scale: Vector3;
  26260. /**
  26261. * Legacy support, changed quaternion to rotationQuaternion
  26262. */
  26263. /**
  26264. * Legacy support, changed quaternion to rotationQuaternion
  26265. */
  26266. quaternion: Nullable<Quaternion>;
  26267. /**
  26268. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26269. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26270. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26271. * @returns true if it intersects
  26272. */
  26273. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26274. /**
  26275. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26276. * A particle is in the frustum if its bounding box intersects the frustum
  26277. * @param frustumPlanes defines the frustum to test
  26278. * @returns true if the particle is in the frustum planes
  26279. */
  26280. isInFrustum(frustumPlanes: Plane[]): boolean;
  26281. /**
  26282. * get the rotation matrix of the particle
  26283. * @hidden
  26284. */
  26285. getRotationMatrix(m: Matrix): void;
  26286. }
  26287. /**
  26288. * Represents the shape of the model used by one particle of a solid particle system.
  26289. * SPS internal tool, don't use it manually.
  26290. */
  26291. export class ModelShape {
  26292. /**
  26293. * The shape id
  26294. * @hidden
  26295. */
  26296. shapeID: number;
  26297. /**
  26298. * flat array of model positions (internal use)
  26299. * @hidden
  26300. */
  26301. _shape: Vector3[];
  26302. /**
  26303. * flat array of model UVs (internal use)
  26304. * @hidden
  26305. */
  26306. _shapeUV: number[];
  26307. /**
  26308. * length of the shape in the model indices array (internal use)
  26309. * @hidden
  26310. */
  26311. _indicesLength: number;
  26312. /**
  26313. * Custom position function (internal use)
  26314. * @hidden
  26315. */
  26316. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26317. /**
  26318. * Custom vertex function (internal use)
  26319. * @hidden
  26320. */
  26321. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26322. /**
  26323. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  26324. * SPS internal tool, don't use it manually.
  26325. * @hidden
  26326. */
  26327. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26328. }
  26329. /**
  26330. * Represents a Depth Sorted Particle in the solid particle system.
  26331. */
  26332. export class DepthSortedParticle {
  26333. /**
  26334. * Index of the particle in the "indices" array
  26335. */
  26336. ind: number;
  26337. /**
  26338. * Length of the particle shape in the "indices" array
  26339. */
  26340. indicesLength: number;
  26341. /**
  26342. * Squared distance from the particle to the camera
  26343. */
  26344. sqDistance: number;
  26345. }
  26346. }
  26347. declare module "babylonjs/Collisions/meshCollisionData" {
  26348. import { Collider } from "babylonjs/Collisions/collider";
  26349. import { Vector3 } from "babylonjs/Maths/math.vector";
  26350. import { Nullable } from "babylonjs/types";
  26351. import { Observer } from "babylonjs/Misc/observable";
  26352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26353. /**
  26354. * @hidden
  26355. */
  26356. export class _MeshCollisionData {
  26357. _checkCollisions: boolean;
  26358. _collisionMask: number;
  26359. _collisionGroup: number;
  26360. _collider: Nullable<Collider>;
  26361. _oldPositionForCollisions: Vector3;
  26362. _diffPositionForCollisions: Vector3;
  26363. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26364. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26365. }
  26366. }
  26367. declare module "babylonjs/Meshes/abstractMesh" {
  26368. import { Observable } from "babylonjs/Misc/observable";
  26369. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26370. import { Camera } from "babylonjs/Cameras/camera";
  26371. import { Scene, IDisposable } from "babylonjs/scene";
  26372. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26373. import { Node } from "babylonjs/node";
  26374. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26375. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26377. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26378. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26379. import { Material } from "babylonjs/Materials/material";
  26380. import { Light } from "babylonjs/Lights/light";
  26381. import { Skeleton } from "babylonjs/Bones/skeleton";
  26382. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26383. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26384. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26385. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26386. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26387. import { Plane } from "babylonjs/Maths/math.plane";
  26388. import { Ray } from "babylonjs/Culling/ray";
  26389. import { Collider } from "babylonjs/Collisions/collider";
  26390. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26391. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26392. /** @hidden */
  26393. class _FacetDataStorage {
  26394. facetPositions: Vector3[];
  26395. facetNormals: Vector3[];
  26396. facetPartitioning: number[][];
  26397. facetNb: number;
  26398. partitioningSubdivisions: number;
  26399. partitioningBBoxRatio: number;
  26400. facetDataEnabled: boolean;
  26401. facetParameters: any;
  26402. bbSize: Vector3;
  26403. subDiv: {
  26404. max: number;
  26405. X: number;
  26406. Y: number;
  26407. Z: number;
  26408. };
  26409. facetDepthSort: boolean;
  26410. facetDepthSortEnabled: boolean;
  26411. depthSortedIndices: IndicesArray;
  26412. depthSortedFacets: {
  26413. ind: number;
  26414. sqDistance: number;
  26415. }[];
  26416. facetDepthSortFunction: (f1: {
  26417. ind: number;
  26418. sqDistance: number;
  26419. }, f2: {
  26420. ind: number;
  26421. sqDistance: number;
  26422. }) => number;
  26423. facetDepthSortFrom: Vector3;
  26424. facetDepthSortOrigin: Vector3;
  26425. invertedMatrix: Matrix;
  26426. }
  26427. /**
  26428. * @hidden
  26429. **/
  26430. class _InternalAbstractMeshDataInfo {
  26431. _hasVertexAlpha: boolean;
  26432. _useVertexColors: boolean;
  26433. _numBoneInfluencers: number;
  26434. _applyFog: boolean;
  26435. _receiveShadows: boolean;
  26436. _facetData: _FacetDataStorage;
  26437. _visibility: number;
  26438. _skeleton: Nullable<Skeleton>;
  26439. _layerMask: number;
  26440. _computeBonesUsingShaders: boolean;
  26441. _isActive: boolean;
  26442. _onlyForInstances: boolean;
  26443. _isActiveIntermediate: boolean;
  26444. _onlyForInstancesIntermediate: boolean;
  26445. }
  26446. /**
  26447. * Class used to store all common mesh properties
  26448. */
  26449. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26450. /** No occlusion */
  26451. static OCCLUSION_TYPE_NONE: number;
  26452. /** Occlusion set to optimisitic */
  26453. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26454. /** Occlusion set to strict */
  26455. static OCCLUSION_TYPE_STRICT: number;
  26456. /** Use an accurante occlusion algorithm */
  26457. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26458. /** Use a conservative occlusion algorithm */
  26459. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26460. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26461. * Test order :
  26462. * Is the bounding sphere outside the frustum ?
  26463. * If not, are the bounding box vertices outside the frustum ?
  26464. * It not, then the cullable object is in the frustum.
  26465. */
  26466. static readonly CULLINGSTRATEGY_STANDARD: number;
  26467. /** Culling strategy : Bounding Sphere Only.
  26468. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26469. * It's also less accurate than the standard because some not visible objects can still be selected.
  26470. * Test : is the bounding sphere outside the frustum ?
  26471. * If not, then the cullable object is in the frustum.
  26472. */
  26473. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26474. /** Culling strategy : Optimistic Inclusion.
  26475. * This in an inclusion test first, then the standard exclusion test.
  26476. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26477. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  26478. * Anyway, it's as accurate as the standard strategy.
  26479. * Test :
  26480. * Is the cullable object bounding sphere center in the frustum ?
  26481. * If not, apply the default culling strategy.
  26482. */
  26483. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26484. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26485. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26486. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26487. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  26488. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26489. * Test :
  26490. * Is the cullable object bounding sphere center in the frustum ?
  26491. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26492. */
  26493. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26494. /**
  26495. * No billboard
  26496. */
  26497. static readonly BILLBOARDMODE_NONE: number;
  26498. /** Billboard on X axis */
  26499. static readonly BILLBOARDMODE_X: number;
  26500. /** Billboard on Y axis */
  26501. static readonly BILLBOARDMODE_Y: number;
  26502. /** Billboard on Z axis */
  26503. static readonly BILLBOARDMODE_Z: number;
  26504. /** Billboard on all axes */
  26505. static readonly BILLBOARDMODE_ALL: number;
  26506. /** Billboard on using position instead of orientation */
  26507. static readonly BILLBOARDMODE_USE_POSITION: number;
  26508. /** @hidden */
  26509. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26510. /**
  26511. * The culling strategy to use to check whether the mesh must be rendered or not.
  26512. * This value can be changed at any time and will be used on the next render mesh selection.
  26513. * The possible values are :
  26514. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26515. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26516. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26517. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26518. * Please read each static variable documentation to get details about the culling process.
  26519. * */
  26520. cullingStrategy: number;
  26521. /**
  26522. * Gets the number of facets in the mesh
  26523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26524. */
  26525. readonly facetNb: number;
  26526. /**
  26527. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26529. */
  26530. partitioningSubdivisions: number;
  26531. /**
  26532. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26533. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26534. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26535. */
  26536. partitioningBBoxRatio: number;
  26537. /**
  26538. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26539. * Works only for updatable meshes.
  26540. * Doesn't work with multi-materials
  26541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26542. */
  26543. mustDepthSortFacets: boolean;
  26544. /**
  26545. * The location (Vector3) where the facet depth sort must be computed from.
  26546. * By default, the active camera position.
  26547. * Used only when facet depth sort is enabled
  26548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26549. */
  26550. facetDepthSortFrom: Vector3;
  26551. /**
  26552. * gets a boolean indicating if facetData is enabled
  26553. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26554. */
  26555. readonly isFacetDataEnabled: boolean;
  26556. /** @hidden */
  26557. _updateNonUniformScalingState(value: boolean): boolean;
  26558. /**
  26559. * An event triggered when this mesh collides with another one
  26560. */
  26561. onCollideObservable: Observable<AbstractMesh>;
  26562. /** Set a function to call when this mesh collides with another one */
  26563. onCollide: () => void;
  26564. /**
  26565. * An event triggered when the collision's position changes
  26566. */
  26567. onCollisionPositionChangeObservable: Observable<Vector3>;
  26568. /** Set a function to call when the collision's position changes */
  26569. onCollisionPositionChange: () => void;
  26570. /**
  26571. * An event triggered when material is changed
  26572. */
  26573. onMaterialChangedObservable: Observable<AbstractMesh>;
  26574. /**
  26575. * Gets or sets the orientation for POV movement & rotation
  26576. */
  26577. definedFacingForward: boolean;
  26578. /** @hidden */
  26579. _occlusionQuery: Nullable<WebGLQuery>;
  26580. /** @hidden */
  26581. _renderingGroup: Nullable<RenderingGroup>;
  26582. /**
  26583. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26584. */
  26585. /**
  26586. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26587. */
  26588. visibility: number;
  26589. /** Gets or sets the alpha index used to sort transparent meshes
  26590. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26591. */
  26592. alphaIndex: number;
  26593. /**
  26594. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26595. */
  26596. isVisible: boolean;
  26597. /**
  26598. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26599. */
  26600. isPickable: boolean;
  26601. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26602. showSubMeshesBoundingBox: boolean;
  26603. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26604. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26605. */
  26606. isBlocker: boolean;
  26607. /**
  26608. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26609. */
  26610. enablePointerMoveEvents: boolean;
  26611. /**
  26612. * Specifies the rendering group id for this mesh (0 by default)
  26613. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26614. */
  26615. renderingGroupId: number;
  26616. private _material;
  26617. /** Gets or sets current material */
  26618. material: Nullable<Material>;
  26619. /**
  26620. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26621. * @see http://doc.babylonjs.com/babylon101/shadows
  26622. */
  26623. receiveShadows: boolean;
  26624. /** Defines color to use when rendering outline */
  26625. outlineColor: Color3;
  26626. /** Define width to use when rendering outline */
  26627. outlineWidth: number;
  26628. /** Defines color to use when rendering overlay */
  26629. overlayColor: Color3;
  26630. /** Defines alpha to use when rendering overlay */
  26631. overlayAlpha: number;
  26632. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26633. hasVertexAlpha: boolean;
  26634. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  26635. useVertexColors: boolean;
  26636. /**
  26637. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26638. */
  26639. computeBonesUsingShaders: boolean;
  26640. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26641. numBoneInfluencers: number;
  26642. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26643. applyFog: boolean;
  26644. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26645. useOctreeForRenderingSelection: boolean;
  26646. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26647. useOctreeForPicking: boolean;
  26648. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26649. useOctreeForCollisions: boolean;
  26650. /**
  26651. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26652. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26653. */
  26654. layerMask: number;
  26655. /**
  26656. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26657. */
  26658. alwaysSelectAsActiveMesh: boolean;
  26659. /**
  26660. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26661. */
  26662. doNotSyncBoundingInfo: boolean;
  26663. /**
  26664. * Gets or sets the current action manager
  26665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26666. */
  26667. actionManager: Nullable<AbstractActionManager>;
  26668. private _meshCollisionData;
  26669. /**
  26670. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26671. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26672. */
  26673. ellipsoid: Vector3;
  26674. /**
  26675. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26676. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26677. */
  26678. ellipsoidOffset: Vector3;
  26679. /**
  26680. * Gets or sets a collision mask used to mask collisions (default is -1).
  26681. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26682. */
  26683. collisionMask: number;
  26684. /**
  26685. * Gets or sets the current collision group mask (-1 by default).
  26686. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26687. */
  26688. collisionGroup: number;
  26689. /**
  26690. * Defines edge width used when edgesRenderer is enabled
  26691. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26692. */
  26693. edgesWidth: number;
  26694. /**
  26695. * Defines edge color used when edgesRenderer is enabled
  26696. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26697. */
  26698. edgesColor: Color4;
  26699. /** @hidden */
  26700. _edgesRenderer: Nullable<IEdgesRenderer>;
  26701. /** @hidden */
  26702. _masterMesh: Nullable<AbstractMesh>;
  26703. /** @hidden */
  26704. _boundingInfo: Nullable<BoundingInfo>;
  26705. /** @hidden */
  26706. _renderId: number;
  26707. /**
  26708. * Gets or sets the list of subMeshes
  26709. * @see http://doc.babylonjs.com/how_to/multi_materials
  26710. */
  26711. subMeshes: SubMesh[];
  26712. /** @hidden */
  26713. _intersectionsInProgress: AbstractMesh[];
  26714. /** @hidden */
  26715. _unIndexed: boolean;
  26716. /** @hidden */
  26717. _lightSources: Light[];
  26718. /** Gets the list of lights affecting that mesh */
  26719. readonly lightSources: Light[];
  26720. /** @hidden */
  26721. readonly _positions: Nullable<Vector3[]>;
  26722. /** @hidden */
  26723. _waitingData: {
  26724. lods: Nullable<any>;
  26725. actions: Nullable<any>;
  26726. freezeWorldMatrix: Nullable<boolean>;
  26727. };
  26728. /** @hidden */
  26729. _bonesTransformMatrices: Nullable<Float32Array>;
  26730. /** @hidden */
  26731. _transformMatrixTexture: Nullable<RawTexture>;
  26732. /**
  26733. * Gets or sets a skeleton to apply skining transformations
  26734. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26735. */
  26736. skeleton: Nullable<Skeleton>;
  26737. /**
  26738. * An event triggered when the mesh is rebuilt.
  26739. */
  26740. onRebuildObservable: Observable<AbstractMesh>;
  26741. /**
  26742. * Creates a new AbstractMesh
  26743. * @param name defines the name of the mesh
  26744. * @param scene defines the hosting scene
  26745. */
  26746. constructor(name: string, scene?: Nullable<Scene>);
  26747. /**
  26748. * Returns the string "AbstractMesh"
  26749. * @returns "AbstractMesh"
  26750. */
  26751. getClassName(): string;
  26752. /**
  26753. * Gets a string representation of the current mesh
  26754. * @param fullDetails defines a boolean indicating if full details must be included
  26755. * @returns a string representation of the current mesh
  26756. */
  26757. toString(fullDetails?: boolean): string;
  26758. /**
  26759. * @hidden
  26760. */
  26761. protected _getEffectiveParent(): Nullable<Node>;
  26762. /** @hidden */
  26763. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26764. /** @hidden */
  26765. _rebuild(): void;
  26766. /** @hidden */
  26767. _resyncLightSources(): void;
  26768. /** @hidden */
  26769. _resyncLighSource(light: Light): void;
  26770. /** @hidden */
  26771. _unBindEffect(): void;
  26772. /** @hidden */
  26773. _removeLightSource(light: Light, dispose: boolean): void;
  26774. private _markSubMeshesAsDirty;
  26775. /** @hidden */
  26776. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26777. /** @hidden */
  26778. _markSubMeshesAsAttributesDirty(): void;
  26779. /** @hidden */
  26780. _markSubMeshesAsMiscDirty(): void;
  26781. /**
  26782. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26783. */
  26784. scaling: Vector3;
  26785. /**
  26786. * Returns true if the mesh is blocked. Implemented by child classes
  26787. */
  26788. readonly isBlocked: boolean;
  26789. /**
  26790. * Returns the mesh itself by default. Implemented by child classes
  26791. * @param camera defines the camera to use to pick the right LOD level
  26792. * @returns the currentAbstractMesh
  26793. */
  26794. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26795. /**
  26796. * Returns 0 by default. Implemented by child classes
  26797. * @returns an integer
  26798. */
  26799. getTotalVertices(): number;
  26800. /**
  26801. * Returns a positive integer : the total number of indices in this mesh geometry.
  26802. * @returns the numner of indices or zero if the mesh has no geometry.
  26803. */
  26804. getTotalIndices(): number;
  26805. /**
  26806. * Returns null by default. Implemented by child classes
  26807. * @returns null
  26808. */
  26809. getIndices(): Nullable<IndicesArray>;
  26810. /**
  26811. * Returns the array of the requested vertex data kind. Implemented by child classes
  26812. * @param kind defines the vertex data kind to use
  26813. * @returns null
  26814. */
  26815. getVerticesData(kind: string): Nullable<FloatArray>;
  26816. /**
  26817. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26818. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26819. * Note that a new underlying VertexBuffer object is created each call.
  26820. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26821. * @param kind defines vertex data kind:
  26822. * * VertexBuffer.PositionKind
  26823. * * VertexBuffer.UVKind
  26824. * * VertexBuffer.UV2Kind
  26825. * * VertexBuffer.UV3Kind
  26826. * * VertexBuffer.UV4Kind
  26827. * * VertexBuffer.UV5Kind
  26828. * * VertexBuffer.UV6Kind
  26829. * * VertexBuffer.ColorKind
  26830. * * VertexBuffer.MatricesIndicesKind
  26831. * * VertexBuffer.MatricesIndicesExtraKind
  26832. * * VertexBuffer.MatricesWeightsKind
  26833. * * VertexBuffer.MatricesWeightsExtraKind
  26834. * @param data defines the data source
  26835. * @param updatable defines if the data must be flagged as updatable (or static)
  26836. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  26837. * @returns the current mesh
  26838. */
  26839. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26840. /**
  26841. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26842. * If the mesh has no geometry, it is simply returned as it is.
  26843. * @param kind defines vertex data kind:
  26844. * * VertexBuffer.PositionKind
  26845. * * VertexBuffer.UVKind
  26846. * * VertexBuffer.UV2Kind
  26847. * * VertexBuffer.UV3Kind
  26848. * * VertexBuffer.UV4Kind
  26849. * * VertexBuffer.UV5Kind
  26850. * * VertexBuffer.UV6Kind
  26851. * * VertexBuffer.ColorKind
  26852. * * VertexBuffer.MatricesIndicesKind
  26853. * * VertexBuffer.MatricesIndicesExtraKind
  26854. * * VertexBuffer.MatricesWeightsKind
  26855. * * VertexBuffer.MatricesWeightsExtraKind
  26856. * @param data defines the data source
  26857. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  26858. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26859. * @returns the current mesh
  26860. */
  26861. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26862. /**
  26863. * Sets the mesh indices,
  26864. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26865. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26866. * @param totalVertices Defines the total number of vertices
  26867. * @returns the current mesh
  26868. */
  26869. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26870. /**
  26871. * Gets a boolean indicating if specific vertex data is present
  26872. * @param kind defines the vertex data kind to use
  26873. * @returns true is data kind is present
  26874. */
  26875. isVerticesDataPresent(kind: string): boolean;
  26876. /**
  26877. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26878. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26879. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26880. * @returns a BoundingInfo
  26881. */
  26882. getBoundingInfo(): BoundingInfo;
  26883. /**
  26884. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26885. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26886. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26887. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26888. * @returns the current mesh
  26889. */
  26890. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26891. /**
  26892. * Overwrite the current bounding info
  26893. * @param boundingInfo defines the new bounding info
  26894. * @returns the current mesh
  26895. */
  26896. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26897. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26898. readonly useBones: boolean;
  26899. /** @hidden */
  26900. _preActivate(): void;
  26901. /** @hidden */
  26902. _preActivateForIntermediateRendering(renderId: number): void;
  26903. /** @hidden */
  26904. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26905. /** @hidden */
  26906. _postActivate(): void;
  26907. /** @hidden */
  26908. _freeze(): void;
  26909. /** @hidden */
  26910. _unFreeze(): void;
  26911. /**
  26912. * Gets the current world matrix
  26913. * @returns a Matrix
  26914. */
  26915. getWorldMatrix(): Matrix;
  26916. /** @hidden */
  26917. _getWorldMatrixDeterminant(): number;
  26918. /**
  26919. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26920. */
  26921. readonly isAnInstance: boolean;
  26922. /**
  26923. * Gets a boolean indicating if this mesh has instances
  26924. */
  26925. readonly hasInstances: boolean;
  26926. /**
  26927. * Perform relative position change from the point of view of behind the front of the mesh.
  26928. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26929. * Supports definition of mesh facing forward or backward
  26930. * @param amountRight defines the distance on the right axis
  26931. * @param amountUp defines the distance on the up axis
  26932. * @param amountForward defines the distance on the forward axis
  26933. * @returns the current mesh
  26934. */
  26935. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26936. /**
  26937. * Calculate relative position change from the point of view of behind the front of the mesh.
  26938. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26939. * Supports definition of mesh facing forward or backward
  26940. * @param amountRight defines the distance on the right axis
  26941. * @param amountUp defines the distance on the up axis
  26942. * @param amountForward defines the distance on the forward axis
  26943. * @returns the new displacement vector
  26944. */
  26945. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26946. /**
  26947. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26948. * Supports definition of mesh facing forward or backward
  26949. * @param flipBack defines the flip
  26950. * @param twirlClockwise defines the twirl
  26951. * @param tiltRight defines the tilt
  26952. * @returns the current mesh
  26953. */
  26954. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26955. /**
  26956. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26957. * Supports definition of mesh facing forward or backward.
  26958. * @param flipBack defines the flip
  26959. * @param twirlClockwise defines the twirl
  26960. * @param tiltRight defines the tilt
  26961. * @returns the new rotation vector
  26962. */
  26963. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26964. /**
  26965. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26966. * This means the mesh underlying bounding box and sphere are recomputed.
  26967. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26968. * @returns the current mesh
  26969. */
  26970. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26971. /** @hidden */
  26972. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26973. /** @hidden */
  26974. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26975. /** @hidden */
  26976. _updateBoundingInfo(): AbstractMesh;
  26977. /** @hidden */
  26978. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26979. /** @hidden */
  26980. protected _afterComputeWorldMatrix(): void;
  26981. /** @hidden */
  26982. readonly _effectiveMesh: AbstractMesh;
  26983. /**
  26984. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26985. * A mesh is in the frustum if its bounding box intersects the frustum
  26986. * @param frustumPlanes defines the frustum to test
  26987. * @returns true if the mesh is in the frustum planes
  26988. */
  26989. isInFrustum(frustumPlanes: Plane[]): boolean;
  26990. /**
  26991. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26992. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26993. * @param frustumPlanes defines the frustum to test
  26994. * @returns true if the mesh is completely in the frustum planes
  26995. */
  26996. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26997. /**
  26998. * True if the mesh intersects another mesh or a SolidParticle object
  26999. * @param mesh defines a target mesh or SolidParticle to test
  27000. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  27001. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27002. * @returns true if there is an intersection
  27003. */
  27004. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27005. /**
  27006. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27007. * @param point defines the point to test
  27008. * @returns true if there is an intersection
  27009. */
  27010. intersectsPoint(point: Vector3): boolean;
  27011. /**
  27012. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27013. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27014. */
  27015. checkCollisions: boolean;
  27016. /**
  27017. * Gets Collider object used to compute collisions (not physics)
  27018. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27019. */
  27020. readonly collider: Nullable<Collider>;
  27021. /**
  27022. * Move the mesh using collision engine
  27023. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27024. * @param displacement defines the requested displacement vector
  27025. * @returns the current mesh
  27026. */
  27027. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27028. private _onCollisionPositionChange;
  27029. /** @hidden */
  27030. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27031. /** @hidden */
  27032. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27033. /** @hidden */
  27034. _checkCollision(collider: Collider): AbstractMesh;
  27035. /** @hidden */
  27036. _generatePointsArray(): boolean;
  27037. /**
  27038. * Checks if the passed Ray intersects with the mesh
  27039. * @param ray defines the ray to use
  27040. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27041. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27042. * @returns the picking info
  27043. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27044. */
  27045. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27046. /**
  27047. * Clones the current mesh
  27048. * @param name defines the mesh name
  27049. * @param newParent defines the new mesh parent
  27050. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27051. * @returns the new mesh
  27052. */
  27053. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27054. /**
  27055. * Disposes all the submeshes of the current meshnp
  27056. * @returns the current mesh
  27057. */
  27058. releaseSubMeshes(): AbstractMesh;
  27059. /**
  27060. * Releases resources associated with this abstract mesh.
  27061. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27062. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27063. */
  27064. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27065. /**
  27066. * Adds the passed mesh as a child to the current mesh
  27067. * @param mesh defines the child mesh
  27068. * @returns the current mesh
  27069. */
  27070. addChild(mesh: AbstractMesh): AbstractMesh;
  27071. /**
  27072. * Removes the passed mesh from the current mesh children list
  27073. * @param mesh defines the child mesh
  27074. * @returns the current mesh
  27075. */
  27076. removeChild(mesh: AbstractMesh): AbstractMesh;
  27077. /** @hidden */
  27078. private _initFacetData;
  27079. /**
  27080. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27081. * This method can be called within the render loop.
  27082. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  27083. * @returns the current mesh
  27084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27085. */
  27086. updateFacetData(): AbstractMesh;
  27087. /**
  27088. * Returns the facetLocalNormals array.
  27089. * The normals are expressed in the mesh local spac
  27090. * @returns an array of Vector3
  27091. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27092. */
  27093. getFacetLocalNormals(): Vector3[];
  27094. /**
  27095. * Returns the facetLocalPositions array.
  27096. * The facet positions are expressed in the mesh local space
  27097. * @returns an array of Vector3
  27098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27099. */
  27100. getFacetLocalPositions(): Vector3[];
  27101. /**
  27102. * Returns the facetLocalPartioning array
  27103. * @returns an array of array of numbers
  27104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27105. */
  27106. getFacetLocalPartitioning(): number[][];
  27107. /**
  27108. * Returns the i-th facet position in the world system.
  27109. * This method allocates a new Vector3 per call
  27110. * @param i defines the facet index
  27111. * @returns a new Vector3
  27112. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27113. */
  27114. getFacetPosition(i: number): Vector3;
  27115. /**
  27116. * Sets the reference Vector3 with the i-th facet position in the world system
  27117. * @param i defines the facet index
  27118. * @param ref defines the target vector
  27119. * @returns the current mesh
  27120. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27121. */
  27122. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27123. /**
  27124. * Returns the i-th facet normal in the world system.
  27125. * This method allocates a new Vector3 per call
  27126. * @param i defines the facet index
  27127. * @returns a new Vector3
  27128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27129. */
  27130. getFacetNormal(i: number): Vector3;
  27131. /**
  27132. * Sets the reference Vector3 with the i-th facet normal in the world system
  27133. * @param i defines the facet index
  27134. * @param ref defines the target vector
  27135. * @returns the current mesh
  27136. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27137. */
  27138. getFacetNormalToRef(i: number, ref: Vector3): this;
  27139. /**
  27140. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  27141. * @param x defines x coordinate
  27142. * @param y defines y coordinate
  27143. * @param z defines z coordinate
  27144. * @returns the array of facet indexes
  27145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27146. */
  27147. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27148. /**
  27149. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27150. * @param projected sets as the (x,y,z) world projection on the facet
  27151. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  27152. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  27153. * @param x defines x coordinate
  27154. * @param y defines y coordinate
  27155. * @param z defines z coordinate
  27156. * @returns the face index if found (or null instead)
  27157. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27158. */
  27159. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27160. /**
  27161. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27162. * @param projected sets as the (x,y,z) local projection on the facet
  27163. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  27164. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  27165. * @param x defines x coordinate
  27166. * @param y defines y coordinate
  27167. * @param z defines z coordinate
  27168. * @returns the face index if found (or null instead)
  27169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27170. */
  27171. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27172. /**
  27173. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27174. * @returns the parameters
  27175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27176. */
  27177. getFacetDataParameters(): any;
  27178. /**
  27179. * Disables the feature FacetData and frees the related memory
  27180. * @returns the current mesh
  27181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27182. */
  27183. disableFacetData(): AbstractMesh;
  27184. /**
  27185. * Updates the AbstractMesh indices array
  27186. * @param indices defines the data source
  27187. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27188. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  27189. * @returns the current mesh
  27190. */
  27191. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27192. /**
  27193. * Creates new normals data for the mesh
  27194. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27195. * @returns the current mesh
  27196. */
  27197. createNormals(updatable: boolean): AbstractMesh;
  27198. /**
  27199. * Align the mesh with a normal
  27200. * @param normal defines the normal to use
  27201. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27202. * @returns the current mesh
  27203. */
  27204. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27205. /** @hidden */
  27206. _checkOcclusionQuery(): boolean;
  27207. /**
  27208. * Disables the mesh edge rendering mode
  27209. * @returns the currentAbstractMesh
  27210. */
  27211. disableEdgesRendering(): AbstractMesh;
  27212. /**
  27213. * Enables the edge rendering mode on the mesh.
  27214. * This mode makes the mesh edges visible
  27215. * @param epsilon defines the maximal distance between two angles to detect a face
  27216. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27217. * @returns the currentAbstractMesh
  27218. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27219. */
  27220. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27221. }
  27222. }
  27223. declare module "babylonjs/Actions/actionEvent" {
  27224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27225. import { Nullable } from "babylonjs/types";
  27226. import { Sprite } from "babylonjs/Sprites/sprite";
  27227. import { Scene } from "babylonjs/scene";
  27228. import { Vector2 } from "babylonjs/Maths/math.vector";
  27229. /**
  27230. * Interface used to define ActionEvent
  27231. */
  27232. export interface IActionEvent {
  27233. /** The mesh or sprite that triggered the action */
  27234. source: any;
  27235. /** The X mouse cursor position at the time of the event */
  27236. pointerX: number;
  27237. /** The Y mouse cursor position at the time of the event */
  27238. pointerY: number;
  27239. /** The mesh that is currently pointed at (can be null) */
  27240. meshUnderPointer: Nullable<AbstractMesh>;
  27241. /** the original (browser) event that triggered the ActionEvent */
  27242. sourceEvent?: any;
  27243. /** additional data for the event */
  27244. additionalData?: any;
  27245. }
  27246. /**
  27247. * ActionEvent is the event being sent when an action is triggered.
  27248. */
  27249. export class ActionEvent implements IActionEvent {
  27250. /** The mesh or sprite that triggered the action */
  27251. source: any;
  27252. /** The X mouse cursor position at the time of the event */
  27253. pointerX: number;
  27254. /** The Y mouse cursor position at the time of the event */
  27255. pointerY: number;
  27256. /** The mesh that is currently pointed at (can be null) */
  27257. meshUnderPointer: Nullable<AbstractMesh>;
  27258. /** the original (browser) event that triggered the ActionEvent */
  27259. sourceEvent?: any;
  27260. /** additional data for the event */
  27261. additionalData?: any;
  27262. /**
  27263. * Creates a new ActionEvent
  27264. * @param source The mesh or sprite that triggered the action
  27265. * @param pointerX The X mouse cursor position at the time of the event
  27266. * @param pointerY The Y mouse cursor position at the time of the event
  27267. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27268. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27269. * @param additionalData additional data for the event
  27270. */
  27271. constructor(
  27272. /** The mesh or sprite that triggered the action */
  27273. source: any,
  27274. /** The X mouse cursor position at the time of the event */
  27275. pointerX: number,
  27276. /** The Y mouse cursor position at the time of the event */
  27277. pointerY: number,
  27278. /** The mesh that is currently pointed at (can be null) */
  27279. meshUnderPointer: Nullable<AbstractMesh>,
  27280. /** the original (browser) event that triggered the ActionEvent */
  27281. sourceEvent?: any,
  27282. /** additional data for the event */
  27283. additionalData?: any);
  27284. /**
  27285. * Helper function to auto-create an ActionEvent from a source mesh.
  27286. * @param source The source mesh that triggered the event
  27287. * @param evt The original (browser) event
  27288. * @param additionalData additional data for the event
  27289. * @returns the new ActionEvent
  27290. */
  27291. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27292. /**
  27293. * Helper function to auto-create an ActionEvent from a source sprite
  27294. * @param source The source sprite that triggered the event
  27295. * @param scene Scene associated with the sprite
  27296. * @param evt The original (browser) event
  27297. * @param additionalData additional data for the event
  27298. * @returns the new ActionEvent
  27299. */
  27300. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27301. /**
  27302. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27303. * @param scene the scene where the event occurred
  27304. * @param evt The original (browser) event
  27305. * @returns the new ActionEvent
  27306. */
  27307. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27308. /**
  27309. * Helper function to auto-create an ActionEvent from a primitive
  27310. * @param prim defines the target primitive
  27311. * @param pointerPos defines the pointer position
  27312. * @param evt The original (browser) event
  27313. * @param additionalData additional data for the event
  27314. * @returns the new ActionEvent
  27315. */
  27316. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27317. }
  27318. }
  27319. declare module "babylonjs/Actions/abstractActionManager" {
  27320. import { IDisposable } from "babylonjs/scene";
  27321. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27322. import { IAction } from "babylonjs/Actions/action";
  27323. import { Nullable } from "babylonjs/types";
  27324. /**
  27325. * Abstract class used to decouple action Manager from scene and meshes.
  27326. * Do not instantiate.
  27327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27328. */
  27329. export abstract class AbstractActionManager implements IDisposable {
  27330. /** Gets the list of active triggers */
  27331. static Triggers: {
  27332. [key: string]: number;
  27333. };
  27334. /** Gets the cursor to use when hovering items */
  27335. hoverCursor: string;
  27336. /** Gets the list of actions */
  27337. actions: IAction[];
  27338. /**
  27339. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27340. */
  27341. isRecursive: boolean;
  27342. /**
  27343. * Releases all associated resources
  27344. */
  27345. abstract dispose(): void;
  27346. /**
  27347. * Does this action manager has pointer triggers
  27348. */
  27349. abstract readonly hasPointerTriggers: boolean;
  27350. /**
  27351. * Does this action manager has pick triggers
  27352. */
  27353. abstract readonly hasPickTriggers: boolean;
  27354. /**
  27355. * Process a specific trigger
  27356. * @param trigger defines the trigger to process
  27357. * @param evt defines the event details to be processed
  27358. */
  27359. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27360. /**
  27361. * Does this action manager handles actions of any of the given triggers
  27362. * @param triggers defines the triggers to be tested
  27363. * @return a boolean indicating whether one (or more) of the triggers is handled
  27364. */
  27365. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27366. /**
  27367. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27368. * speed.
  27369. * @param triggerA defines the trigger to be tested
  27370. * @param triggerB defines the trigger to be tested
  27371. * @return a boolean indicating whether one (or more) of the triggers is handled
  27372. */
  27373. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27374. /**
  27375. * Does this action manager handles actions of a given trigger
  27376. * @param trigger defines the trigger to be tested
  27377. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27378. * @return whether the trigger is handled
  27379. */
  27380. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27381. /**
  27382. * Serialize this manager to a JSON object
  27383. * @param name defines the property name to store this manager
  27384. * @returns a JSON representation of this manager
  27385. */
  27386. abstract serialize(name: string): any;
  27387. /**
  27388. * Registers an action to this action manager
  27389. * @param action defines the action to be registered
  27390. * @return the action amended (prepared) after registration
  27391. */
  27392. abstract registerAction(action: IAction): Nullable<IAction>;
  27393. /**
  27394. * Unregisters an action to this action manager
  27395. * @param action defines the action to be unregistered
  27396. * @return a boolean indicating whether the action has been unregistered
  27397. */
  27398. abstract unregisterAction(action: IAction): Boolean;
  27399. /**
  27400. * Does exist one action manager with at least one trigger
  27401. **/
  27402. static readonly HasTriggers: boolean;
  27403. /**
  27404. * Does exist one action manager with at least one pick trigger
  27405. **/
  27406. static readonly HasPickTriggers: boolean;
  27407. /**
  27408. * Does exist one action manager that handles actions of a given trigger
  27409. * @param trigger defines the trigger to be tested
  27410. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27411. **/
  27412. static HasSpecificTrigger(trigger: number): boolean;
  27413. }
  27414. }
  27415. declare module "babylonjs/node" {
  27416. import { Scene } from "babylonjs/scene";
  27417. import { Nullable } from "babylonjs/types";
  27418. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27419. import { Engine } from "babylonjs/Engines/engine";
  27420. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27421. import { Observable } from "babylonjs/Misc/observable";
  27422. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27423. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27424. import { Animatable } from "babylonjs/Animations/animatable";
  27425. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27426. import { Animation } from "babylonjs/Animations/animation";
  27427. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27429. /**
  27430. * Defines how a node can be built from a string name.
  27431. */
  27432. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27433. /**
  27434. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27435. */
  27436. export class Node implements IBehaviorAware<Node> {
  27437. /** @hidden */
  27438. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27439. private static _NodeConstructors;
  27440. /**
  27441. * Add a new node constructor
  27442. * @param type defines the type name of the node to construct
  27443. * @param constructorFunc defines the constructor function
  27444. */
  27445. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27446. /**
  27447. * Returns a node constructor based on type name
  27448. * @param type defines the type name
  27449. * @param name defines the new node name
  27450. * @param scene defines the hosting scene
  27451. * @param options defines optional options to transmit to constructors
  27452. * @returns the new constructor or null
  27453. */
  27454. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27455. /**
  27456. * Gets or sets the name of the node
  27457. */
  27458. name: string;
  27459. /**
  27460. * Gets or sets the id of the node
  27461. */
  27462. id: string;
  27463. /**
  27464. * Gets or sets the unique id of the node
  27465. */
  27466. uniqueId: number;
  27467. /**
  27468. * Gets or sets a string used to store user defined state for the node
  27469. */
  27470. state: string;
  27471. /**
  27472. * Gets or sets an object used to store user defined information for the node
  27473. */
  27474. metadata: any;
  27475. /**
  27476. * For internal use only. Please do not use.
  27477. */
  27478. reservedDataStore: any;
  27479. /**
  27480. * List of inspectable custom properties (used by the Inspector)
  27481. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27482. */
  27483. inspectableCustomProperties: IInspectable[];
  27484. /**
  27485. * Gets or sets a boolean used to define if the node must be serialized
  27486. */
  27487. doNotSerialize: boolean;
  27488. /** @hidden */
  27489. _isDisposed: boolean;
  27490. /**
  27491. * Gets a list of Animations associated with the node
  27492. */
  27493. animations: import("babylonjs/Animations/animation").Animation[];
  27494. protected _ranges: {
  27495. [name: string]: Nullable<AnimationRange>;
  27496. };
  27497. /**
  27498. * Callback raised when the node is ready to be used
  27499. */
  27500. onReady: Nullable<(node: Node) => void>;
  27501. private _isEnabled;
  27502. private _isParentEnabled;
  27503. private _isReady;
  27504. /** @hidden */
  27505. _currentRenderId: number;
  27506. private _parentUpdateId;
  27507. /** @hidden */
  27508. _childUpdateId: number;
  27509. /** @hidden */
  27510. _waitingParentId: Nullable<string>;
  27511. /** @hidden */
  27512. _scene: Scene;
  27513. /** @hidden */
  27514. _cache: any;
  27515. private _parentNode;
  27516. private _children;
  27517. /** @hidden */
  27518. _worldMatrix: Matrix;
  27519. /** @hidden */
  27520. _worldMatrixDeterminant: number;
  27521. /** @hidden */
  27522. _worldMatrixDeterminantIsDirty: boolean;
  27523. /** @hidden */
  27524. private _sceneRootNodesIndex;
  27525. /**
  27526. * Gets a boolean indicating if the node has been disposed
  27527. * @returns true if the node was disposed
  27528. */
  27529. isDisposed(): boolean;
  27530. /**
  27531. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27532. * @see https://doc.babylonjs.com/how_to/parenting
  27533. */
  27534. parent: Nullable<Node>;
  27535. private addToSceneRootNodes;
  27536. private removeFromSceneRootNodes;
  27537. private _animationPropertiesOverride;
  27538. /**
  27539. * Gets or sets the animation properties override
  27540. */
  27541. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27542. /**
  27543. * Gets a string idenfifying the name of the class
  27544. * @returns "Node" string
  27545. */
  27546. getClassName(): string;
  27547. /** @hidden */
  27548. readonly _isNode: boolean;
  27549. /**
  27550. * An event triggered when the mesh is disposed
  27551. */
  27552. onDisposeObservable: Observable<Node>;
  27553. private _onDisposeObserver;
  27554. /**
  27555. * Sets a callback that will be raised when the node will be disposed
  27556. */
  27557. onDispose: () => void;
  27558. /**
  27559. * Creates a new Node
  27560. * @param name the name and id to be given to this node
  27561. * @param scene the scene this node will be added to
  27562. * @param addToRootNodes the node will be added to scene.rootNodes
  27563. */
  27564. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27565. /**
  27566. * Gets the scene of the node
  27567. * @returns a scene
  27568. */
  27569. getScene(): Scene;
  27570. /**
  27571. * Gets the engine of the node
  27572. * @returns a Engine
  27573. */
  27574. getEngine(): Engine;
  27575. private _behaviors;
  27576. /**
  27577. * Attach a behavior to the node
  27578. * @see http://doc.babylonjs.com/features/behaviour
  27579. * @param behavior defines the behavior to attach
  27580. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27581. * @returns the current Node
  27582. */
  27583. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27584. /**
  27585. * Remove an attached behavior
  27586. * @see http://doc.babylonjs.com/features/behaviour
  27587. * @param behavior defines the behavior to attach
  27588. * @returns the current Node
  27589. */
  27590. removeBehavior(behavior: Behavior<Node>): Node;
  27591. /**
  27592. * Gets the list of attached behaviors
  27593. * @see http://doc.babylonjs.com/features/behaviour
  27594. */
  27595. readonly behaviors: Behavior<Node>[];
  27596. /**
  27597. * Gets an attached behavior by name
  27598. * @param name defines the name of the behavior to look for
  27599. * @see http://doc.babylonjs.com/features/behaviour
  27600. * @returns null if behavior was not found else the requested behavior
  27601. */
  27602. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27603. /**
  27604. * Returns the latest update of the World matrix
  27605. * @returns a Matrix
  27606. */
  27607. getWorldMatrix(): Matrix;
  27608. /** @hidden */
  27609. _getWorldMatrixDeterminant(): number;
  27610. /**
  27611. * Returns directly the latest state of the mesh World matrix.
  27612. * A Matrix is returned.
  27613. */
  27614. readonly worldMatrixFromCache: Matrix;
  27615. /** @hidden */
  27616. _initCache(): void;
  27617. /** @hidden */
  27618. updateCache(force?: boolean): void;
  27619. /** @hidden */
  27620. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27621. /** @hidden */
  27622. _updateCache(ignoreParentClass?: boolean): void;
  27623. /** @hidden */
  27624. _isSynchronized(): boolean;
  27625. /** @hidden */
  27626. _markSyncedWithParent(): void;
  27627. /** @hidden */
  27628. isSynchronizedWithParent(): boolean;
  27629. /** @hidden */
  27630. isSynchronized(): boolean;
  27631. /**
  27632. * Is this node ready to be used/rendered
  27633. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27634. * @return true if the node is ready
  27635. */
  27636. isReady(completeCheck?: boolean): boolean;
  27637. /**
  27638. * Is this node enabled?
  27639. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  27640. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  27641. * @return whether this node (and its parent) is enabled
  27642. */
  27643. isEnabled(checkAncestors?: boolean): boolean;
  27644. /** @hidden */
  27645. protected _syncParentEnabledState(): void;
  27646. /**
  27647. * Set the enabled state of this node
  27648. * @param value defines the new enabled state
  27649. */
  27650. setEnabled(value: boolean): void;
  27651. /**
  27652. * Is this node a descendant of the given node?
  27653. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27654. * @param ancestor defines the parent node to inspect
  27655. * @returns a boolean indicating if this node is a descendant of the given node
  27656. */
  27657. isDescendantOf(ancestor: Node): boolean;
  27658. /** @hidden */
  27659. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27660. /**
  27661. * Will return all nodes that have this node as ascendant
  27662. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  27663. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27664. * @return all children nodes of all types
  27665. */
  27666. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27667. /**
  27668. * Get all child-meshes of this node
  27669. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  27670. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27671. * @returns an array of AbstractMesh
  27672. */
  27673. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27674. /**
  27675. * Get all direct children of this node
  27676. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27677. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  27678. * @returns an array of Node
  27679. */
  27680. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27681. /** @hidden */
  27682. _setReady(state: boolean): void;
  27683. /**
  27684. * Get an animation by name
  27685. * @param name defines the name of the animation to look for
  27686. * @returns null if not found else the requested animation
  27687. */
  27688. getAnimationByName(name: string): Nullable<Animation>;
  27689. /**
  27690. * Creates an animation range for this node
  27691. * @param name defines the name of the range
  27692. * @param from defines the starting key
  27693. * @param to defines the end key
  27694. */
  27695. createAnimationRange(name: string, from: number, to: number): void;
  27696. /**
  27697. * Delete a specific animation range
  27698. * @param name defines the name of the range to delete
  27699. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27700. */
  27701. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27702. /**
  27703. * Get an animation range by name
  27704. * @param name defines the name of the animation range to look for
  27705. * @returns null if not found else the requested animation range
  27706. */
  27707. getAnimationRange(name: string): Nullable<AnimationRange>;
  27708. /**
  27709. * Gets the list of all animation ranges defined on this node
  27710. * @returns an array
  27711. */
  27712. getAnimationRanges(): Nullable<AnimationRange>[];
  27713. /**
  27714. * Will start the animation sequence
  27715. * @param name defines the range frames for animation sequence
  27716. * @param loop defines if the animation should loop (false by default)
  27717. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27718. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27719. * @returns the object created for this animation. If range does not exist, it will return null
  27720. */
  27721. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27722. /**
  27723. * Serialize animation ranges into a JSON compatible object
  27724. * @returns serialization object
  27725. */
  27726. serializeAnimationRanges(): any;
  27727. /**
  27728. * Computes the world matrix of the node
  27729. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27730. * @returns the world matrix
  27731. */
  27732. computeWorldMatrix(force?: boolean): Matrix;
  27733. /**
  27734. * Releases resources associated with this node.
  27735. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27736. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27737. */
  27738. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27739. /**
  27740. * Parse animation range data from a serialization object and store them into a given node
  27741. * @param node defines where to store the animation ranges
  27742. * @param parsedNode defines the serialization object to read data from
  27743. * @param scene defines the hosting scene
  27744. */
  27745. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27746. /**
  27747. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27748. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27749. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  27750. * @returns the new bounding vectors
  27751. */
  27752. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27753. min: Vector3;
  27754. max: Vector3;
  27755. };
  27756. }
  27757. }
  27758. declare module "babylonjs/Animations/animation" {
  27759. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27760. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27761. import { Color3 } from "babylonjs/Maths/math.color";
  27762. import { Nullable } from "babylonjs/types";
  27763. import { Scene } from "babylonjs/scene";
  27764. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27765. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27766. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27767. import { Node } from "babylonjs/node";
  27768. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27769. import { Size } from "babylonjs/Maths/math.size";
  27770. import { Animatable } from "babylonjs/Animations/animatable";
  27771. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27772. /**
  27773. * @hidden
  27774. */
  27775. export class _IAnimationState {
  27776. key: number;
  27777. repeatCount: number;
  27778. workValue?: any;
  27779. loopMode?: number;
  27780. offsetValue?: any;
  27781. highLimitValue?: any;
  27782. }
  27783. /**
  27784. * Class used to store any kind of animation
  27785. */
  27786. export class Animation {
  27787. /**Name of the animation */
  27788. name: string;
  27789. /**Property to animate */
  27790. targetProperty: string;
  27791. /**The frames per second of the animation */
  27792. framePerSecond: number;
  27793. /**The data type of the animation */
  27794. dataType: number;
  27795. /**The loop mode of the animation */
  27796. loopMode?: number | undefined;
  27797. /**Specifies if blending should be enabled */
  27798. enableBlending?: boolean | undefined;
  27799. /**
  27800. * Use matrix interpolation instead of using direct key value when animating matrices
  27801. */
  27802. static AllowMatricesInterpolation: boolean;
  27803. /**
  27804. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27805. */
  27806. static AllowMatrixDecomposeForInterpolation: boolean;
  27807. /**
  27808. * Stores the key frames of the animation
  27809. */
  27810. private _keys;
  27811. /**
  27812. * Stores the easing function of the animation
  27813. */
  27814. private _easingFunction;
  27815. /**
  27816. * @hidden Internal use only
  27817. */
  27818. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27819. /**
  27820. * The set of event that will be linked to this animation
  27821. */
  27822. private _events;
  27823. /**
  27824. * Stores an array of target property paths
  27825. */
  27826. targetPropertyPath: string[];
  27827. /**
  27828. * Stores the blending speed of the animation
  27829. */
  27830. blendingSpeed: number;
  27831. /**
  27832. * Stores the animation ranges for the animation
  27833. */
  27834. private _ranges;
  27835. /**
  27836. * @hidden Internal use
  27837. */
  27838. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27839. /**
  27840. * Sets up an animation
  27841. * @param property The property to animate
  27842. * @param animationType The animation type to apply
  27843. * @param framePerSecond The frames per second of the animation
  27844. * @param easingFunction The easing function used in the animation
  27845. * @returns The created animation
  27846. */
  27847. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27848. /**
  27849. * Create and start an animation on a node
  27850. * @param name defines the name of the global animation that will be run on all nodes
  27851. * @param node defines the root node where the animation will take place
  27852. * @param targetProperty defines property to animate
  27853. * @param framePerSecond defines the number of frame per second yo use
  27854. * @param totalFrame defines the number of frames in total
  27855. * @param from defines the initial value
  27856. * @param to defines the final value
  27857. * @param loopMode defines which loop mode you want to use (off by default)
  27858. * @param easingFunction defines the easing function to use (linear by default)
  27859. * @param onAnimationEnd defines the callback to call when animation end
  27860. * @returns the animatable created for this animation
  27861. */
  27862. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27863. /**
  27864. * Create and start an animation on a node and its descendants
  27865. * @param name defines the name of the global animation that will be run on all nodes
  27866. * @param node defines the root node where the animation will take place
  27867. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  27868. * @param targetProperty defines property to animate
  27869. * @param framePerSecond defines the number of frame per second to use
  27870. * @param totalFrame defines the number of frames in total
  27871. * @param from defines the initial value
  27872. * @param to defines the final value
  27873. * @param loopMode defines which loop mode you want to use (off by default)
  27874. * @param easingFunction defines the easing function to use (linear by default)
  27875. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27876. * @returns the list of animatables created for all nodes
  27877. * @example https://www.babylonjs-playground.com/#MH0VLI
  27878. */
  27879. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  27880. /**
  27881. * Creates a new animation, merges it with the existing animations and starts it
  27882. * @param name Name of the animation
  27883. * @param node Node which contains the scene that begins the animations
  27884. * @param targetProperty Specifies which property to animate
  27885. * @param framePerSecond The frames per second of the animation
  27886. * @param totalFrame The total number of frames
  27887. * @param from The frame at the beginning of the animation
  27888. * @param to The frame at the end of the animation
  27889. * @param loopMode Specifies the loop mode of the animation
  27890. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27891. * @param onAnimationEnd Callback to run once the animation is complete
  27892. * @returns Nullable animation
  27893. */
  27894. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27895. /**
  27896. * Transition property of an host to the target Value
  27897. * @param property The property to transition
  27898. * @param targetValue The target Value of the property
  27899. * @param host The object where the property to animate belongs
  27900. * @param scene Scene used to run the animation
  27901. * @param frameRate Framerate (in frame/s) to use
  27902. * @param transition The transition type we want to use
  27903. * @param duration The duration of the animation, in milliseconds
  27904. * @param onAnimationEnd Callback trigger at the end of the animation
  27905. * @returns Nullable animation
  27906. */
  27907. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27908. /**
  27909. * Return the array of runtime animations currently using this animation
  27910. */
  27911. readonly runtimeAnimations: RuntimeAnimation[];
  27912. /**
  27913. * Specifies if any of the runtime animations are currently running
  27914. */
  27915. readonly hasRunningRuntimeAnimations: boolean;
  27916. /**
  27917. * Initializes the animation
  27918. * @param name Name of the animation
  27919. * @param targetProperty Property to animate
  27920. * @param framePerSecond The frames per second of the animation
  27921. * @param dataType The data type of the animation
  27922. * @param loopMode The loop mode of the animation
  27923. * @param enableBlending Specifies if blending should be enabled
  27924. */
  27925. constructor(
  27926. /**Name of the animation */
  27927. name: string,
  27928. /**Property to animate */
  27929. targetProperty: string,
  27930. /**The frames per second of the animation */
  27931. framePerSecond: number,
  27932. /**The data type of the animation */
  27933. dataType: number,
  27934. /**The loop mode of the animation */
  27935. loopMode?: number | undefined,
  27936. /**Specifies if blending should be enabled */
  27937. enableBlending?: boolean | undefined);
  27938. /**
  27939. * Converts the animation to a string
  27940. * @param fullDetails support for multiple levels of logging within scene loading
  27941. * @returns String form of the animation
  27942. */
  27943. toString(fullDetails?: boolean): string;
  27944. /**
  27945. * Add an event to this animation
  27946. * @param event Event to add
  27947. */
  27948. addEvent(event: AnimationEvent): void;
  27949. /**
  27950. * Remove all events found at the given frame
  27951. * @param frame The frame to remove events from
  27952. */
  27953. removeEvents(frame: number): void;
  27954. /**
  27955. * Retrieves all the events from the animation
  27956. * @returns Events from the animation
  27957. */
  27958. getEvents(): AnimationEvent[];
  27959. /**
  27960. * Creates an animation range
  27961. * @param name Name of the animation range
  27962. * @param from Starting frame of the animation range
  27963. * @param to Ending frame of the animation
  27964. */
  27965. createRange(name: string, from: number, to: number): void;
  27966. /**
  27967. * Deletes an animation range by name
  27968. * @param name Name of the animation range to delete
  27969. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27970. */
  27971. deleteRange(name: string, deleteFrames?: boolean): void;
  27972. /**
  27973. * Gets the animation range by name, or null if not defined
  27974. * @param name Name of the animation range
  27975. * @returns Nullable animation range
  27976. */
  27977. getRange(name: string): Nullable<AnimationRange>;
  27978. /**
  27979. * Gets the key frames from the animation
  27980. * @returns The key frames of the animation
  27981. */
  27982. getKeys(): Array<IAnimationKey>;
  27983. /**
  27984. * Gets the highest frame rate of the animation
  27985. * @returns Highest frame rate of the animation
  27986. */
  27987. getHighestFrame(): number;
  27988. /**
  27989. * Gets the easing function of the animation
  27990. * @returns Easing function of the animation
  27991. */
  27992. getEasingFunction(): IEasingFunction;
  27993. /**
  27994. * Sets the easing function of the animation
  27995. * @param easingFunction A custom mathematical formula for animation
  27996. */
  27997. setEasingFunction(easingFunction: EasingFunction): void;
  27998. /**
  27999. * Interpolates a scalar linearly
  28000. * @param startValue Start value of the animation curve
  28001. * @param endValue End value of the animation curve
  28002. * @param gradient Scalar amount to interpolate
  28003. * @returns Interpolated scalar value
  28004. */
  28005. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28006. /**
  28007. * Interpolates a scalar cubically
  28008. * @param startValue Start value of the animation curve
  28009. * @param outTangent End tangent of the animation
  28010. * @param endValue End value of the animation curve
  28011. * @param inTangent Start tangent of the animation curve
  28012. * @param gradient Scalar amount to interpolate
  28013. * @returns Interpolated scalar value
  28014. */
  28015. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28016. /**
  28017. * Interpolates a quaternion using a spherical linear interpolation
  28018. * @param startValue Start value of the animation curve
  28019. * @param endValue End value of the animation curve
  28020. * @param gradient Scalar amount to interpolate
  28021. * @returns Interpolated quaternion value
  28022. */
  28023. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28024. /**
  28025. * Interpolates a quaternion cubically
  28026. * @param startValue Start value of the animation curve
  28027. * @param outTangent End tangent of the animation curve
  28028. * @param endValue End value of the animation curve
  28029. * @param inTangent Start tangent of the animation curve
  28030. * @param gradient Scalar amount to interpolate
  28031. * @returns Interpolated quaternion value
  28032. */
  28033. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28034. /**
  28035. * Interpolates a Vector3 linearl
  28036. * @param startValue Start value of the animation curve
  28037. * @param endValue End value of the animation curve
  28038. * @param gradient Scalar amount to interpolate
  28039. * @returns Interpolated scalar value
  28040. */
  28041. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28042. /**
  28043. * Interpolates a Vector3 cubically
  28044. * @param startValue Start value of the animation curve
  28045. * @param outTangent End tangent of the animation
  28046. * @param endValue End value of the animation curve
  28047. * @param inTangent Start tangent of the animation curve
  28048. * @param gradient Scalar amount to interpolate
  28049. * @returns InterpolatedVector3 value
  28050. */
  28051. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28052. /**
  28053. * Interpolates a Vector2 linearly
  28054. * @param startValue Start value of the animation curve
  28055. * @param endValue End value of the animation curve
  28056. * @param gradient Scalar amount to interpolate
  28057. * @returns Interpolated Vector2 value
  28058. */
  28059. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28060. /**
  28061. * Interpolates a Vector2 cubically
  28062. * @param startValue Start value of the animation curve
  28063. * @param outTangent End tangent of the animation
  28064. * @param endValue End value of the animation curve
  28065. * @param inTangent Start tangent of the animation curve
  28066. * @param gradient Scalar amount to interpolate
  28067. * @returns Interpolated Vector2 value
  28068. */
  28069. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28070. /**
  28071. * Interpolates a size linearly
  28072. * @param startValue Start value of the animation curve
  28073. * @param endValue End value of the animation curve
  28074. * @param gradient Scalar amount to interpolate
  28075. * @returns Interpolated Size value
  28076. */
  28077. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28078. /**
  28079. * Interpolates a Color3 linearly
  28080. * @param startValue Start value of the animation curve
  28081. * @param endValue End value of the animation curve
  28082. * @param gradient Scalar amount to interpolate
  28083. * @returns Interpolated Color3 value
  28084. */
  28085. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28086. /**
  28087. * @hidden Internal use only
  28088. */
  28089. _getKeyValue(value: any): any;
  28090. /**
  28091. * @hidden Internal use only
  28092. */
  28093. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28094. /**
  28095. * Defines the function to use to interpolate matrices
  28096. * @param startValue defines the start matrix
  28097. * @param endValue defines the end matrix
  28098. * @param gradient defines the gradient between both matrices
  28099. * @param result defines an optional target matrix where to store the interpolation
  28100. * @returns the interpolated matrix
  28101. */
  28102. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28103. /**
  28104. * Makes a copy of the animation
  28105. * @returns Cloned animation
  28106. */
  28107. clone(): Animation;
  28108. /**
  28109. * Sets the key frames of the animation
  28110. * @param values The animation key frames to set
  28111. */
  28112. setKeys(values: Array<IAnimationKey>): void;
  28113. /**
  28114. * Serializes the animation to an object
  28115. * @returns Serialized object
  28116. */
  28117. serialize(): any;
  28118. /**
  28119. * Float animation type
  28120. */
  28121. private static _ANIMATIONTYPE_FLOAT;
  28122. /**
  28123. * Vector3 animation type
  28124. */
  28125. private static _ANIMATIONTYPE_VECTOR3;
  28126. /**
  28127. * Quaternion animation type
  28128. */
  28129. private static _ANIMATIONTYPE_QUATERNION;
  28130. /**
  28131. * Matrix animation type
  28132. */
  28133. private static _ANIMATIONTYPE_MATRIX;
  28134. /**
  28135. * Color3 animation type
  28136. */
  28137. private static _ANIMATIONTYPE_COLOR3;
  28138. /**
  28139. * Vector2 animation type
  28140. */
  28141. private static _ANIMATIONTYPE_VECTOR2;
  28142. /**
  28143. * Size animation type
  28144. */
  28145. private static _ANIMATIONTYPE_SIZE;
  28146. /**
  28147. * Relative Loop Mode
  28148. */
  28149. private static _ANIMATIONLOOPMODE_RELATIVE;
  28150. /**
  28151. * Cycle Loop Mode
  28152. */
  28153. private static _ANIMATIONLOOPMODE_CYCLE;
  28154. /**
  28155. * Constant Loop Mode
  28156. */
  28157. private static _ANIMATIONLOOPMODE_CONSTANT;
  28158. /**
  28159. * Get the float animation type
  28160. */
  28161. static readonly ANIMATIONTYPE_FLOAT: number;
  28162. /**
  28163. * Get the Vector3 animation type
  28164. */
  28165. static readonly ANIMATIONTYPE_VECTOR3: number;
  28166. /**
  28167. * Get the Vector2 animation type
  28168. */
  28169. static readonly ANIMATIONTYPE_VECTOR2: number;
  28170. /**
  28171. * Get the Size animation type
  28172. */
  28173. static readonly ANIMATIONTYPE_SIZE: number;
  28174. /**
  28175. * Get the Quaternion animation type
  28176. */
  28177. static readonly ANIMATIONTYPE_QUATERNION: number;
  28178. /**
  28179. * Get the Matrix animation type
  28180. */
  28181. static readonly ANIMATIONTYPE_MATRIX: number;
  28182. /**
  28183. * Get the Color3 animation type
  28184. */
  28185. static readonly ANIMATIONTYPE_COLOR3: number;
  28186. /**
  28187. * Get the Relative Loop Mode
  28188. */
  28189. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28190. /**
  28191. * Get the Cycle Loop Mode
  28192. */
  28193. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28194. /**
  28195. * Get the Constant Loop Mode
  28196. */
  28197. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28198. /** @hidden */
  28199. static _UniversalLerp(left: any, right: any, amount: number): any;
  28200. /**
  28201. * Parses an animation object and creates an animation
  28202. * @param parsedAnimation Parsed animation object
  28203. * @returns Animation object
  28204. */
  28205. static Parse(parsedAnimation: any): Animation;
  28206. /**
  28207. * Appends the serialized animations from the source animations
  28208. * @param source Source containing the animations
  28209. * @param destination Target to store the animations
  28210. */
  28211. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28212. }
  28213. }
  28214. declare module "babylonjs/Animations/animatable.interface" {
  28215. import { Nullable } from "babylonjs/types";
  28216. import { Animation } from "babylonjs/Animations/animation";
  28217. /**
  28218. * Interface containing an array of animations
  28219. */
  28220. export interface IAnimatable {
  28221. /**
  28222. * Array of animations
  28223. */
  28224. animations: Nullable<Array<Animation>>;
  28225. }
  28226. }
  28227. declare module "babylonjs/Materials/fresnelParameters" {
  28228. import { Color3 } from "babylonjs/Maths/math.color";
  28229. /**
  28230. * This represents all the required information to add a fresnel effect on a material:
  28231. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28232. */
  28233. export class FresnelParameters {
  28234. private _isEnabled;
  28235. /**
  28236. * Define if the fresnel effect is enable or not.
  28237. */
  28238. isEnabled: boolean;
  28239. /**
  28240. * Define the color used on edges (grazing angle)
  28241. */
  28242. leftColor: Color3;
  28243. /**
  28244. * Define the color used on center
  28245. */
  28246. rightColor: Color3;
  28247. /**
  28248. * Define bias applied to computed fresnel term
  28249. */
  28250. bias: number;
  28251. /**
  28252. * Defined the power exponent applied to fresnel term
  28253. */
  28254. power: number;
  28255. /**
  28256. * Clones the current fresnel and its valuues
  28257. * @returns a clone fresnel configuration
  28258. */
  28259. clone(): FresnelParameters;
  28260. /**
  28261. * Serializes the current fresnel parameters to a JSON representation.
  28262. * @return the JSON serialization
  28263. */
  28264. serialize(): any;
  28265. /**
  28266. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28267. * @param parsedFresnelParameters Define the JSON representation
  28268. * @returns the parsed parameters
  28269. */
  28270. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28271. }
  28272. }
  28273. declare module "babylonjs/Misc/decorators" {
  28274. import { Nullable } from "babylonjs/types";
  28275. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28276. import { Scene } from "babylonjs/scene";
  28277. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28278. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28279. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28280. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28281. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28282. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28283. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28284. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28285. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28286. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28287. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28288. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28289. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28290. /**
  28291. * Decorator used to define property that can be serialized as reference to a camera
  28292. * @param sourceName defines the name of the property to decorate
  28293. */
  28294. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28295. /**
  28296. * Class used to help serialization objects
  28297. */
  28298. export class SerializationHelper {
  28299. /** @hidden */
  28300. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28301. /** @hidden */
  28302. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28303. /** @hidden */
  28304. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28305. /** @hidden */
  28306. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28307. /**
  28308. * Appends the serialized animations from the source animations
  28309. * @param source Source containing the animations
  28310. * @param destination Target to store the animations
  28311. */
  28312. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28313. /**
  28314. * Static function used to serialized a specific entity
  28315. * @param entity defines the entity to serialize
  28316. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28317. * @returns a JSON compatible object representing the serialization of the entity
  28318. */
  28319. static Serialize<T>(entity: T, serializationObject?: any): any;
  28320. /**
  28321. * Creates a new entity from a serialization data object
  28322. * @param creationFunction defines a function used to instanciated the new entity
  28323. * @param source defines the source serialization data
  28324. * @param scene defines the hosting scene
  28325. * @param rootUrl defines the root url for resources
  28326. * @returns a new entity
  28327. */
  28328. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28329. /**
  28330. * Clones an object
  28331. * @param creationFunction defines the function used to instanciate the new object
  28332. * @param source defines the source object
  28333. * @returns the cloned object
  28334. */
  28335. static Clone<T>(creationFunction: () => T, source: T): T;
  28336. /**
  28337. * Instanciates a new object based on a source one (some data will be shared between both object)
  28338. * @param creationFunction defines the function used to instanciate the new object
  28339. * @param source defines the source object
  28340. * @returns the new object
  28341. */
  28342. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28343. }
  28344. }
  28345. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28346. import { Nullable } from "babylonjs/types";
  28347. /**
  28348. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28349. */
  28350. export interface CubeMapInfo {
  28351. /**
  28352. * The pixel array for the front face.
  28353. * This is stored in format, left to right, up to down format.
  28354. */
  28355. front: Nullable<ArrayBufferView>;
  28356. /**
  28357. * The pixel array for the back face.
  28358. * This is stored in format, left to right, up to down format.
  28359. */
  28360. back: Nullable<ArrayBufferView>;
  28361. /**
  28362. * The pixel array for the left face.
  28363. * This is stored in format, left to right, up to down format.
  28364. */
  28365. left: Nullable<ArrayBufferView>;
  28366. /**
  28367. * The pixel array for the right face.
  28368. * This is stored in format, left to right, up to down format.
  28369. */
  28370. right: Nullable<ArrayBufferView>;
  28371. /**
  28372. * The pixel array for the up face.
  28373. * This is stored in format, left to right, up to down format.
  28374. */
  28375. up: Nullable<ArrayBufferView>;
  28376. /**
  28377. * The pixel array for the down face.
  28378. * This is stored in format, left to right, up to down format.
  28379. */
  28380. down: Nullable<ArrayBufferView>;
  28381. /**
  28382. * The size of the cubemap stored.
  28383. *
  28384. * Each faces will be size * size pixels.
  28385. */
  28386. size: number;
  28387. /**
  28388. * The format of the texture.
  28389. *
  28390. * RGBA, RGB.
  28391. */
  28392. format: number;
  28393. /**
  28394. * The type of the texture data.
  28395. *
  28396. * UNSIGNED_INT, FLOAT.
  28397. */
  28398. type: number;
  28399. /**
  28400. * Specifies whether the texture is in gamma space.
  28401. */
  28402. gammaSpace: boolean;
  28403. }
  28404. /**
  28405. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28406. */
  28407. export class PanoramaToCubeMapTools {
  28408. private static FACE_FRONT;
  28409. private static FACE_BACK;
  28410. private static FACE_RIGHT;
  28411. private static FACE_LEFT;
  28412. private static FACE_DOWN;
  28413. private static FACE_UP;
  28414. /**
  28415. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28416. *
  28417. * @param float32Array The source data.
  28418. * @param inputWidth The width of the input panorama.
  28419. * @param inputHeight The height of the input panorama.
  28420. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28421. * @return The cubemap data
  28422. */
  28423. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28424. private static CreateCubemapTexture;
  28425. private static CalcProjectionSpherical;
  28426. }
  28427. }
  28428. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28429. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28430. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28431. import { Nullable } from "babylonjs/types";
  28432. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28433. /**
  28434. * Helper class dealing with the extraction of spherical polynomial dataArray
  28435. * from a cube map.
  28436. */
  28437. export class CubeMapToSphericalPolynomialTools {
  28438. private static FileFaces;
  28439. /**
  28440. * Converts a texture to the according Spherical Polynomial data.
  28441. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28442. *
  28443. * @param texture The texture to extract the information from.
  28444. * @return The Spherical Polynomial data.
  28445. */
  28446. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28447. /**
  28448. * Converts a cubemap to the according Spherical Polynomial data.
  28449. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28450. *
  28451. * @param cubeInfo The Cube map to extract the information from.
  28452. * @return The Spherical Polynomial data.
  28453. */
  28454. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28455. }
  28456. }
  28457. declare module "babylonjs/Misc/guid" {
  28458. /**
  28459. * Class used to manipulate GUIDs
  28460. */
  28461. export class GUID {
  28462. /**
  28463. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28464. * Be aware Math.random() could cause collisions, but:
  28465. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  28466. * @returns a pseudo random id
  28467. */
  28468. static RandomId(): string;
  28469. }
  28470. }
  28471. declare module "babylonjs/Materials/Textures/baseTexture" {
  28472. import { Observable } from "babylonjs/Misc/observable";
  28473. import { Nullable } from "babylonjs/types";
  28474. import { Scene } from "babylonjs/scene";
  28475. import { Matrix } from "babylonjs/Maths/math.vector";
  28476. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28477. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28478. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28479. import { ISize } from "babylonjs/Maths/math.size";
  28480. /**
  28481. * Base class of all the textures in babylon.
  28482. * It groups all the common properties the materials, post process, lights... might need
  28483. * in order to make a correct use of the texture.
  28484. */
  28485. export class BaseTexture implements IAnimatable {
  28486. /**
  28487. * Default anisotropic filtering level for the application.
  28488. * It is set to 4 as a good tradeoff between perf and quality.
  28489. */
  28490. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28491. /**
  28492. * Gets or sets the unique id of the texture
  28493. */
  28494. uniqueId: number;
  28495. /**
  28496. * Define the name of the texture.
  28497. */
  28498. name: string;
  28499. /**
  28500. * Gets or sets an object used to store user defined information.
  28501. */
  28502. metadata: any;
  28503. /**
  28504. * For internal use only. Please do not use.
  28505. */
  28506. reservedDataStore: any;
  28507. private _hasAlpha;
  28508. /**
  28509. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28510. */
  28511. hasAlpha: boolean;
  28512. /**
  28513. * Defines if the alpha value should be determined via the rgb values.
  28514. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28515. */
  28516. getAlphaFromRGB: boolean;
  28517. /**
  28518. * Intensity or strength of the texture.
  28519. * It is commonly used by materials to fine tune the intensity of the texture
  28520. */
  28521. level: number;
  28522. /**
  28523. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28524. * This is part of the texture as textures usually maps to one uv set.
  28525. */
  28526. coordinatesIndex: number;
  28527. private _coordinatesMode;
  28528. /**
  28529. * How a texture is mapped.
  28530. *
  28531. * | Value | Type | Description |
  28532. * | ----- | ----------------------------------- | ----------- |
  28533. * | 0 | EXPLICIT_MODE | |
  28534. * | 1 | SPHERICAL_MODE | |
  28535. * | 2 | PLANAR_MODE | |
  28536. * | 3 | CUBIC_MODE | |
  28537. * | 4 | PROJECTION_MODE | |
  28538. * | 5 | SKYBOX_MODE | |
  28539. * | 6 | INVCUBIC_MODE | |
  28540. * | 7 | EQUIRECTANGULAR_MODE | |
  28541. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28542. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28543. */
  28544. coordinatesMode: number;
  28545. /**
  28546. * | Value | Type | Description |
  28547. * | ----- | ------------------ | ----------- |
  28548. * | 0 | CLAMP_ADDRESSMODE | |
  28549. * | 1 | WRAP_ADDRESSMODE | |
  28550. * | 2 | MIRROR_ADDRESSMODE | |
  28551. */
  28552. wrapU: number;
  28553. /**
  28554. * | Value | Type | Description |
  28555. * | ----- | ------------------ | ----------- |
  28556. * | 0 | CLAMP_ADDRESSMODE | |
  28557. * | 1 | WRAP_ADDRESSMODE | |
  28558. * | 2 | MIRROR_ADDRESSMODE | |
  28559. */
  28560. wrapV: number;
  28561. /**
  28562. * | Value | Type | Description |
  28563. * | ----- | ------------------ | ----------- |
  28564. * | 0 | CLAMP_ADDRESSMODE | |
  28565. * | 1 | WRAP_ADDRESSMODE | |
  28566. * | 2 | MIRROR_ADDRESSMODE | |
  28567. */
  28568. wrapR: number;
  28569. /**
  28570. * With compliant hardware and browser (supporting anisotropic filtering)
  28571. * this defines the level of anisotropic filtering in the texture.
  28572. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28573. */
  28574. anisotropicFilteringLevel: number;
  28575. /**
  28576. * Define if the texture is a cube texture or if false a 2d texture.
  28577. */
  28578. isCube: boolean;
  28579. /**
  28580. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28581. */
  28582. is3D: boolean;
  28583. /**
  28584. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28585. * HDR texture are usually stored in linear space.
  28586. * This only impacts the PBR and Background materials
  28587. */
  28588. gammaSpace: boolean;
  28589. /**
  28590. * Gets or sets whether or not the texture contains RGBD data.
  28591. */
  28592. isRGBD: boolean;
  28593. /**
  28594. * Is Z inverted in the texture (useful in a cube texture).
  28595. */
  28596. invertZ: boolean;
  28597. /**
  28598. * Are mip maps generated for this texture or not.
  28599. */
  28600. readonly noMipmap: boolean;
  28601. /**
  28602. * @hidden
  28603. */
  28604. lodLevelInAlpha: boolean;
  28605. /**
  28606. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28607. */
  28608. lodGenerationOffset: number;
  28609. /**
  28610. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28611. */
  28612. lodGenerationScale: number;
  28613. /**
  28614. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28615. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28616. * average roughness values.
  28617. */
  28618. linearSpecularLOD: boolean;
  28619. /**
  28620. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28621. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28622. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28623. */
  28624. irradianceTexture: Nullable<BaseTexture>;
  28625. /**
  28626. * Define if the texture is a render target.
  28627. */
  28628. isRenderTarget: boolean;
  28629. /**
  28630. * Define the unique id of the texture in the scene.
  28631. */
  28632. readonly uid: string;
  28633. /**
  28634. * Return a string representation of the texture.
  28635. * @returns the texture as a string
  28636. */
  28637. toString(): string;
  28638. /**
  28639. * Get the class name of the texture.
  28640. * @returns "BaseTexture"
  28641. */
  28642. getClassName(): string;
  28643. /**
  28644. * Define the list of animation attached to the texture.
  28645. */
  28646. animations: import("babylonjs/Animations/animation").Animation[];
  28647. /**
  28648. * An event triggered when the texture is disposed.
  28649. */
  28650. onDisposeObservable: Observable<BaseTexture>;
  28651. private _onDisposeObserver;
  28652. /**
  28653. * Callback triggered when the texture has been disposed.
  28654. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28655. */
  28656. onDispose: () => void;
  28657. /**
  28658. * Define the current state of the loading sequence when in delayed load mode.
  28659. */
  28660. delayLoadState: number;
  28661. private _scene;
  28662. /** @hidden */
  28663. _texture: Nullable<InternalTexture>;
  28664. private _uid;
  28665. /**
  28666. * Define if the texture is preventinga material to render or not.
  28667. * If not and the texture is not ready, the engine will use a default black texture instead.
  28668. */
  28669. readonly isBlocking: boolean;
  28670. /**
  28671. * Instantiates a new BaseTexture.
  28672. * Base class of all the textures in babylon.
  28673. * It groups all the common properties the materials, post process, lights... might need
  28674. * in order to make a correct use of the texture.
  28675. * @param scene Define the scene the texture blongs to
  28676. */
  28677. constructor(scene: Nullable<Scene>);
  28678. /**
  28679. * Get the scene the texture belongs to.
  28680. * @returns the scene or null if undefined
  28681. */
  28682. getScene(): Nullable<Scene>;
  28683. /**
  28684. * Get the texture transform matrix used to offset tile the texture for istance.
  28685. * @returns the transformation matrix
  28686. */
  28687. getTextureMatrix(): Matrix;
  28688. /**
  28689. * Get the texture reflection matrix used to rotate/transform the reflection.
  28690. * @returns the reflection matrix
  28691. */
  28692. getReflectionTextureMatrix(): Matrix;
  28693. /**
  28694. * Get the underlying lower level texture from Babylon.
  28695. * @returns the insternal texture
  28696. */
  28697. getInternalTexture(): Nullable<InternalTexture>;
  28698. /**
  28699. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28700. * @returns true if ready or not blocking
  28701. */
  28702. isReadyOrNotBlocking(): boolean;
  28703. /**
  28704. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28705. * @returns true if fully ready
  28706. */
  28707. isReady(): boolean;
  28708. private _cachedSize;
  28709. /**
  28710. * Get the size of the texture.
  28711. * @returns the texture size.
  28712. */
  28713. getSize(): ISize;
  28714. /**
  28715. * Get the base size of the texture.
  28716. * It can be different from the size if the texture has been resized for POT for instance
  28717. * @returns the base size
  28718. */
  28719. getBaseSize(): ISize;
  28720. /**
  28721. * Update the sampling mode of the texture.
  28722. * Default is Trilinear mode.
  28723. *
  28724. * | Value | Type | Description |
  28725. * | ----- | ------------------ | ----------- |
  28726. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28727. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28728. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28729. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28730. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28731. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28732. * | 7 | NEAREST_LINEAR | |
  28733. * | 8 | NEAREST_NEAREST | |
  28734. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28735. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28736. * | 11 | LINEAR_LINEAR | |
  28737. * | 12 | LINEAR_NEAREST | |
  28738. *
  28739. * > _mag_: magnification filter (close to the viewer)
  28740. * > _min_: minification filter (far from the viewer)
  28741. * > _mip_: filter used between mip map levels
  28742. *@param samplingMode Define the new sampling mode of the texture
  28743. */
  28744. updateSamplingMode(samplingMode: number): void;
  28745. /**
  28746. * Scales the texture if is `canRescale()`
  28747. * @param ratio the resize factor we want to use to rescale
  28748. */
  28749. scale(ratio: number): void;
  28750. /**
  28751. * Get if the texture can rescale.
  28752. */
  28753. readonly canRescale: boolean;
  28754. /** @hidden */
  28755. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28756. /** @hidden */
  28757. _rebuild(): void;
  28758. /**
  28759. * Triggers the load sequence in delayed load mode.
  28760. */
  28761. delayLoad(): void;
  28762. /**
  28763. * Clones the texture.
  28764. * @returns the cloned texture
  28765. */
  28766. clone(): Nullable<BaseTexture>;
  28767. /**
  28768. * Get the texture underlying type (INT, FLOAT...)
  28769. */
  28770. readonly textureType: number;
  28771. /**
  28772. * Get the texture underlying format (RGB, RGBA...)
  28773. */
  28774. readonly textureFormat: number;
  28775. /**
  28776. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28777. * This will returns an RGBA array buffer containing either in values (0-255) or
  28778. * float values (0-1) depending of the underlying buffer type.
  28779. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28780. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28781. * @param buffer defines a user defined buffer to fill with data (can be null)
  28782. * @returns The Array buffer containing the pixels data.
  28783. */
  28784. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28785. /**
  28786. * Release and destroy the underlying lower level texture aka internalTexture.
  28787. */
  28788. releaseInternalTexture(): void;
  28789. /**
  28790. * Get the polynomial representation of the texture data.
  28791. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28792. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28793. */
  28794. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28795. /** @hidden */
  28796. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28797. /** @hidden */
  28798. readonly _lodTextureMid: Nullable<BaseTexture>;
  28799. /** @hidden */
  28800. readonly _lodTextureLow: Nullable<BaseTexture>;
  28801. /**
  28802. * Dispose the texture and release its associated resources.
  28803. */
  28804. dispose(): void;
  28805. /**
  28806. * Serialize the texture into a JSON representation that can be parsed later on.
  28807. * @returns the JSON representation of the texture
  28808. */
  28809. serialize(): any;
  28810. /**
  28811. * Helper function to be called back once a list of texture contains only ready textures.
  28812. * @param textures Define the list of textures to wait for
  28813. * @param callback Define the callback triggered once the entire list will be ready
  28814. */
  28815. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28816. }
  28817. }
  28818. declare module "babylonjs/Materials/Textures/internalTexture" {
  28819. import { Observable } from "babylonjs/Misc/observable";
  28820. import { Nullable, int } from "babylonjs/types";
  28821. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28822. import { Engine } from "babylonjs/Engines/engine";
  28823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28824. /**
  28825. * Class used to store data associated with WebGL texture data for the engine
  28826. * This class should not be used directly
  28827. */
  28828. export class InternalTexture {
  28829. /** @hidden */
  28830. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28831. /**
  28832. * The source of the texture data is unknown
  28833. */
  28834. static DATASOURCE_UNKNOWN: number;
  28835. /**
  28836. * Texture data comes from an URL
  28837. */
  28838. static DATASOURCE_URL: number;
  28839. /**
  28840. * Texture data is only used for temporary storage
  28841. */
  28842. static DATASOURCE_TEMP: number;
  28843. /**
  28844. * Texture data comes from raw data (ArrayBuffer)
  28845. */
  28846. static DATASOURCE_RAW: number;
  28847. /**
  28848. * Texture content is dynamic (video or dynamic texture)
  28849. */
  28850. static DATASOURCE_DYNAMIC: number;
  28851. /**
  28852. * Texture content is generated by rendering to it
  28853. */
  28854. static DATASOURCE_RENDERTARGET: number;
  28855. /**
  28856. * Texture content is part of a multi render target process
  28857. */
  28858. static DATASOURCE_MULTIRENDERTARGET: number;
  28859. /**
  28860. * Texture data comes from a cube data file
  28861. */
  28862. static DATASOURCE_CUBE: number;
  28863. /**
  28864. * Texture data comes from a raw cube data
  28865. */
  28866. static DATASOURCE_CUBERAW: number;
  28867. /**
  28868. * Texture data come from a prefiltered cube data file
  28869. */
  28870. static DATASOURCE_CUBEPREFILTERED: number;
  28871. /**
  28872. * Texture content is raw 3D data
  28873. */
  28874. static DATASOURCE_RAW3D: number;
  28875. /**
  28876. * Texture content is a depth texture
  28877. */
  28878. static DATASOURCE_DEPTHTEXTURE: number;
  28879. /**
  28880. * Texture data comes from a raw cube data encoded with RGBD
  28881. */
  28882. static DATASOURCE_CUBERAW_RGBD: number;
  28883. /**
  28884. * Defines if the texture is ready
  28885. */
  28886. isReady: boolean;
  28887. /**
  28888. * Defines if the texture is a cube texture
  28889. */
  28890. isCube: boolean;
  28891. /**
  28892. * Defines if the texture contains 3D data
  28893. */
  28894. is3D: boolean;
  28895. /**
  28896. * Defines if the texture contains multiview data
  28897. */
  28898. isMultiview: boolean;
  28899. /**
  28900. * Gets the URL used to load this texture
  28901. */
  28902. url: string;
  28903. /**
  28904. * Gets the sampling mode of the texture
  28905. */
  28906. samplingMode: number;
  28907. /**
  28908. * Gets a boolean indicating if the texture needs mipmaps generation
  28909. */
  28910. generateMipMaps: boolean;
  28911. /**
  28912. * Gets the number of samples used by the texture (WebGL2+ only)
  28913. */
  28914. samples: number;
  28915. /**
  28916. * Gets the type of the texture (int, float...)
  28917. */
  28918. type: number;
  28919. /**
  28920. * Gets the format of the texture (RGB, RGBA...)
  28921. */
  28922. format: number;
  28923. /**
  28924. * Observable called when the texture is loaded
  28925. */
  28926. onLoadedObservable: Observable<InternalTexture>;
  28927. /**
  28928. * Gets the width of the texture
  28929. */
  28930. width: number;
  28931. /**
  28932. * Gets the height of the texture
  28933. */
  28934. height: number;
  28935. /**
  28936. * Gets the depth of the texture
  28937. */
  28938. depth: number;
  28939. /**
  28940. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28941. */
  28942. baseWidth: number;
  28943. /**
  28944. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28945. */
  28946. baseHeight: number;
  28947. /**
  28948. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28949. */
  28950. baseDepth: number;
  28951. /**
  28952. * Gets a boolean indicating if the texture is inverted on Y axis
  28953. */
  28954. invertY: boolean;
  28955. /** @hidden */
  28956. _invertVScale: boolean;
  28957. /** @hidden */
  28958. _associatedChannel: number;
  28959. /** @hidden */
  28960. _dataSource: number;
  28961. /** @hidden */
  28962. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28963. /** @hidden */
  28964. _bufferView: Nullable<ArrayBufferView>;
  28965. /** @hidden */
  28966. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28967. /** @hidden */
  28968. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28969. /** @hidden */
  28970. _size: number;
  28971. /** @hidden */
  28972. _extension: string;
  28973. /** @hidden */
  28974. _files: Nullable<string[]>;
  28975. /** @hidden */
  28976. _workingCanvas: Nullable<HTMLCanvasElement>;
  28977. /** @hidden */
  28978. _workingContext: Nullable<CanvasRenderingContext2D>;
  28979. /** @hidden */
  28980. _framebuffer: Nullable<WebGLFramebuffer>;
  28981. /** @hidden */
  28982. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28983. /** @hidden */
  28984. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28985. /** @hidden */
  28986. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28987. /** @hidden */
  28988. _attachments: Nullable<number[]>;
  28989. /** @hidden */
  28990. _cachedCoordinatesMode: Nullable<number>;
  28991. /** @hidden */
  28992. _cachedWrapU: Nullable<number>;
  28993. /** @hidden */
  28994. _cachedWrapV: Nullable<number>;
  28995. /** @hidden */
  28996. _cachedWrapR: Nullable<number>;
  28997. /** @hidden */
  28998. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28999. /** @hidden */
  29000. _isDisabled: boolean;
  29001. /** @hidden */
  29002. _compression: Nullable<string>;
  29003. /** @hidden */
  29004. _generateStencilBuffer: boolean;
  29005. /** @hidden */
  29006. _generateDepthBuffer: boolean;
  29007. /** @hidden */
  29008. _comparisonFunction: number;
  29009. /** @hidden */
  29010. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  29011. /** @hidden */
  29012. _lodGenerationScale: number;
  29013. /** @hidden */
  29014. _lodGenerationOffset: number;
  29015. /** @hidden */
  29016. _colorTextureArray: Nullable<WebGLTexture>;
  29017. /** @hidden */
  29018. _depthStencilTextureArray: Nullable<WebGLTexture>;
  29019. /** @hidden */
  29020. _lodTextureHigh: Nullable<BaseTexture>;
  29021. /** @hidden */
  29022. _lodTextureMid: Nullable<BaseTexture>;
  29023. /** @hidden */
  29024. _lodTextureLow: Nullable<BaseTexture>;
  29025. /** @hidden */
  29026. _isRGBD: boolean;
  29027. /** @hidden */
  29028. _linearSpecularLOD: boolean;
  29029. /** @hidden */
  29030. _irradianceTexture: Nullable<BaseTexture>;
  29031. /** @hidden */
  29032. _webGLTexture: Nullable<WebGLTexture>;
  29033. /** @hidden */
  29034. _references: number;
  29035. private _engine;
  29036. /**
  29037. * Gets the Engine the texture belongs to.
  29038. * @returns The babylon engine
  29039. */
  29040. getEngine(): Engine;
  29041. /**
  29042. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  29043. */
  29044. readonly dataSource: number;
  29045. /**
  29046. * Creates a new InternalTexture
  29047. * @param engine defines the engine to use
  29048. * @param dataSource defines the type of data that will be used
  29049. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29050. */
  29051. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  29052. /**
  29053. * Increments the number of references (ie. the number of Texture that point to it)
  29054. */
  29055. incrementReferences(): void;
  29056. /**
  29057. * Change the size of the texture (not the size of the content)
  29058. * @param width defines the new width
  29059. * @param height defines the new height
  29060. * @param depth defines the new depth (1 by default)
  29061. */
  29062. updateSize(width: int, height: int, depth?: int): void;
  29063. /** @hidden */
  29064. _rebuild(): void;
  29065. /** @hidden */
  29066. _swapAndDie(target: InternalTexture): void;
  29067. /**
  29068. * Dispose the current allocated resources
  29069. */
  29070. dispose(): void;
  29071. }
  29072. }
  29073. declare module "babylonjs/Materials/effect" {
  29074. import { Observable } from "babylonjs/Misc/observable";
  29075. import { Nullable } from "babylonjs/types";
  29076. import { IDisposable } from "babylonjs/scene";
  29077. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29078. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29079. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29080. import { Engine } from "babylonjs/Engines/engine";
  29081. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29083. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29084. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29086. /**
  29087. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29088. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29089. */
  29090. export class EffectFallbacks {
  29091. private _defines;
  29092. private _currentRank;
  29093. private _maxRank;
  29094. private _mesh;
  29095. /**
  29096. * Removes the fallback from the bound mesh.
  29097. */
  29098. unBindMesh(): void;
  29099. /**
  29100. * Adds a fallback on the specified property.
  29101. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29102. * @param define The name of the define in the shader
  29103. */
  29104. addFallback(rank: number, define: string): void;
  29105. /**
  29106. * Sets the mesh to use CPU skinning when needing to fallback.
  29107. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29108. * @param mesh The mesh to use the fallbacks.
  29109. */
  29110. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29111. /**
  29112. * Checks to see if more fallbacks are still availible.
  29113. */
  29114. readonly hasMoreFallbacks: boolean;
  29115. /**
  29116. * Removes the defines that should be removed when falling back.
  29117. * @param currentDefines defines the current define statements for the shader.
  29118. * @param effect defines the current effect we try to compile
  29119. * @returns The resulting defines with defines of the current rank removed.
  29120. */
  29121. reduce(currentDefines: string, effect: Effect): string;
  29122. }
  29123. /**
  29124. * Options to be used when creating an effect.
  29125. */
  29126. export class EffectCreationOptions {
  29127. /**
  29128. * Atrributes that will be used in the shader.
  29129. */
  29130. attributes: string[];
  29131. /**
  29132. * Uniform varible names that will be set in the shader.
  29133. */
  29134. uniformsNames: string[];
  29135. /**
  29136. * Uniform buffer varible names that will be set in the shader.
  29137. */
  29138. uniformBuffersNames: string[];
  29139. /**
  29140. * Sampler texture variable names that will be set in the shader.
  29141. */
  29142. samplers: string[];
  29143. /**
  29144. * Define statements that will be set in the shader.
  29145. */
  29146. defines: any;
  29147. /**
  29148. * Possible fallbacks for this effect to improve performance when needed.
  29149. */
  29150. fallbacks: Nullable<EffectFallbacks>;
  29151. /**
  29152. * Callback that will be called when the shader is compiled.
  29153. */
  29154. onCompiled: Nullable<(effect: Effect) => void>;
  29155. /**
  29156. * Callback that will be called if an error occurs during shader compilation.
  29157. */
  29158. onError: Nullable<(effect: Effect, errors: string) => void>;
  29159. /**
  29160. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29161. */
  29162. indexParameters: any;
  29163. /**
  29164. * Max number of lights that can be used in the shader.
  29165. */
  29166. maxSimultaneousLights: number;
  29167. /**
  29168. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29169. */
  29170. transformFeedbackVaryings: Nullable<string[]>;
  29171. }
  29172. /**
  29173. * Effect containing vertex and fragment shader that can be executed on an object.
  29174. */
  29175. export class Effect implements IDisposable {
  29176. /**
  29177. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29178. */
  29179. static ShadersRepository: string;
  29180. /**
  29181. * Name of the effect.
  29182. */
  29183. name: any;
  29184. /**
  29185. * String container all the define statements that should be set on the shader.
  29186. */
  29187. defines: string;
  29188. /**
  29189. * Callback that will be called when the shader is compiled.
  29190. */
  29191. onCompiled: Nullable<(effect: Effect) => void>;
  29192. /**
  29193. * Callback that will be called if an error occurs during shader compilation.
  29194. */
  29195. onError: Nullable<(effect: Effect, errors: string) => void>;
  29196. /**
  29197. * Callback that will be called when effect is bound.
  29198. */
  29199. onBind: Nullable<(effect: Effect) => void>;
  29200. /**
  29201. * Unique ID of the effect.
  29202. */
  29203. uniqueId: number;
  29204. /**
  29205. * Observable that will be called when the shader is compiled.
  29206. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29207. */
  29208. onCompileObservable: Observable<Effect>;
  29209. /**
  29210. * Observable that will be called if an error occurs during shader compilation.
  29211. */
  29212. onErrorObservable: Observable<Effect>;
  29213. /** @hidden */
  29214. _onBindObservable: Nullable<Observable<Effect>>;
  29215. /**
  29216. * Observable that will be called when effect is bound.
  29217. */
  29218. readonly onBindObservable: Observable<Effect>;
  29219. /** @hidden */
  29220. _bonesComputationForcedToCPU: boolean;
  29221. private static _uniqueIdSeed;
  29222. private _engine;
  29223. private _uniformBuffersNames;
  29224. private _uniformsNames;
  29225. private _samplerList;
  29226. private _samplers;
  29227. private _isReady;
  29228. private _compilationError;
  29229. private _attributesNames;
  29230. private _attributes;
  29231. private _uniforms;
  29232. /**
  29233. * Key for the effect.
  29234. * @hidden
  29235. */
  29236. _key: string;
  29237. private _indexParameters;
  29238. private _fallbacks;
  29239. private _vertexSourceCode;
  29240. private _fragmentSourceCode;
  29241. private _vertexSourceCodeOverride;
  29242. private _fragmentSourceCodeOverride;
  29243. private _transformFeedbackVaryings;
  29244. /**
  29245. * Compiled shader to webGL program.
  29246. * @hidden
  29247. */
  29248. _pipelineContext: Nullable<IPipelineContext>;
  29249. private _valueCache;
  29250. private static _baseCache;
  29251. /**
  29252. * Instantiates an effect.
  29253. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29254. * @param baseName Name of the effect.
  29255. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29256. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29257. * @param samplers List of sampler variables that will be passed to the shader.
  29258. * @param engine Engine to be used to render the effect
  29259. * @param defines Define statements to be added to the shader.
  29260. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29261. * @param onCompiled Callback that will be called when the shader is compiled.
  29262. * @param onError Callback that will be called if an error occurs during shader compilation.
  29263. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29264. */
  29265. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29266. private _useFinalCode;
  29267. /**
  29268. * Unique key for this effect
  29269. */
  29270. readonly key: string;
  29271. /**
  29272. * If the effect has been compiled and prepared.
  29273. * @returns if the effect is compiled and prepared.
  29274. */
  29275. isReady(): boolean;
  29276. private _isReadyInternal;
  29277. /**
  29278. * The engine the effect was initialized with.
  29279. * @returns the engine.
  29280. */
  29281. getEngine(): Engine;
  29282. /**
  29283. * The pipeline context for this effect
  29284. * @returns the associated pipeline context
  29285. */
  29286. getPipelineContext(): Nullable<IPipelineContext>;
  29287. /**
  29288. * The set of names of attribute variables for the shader.
  29289. * @returns An array of attribute names.
  29290. */
  29291. getAttributesNames(): string[];
  29292. /**
  29293. * Returns the attribute at the given index.
  29294. * @param index The index of the attribute.
  29295. * @returns The location of the attribute.
  29296. */
  29297. getAttributeLocation(index: number): number;
  29298. /**
  29299. * Returns the attribute based on the name of the variable.
  29300. * @param name of the attribute to look up.
  29301. * @returns the attribute location.
  29302. */
  29303. getAttributeLocationByName(name: string): number;
  29304. /**
  29305. * The number of attributes.
  29306. * @returns the numnber of attributes.
  29307. */
  29308. getAttributesCount(): number;
  29309. /**
  29310. * Gets the index of a uniform variable.
  29311. * @param uniformName of the uniform to look up.
  29312. * @returns the index.
  29313. */
  29314. getUniformIndex(uniformName: string): number;
  29315. /**
  29316. * Returns the attribute based on the name of the variable.
  29317. * @param uniformName of the uniform to look up.
  29318. * @returns the location of the uniform.
  29319. */
  29320. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29321. /**
  29322. * Returns an array of sampler variable names
  29323. * @returns The array of sampler variable neames.
  29324. */
  29325. getSamplers(): string[];
  29326. /**
  29327. * The error from the last compilation.
  29328. * @returns the error string.
  29329. */
  29330. getCompilationError(): string;
  29331. /**
  29332. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29333. * @param func The callback to be used.
  29334. */
  29335. executeWhenCompiled(func: (effect: Effect) => void): void;
  29336. private _checkIsReady;
  29337. /** @hidden */
  29338. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29339. /** @hidden */
  29340. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29341. /** @hidden */
  29342. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29343. /**
  29344. * Recompiles the webGL program
  29345. * @param vertexSourceCode The source code for the vertex shader.
  29346. * @param fragmentSourceCode The source code for the fragment shader.
  29347. * @param onCompiled Callback called when completed.
  29348. * @param onError Callback called on error.
  29349. * @hidden
  29350. */
  29351. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29352. /**
  29353. * Prepares the effect
  29354. * @hidden
  29355. */
  29356. _prepareEffect(): void;
  29357. private _processCompilationErrors;
  29358. /**
  29359. * Checks if the effect is supported. (Must be called after compilation)
  29360. */
  29361. readonly isSupported: boolean;
  29362. /**
  29363. * Binds a texture to the engine to be used as output of the shader.
  29364. * @param channel Name of the output variable.
  29365. * @param texture Texture to bind.
  29366. * @hidden
  29367. */
  29368. _bindTexture(channel: string, texture: InternalTexture): void;
  29369. /**
  29370. * Sets a texture on the engine to be used in the shader.
  29371. * @param channel Name of the sampler variable.
  29372. * @param texture Texture to set.
  29373. */
  29374. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29375. /**
  29376. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29377. * @param channel Name of the sampler variable.
  29378. * @param texture Texture to set.
  29379. */
  29380. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29381. /**
  29382. * Sets an array of textures on the engine to be used in the shader.
  29383. * @param channel Name of the variable.
  29384. * @param textures Textures to set.
  29385. */
  29386. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29387. /**
  29388. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  29389. * @param channel Name of the sampler variable.
  29390. * @param postProcess Post process to get the input texture from.
  29391. */
  29392. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29393. /**
  29394. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29395. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  29396. * @param channel Name of the sampler variable.
  29397. * @param postProcess Post process to get the output texture from.
  29398. */
  29399. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29400. /** @hidden */
  29401. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29402. /** @hidden */
  29403. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29404. /** @hidden */
  29405. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29406. /** @hidden */
  29407. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29408. /**
  29409. * Binds a buffer to a uniform.
  29410. * @param buffer Buffer to bind.
  29411. * @param name Name of the uniform variable to bind to.
  29412. */
  29413. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29414. /**
  29415. * Binds block to a uniform.
  29416. * @param blockName Name of the block to bind.
  29417. * @param index Index to bind.
  29418. */
  29419. bindUniformBlock(blockName: string, index: number): void;
  29420. /**
  29421. * Sets an interger value on a uniform variable.
  29422. * @param uniformName Name of the variable.
  29423. * @param value Value to be set.
  29424. * @returns this effect.
  29425. */
  29426. setInt(uniformName: string, value: number): Effect;
  29427. /**
  29428. * Sets an int array on a uniform variable.
  29429. * @param uniformName Name of the variable.
  29430. * @param array array to be set.
  29431. * @returns this effect.
  29432. */
  29433. setIntArray(uniformName: string, array: Int32Array): Effect;
  29434. /**
  29435. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29436. * @param uniformName Name of the variable.
  29437. * @param array array to be set.
  29438. * @returns this effect.
  29439. */
  29440. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29441. /**
  29442. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29443. * @param uniformName Name of the variable.
  29444. * @param array array to be set.
  29445. * @returns this effect.
  29446. */
  29447. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29448. /**
  29449. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29450. * @param uniformName Name of the variable.
  29451. * @param array array to be set.
  29452. * @returns this effect.
  29453. */
  29454. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29455. /**
  29456. * Sets an float array on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param array array to be set.
  29459. * @returns this effect.
  29460. */
  29461. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29462. /**
  29463. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29464. * @param uniformName Name of the variable.
  29465. * @param array array to be set.
  29466. * @returns this effect.
  29467. */
  29468. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29469. /**
  29470. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29471. * @param uniformName Name of the variable.
  29472. * @param array array to be set.
  29473. * @returns this effect.
  29474. */
  29475. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29476. /**
  29477. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29478. * @param uniformName Name of the variable.
  29479. * @param array array to be set.
  29480. * @returns this effect.
  29481. */
  29482. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29483. /**
  29484. * Sets an array on a uniform variable.
  29485. * @param uniformName Name of the variable.
  29486. * @param array array to be set.
  29487. * @returns this effect.
  29488. */
  29489. setArray(uniformName: string, array: number[]): Effect;
  29490. /**
  29491. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29492. * @param uniformName Name of the variable.
  29493. * @param array array to be set.
  29494. * @returns this effect.
  29495. */
  29496. setArray2(uniformName: string, array: number[]): Effect;
  29497. /**
  29498. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29499. * @param uniformName Name of the variable.
  29500. * @param array array to be set.
  29501. * @returns this effect.
  29502. */
  29503. setArray3(uniformName: string, array: number[]): Effect;
  29504. /**
  29505. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29506. * @param uniformName Name of the variable.
  29507. * @param array array to be set.
  29508. * @returns this effect.
  29509. */
  29510. setArray4(uniformName: string, array: number[]): Effect;
  29511. /**
  29512. * Sets matrices on a uniform variable.
  29513. * @param uniformName Name of the variable.
  29514. * @param matrices matrices to be set.
  29515. * @returns this effect.
  29516. */
  29517. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29518. /**
  29519. * Sets matrix on a uniform variable.
  29520. * @param uniformName Name of the variable.
  29521. * @param matrix matrix to be set.
  29522. * @returns this effect.
  29523. */
  29524. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29525. /**
  29526. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  29527. * @param uniformName Name of the variable.
  29528. * @param matrix matrix to be set.
  29529. * @returns this effect.
  29530. */
  29531. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29532. /**
  29533. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29534. * @param uniformName Name of the variable.
  29535. * @param matrix matrix to be set.
  29536. * @returns this effect.
  29537. */
  29538. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29539. /**
  29540. * Sets a float on a uniform variable.
  29541. * @param uniformName Name of the variable.
  29542. * @param value value to be set.
  29543. * @returns this effect.
  29544. */
  29545. setFloat(uniformName: string, value: number): Effect;
  29546. /**
  29547. * Sets a boolean on a uniform variable.
  29548. * @param uniformName Name of the variable.
  29549. * @param bool value to be set.
  29550. * @returns this effect.
  29551. */
  29552. setBool(uniformName: string, bool: boolean): Effect;
  29553. /**
  29554. * Sets a Vector2 on a uniform variable.
  29555. * @param uniformName Name of the variable.
  29556. * @param vector2 vector2 to be set.
  29557. * @returns this effect.
  29558. */
  29559. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29560. /**
  29561. * Sets a float2 on a uniform variable.
  29562. * @param uniformName Name of the variable.
  29563. * @param x First float in float2.
  29564. * @param y Second float in float2.
  29565. * @returns this effect.
  29566. */
  29567. setFloat2(uniformName: string, x: number, y: number): Effect;
  29568. /**
  29569. * Sets a Vector3 on a uniform variable.
  29570. * @param uniformName Name of the variable.
  29571. * @param vector3 Value to be set.
  29572. * @returns this effect.
  29573. */
  29574. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29575. /**
  29576. * Sets a float3 on a uniform variable.
  29577. * @param uniformName Name of the variable.
  29578. * @param x First float in float3.
  29579. * @param y Second float in float3.
  29580. * @param z Third float in float3.
  29581. * @returns this effect.
  29582. */
  29583. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29584. /**
  29585. * Sets a Vector4 on a uniform variable.
  29586. * @param uniformName Name of the variable.
  29587. * @param vector4 Value to be set.
  29588. * @returns this effect.
  29589. */
  29590. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29591. /**
  29592. * Sets a float4 on a uniform variable.
  29593. * @param uniformName Name of the variable.
  29594. * @param x First float in float4.
  29595. * @param y Second float in float4.
  29596. * @param z Third float in float4.
  29597. * @param w Fourth float in float4.
  29598. * @returns this effect.
  29599. */
  29600. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29601. /**
  29602. * Sets a Color3 on a uniform variable.
  29603. * @param uniformName Name of the variable.
  29604. * @param color3 Value to be set.
  29605. * @returns this effect.
  29606. */
  29607. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29608. /**
  29609. * Sets a Color4 on a uniform variable.
  29610. * @param uniformName Name of the variable.
  29611. * @param color3 Value to be set.
  29612. * @param alpha Alpha value to be set.
  29613. * @returns this effect.
  29614. */
  29615. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29616. /**
  29617. * Sets a Color4 on a uniform variable
  29618. * @param uniformName defines the name of the variable
  29619. * @param color4 defines the value to be set
  29620. * @returns this effect.
  29621. */
  29622. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29623. /** Release all associated resources */
  29624. dispose(): void;
  29625. /**
  29626. * This function will add a new shader to the shader store
  29627. * @param name the name of the shader
  29628. * @param pixelShader optional pixel shader content
  29629. * @param vertexShader optional vertex shader content
  29630. */
  29631. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29632. /**
  29633. * Store of each shader (The can be looked up using effect.key)
  29634. */
  29635. static ShadersStore: {
  29636. [key: string]: string;
  29637. };
  29638. /**
  29639. * Store of each included file for a shader (The can be looked up using effect.key)
  29640. */
  29641. static IncludesShadersStore: {
  29642. [key: string]: string;
  29643. };
  29644. /**
  29645. * Resets the cache of effects.
  29646. */
  29647. static ResetCache(): void;
  29648. }
  29649. }
  29650. declare module "babylonjs/Materials/uniformBuffer" {
  29651. import { Nullable, FloatArray } from "babylonjs/types";
  29652. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29653. import { Engine } from "babylonjs/Engines/engine";
  29654. import { Effect } from "babylonjs/Materials/effect";
  29655. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29656. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29657. import { Color3 } from "babylonjs/Maths/math.color";
  29658. /**
  29659. * Uniform buffer objects.
  29660. *
  29661. * Handles blocks of uniform on the GPU.
  29662. *
  29663. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29664. *
  29665. * For more information, please refer to :
  29666. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29667. */
  29668. export class UniformBuffer {
  29669. private _engine;
  29670. private _buffer;
  29671. private _data;
  29672. private _bufferData;
  29673. private _dynamic?;
  29674. private _uniformLocations;
  29675. private _uniformSizes;
  29676. private _uniformLocationPointer;
  29677. private _needSync;
  29678. private _noUBO;
  29679. private _currentEffect;
  29680. private static _MAX_UNIFORM_SIZE;
  29681. private static _tempBuffer;
  29682. /**
  29683. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29684. * This is dynamic to allow compat with webgl 1 and 2.
  29685. * You will need to pass the name of the uniform as well as the value.
  29686. */
  29687. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29688. /**
  29689. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29690. * This is dynamic to allow compat with webgl 1 and 2.
  29691. * You will need to pass the name of the uniform as well as the value.
  29692. */
  29693. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29694. /**
  29695. * Lambda to Update a single float in a uniform buffer.
  29696. * This is dynamic to allow compat with webgl 1 and 2.
  29697. * You will need to pass the name of the uniform as well as the value.
  29698. */
  29699. updateFloat: (name: string, x: number) => void;
  29700. /**
  29701. * Lambda to Update a vec2 of float in a uniform buffer.
  29702. * This is dynamic to allow compat with webgl 1 and 2.
  29703. * You will need to pass the name of the uniform as well as the value.
  29704. */
  29705. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29706. /**
  29707. * Lambda to Update a vec3 of float in a uniform buffer.
  29708. * This is dynamic to allow compat with webgl 1 and 2.
  29709. * You will need to pass the name of the uniform as well as the value.
  29710. */
  29711. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29712. /**
  29713. * Lambda to Update a vec4 of float in a uniform buffer.
  29714. * This is dynamic to allow compat with webgl 1 and 2.
  29715. * You will need to pass the name of the uniform as well as the value.
  29716. */
  29717. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29718. /**
  29719. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29720. * This is dynamic to allow compat with webgl 1 and 2.
  29721. * You will need to pass the name of the uniform as well as the value.
  29722. */
  29723. updateMatrix: (name: string, mat: Matrix) => void;
  29724. /**
  29725. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29726. * This is dynamic to allow compat with webgl 1 and 2.
  29727. * You will need to pass the name of the uniform as well as the value.
  29728. */
  29729. updateVector3: (name: string, vector: Vector3) => void;
  29730. /**
  29731. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29732. * This is dynamic to allow compat with webgl 1 and 2.
  29733. * You will need to pass the name of the uniform as well as the value.
  29734. */
  29735. updateVector4: (name: string, vector: Vector4) => void;
  29736. /**
  29737. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29738. * This is dynamic to allow compat with webgl 1 and 2.
  29739. * You will need to pass the name of the uniform as well as the value.
  29740. */
  29741. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29742. /**
  29743. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29744. * This is dynamic to allow compat with webgl 1 and 2.
  29745. * You will need to pass the name of the uniform as well as the value.
  29746. */
  29747. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29748. /**
  29749. * Instantiates a new Uniform buffer objects.
  29750. *
  29751. * Handles blocks of uniform on the GPU.
  29752. *
  29753. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29754. *
  29755. * For more information, please refer to :
  29756. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29757. * @param engine Define the engine the buffer is associated with
  29758. * @param data Define the data contained in the buffer
  29759. * @param dynamic Define if the buffer is updatable
  29760. */
  29761. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29762. /**
  29763. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29764. * or just falling back on setUniformXXX calls.
  29765. */
  29766. readonly useUbo: boolean;
  29767. /**
  29768. * Indicates if the WebGL underlying uniform buffer is in sync
  29769. * with the javascript cache data.
  29770. */
  29771. readonly isSync: boolean;
  29772. /**
  29773. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29774. * Also, a dynamic UniformBuffer will disable cache verification and always
  29775. * update the underlying WebGL uniform buffer to the GPU.
  29776. * @returns if Dynamic, otherwise false
  29777. */
  29778. isDynamic(): boolean;
  29779. /**
  29780. * The data cache on JS side.
  29781. * @returns the underlying data as a float array
  29782. */
  29783. getData(): Float32Array;
  29784. /**
  29785. * The underlying WebGL Uniform buffer.
  29786. * @returns the webgl buffer
  29787. */
  29788. getBuffer(): Nullable<DataBuffer>;
  29789. /**
  29790. * std140 layout specifies how to align data within an UBO structure.
  29791. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29792. * for specs.
  29793. */
  29794. private _fillAlignment;
  29795. /**
  29796. * Adds an uniform in the buffer.
  29797. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29798. * for the layout to be correct !
  29799. * @param name Name of the uniform, as used in the uniform block in the shader.
  29800. * @param size Data size, or data directly.
  29801. */
  29802. addUniform(name: string, size: number | number[]): void;
  29803. /**
  29804. * Adds a Matrix 4x4 to the uniform buffer.
  29805. * @param name Name of the uniform, as used in the uniform block in the shader.
  29806. * @param mat A 4x4 matrix.
  29807. */
  29808. addMatrix(name: string, mat: Matrix): void;
  29809. /**
  29810. * Adds a vec2 to the uniform buffer.
  29811. * @param name Name of the uniform, as used in the uniform block in the shader.
  29812. * @param x Define the x component value of the vec2
  29813. * @param y Define the y component value of the vec2
  29814. */
  29815. addFloat2(name: string, x: number, y: number): void;
  29816. /**
  29817. * Adds a vec3 to the uniform buffer.
  29818. * @param name Name of the uniform, as used in the uniform block in the shader.
  29819. * @param x Define the x component value of the vec3
  29820. * @param y Define the y component value of the vec3
  29821. * @param z Define the z component value of the vec3
  29822. */
  29823. addFloat3(name: string, x: number, y: number, z: number): void;
  29824. /**
  29825. * Adds a vec3 to the uniform buffer.
  29826. * @param name Name of the uniform, as used in the uniform block in the shader.
  29827. * @param color Define the vec3 from a Color
  29828. */
  29829. addColor3(name: string, color: Color3): void;
  29830. /**
  29831. * Adds a vec4 to the uniform buffer.
  29832. * @param name Name of the uniform, as used in the uniform block in the shader.
  29833. * @param color Define the rgb components from a Color
  29834. * @param alpha Define the a component of the vec4
  29835. */
  29836. addColor4(name: string, color: Color3, alpha: number): void;
  29837. /**
  29838. * Adds a vec3 to the uniform buffer.
  29839. * @param name Name of the uniform, as used in the uniform block in the shader.
  29840. * @param vector Define the vec3 components from a Vector
  29841. */
  29842. addVector3(name: string, vector: Vector3): void;
  29843. /**
  29844. * Adds a Matrix 3x3 to the uniform buffer.
  29845. * @param name Name of the uniform, as used in the uniform block in the shader.
  29846. */
  29847. addMatrix3x3(name: string): void;
  29848. /**
  29849. * Adds a Matrix 2x2 to the uniform buffer.
  29850. * @param name Name of the uniform, as used in the uniform block in the shader.
  29851. */
  29852. addMatrix2x2(name: string): void;
  29853. /**
  29854. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29855. */
  29856. create(): void;
  29857. /** @hidden */
  29858. _rebuild(): void;
  29859. /**
  29860. * Updates the WebGL Uniform Buffer on the GPU.
  29861. * If the `dynamic` flag is set to true, no cache comparison is done.
  29862. * Otherwise, the buffer will be updated only if the cache differs.
  29863. */
  29864. update(): void;
  29865. /**
  29866. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29867. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29868. * @param data Define the flattened data
  29869. * @param size Define the size of the data.
  29870. */
  29871. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29872. private _valueCache;
  29873. private _cacheMatrix;
  29874. private _updateMatrix3x3ForUniform;
  29875. private _updateMatrix3x3ForEffect;
  29876. private _updateMatrix2x2ForEffect;
  29877. private _updateMatrix2x2ForUniform;
  29878. private _updateFloatForEffect;
  29879. private _updateFloatForUniform;
  29880. private _updateFloat2ForEffect;
  29881. private _updateFloat2ForUniform;
  29882. private _updateFloat3ForEffect;
  29883. private _updateFloat3ForUniform;
  29884. private _updateFloat4ForEffect;
  29885. private _updateFloat4ForUniform;
  29886. private _updateMatrixForEffect;
  29887. private _updateMatrixForUniform;
  29888. private _updateVector3ForEffect;
  29889. private _updateVector3ForUniform;
  29890. private _updateVector4ForEffect;
  29891. private _updateVector4ForUniform;
  29892. private _updateColor3ForEffect;
  29893. private _updateColor3ForUniform;
  29894. private _updateColor4ForEffect;
  29895. private _updateColor4ForUniform;
  29896. /**
  29897. * Sets a sampler uniform on the effect.
  29898. * @param name Define the name of the sampler.
  29899. * @param texture Define the texture to set in the sampler
  29900. */
  29901. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29902. /**
  29903. * Directly updates the value of the uniform in the cache AND on the GPU.
  29904. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29905. * @param data Define the flattened data
  29906. */
  29907. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29908. /**
  29909. * Binds this uniform buffer to an effect.
  29910. * @param effect Define the effect to bind the buffer to
  29911. * @param name Name of the uniform block in the shader.
  29912. */
  29913. bindToEffect(effect: Effect, name: string): void;
  29914. /**
  29915. * Disposes the uniform buffer.
  29916. */
  29917. dispose(): void;
  29918. }
  29919. }
  29920. declare module "babylonjs/Audio/analyser" {
  29921. import { Scene } from "babylonjs/scene";
  29922. /**
  29923. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29925. */
  29926. export class Analyser {
  29927. /**
  29928. * Gets or sets the smoothing
  29929. * @ignorenaming
  29930. */
  29931. SMOOTHING: number;
  29932. /**
  29933. * Gets or sets the FFT table size
  29934. * @ignorenaming
  29935. */
  29936. FFT_SIZE: number;
  29937. /**
  29938. * Gets or sets the bar graph amplitude
  29939. * @ignorenaming
  29940. */
  29941. BARGRAPHAMPLITUDE: number;
  29942. /**
  29943. * Gets or sets the position of the debug canvas
  29944. * @ignorenaming
  29945. */
  29946. DEBUGCANVASPOS: {
  29947. x: number;
  29948. y: number;
  29949. };
  29950. /**
  29951. * Gets or sets the debug canvas size
  29952. * @ignorenaming
  29953. */
  29954. DEBUGCANVASSIZE: {
  29955. width: number;
  29956. height: number;
  29957. };
  29958. private _byteFreqs;
  29959. private _byteTime;
  29960. private _floatFreqs;
  29961. private _webAudioAnalyser;
  29962. private _debugCanvas;
  29963. private _debugCanvasContext;
  29964. private _scene;
  29965. private _registerFunc;
  29966. private _audioEngine;
  29967. /**
  29968. * Creates a new analyser
  29969. * @param scene defines hosting scene
  29970. */
  29971. constructor(scene: Scene);
  29972. /**
  29973. * Get the number of data values you will have to play with for the visualization
  29974. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29975. * @returns a number
  29976. */
  29977. getFrequencyBinCount(): number;
  29978. /**
  29979. * Gets the current frequency data as a byte array
  29980. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29981. * @returns a Uint8Array
  29982. */
  29983. getByteFrequencyData(): Uint8Array;
  29984. /**
  29985. * Gets the current waveform as a byte array
  29986. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29987. * @returns a Uint8Array
  29988. */
  29989. getByteTimeDomainData(): Uint8Array;
  29990. /**
  29991. * Gets the current frequency data as a float array
  29992. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29993. * @returns a Float32Array
  29994. */
  29995. getFloatFrequencyData(): Float32Array;
  29996. /**
  29997. * Renders the debug canvas
  29998. */
  29999. drawDebugCanvas(): void;
  30000. /**
  30001. * Stops rendering the debug canvas and removes it
  30002. */
  30003. stopDebugCanvas(): void;
  30004. /**
  30005. * Connects two audio nodes
  30006. * @param inputAudioNode defines first node to connect
  30007. * @param outputAudioNode defines second node to connect
  30008. */
  30009. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30010. /**
  30011. * Releases all associated resources
  30012. */
  30013. dispose(): void;
  30014. }
  30015. }
  30016. declare module "babylonjs/Audio/audioEngine" {
  30017. import { IDisposable } from "babylonjs/scene";
  30018. import { Analyser } from "babylonjs/Audio/analyser";
  30019. import { Nullable } from "babylonjs/types";
  30020. import { Observable } from "babylonjs/Misc/observable";
  30021. /**
  30022. * This represents an audio engine and it is responsible
  30023. * to play, synchronize and analyse sounds throughout the application.
  30024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30025. */
  30026. export interface IAudioEngine extends IDisposable {
  30027. /**
  30028. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30029. */
  30030. readonly canUseWebAudio: boolean;
  30031. /**
  30032. * Gets the current AudioContext if available.
  30033. */
  30034. readonly audioContext: Nullable<AudioContext>;
  30035. /**
  30036. * The master gain node defines the global audio volume of your audio engine.
  30037. */
  30038. readonly masterGain: GainNode;
  30039. /**
  30040. * Gets whether or not mp3 are supported by your browser.
  30041. */
  30042. readonly isMP3supported: boolean;
  30043. /**
  30044. * Gets whether or not ogg are supported by your browser.
  30045. */
  30046. readonly isOGGsupported: boolean;
  30047. /**
  30048. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30049. * @ignoreNaming
  30050. */
  30051. WarnedWebAudioUnsupported: boolean;
  30052. /**
  30053. * Defines if the audio engine relies on a custom unlocked button.
  30054. * In this case, the embedded button will not be displayed.
  30055. */
  30056. useCustomUnlockedButton: boolean;
  30057. /**
  30058. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30059. */
  30060. readonly unlocked: boolean;
  30061. /**
  30062. * Event raised when audio has been unlocked on the browser.
  30063. */
  30064. onAudioUnlockedObservable: Observable<AudioEngine>;
  30065. /**
  30066. * Event raised when audio has been locked on the browser.
  30067. */
  30068. onAudioLockedObservable: Observable<AudioEngine>;
  30069. /**
  30070. * Flags the audio engine in Locked state.
  30071. * This happens due to new browser policies preventing audio to autoplay.
  30072. */
  30073. lock(): void;
  30074. /**
  30075. * Unlocks the audio engine once a user action has been done on the dom.
  30076. * This is helpful to resume play once browser policies have been satisfied.
  30077. */
  30078. unlock(): void;
  30079. }
  30080. /**
  30081. * This represents the default audio engine used in babylon.
  30082. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30084. */
  30085. export class AudioEngine implements IAudioEngine {
  30086. private _audioContext;
  30087. private _audioContextInitialized;
  30088. private _muteButton;
  30089. private _hostElement;
  30090. /**
  30091. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30092. */
  30093. canUseWebAudio: boolean;
  30094. /**
  30095. * The master gain node defines the global audio volume of your audio engine.
  30096. */
  30097. masterGain: GainNode;
  30098. /**
  30099. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30100. * @ignoreNaming
  30101. */
  30102. WarnedWebAudioUnsupported: boolean;
  30103. /**
  30104. * Gets whether or not mp3 are supported by your browser.
  30105. */
  30106. isMP3supported: boolean;
  30107. /**
  30108. * Gets whether or not ogg are supported by your browser.
  30109. */
  30110. isOGGsupported: boolean;
  30111. /**
  30112. * Gets whether audio has been unlocked on the device.
  30113. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30114. * a user interaction has happened.
  30115. */
  30116. unlocked: boolean;
  30117. /**
  30118. * Defines if the audio engine relies on a custom unlocked button.
  30119. * In this case, the embedded button will not be displayed.
  30120. */
  30121. useCustomUnlockedButton: boolean;
  30122. /**
  30123. * Event raised when audio has been unlocked on the browser.
  30124. */
  30125. onAudioUnlockedObservable: Observable<AudioEngine>;
  30126. /**
  30127. * Event raised when audio has been locked on the browser.
  30128. */
  30129. onAudioLockedObservable: Observable<AudioEngine>;
  30130. /**
  30131. * Gets the current AudioContext if available.
  30132. */
  30133. readonly audioContext: Nullable<AudioContext>;
  30134. private _connectedAnalyser;
  30135. /**
  30136. * Instantiates a new audio engine.
  30137. *
  30138. * There should be only one per page as some browsers restrict the number
  30139. * of audio contexts you can create.
  30140. * @param hostElement defines the host element where to display the mute icon if necessary
  30141. */
  30142. constructor(hostElement?: Nullable<HTMLElement>);
  30143. /**
  30144. * Flags the audio engine in Locked state.
  30145. * This happens due to new browser policies preventing audio to autoplay.
  30146. */
  30147. lock(): void;
  30148. /**
  30149. * Unlocks the audio engine once a user action has been done on the dom.
  30150. * This is helpful to resume play once browser policies have been satisfied.
  30151. */
  30152. unlock(): void;
  30153. private _resumeAudioContext;
  30154. private _initializeAudioContext;
  30155. private _tryToRun;
  30156. private _triggerRunningState;
  30157. private _triggerSuspendedState;
  30158. private _displayMuteButton;
  30159. private _moveButtonToTopLeft;
  30160. private _onResize;
  30161. private _hideMuteButton;
  30162. /**
  30163. * Destroy and release the resources associated with the audio ccontext.
  30164. */
  30165. dispose(): void;
  30166. /**
  30167. * Gets the global volume sets on the master gain.
  30168. * @returns the global volume if set or -1 otherwise
  30169. */
  30170. getGlobalVolume(): number;
  30171. /**
  30172. * Sets the global volume of your experience (sets on the master gain).
  30173. * @param newVolume Defines the new global volume of the application
  30174. */
  30175. setGlobalVolume(newVolume: number): void;
  30176. /**
  30177. * Connect the audio engine to an audio analyser allowing some amazing
  30178. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30180. * @param analyser The analyser to connect to the engine
  30181. */
  30182. connectToAnalyser(analyser: Analyser): void;
  30183. }
  30184. }
  30185. declare module "babylonjs/Loading/loadingScreen" {
  30186. /**
  30187. * Interface used to present a loading screen while loading a scene
  30188. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30189. */
  30190. export interface ILoadingScreen {
  30191. /**
  30192. * Function called to display the loading screen
  30193. */
  30194. displayLoadingUI: () => void;
  30195. /**
  30196. * Function called to hide the loading screen
  30197. */
  30198. hideLoadingUI: () => void;
  30199. /**
  30200. * Gets or sets the color to use for the background
  30201. */
  30202. loadingUIBackgroundColor: string;
  30203. /**
  30204. * Gets or sets the text to display while loading
  30205. */
  30206. loadingUIText: string;
  30207. }
  30208. /**
  30209. * Class used for the default loading screen
  30210. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30211. */
  30212. export class DefaultLoadingScreen implements ILoadingScreen {
  30213. private _renderingCanvas;
  30214. private _loadingText;
  30215. private _loadingDivBackgroundColor;
  30216. private _loadingDiv;
  30217. private _loadingTextDiv;
  30218. /** Gets or sets the logo url to use for the default loading screen */
  30219. static DefaultLogoUrl: string;
  30220. /** Gets or sets the spinner url to use for the default loading screen */
  30221. static DefaultSpinnerUrl: string;
  30222. /**
  30223. * Creates a new default loading screen
  30224. * @param _renderingCanvas defines the canvas used to render the scene
  30225. * @param _loadingText defines the default text to display
  30226. * @param _loadingDivBackgroundColor defines the default background color
  30227. */
  30228. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30229. /**
  30230. * Function called to display the loading screen
  30231. */
  30232. displayLoadingUI(): void;
  30233. /**
  30234. * Function called to hide the loading screen
  30235. */
  30236. hideLoadingUI(): void;
  30237. /**
  30238. * Gets or sets the text to display while loading
  30239. */
  30240. loadingUIText: string;
  30241. /**
  30242. * Gets or sets the color to use for the background
  30243. */
  30244. loadingUIBackgroundColor: string;
  30245. private _resizeLoadingUI;
  30246. }
  30247. }
  30248. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30249. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30250. import { Engine } from "babylonjs/Engines/engine";
  30251. import { Nullable } from "babylonjs/types";
  30252. /** @hidden */
  30253. export class WebGLPipelineContext implements IPipelineContext {
  30254. engine: Engine;
  30255. program: Nullable<WebGLProgram>;
  30256. context?: WebGLRenderingContext;
  30257. vertexShader?: WebGLShader;
  30258. fragmentShader?: WebGLShader;
  30259. isParallelCompiled: boolean;
  30260. onCompiled?: () => void;
  30261. transformFeedback?: WebGLTransformFeedback | null;
  30262. readonly isAsync: boolean;
  30263. readonly isReady: boolean;
  30264. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30265. }
  30266. }
  30267. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30268. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30269. /** @hidden */
  30270. export class WebGLDataBuffer extends DataBuffer {
  30271. private _buffer;
  30272. constructor(resource: WebGLBuffer);
  30273. readonly underlyingResource: any;
  30274. }
  30275. }
  30276. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30277. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30278. /** @hidden */
  30279. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30280. attributeProcessor(attribute: string): string;
  30281. varyingProcessor(varying: string, isFragment: boolean): string;
  30282. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30283. }
  30284. }
  30285. declare module "babylonjs/Misc/perfCounter" {
  30286. /**
  30287. * This class is used to track a performance counter which is number based.
  30288. * The user has access to many properties which give statistics of different nature.
  30289. *
  30290. * The implementer can track two kinds of Performance Counter: time and count.
  30291. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  30292. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  30293. */
  30294. export class PerfCounter {
  30295. /**
  30296. * Gets or sets a global boolean to turn on and off all the counters
  30297. */
  30298. static Enabled: boolean;
  30299. /**
  30300. * Returns the smallest value ever
  30301. */
  30302. readonly min: number;
  30303. /**
  30304. * Returns the biggest value ever
  30305. */
  30306. readonly max: number;
  30307. /**
  30308. * Returns the average value since the performance counter is running
  30309. */
  30310. readonly average: number;
  30311. /**
  30312. * Returns the average value of the last second the counter was monitored
  30313. */
  30314. readonly lastSecAverage: number;
  30315. /**
  30316. * Returns the current value
  30317. */
  30318. readonly current: number;
  30319. /**
  30320. * Gets the accumulated total
  30321. */
  30322. readonly total: number;
  30323. /**
  30324. * Gets the total value count
  30325. */
  30326. readonly count: number;
  30327. /**
  30328. * Creates a new counter
  30329. */
  30330. constructor();
  30331. /**
  30332. * Call this method to start monitoring a new frame.
  30333. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  30334. */
  30335. fetchNewFrame(): void;
  30336. /**
  30337. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30338. * @param newCount the count value to add to the monitored count
  30339. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  30340. */
  30341. addCount(newCount: number, fetchResult: boolean): void;
  30342. /**
  30343. * Start monitoring this performance counter
  30344. */
  30345. beginMonitoring(): void;
  30346. /**
  30347. * Compute the time lapsed since the previous beginMonitoring() call.
  30348. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  30349. */
  30350. endMonitoring(newFrame?: boolean): void;
  30351. private _fetchResult;
  30352. private _startMonitoringTime;
  30353. private _min;
  30354. private _max;
  30355. private _average;
  30356. private _current;
  30357. private _totalValueCount;
  30358. private _totalAccumulated;
  30359. private _lastSecAverage;
  30360. private _lastSecAccumulated;
  30361. private _lastSecTime;
  30362. private _lastSecValueCount;
  30363. }
  30364. }
  30365. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30366. /**
  30367. * Interface for any object that can request an animation frame
  30368. */
  30369. export interface ICustomAnimationFrameRequester {
  30370. /**
  30371. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30372. */
  30373. renderFunction?: Function;
  30374. /**
  30375. * Called to request the next frame to render to
  30376. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30377. */
  30378. requestAnimationFrame: Function;
  30379. /**
  30380. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30381. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30382. */
  30383. requestID?: number;
  30384. }
  30385. }
  30386. declare module "babylonjs/Materials/Textures/videoTexture" {
  30387. import { Observable } from "babylonjs/Misc/observable";
  30388. import { Nullable } from "babylonjs/types";
  30389. import { Scene } from "babylonjs/scene";
  30390. import { Texture } from "babylonjs/Materials/Textures/texture";
  30391. /**
  30392. * Settings for finer control over video usage
  30393. */
  30394. export interface VideoTextureSettings {
  30395. /**
  30396. * Applies `autoplay` to video, if specified
  30397. */
  30398. autoPlay?: boolean;
  30399. /**
  30400. * Applies `loop` to video, if specified
  30401. */
  30402. loop?: boolean;
  30403. /**
  30404. * Automatically updates internal texture from video at every frame in the render loop
  30405. */
  30406. autoUpdateTexture: boolean;
  30407. /**
  30408. * Image src displayed during the video loading or until the user interacts with the video.
  30409. */
  30410. poster?: string;
  30411. }
  30412. /**
  30413. * If you want to display a video in your scene, this is the special texture for that.
  30414. * This special texture works similar to other textures, with the exception of a few parameters.
  30415. * @see https://doc.babylonjs.com/how_to/video_texture
  30416. */
  30417. export class VideoTexture extends Texture {
  30418. /**
  30419. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30420. */
  30421. readonly autoUpdateTexture: boolean;
  30422. /**
  30423. * The video instance used by the texture internally
  30424. */
  30425. readonly video: HTMLVideoElement;
  30426. private _onUserActionRequestedObservable;
  30427. /**
  30428. * Event triggerd when a dom action is required by the user to play the video.
  30429. * This happens due to recent changes in browser policies preventing video to auto start.
  30430. */
  30431. readonly onUserActionRequestedObservable: Observable<Texture>;
  30432. private _generateMipMaps;
  30433. private _engine;
  30434. private _stillImageCaptured;
  30435. private _displayingPosterTexture;
  30436. private _settings;
  30437. private _createInternalTextureOnEvent;
  30438. private _frameId;
  30439. /**
  30440. * Creates a video texture.
  30441. * If you want to display a video in your scene, this is the special texture for that.
  30442. * This special texture works similar to other textures, with the exception of a few parameters.
  30443. * @see https://doc.babylonjs.com/how_to/video_texture
  30444. * @param name optional name, will detect from video source, if not defined
  30445. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30446. * @param scene is obviously the current scene.
  30447. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30448. * @param invertY is false by default but can be used to invert video on Y axis
  30449. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30450. * @param settings allows finer control over video usage
  30451. */
  30452. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30453. private _getName;
  30454. private _getVideo;
  30455. private _createInternalTexture;
  30456. private reset;
  30457. /**
  30458. * @hidden Internal method to initiate `update`.
  30459. */
  30460. _rebuild(): void;
  30461. /**
  30462. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30463. */
  30464. update(): void;
  30465. /**
  30466. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30467. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30468. */
  30469. updateTexture(isVisible: boolean): void;
  30470. protected _updateInternalTexture: () => void;
  30471. /**
  30472. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30473. * @param url New url.
  30474. */
  30475. updateURL(url: string): void;
  30476. /**
  30477. * Dispose the texture and release its associated resources.
  30478. */
  30479. dispose(): void;
  30480. /**
  30481. * Creates a video texture straight from a stream.
  30482. * @param scene Define the scene the texture should be created in
  30483. * @param stream Define the stream the texture should be created from
  30484. * @returns The created video texture as a promise
  30485. */
  30486. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30487. /**
  30488. * Creates a video texture straight from your WebCam video feed.
  30489. * @param scene Define the scene the texture should be created in
  30490. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30491. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30492. * @returns The created video texture as a promise
  30493. */
  30494. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30495. minWidth: number;
  30496. maxWidth: number;
  30497. minHeight: number;
  30498. maxHeight: number;
  30499. deviceId: string;
  30500. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30501. /**
  30502. * Creates a video texture straight from your WebCam video feed.
  30503. * @param scene Define the scene the texture should be created in
  30504. * @param onReady Define a callback to triggered once the texture will be ready
  30505. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30506. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30507. */
  30508. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30509. minWidth: number;
  30510. maxWidth: number;
  30511. minHeight: number;
  30512. maxHeight: number;
  30513. deviceId: string;
  30514. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30515. }
  30516. }
  30517. declare module "babylonjs/Engines/engine" {
  30518. import { Observable } from "babylonjs/Misc/observable";
  30519. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30520. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30521. import { Scene } from "babylonjs/scene";
  30522. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30523. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30524. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30525. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30526. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30528. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30529. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30530. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30531. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30532. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30533. import { WebRequest } from "babylonjs/Misc/webRequest";
  30534. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30536. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30537. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30538. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30539. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30540. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30541. import { Material } from "babylonjs/Materials/material";
  30542. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30543. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30544. /**
  30545. * Defines the interface used by objects containing a viewport (like a camera)
  30546. */
  30547. interface IViewportOwnerLike {
  30548. /**
  30549. * Gets or sets the viewport
  30550. */
  30551. viewport: IViewportLike;
  30552. }
  30553. /**
  30554. * Interface for attribute information associated with buffer instanciation
  30555. */
  30556. export class InstancingAttributeInfo {
  30557. /**
  30558. * Index/offset of the attribute in the vertex shader
  30559. */
  30560. index: number;
  30561. /**
  30562. * size of the attribute, 1, 2, 3 or 4
  30563. */
  30564. attributeSize: number;
  30565. /**
  30566. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30567. * default is FLOAT
  30568. */
  30569. attribyteType: number;
  30570. /**
  30571. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30572. */
  30573. normalized: boolean;
  30574. /**
  30575. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30576. */
  30577. offset: number;
  30578. /**
  30579. * Name of the GLSL attribute, for debugging purpose only
  30580. */
  30581. attributeName: string;
  30582. }
  30583. /**
  30584. * Define options used to create a depth texture
  30585. */
  30586. export class DepthTextureCreationOptions {
  30587. /** Specifies whether or not a stencil should be allocated in the texture */
  30588. generateStencil?: boolean;
  30589. /** Specifies whether or not bilinear filtering is enable on the texture */
  30590. bilinearFiltering?: boolean;
  30591. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30592. comparisonFunction?: number;
  30593. /** Specifies if the created texture is a cube texture */
  30594. isCube?: boolean;
  30595. }
  30596. /**
  30597. * Class used to describe the capabilities of the engine relatively to the current browser
  30598. */
  30599. export class EngineCapabilities {
  30600. /** Maximum textures units per fragment shader */
  30601. maxTexturesImageUnits: number;
  30602. /** Maximum texture units per vertex shader */
  30603. maxVertexTextureImageUnits: number;
  30604. /** Maximum textures units in the entire pipeline */
  30605. maxCombinedTexturesImageUnits: number;
  30606. /** Maximum texture size */
  30607. maxTextureSize: number;
  30608. /** Maximum cube texture size */
  30609. maxCubemapTextureSize: number;
  30610. /** Maximum render texture size */
  30611. maxRenderTextureSize: number;
  30612. /** Maximum number of vertex attributes */
  30613. maxVertexAttribs: number;
  30614. /** Maximum number of varyings */
  30615. maxVaryingVectors: number;
  30616. /** Maximum number of uniforms per vertex shader */
  30617. maxVertexUniformVectors: number;
  30618. /** Maximum number of uniforms per fragment shader */
  30619. maxFragmentUniformVectors: number;
  30620. /** Defines if standard derivates (dx/dy) are supported */
  30621. standardDerivatives: boolean;
  30622. /** Defines if s3tc texture compression is supported */
  30623. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30624. /** Defines if pvrtc texture compression is supported */
  30625. pvrtc: any;
  30626. /** Defines if etc1 texture compression is supported */
  30627. etc1: any;
  30628. /** Defines if etc2 texture compression is supported */
  30629. etc2: any;
  30630. /** Defines if astc texture compression is supported */
  30631. astc: any;
  30632. /** Defines if float textures are supported */
  30633. textureFloat: boolean;
  30634. /** Defines if vertex array objects are supported */
  30635. vertexArrayObject: boolean;
  30636. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30637. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30638. /** Gets the maximum level of anisotropy supported */
  30639. maxAnisotropy: number;
  30640. /** Defines if instancing is supported */
  30641. instancedArrays: boolean;
  30642. /** Defines if 32 bits indices are supported */
  30643. uintIndices: boolean;
  30644. /** Defines if high precision shaders are supported */
  30645. highPrecisionShaderSupported: boolean;
  30646. /** Defines if depth reading in the fragment shader is supported */
  30647. fragmentDepthSupported: boolean;
  30648. /** Defines if float texture linear filtering is supported*/
  30649. textureFloatLinearFiltering: boolean;
  30650. /** Defines if rendering to float textures is supported */
  30651. textureFloatRender: boolean;
  30652. /** Defines if half float textures are supported*/
  30653. textureHalfFloat: boolean;
  30654. /** Defines if half float texture linear filtering is supported*/
  30655. textureHalfFloatLinearFiltering: boolean;
  30656. /** Defines if rendering to half float textures is supported */
  30657. textureHalfFloatRender: boolean;
  30658. /** Defines if textureLOD shader command is supported */
  30659. textureLOD: boolean;
  30660. /** Defines if draw buffers extension is supported */
  30661. drawBuffersExtension: boolean;
  30662. /** Defines if depth textures are supported */
  30663. depthTextureExtension: boolean;
  30664. /** Defines if float color buffer are supported */
  30665. colorBufferFloat: boolean;
  30666. /** Gets disjoint timer query extension (null if not supported) */
  30667. timerQuery: EXT_disjoint_timer_query;
  30668. /** Defines if timestamp can be used with timer query */
  30669. canUseTimestampForTimerQuery: boolean;
  30670. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30671. multiview: any;
  30672. /** Function used to let the system compiles shaders in background */
  30673. parallelShaderCompile: {
  30674. COMPLETION_STATUS_KHR: number;
  30675. };
  30676. /** Max number of texture samples for MSAA */
  30677. maxMSAASamples: number;
  30678. }
  30679. /** Interface defining initialization parameters for Engine class */
  30680. export interface EngineOptions extends WebGLContextAttributes {
  30681. /**
  30682. * Defines if the engine should no exceed a specified device ratio
  30683. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30684. */
  30685. limitDeviceRatio?: number;
  30686. /**
  30687. * Defines if webvr should be enabled automatically
  30688. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30689. */
  30690. autoEnableWebVR?: boolean;
  30691. /**
  30692. * Defines if webgl2 should be turned off even if supported
  30693. * @see http://doc.babylonjs.com/features/webgl2
  30694. */
  30695. disableWebGL2Support?: boolean;
  30696. /**
  30697. * Defines if webaudio should be initialized as well
  30698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30699. */
  30700. audioEngine?: boolean;
  30701. /**
  30702. * Defines if animations should run using a deterministic lock step
  30703. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30704. */
  30705. deterministicLockstep?: boolean;
  30706. /** Defines the maximum steps to use with deterministic lock step mode */
  30707. lockstepMaxSteps?: number;
  30708. /**
  30709. * Defines that engine should ignore context lost events
  30710. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30711. */
  30712. doNotHandleContextLost?: boolean;
  30713. /**
  30714. * Defines that engine should ignore modifying touch action attribute and style
  30715. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30716. */
  30717. doNotHandleTouchAction?: boolean;
  30718. /**
  30719. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30720. */
  30721. useHighPrecisionFloats?: boolean;
  30722. }
  30723. /**
  30724. * Defines the interface used by display changed events
  30725. */
  30726. export interface IDisplayChangedEventArgs {
  30727. /** Gets the vrDisplay object (if any) */
  30728. vrDisplay: Nullable<any>;
  30729. /** Gets a boolean indicating if webVR is supported */
  30730. vrSupported: boolean;
  30731. }
  30732. /**
  30733. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30734. */
  30735. export class Engine {
  30736. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30737. static ExceptionList: ({
  30738. key: string;
  30739. capture: string;
  30740. captureConstraint: number;
  30741. targets: string[];
  30742. } | {
  30743. key: string;
  30744. capture: null;
  30745. captureConstraint: null;
  30746. targets: string[];
  30747. })[];
  30748. /** Gets the list of created engines */
  30749. static readonly Instances: Engine[];
  30750. /**
  30751. * Gets the latest created engine
  30752. */
  30753. static readonly LastCreatedEngine: Nullable<Engine>;
  30754. /**
  30755. * Gets the latest created scene
  30756. */
  30757. static readonly LastCreatedScene: Nullable<Scene>;
  30758. /**
  30759. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30760. * @param flag defines which part of the materials must be marked as dirty
  30761. * @param predicate defines a predicate used to filter which materials should be affected
  30762. */
  30763. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30764. /** @hidden */
  30765. static _TextureLoaders: IInternalTextureLoader[];
  30766. /** Defines that alpha blending is disabled */
  30767. static readonly ALPHA_DISABLE: number;
  30768. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30769. static readonly ALPHA_ADD: number;
  30770. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30771. static readonly ALPHA_COMBINE: number;
  30772. /** Defines that alpha blending to DEST - SRC * DEST */
  30773. static readonly ALPHA_SUBTRACT: number;
  30774. /** Defines that alpha blending to SRC * DEST */
  30775. static readonly ALPHA_MULTIPLY: number;
  30776. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30777. static readonly ALPHA_MAXIMIZED: number;
  30778. /** Defines that alpha blending to SRC + DEST */
  30779. static readonly ALPHA_ONEONE: number;
  30780. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30781. static readonly ALPHA_PREMULTIPLIED: number;
  30782. /**
  30783. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30784. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30785. */
  30786. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30787. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30788. static readonly ALPHA_INTERPOLATE: number;
  30789. /**
  30790. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30791. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30792. */
  30793. static readonly ALPHA_SCREENMODE: number;
  30794. /** Defines that the ressource is not delayed*/
  30795. static readonly DELAYLOADSTATE_NONE: number;
  30796. /** Defines that the ressource was successfully delay loaded */
  30797. static readonly DELAYLOADSTATE_LOADED: number;
  30798. /** Defines that the ressource is currently delay loading */
  30799. static readonly DELAYLOADSTATE_LOADING: number;
  30800. /** Defines that the ressource is delayed and has not started loading */
  30801. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30802. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30803. static readonly NEVER: number;
  30804. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  30805. static readonly ALWAYS: number;
  30806. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30807. static readonly LESS: number;
  30808. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30809. static readonly EQUAL: number;
  30810. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  30811. static readonly LEQUAL: number;
  30812. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30813. static readonly GREATER: number;
  30814. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  30815. static readonly GEQUAL: number;
  30816. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  30817. static readonly NOTEQUAL: number;
  30818. /** Passed to stencilOperation to specify that stencil value must be kept */
  30819. static readonly KEEP: number;
  30820. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30821. static readonly REPLACE: number;
  30822. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30823. static readonly INCR: number;
  30824. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30825. static readonly DECR: number;
  30826. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30827. static readonly INVERT: number;
  30828. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30829. static readonly INCR_WRAP: number;
  30830. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30831. static readonly DECR_WRAP: number;
  30832. /** Texture is not repeating outside of 0..1 UVs */
  30833. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30834. /** Texture is repeating outside of 0..1 UVs */
  30835. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30836. /** Texture is repeating and mirrored */
  30837. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30838. /** ALPHA */
  30839. static readonly TEXTUREFORMAT_ALPHA: number;
  30840. /** LUMINANCE */
  30841. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30842. /** LUMINANCE_ALPHA */
  30843. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30844. /** RGB */
  30845. static readonly TEXTUREFORMAT_RGB: number;
  30846. /** RGBA */
  30847. static readonly TEXTUREFORMAT_RGBA: number;
  30848. /** RED */
  30849. static readonly TEXTUREFORMAT_RED: number;
  30850. /** RED (2nd reference) */
  30851. static readonly TEXTUREFORMAT_R: number;
  30852. /** RG */
  30853. static readonly TEXTUREFORMAT_RG: number;
  30854. /** RED_INTEGER */
  30855. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30856. /** RED_INTEGER (2nd reference) */
  30857. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30858. /** RG_INTEGER */
  30859. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30860. /** RGB_INTEGER */
  30861. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30862. /** RGBA_INTEGER */
  30863. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30864. /** UNSIGNED_BYTE */
  30865. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30866. /** UNSIGNED_BYTE (2nd reference) */
  30867. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30868. /** FLOAT */
  30869. static readonly TEXTURETYPE_FLOAT: number;
  30870. /** HALF_FLOAT */
  30871. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30872. /** BYTE */
  30873. static readonly TEXTURETYPE_BYTE: number;
  30874. /** SHORT */
  30875. static readonly TEXTURETYPE_SHORT: number;
  30876. /** UNSIGNED_SHORT */
  30877. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30878. /** INT */
  30879. static readonly TEXTURETYPE_INT: number;
  30880. /** UNSIGNED_INT */
  30881. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30882. /** UNSIGNED_SHORT_4_4_4_4 */
  30883. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30884. /** UNSIGNED_SHORT_5_5_5_1 */
  30885. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30886. /** UNSIGNED_SHORT_5_6_5 */
  30887. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30888. /** UNSIGNED_INT_2_10_10_10_REV */
  30889. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30890. /** UNSIGNED_INT_24_8 */
  30891. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30892. /** UNSIGNED_INT_10F_11F_11F_REV */
  30893. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30894. /** UNSIGNED_INT_5_9_9_9_REV */
  30895. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30896. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30897. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30898. /** nearest is mag = nearest and min = nearest and mip = linear */
  30899. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30900. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30901. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30902. /** Trilinear is mag = linear and min = linear and mip = linear */
  30903. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30904. /** nearest is mag = nearest and min = nearest and mip = linear */
  30905. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30906. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30907. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30908. /** Trilinear is mag = linear and min = linear and mip = linear */
  30909. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30910. /** mag = nearest and min = nearest and mip = nearest */
  30911. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30912. /** mag = nearest and min = linear and mip = nearest */
  30913. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30914. /** mag = nearest and min = linear and mip = linear */
  30915. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30916. /** mag = nearest and min = linear and mip = none */
  30917. static readonly TEXTURE_NEAREST_LINEAR: number;
  30918. /** mag = nearest and min = nearest and mip = none */
  30919. static readonly TEXTURE_NEAREST_NEAREST: number;
  30920. /** mag = linear and min = nearest and mip = nearest */
  30921. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30922. /** mag = linear and min = nearest and mip = linear */
  30923. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30924. /** mag = linear and min = linear and mip = none */
  30925. static readonly TEXTURE_LINEAR_LINEAR: number;
  30926. /** mag = linear and min = nearest and mip = none */
  30927. static readonly TEXTURE_LINEAR_NEAREST: number;
  30928. /** Explicit coordinates mode */
  30929. static readonly TEXTURE_EXPLICIT_MODE: number;
  30930. /** Spherical coordinates mode */
  30931. static readonly TEXTURE_SPHERICAL_MODE: number;
  30932. /** Planar coordinates mode */
  30933. static readonly TEXTURE_PLANAR_MODE: number;
  30934. /** Cubic coordinates mode */
  30935. static readonly TEXTURE_CUBIC_MODE: number;
  30936. /** Projection coordinates mode */
  30937. static readonly TEXTURE_PROJECTION_MODE: number;
  30938. /** Skybox coordinates mode */
  30939. static readonly TEXTURE_SKYBOX_MODE: number;
  30940. /** Inverse Cubic coordinates mode */
  30941. static readonly TEXTURE_INVCUBIC_MODE: number;
  30942. /** Equirectangular coordinates mode */
  30943. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30944. /** Equirectangular Fixed coordinates mode */
  30945. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30946. /** Equirectangular Fixed Mirrored coordinates mode */
  30947. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30948. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30949. static readonly SCALEMODE_FLOOR: number;
  30950. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30951. static readonly SCALEMODE_NEAREST: number;
  30952. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30953. static readonly SCALEMODE_CEILING: number;
  30954. /**
  30955. * Returns the current npm package of the sdk
  30956. */
  30957. static readonly NpmPackage: string;
  30958. /**
  30959. * Returns the current version of the framework
  30960. */
  30961. static readonly Version: string;
  30962. /**
  30963. * Returns a string describing the current engine
  30964. */
  30965. readonly description: string;
  30966. /**
  30967. * Gets or sets the epsilon value used by collision engine
  30968. */
  30969. static CollisionsEpsilon: number;
  30970. /**
  30971. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30972. */
  30973. static ShadersRepository: string;
  30974. /**
  30975. * Method called to create the default loading screen.
  30976. * This can be overriden in your own app.
  30977. * @param canvas The rendering canvas element
  30978. * @returns The loading screen
  30979. */
  30980. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30981. /**
  30982. * Method called to create the default rescale post process on each engine.
  30983. */
  30984. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30985. /** @hidden */
  30986. _shaderProcessor: IShaderProcessor;
  30987. /**
  30988. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30989. */
  30990. forcePOTTextures: boolean;
  30991. /**
  30992. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30993. */
  30994. isFullscreen: boolean;
  30995. /**
  30996. * Gets a boolean indicating if the pointer is currently locked
  30997. */
  30998. isPointerLock: boolean;
  30999. /**
  31000. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31001. */
  31002. cullBackFaces: boolean;
  31003. /**
  31004. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31005. */
  31006. renderEvenInBackground: boolean;
  31007. /**
  31008. * Gets or sets a boolean indicating that cache can be kept between frames
  31009. */
  31010. preventCacheWipeBetweenFrames: boolean;
  31011. /**
  31012. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31013. **/
  31014. enableOfflineSupport: boolean;
  31015. /**
  31016. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  31017. **/
  31018. disableManifestCheck: boolean;
  31019. /**
  31020. * Gets the list of created scenes
  31021. */
  31022. scenes: Scene[];
  31023. /**
  31024. * Event raised when a new scene is created
  31025. */
  31026. onNewSceneAddedObservable: Observable<Scene>;
  31027. /**
  31028. * Gets the list of created postprocesses
  31029. */
  31030. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  31031. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31032. validateShaderPrograms: boolean;
  31033. /**
  31034. * Observable event triggered each time the rendering canvas is resized
  31035. */
  31036. onResizeObservable: Observable<Engine>;
  31037. /**
  31038. * Observable event triggered each time the canvas loses focus
  31039. */
  31040. onCanvasBlurObservable: Observable<Engine>;
  31041. /**
  31042. * Observable event triggered each time the canvas gains focus
  31043. */
  31044. onCanvasFocusObservable: Observable<Engine>;
  31045. /**
  31046. * Observable event triggered each time the canvas receives pointerout event
  31047. */
  31048. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31049. /**
  31050. * Observable event triggered before each texture is initialized
  31051. */
  31052. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31053. /**
  31054. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31055. */
  31056. disableUniformBuffers: boolean;
  31057. /** @hidden */
  31058. _uniformBuffers: UniformBuffer[];
  31059. /**
  31060. * Gets a boolean indicating that the engine supports uniform buffers
  31061. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31062. */
  31063. readonly supportsUniformBuffers: boolean;
  31064. /**
  31065. * Observable raised when the engine begins a new frame
  31066. */
  31067. onBeginFrameObservable: Observable<Engine>;
  31068. /**
  31069. * If set, will be used to request the next animation frame for the render loop
  31070. */
  31071. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31072. /**
  31073. * Observable raised when the engine ends the current frame
  31074. */
  31075. onEndFrameObservable: Observable<Engine>;
  31076. /**
  31077. * Observable raised when the engine is about to compile a shader
  31078. */
  31079. onBeforeShaderCompilationObservable: Observable<Engine>;
  31080. /**
  31081. * Observable raised when the engine has jsut compiled a shader
  31082. */
  31083. onAfterShaderCompilationObservable: Observable<Engine>;
  31084. /** @hidden */
  31085. _gl: WebGLRenderingContext;
  31086. private _renderingCanvas;
  31087. private _windowIsBackground;
  31088. protected _webGLVersion: number;
  31089. protected _highPrecisionShadersAllowed: boolean;
  31090. /** @hidden */
  31091. readonly _shouldUseHighPrecisionShader: boolean;
  31092. /**
  31093. * Gets a boolean indicating that only power of 2 textures are supported
  31094. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31095. */
  31096. readonly needPOTTextures: boolean;
  31097. /** @hidden */
  31098. _badOS: boolean;
  31099. /** @hidden */
  31100. _badDesktopOS: boolean;
  31101. /**
  31102. * Gets the audio engine
  31103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31104. * @ignorenaming
  31105. */
  31106. static audioEngine: IAudioEngine;
  31107. /**
  31108. * Default AudioEngine factory responsible of creating the Audio Engine.
  31109. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31110. */
  31111. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31112. /**
  31113. * Default offline support factory responsible of creating a tool used to store data locally.
  31114. * By default, this will create a Database object if the workload has been embedded.
  31115. */
  31116. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31117. private _onFocus;
  31118. private _onBlur;
  31119. private _onCanvasPointerOut;
  31120. private _onCanvasBlur;
  31121. private _onCanvasFocus;
  31122. private _onFullscreenChange;
  31123. private _onPointerLockChange;
  31124. private _hardwareScalingLevel;
  31125. /** @hidden */
  31126. _caps: EngineCapabilities;
  31127. private _pointerLockRequested;
  31128. private _isStencilEnable;
  31129. protected _colorWrite: boolean;
  31130. private _loadingScreen;
  31131. /** @hidden */
  31132. _drawCalls: PerfCounter;
  31133. private _glVersion;
  31134. private _glRenderer;
  31135. private _glVendor;
  31136. private _videoTextureSupported;
  31137. private _renderingQueueLaunched;
  31138. private _activeRenderLoops;
  31139. private _deterministicLockstep;
  31140. private _lockstepMaxSteps;
  31141. /**
  31142. * Observable signaled when a context lost event is raised
  31143. */
  31144. onContextLostObservable: Observable<Engine>;
  31145. /**
  31146. * Observable signaled when a context restored event is raised
  31147. */
  31148. onContextRestoredObservable: Observable<Engine>;
  31149. private _onContextLost;
  31150. private _onContextRestored;
  31151. private _contextWasLost;
  31152. /** @hidden */
  31153. _doNotHandleContextLost: boolean;
  31154. /**
  31155. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31157. */
  31158. doNotHandleContextLost: boolean;
  31159. private _performanceMonitor;
  31160. private _fps;
  31161. private _deltaTime;
  31162. /**
  31163. * Turn this value on if you want to pause FPS computation when in background
  31164. */
  31165. disablePerformanceMonitorInBackground: boolean;
  31166. /**
  31167. * Gets the performance monitor attached to this engine
  31168. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31169. */
  31170. readonly performanceMonitor: PerformanceMonitor;
  31171. /**
  31172. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31173. */
  31174. disableVertexArrayObjects: boolean;
  31175. /** @hidden */
  31176. protected _depthCullingState: _DepthCullingState;
  31177. /** @hidden */
  31178. protected _stencilState: _StencilState;
  31179. /** @hidden */
  31180. protected _alphaState: _AlphaState;
  31181. /** @hidden */
  31182. protected _alphaMode: number;
  31183. /** @hidden */
  31184. _internalTexturesCache: InternalTexture[];
  31185. /** @hidden */
  31186. protected _activeChannel: number;
  31187. private _currentTextureChannel;
  31188. /** @hidden */
  31189. protected _boundTexturesCache: {
  31190. [key: string]: Nullable<InternalTexture>;
  31191. };
  31192. /** @hidden */
  31193. protected _currentEffect: Nullable<Effect>;
  31194. /** @hidden */
  31195. protected _currentProgram: Nullable<WebGLProgram>;
  31196. private _compiledEffects;
  31197. private _vertexAttribArraysEnabled;
  31198. /** @hidden */
  31199. protected _cachedViewport: Nullable<IViewportLike>;
  31200. private _cachedVertexArrayObject;
  31201. /** @hidden */
  31202. protected _cachedVertexBuffers: any;
  31203. /** @hidden */
  31204. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31205. /** @hidden */
  31206. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31207. /** @hidden */
  31208. _currentRenderTarget: Nullable<InternalTexture>;
  31209. private _uintIndicesCurrentlySet;
  31210. private _currentBoundBuffer;
  31211. /** @hidden */
  31212. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31213. private _currentBufferPointers;
  31214. private _currentInstanceLocations;
  31215. private _currentInstanceBuffers;
  31216. private _textureUnits;
  31217. /** @hidden */
  31218. _workingCanvas: Nullable<HTMLCanvasElement>;
  31219. /** @hidden */
  31220. _workingContext: Nullable<CanvasRenderingContext2D>;
  31221. private _rescalePostProcess;
  31222. private _dummyFramebuffer;
  31223. private _externalData;
  31224. /** @hidden */
  31225. _bindedRenderFunction: any;
  31226. private _vaoRecordInProgress;
  31227. private _mustWipeVertexAttributes;
  31228. private _emptyTexture;
  31229. private _emptyCubeTexture;
  31230. private _emptyTexture3D;
  31231. /** @hidden */
  31232. _frameHandler: number;
  31233. private _nextFreeTextureSlots;
  31234. private _maxSimultaneousTextures;
  31235. private _activeRequests;
  31236. private _texturesSupported;
  31237. /** @hidden */
  31238. _textureFormatInUse: Nullable<string>;
  31239. /**
  31240. * Gets the list of texture formats supported
  31241. */
  31242. readonly texturesSupported: Array<string>;
  31243. /**
  31244. * Gets the list of texture formats in use
  31245. */
  31246. readonly textureFormatInUse: Nullable<string>;
  31247. /**
  31248. * Gets the current viewport
  31249. */
  31250. readonly currentViewport: Nullable<IViewportLike>;
  31251. /**
  31252. * Gets the default empty texture
  31253. */
  31254. readonly emptyTexture: InternalTexture;
  31255. /**
  31256. * Gets the default empty 3D texture
  31257. */
  31258. readonly emptyTexture3D: InternalTexture;
  31259. /**
  31260. * Gets the default empty cube texture
  31261. */
  31262. readonly emptyCubeTexture: InternalTexture;
  31263. /**
  31264. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31265. */
  31266. readonly premultipliedAlpha: boolean;
  31267. /**
  31268. * Creates a new engine
  31269. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  31270. * @param antialias defines enable antialiasing (default: false)
  31271. * @param options defines further options to be sent to the getContext() function
  31272. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31273. */
  31274. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31275. /**
  31276. * Initializes a webVR display and starts listening to display change events
  31277. * The onVRDisplayChangedObservable will be notified upon these changes
  31278. * @returns The onVRDisplayChangedObservable
  31279. */
  31280. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31281. /** @hidden */
  31282. _prepareVRComponent(): void;
  31283. /** @hidden */
  31284. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31285. /** @hidden */
  31286. _submitVRFrame(): void;
  31287. /**
  31288. * Call this function to leave webVR mode
  31289. * Will do nothing if webVR is not supported or if there is no webVR device
  31290. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31291. */
  31292. disableVR(): void;
  31293. /**
  31294. * Gets a boolean indicating that the system is in VR mode and is presenting
  31295. * @returns true if VR mode is engaged
  31296. */
  31297. isVRPresenting(): boolean;
  31298. /** @hidden */
  31299. _requestVRFrame(): void;
  31300. private _disableTouchAction;
  31301. private _rebuildInternalTextures;
  31302. private _rebuildEffects;
  31303. /**
  31304. * Gets a boolean indicating if all created effects are ready
  31305. * @returns true if all effects are ready
  31306. */
  31307. areAllEffectsReady(): boolean;
  31308. private _rebuildBuffers;
  31309. private _initGLContext;
  31310. /**
  31311. * Gets version of the current webGL context
  31312. */
  31313. readonly webGLVersion: number;
  31314. /**
  31315. * Gets a string idenfifying the name of the class
  31316. * @returns "Engine" string
  31317. */
  31318. getClassName(): string;
  31319. /**
  31320. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31321. */
  31322. readonly isStencilEnable: boolean;
  31323. /** @hidden */
  31324. _prepareWorkingCanvas(): void;
  31325. /**
  31326. * Reset the texture cache to empty state
  31327. */
  31328. resetTextureCache(): void;
  31329. /**
  31330. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31331. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31332. * @returns true if engine is in deterministic lock step mode
  31333. */
  31334. isDeterministicLockStep(): boolean;
  31335. /**
  31336. * Gets the max steps when engine is running in deterministic lock step
  31337. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31338. * @returns the max steps
  31339. */
  31340. getLockstepMaxSteps(): number;
  31341. /**
  31342. * Gets an object containing information about the current webGL context
  31343. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31344. */
  31345. getGlInfo(): {
  31346. vendor: string;
  31347. renderer: string;
  31348. version: string;
  31349. };
  31350. /**
  31351. * Gets current aspect ratio
  31352. * @param viewportOwner defines the camera to use to get the aspect ratio
  31353. * @param useScreen defines if screen size must be used (or the current render target if any)
  31354. * @returns a number defining the aspect ratio
  31355. */
  31356. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31357. /**
  31358. * Gets current screen aspect ratio
  31359. * @returns a number defining the aspect ratio
  31360. */
  31361. getScreenAspectRatio(): number;
  31362. /**
  31363. * Gets the current render width
  31364. * @param useScreen defines if screen size must be used (or the current render target if any)
  31365. * @returns a number defining the current render width
  31366. */
  31367. getRenderWidth(useScreen?: boolean): number;
  31368. /**
  31369. * Gets the current render height
  31370. * @param useScreen defines if screen size must be used (or the current render target if any)
  31371. * @returns a number defining the current render height
  31372. */
  31373. getRenderHeight(useScreen?: boolean): number;
  31374. /**
  31375. * Gets the HTML canvas attached with the current webGL context
  31376. * @returns a HTML canvas
  31377. */
  31378. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31379. /**
  31380. * Gets host window
  31381. * @returns the host window object
  31382. */
  31383. getHostWindow(): Window;
  31384. /**
  31385. * Gets host document
  31386. * @returns the host document object
  31387. */
  31388. getHostDocument(): Document;
  31389. /**
  31390. * Gets the client rect of the HTML canvas attached with the current webGL context
  31391. * @returns a client rectanglee
  31392. */
  31393. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31394. /**
  31395. * Defines the hardware scaling level.
  31396. * By default the hardware scaling level is computed from the window device ratio.
  31397. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  31398. * @param level defines the level to use
  31399. */
  31400. setHardwareScalingLevel(level: number): void;
  31401. /**
  31402. * Gets the current hardware scaling level.
  31403. * By default the hardware scaling level is computed from the window device ratio.
  31404. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  31405. * @returns a number indicating the current hardware scaling level
  31406. */
  31407. getHardwareScalingLevel(): number;
  31408. /**
  31409. * Gets the list of loaded textures
  31410. * @returns an array containing all loaded textures
  31411. */
  31412. getLoadedTexturesCache(): InternalTexture[];
  31413. /**
  31414. * Gets the object containing all engine capabilities
  31415. * @returns the EngineCapabilities object
  31416. */
  31417. getCaps(): EngineCapabilities;
  31418. /**
  31419. * Gets the current depth function
  31420. * @returns a number defining the depth function
  31421. */
  31422. getDepthFunction(): Nullable<number>;
  31423. /**
  31424. * Sets the current depth function
  31425. * @param depthFunc defines the function to use
  31426. */
  31427. setDepthFunction(depthFunc: number): void;
  31428. /**
  31429. * Sets the current depth function to GREATER
  31430. */
  31431. setDepthFunctionToGreater(): void;
  31432. /**
  31433. * Sets the current depth function to GEQUAL
  31434. */
  31435. setDepthFunctionToGreaterOrEqual(): void;
  31436. /**
  31437. * Sets the current depth function to LESS
  31438. */
  31439. setDepthFunctionToLess(): void;
  31440. private _cachedStencilBuffer;
  31441. private _cachedStencilFunction;
  31442. private _cachedStencilMask;
  31443. private _cachedStencilOperationPass;
  31444. private _cachedStencilOperationFail;
  31445. private _cachedStencilOperationDepthFail;
  31446. private _cachedStencilReference;
  31447. /**
  31448. * Caches the the state of the stencil buffer
  31449. */
  31450. cacheStencilState(): void;
  31451. /**
  31452. * Restores the state of the stencil buffer
  31453. */
  31454. restoreStencilState(): void;
  31455. /**
  31456. * Sets the current depth function to LEQUAL
  31457. */
  31458. setDepthFunctionToLessOrEqual(): void;
  31459. /**
  31460. * Gets a boolean indicating if stencil buffer is enabled
  31461. * @returns the current stencil buffer state
  31462. */
  31463. getStencilBuffer(): boolean;
  31464. /**
  31465. * Enable or disable the stencil buffer
  31466. * @param enable defines if the stencil buffer must be enabled or disabled
  31467. */
  31468. setStencilBuffer(enable: boolean): void;
  31469. /**
  31470. * Gets the current stencil mask
  31471. * @returns a number defining the new stencil mask to use
  31472. */
  31473. getStencilMask(): number;
  31474. /**
  31475. * Sets the current stencil mask
  31476. * @param mask defines the new stencil mask to use
  31477. */
  31478. setStencilMask(mask: number): void;
  31479. /**
  31480. * Gets the current stencil function
  31481. * @returns a number defining the stencil function to use
  31482. */
  31483. getStencilFunction(): number;
  31484. /**
  31485. * Gets the current stencil reference value
  31486. * @returns a number defining the stencil reference value to use
  31487. */
  31488. getStencilFunctionReference(): number;
  31489. /**
  31490. * Gets the current stencil mask
  31491. * @returns a number defining the stencil mask to use
  31492. */
  31493. getStencilFunctionMask(): number;
  31494. /**
  31495. * Sets the current stencil function
  31496. * @param stencilFunc defines the new stencil function to use
  31497. */
  31498. setStencilFunction(stencilFunc: number): void;
  31499. /**
  31500. * Sets the current stencil reference
  31501. * @param reference defines the new stencil reference to use
  31502. */
  31503. setStencilFunctionReference(reference: number): void;
  31504. /**
  31505. * Sets the current stencil mask
  31506. * @param mask defines the new stencil mask to use
  31507. */
  31508. setStencilFunctionMask(mask: number): void;
  31509. /**
  31510. * Gets the current stencil operation when stencil fails
  31511. * @returns a number defining stencil operation to use when stencil fails
  31512. */
  31513. getStencilOperationFail(): number;
  31514. /**
  31515. * Gets the current stencil operation when depth fails
  31516. * @returns a number defining stencil operation to use when depth fails
  31517. */
  31518. getStencilOperationDepthFail(): number;
  31519. /**
  31520. * Gets the current stencil operation when stencil passes
  31521. * @returns a number defining stencil operation to use when stencil passes
  31522. */
  31523. getStencilOperationPass(): number;
  31524. /**
  31525. * Sets the stencil operation to use when stencil fails
  31526. * @param operation defines the stencil operation to use when stencil fails
  31527. */
  31528. setStencilOperationFail(operation: number): void;
  31529. /**
  31530. * Sets the stencil operation to use when depth fails
  31531. * @param operation defines the stencil operation to use when depth fails
  31532. */
  31533. setStencilOperationDepthFail(operation: number): void;
  31534. /**
  31535. * Sets the stencil operation to use when stencil passes
  31536. * @param operation defines the stencil operation to use when stencil passes
  31537. */
  31538. setStencilOperationPass(operation: number): void;
  31539. /**
  31540. * Sets a boolean indicating if the dithering state is enabled or disabled
  31541. * @param value defines the dithering state
  31542. */
  31543. setDitheringState(value: boolean): void;
  31544. /**
  31545. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31546. * @param value defines the rasterizer state
  31547. */
  31548. setRasterizerState(value: boolean): void;
  31549. /**
  31550. * stop executing a render loop function and remove it from the execution array
  31551. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31552. */
  31553. stopRenderLoop(renderFunction?: () => void): void;
  31554. /** @hidden */
  31555. _renderLoop(): void;
  31556. /**
  31557. * Can be used to override the current requestAnimationFrame requester.
  31558. * @hidden
  31559. */
  31560. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31561. /**
  31562. * Register and execute a render loop. The engine can have more than one render function
  31563. * @param renderFunction defines the function to continuously execute
  31564. */
  31565. runRenderLoop(renderFunction: () => void): void;
  31566. /**
  31567. * Toggle full screen mode
  31568. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31569. */
  31570. switchFullscreen(requestPointerLock: boolean): void;
  31571. /**
  31572. * Enters full screen mode
  31573. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31574. */
  31575. enterFullscreen(requestPointerLock: boolean): void;
  31576. /**
  31577. * Exits full screen mode
  31578. */
  31579. exitFullscreen(): void;
  31580. /**
  31581. * Enters Pointerlock mode
  31582. */
  31583. enterPointerlock(): void;
  31584. /**
  31585. * Exits Pointerlock mode
  31586. */
  31587. exitPointerlock(): void;
  31588. /**
  31589. * Clear the current render buffer or the current render target (if any is set up)
  31590. * @param color defines the color to use
  31591. * @param backBuffer defines if the back buffer must be cleared
  31592. * @param depth defines if the depth buffer must be cleared
  31593. * @param stencil defines if the stencil buffer must be cleared
  31594. */
  31595. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31596. /**
  31597. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31598. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31599. * @param y defines the y-coordinate of the corner of the clear rectangle
  31600. * @param width defines the width of the clear rectangle
  31601. * @param height defines the height of the clear rectangle
  31602. * @param clearColor defines the clear color
  31603. */
  31604. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31605. /**
  31606. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31607. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31608. * @param y defines the y-coordinate of the corner of the clear rectangle
  31609. * @param width defines the width of the clear rectangle
  31610. * @param height defines the height of the clear rectangle
  31611. */
  31612. enableScissor(x: number, y: number, width: number, height: number): void;
  31613. /**
  31614. * Disable previously set scissor test rectangle
  31615. */
  31616. disableScissor(): void;
  31617. private _viewportCached;
  31618. /** @hidden */
  31619. _viewport(x: number, y: number, width: number, height: number): void;
  31620. /**
  31621. * Set the WebGL's viewport
  31622. * @param viewport defines the viewport element to be used
  31623. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31624. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31625. */
  31626. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31627. /**
  31628. * Directly set the WebGL Viewport
  31629. * @param x defines the x coordinate of the viewport (in screen space)
  31630. * @param y defines the y coordinate of the viewport (in screen space)
  31631. * @param width defines the width of the viewport (in screen space)
  31632. * @param height defines the height of the viewport (in screen space)
  31633. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state
  31634. */
  31635. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31636. /**
  31637. * Begin a new frame
  31638. */
  31639. beginFrame(): void;
  31640. /**
  31641. * Enf the current frame
  31642. */
  31643. endFrame(): void;
  31644. /**
  31645. * Resize the view according to the canvas' size
  31646. */
  31647. resize(): void;
  31648. /**
  31649. * Force a specific size of the canvas
  31650. * @param width defines the new canvas' width
  31651. * @param height defines the new canvas' height
  31652. */
  31653. setSize(width: number, height: number): void;
  31654. /**
  31655. * Binds the frame buffer to the specified texture.
  31656. * @param texture The texture to render to or null for the default canvas
  31657. * @param faceIndex The face of the texture to render to in case of cube texture
  31658. * @param requiredWidth The width of the target to render to
  31659. * @param requiredHeight The height of the target to render to
  31660. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31661. * @param depthStencilTexture The depth stencil texture to use to render
  31662. * @param lodLevel defines le lod level to bind to the frame buffer
  31663. */
  31664. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31665. /** @hidden */
  31666. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31667. /**
  31668. * Unbind the current render target texture from the webGL context
  31669. * @param texture defines the render target texture to unbind
  31670. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31671. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31672. */
  31673. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31674. /**
  31675. * Force the mipmap generation for the given render target texture
  31676. * @param texture defines the render target texture to use
  31677. */
  31678. generateMipMapsForCubemap(texture: InternalTexture): void;
  31679. /**
  31680. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31681. */
  31682. flushFramebuffer(): void;
  31683. /**
  31684. * Unbind the current render target and bind the default framebuffer
  31685. */
  31686. restoreDefaultFramebuffer(): void;
  31687. /**
  31688. * Create an uniform buffer
  31689. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31690. * @param elements defines the content of the uniform buffer
  31691. * @returns the webGL uniform buffer
  31692. */
  31693. createUniformBuffer(elements: FloatArray): DataBuffer;
  31694. /**
  31695. * Create a dynamic uniform buffer
  31696. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31697. * @param elements defines the content of the uniform buffer
  31698. * @returns the webGL uniform buffer
  31699. */
  31700. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31701. /**
  31702. * Update an existing uniform buffer
  31703. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31704. * @param uniformBuffer defines the target uniform buffer
  31705. * @param elements defines the content to update
  31706. * @param offset defines the offset in the uniform buffer where update should start
  31707. * @param count defines the size of the data to update
  31708. */
  31709. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31710. private _resetVertexBufferBinding;
  31711. /**
  31712. * Creates a vertex buffer
  31713. * @param data the data for the vertex buffer
  31714. * @returns the new WebGL static buffer
  31715. */
  31716. createVertexBuffer(data: DataArray): DataBuffer;
  31717. /**
  31718. * Creates a dynamic vertex buffer
  31719. * @param data the data for the dynamic vertex buffer
  31720. * @returns the new WebGL dynamic buffer
  31721. */
  31722. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31723. /**
  31724. * Update a dynamic index buffer
  31725. * @param indexBuffer defines the target index buffer
  31726. * @param indices defines the data to update
  31727. * @param offset defines the offset in the target index buffer where update should start
  31728. */
  31729. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31730. /**
  31731. * Updates a dynamic vertex buffer.
  31732. * @param vertexBuffer the vertex buffer to update
  31733. * @param data the data used to update the vertex buffer
  31734. * @param byteOffset the byte offset of the data
  31735. * @param byteLength the byte length of the data
  31736. */
  31737. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31738. private _resetIndexBufferBinding;
  31739. /**
  31740. * Creates a new index buffer
  31741. * @param indices defines the content of the index buffer
  31742. * @param updatable defines if the index buffer must be updatable
  31743. * @returns a new webGL buffer
  31744. */
  31745. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31746. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31747. /**
  31748. * Bind a webGL buffer to the webGL context
  31749. * @param buffer defines the buffer to bind
  31750. */
  31751. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31752. /**
  31753. * Bind an uniform buffer to the current webGL context
  31754. * @param buffer defines the buffer to bind
  31755. */
  31756. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31757. /**
  31758. * Bind a buffer to the current webGL context at a given location
  31759. * @param buffer defines the buffer to bind
  31760. * @param location defines the index where to bind the buffer
  31761. */
  31762. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31763. /**
  31764. * Bind a specific block at a given index in a specific shader program
  31765. * @param pipelineContext defines the pipeline context to use
  31766. * @param blockName defines the block name
  31767. * @param index defines the index where to bind the block
  31768. */
  31769. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31770. private bindIndexBuffer;
  31771. private bindBuffer;
  31772. /**
  31773. * update the bound buffer with the given data
  31774. * @param data defines the data to update
  31775. */
  31776. updateArrayBuffer(data: Float32Array): void;
  31777. private _vertexAttribPointer;
  31778. private _bindIndexBufferWithCache;
  31779. private _bindVertexBuffersAttributes;
  31780. /**
  31781. * Records a vertex array object
  31782. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31783. * @param vertexBuffers defines the list of vertex buffers to store
  31784. * @param indexBuffer defines the index buffer to store
  31785. * @param effect defines the effect to store
  31786. * @returns the new vertex array object
  31787. */
  31788. recordVertexArrayObject(vertexBuffers: {
  31789. [key: string]: VertexBuffer;
  31790. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31791. /**
  31792. * Bind a specific vertex array object
  31793. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31794. * @param vertexArrayObject defines the vertex array object to bind
  31795. * @param indexBuffer defines the index buffer to bind
  31796. */
  31797. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31798. /**
  31799. * Bind webGl buffers directly to the webGL context
  31800. * @param vertexBuffer defines the vertex buffer to bind
  31801. * @param indexBuffer defines the index buffer to bind
  31802. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31803. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31804. * @param effect defines the effect associated with the vertex buffer
  31805. */
  31806. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31807. private _unbindVertexArrayObject;
  31808. /**
  31809. * Bind a list of vertex buffers to the webGL context
  31810. * @param vertexBuffers defines the list of vertex buffers to bind
  31811. * @param indexBuffer defines the index buffer to bind
  31812. * @param effect defines the effect associated with the vertex buffers
  31813. */
  31814. bindBuffers(vertexBuffers: {
  31815. [key: string]: Nullable<VertexBuffer>;
  31816. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31817. /**
  31818. * Unbind all instance attributes
  31819. */
  31820. unbindInstanceAttributes(): void;
  31821. /**
  31822. * Release and free the memory of a vertex array object
  31823. * @param vao defines the vertex array object to delete
  31824. */
  31825. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31826. /** @hidden */
  31827. _releaseBuffer(buffer: DataBuffer): boolean;
  31828. protected _deleteBuffer(buffer: DataBuffer): void;
  31829. /**
  31830. * Creates a webGL buffer to use with instanciation
  31831. * @param capacity defines the size of the buffer
  31832. * @returns the webGL buffer
  31833. */
  31834. createInstancesBuffer(capacity: number): DataBuffer;
  31835. /**
  31836. * Delete a webGL buffer used with instanciation
  31837. * @param buffer defines the webGL buffer to delete
  31838. */
  31839. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31840. /**
  31841. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31842. * @param instancesBuffer defines the webGL buffer to update and bind
  31843. * @param data defines the data to store in the buffer
  31844. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31845. */
  31846. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31847. /**
  31848. * Apply all cached states (depth, culling, stencil and alpha)
  31849. */
  31850. applyStates(): void;
  31851. /**
  31852. * Send a draw order
  31853. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31854. * @param indexStart defines the starting index
  31855. * @param indexCount defines the number of index to draw
  31856. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31857. */
  31858. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31859. /**
  31860. * Draw a list of points
  31861. * @param verticesStart defines the index of first vertex to draw
  31862. * @param verticesCount defines the count of vertices to draw
  31863. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31864. */
  31865. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31866. /**
  31867. * Draw a list of unindexed primitives
  31868. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31869. * @param verticesStart defines the index of first vertex to draw
  31870. * @param verticesCount defines the count of vertices to draw
  31871. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31872. */
  31873. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31874. /**
  31875. * Draw a list of indexed primitives
  31876. * @param fillMode defines the primitive to use
  31877. * @param indexStart defines the starting index
  31878. * @param indexCount defines the number of index to draw
  31879. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31880. */
  31881. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31882. /**
  31883. * Draw a list of unindexed primitives
  31884. * @param fillMode defines the primitive to use
  31885. * @param verticesStart defines the index of first vertex to draw
  31886. * @param verticesCount defines the count of vertices to draw
  31887. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31888. */
  31889. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31890. private _drawMode;
  31891. /** @hidden */
  31892. _releaseEffect(effect: Effect): void;
  31893. /** @hidden */
  31894. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31895. /**
  31896. * Create a new effect (used to store vertex/fragment shaders)
  31897. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31898. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31899. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31900. * @param samplers defines an array of string used to represent textures
  31901. * @param defines defines the string containing the defines to use to compile the shaders
  31902. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31903. * @param onCompiled defines a function to call when the effect creation is successful
  31904. * @param onError defines a function to call when the effect creation has failed
  31905. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31906. * @returns the new Effect
  31907. */
  31908. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31909. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31910. private _compileShader;
  31911. private _compileRawShader;
  31912. /**
  31913. * Directly creates a webGL program
  31914. * @param pipelineContext defines the pipeline context to attach to
  31915. * @param vertexCode defines the vertex shader code to use
  31916. * @param fragmentCode defines the fragment shader code to use
  31917. * @param context defines the webGL context to use (if not set, the current one will be used)
  31918. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31919. * @returns the new webGL program
  31920. */
  31921. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31922. /**
  31923. * Creates a webGL program
  31924. * @param pipelineContext defines the pipeline context to attach to
  31925. * @param vertexCode defines the vertex shader code to use
  31926. * @param fragmentCode defines the fragment shader code to use
  31927. * @param defines defines the string containing the defines to use to compile the shaders
  31928. * @param context defines the webGL context to use (if not set, the current one will be used)
  31929. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31930. * @returns the new webGL program
  31931. */
  31932. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31933. /**
  31934. * Creates a new pipeline context
  31935. * @returns the new pipeline
  31936. */
  31937. createPipelineContext(): IPipelineContext;
  31938. private _createShaderProgram;
  31939. private _finalizePipelineContext;
  31940. /** @hidden */
  31941. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31942. /** @hidden */
  31943. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31944. /** @hidden */
  31945. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31946. /**
  31947. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31948. * @param pipelineContext defines the pipeline context to use
  31949. * @param uniformsNames defines the list of uniform names
  31950. * @returns an array of webGL uniform locations
  31951. */
  31952. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31953. /**
  31954. * Gets the lsit of active attributes for a given webGL program
  31955. * @param pipelineContext defines the pipeline context to use
  31956. * @param attributesNames defines the list of attribute names to get
  31957. * @returns an array of indices indicating the offset of each attribute
  31958. */
  31959. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31960. /**
  31961. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31962. * @param effect defines the effect to activate
  31963. */
  31964. enableEffect(effect: Nullable<Effect>): void;
  31965. /**
  31966. * Set the value of an uniform to an array of int32
  31967. * @param uniform defines the webGL uniform location where to store the value
  31968. * @param array defines the array of int32 to store
  31969. */
  31970. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31971. /**
  31972. * Set the value of an uniform to an array of int32 (stored as vec2)
  31973. * @param uniform defines the webGL uniform location where to store the value
  31974. * @param array defines the array of int32 to store
  31975. */
  31976. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31977. /**
  31978. * Set the value of an uniform to an array of int32 (stored as vec3)
  31979. * @param uniform defines the webGL uniform location where to store the value
  31980. * @param array defines the array of int32 to store
  31981. */
  31982. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31983. /**
  31984. * Set the value of an uniform to an array of int32 (stored as vec4)
  31985. * @param uniform defines the webGL uniform location where to store the value
  31986. * @param array defines the array of int32 to store
  31987. */
  31988. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31989. /**
  31990. * Set the value of an uniform to an array of float32
  31991. * @param uniform defines the webGL uniform location where to store the value
  31992. * @param array defines the array of float32 to store
  31993. */
  31994. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31995. /**
  31996. * Set the value of an uniform to an array of float32 (stored as vec2)
  31997. * @param uniform defines the webGL uniform location where to store the value
  31998. * @param array defines the array of float32 to store
  31999. */
  32000. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32001. /**
  32002. * Set the value of an uniform to an array of float32 (stored as vec3)
  32003. * @param uniform defines the webGL uniform location where to store the value
  32004. * @param array defines the array of float32 to store
  32005. */
  32006. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32007. /**
  32008. * Set the value of an uniform to an array of float32 (stored as vec4)
  32009. * @param uniform defines the webGL uniform location where to store the value
  32010. * @param array defines the array of float32 to store
  32011. */
  32012. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32013. /**
  32014. * Set the value of an uniform to an array of number
  32015. * @param uniform defines the webGL uniform location where to store the value
  32016. * @param array defines the array of number to store
  32017. */
  32018. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32019. /**
  32020. * Set the value of an uniform to an array of number (stored as vec2)
  32021. * @param uniform defines the webGL uniform location where to store the value
  32022. * @param array defines the array of number to store
  32023. */
  32024. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32025. /**
  32026. * Set the value of an uniform to an array of number (stored as vec3)
  32027. * @param uniform defines the webGL uniform location where to store the value
  32028. * @param array defines the array of number to store
  32029. */
  32030. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32031. /**
  32032. * Set the value of an uniform to an array of number (stored as vec4)
  32033. * @param uniform defines the webGL uniform location where to store the value
  32034. * @param array defines the array of number to store
  32035. */
  32036. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32037. /**
  32038. * Set the value of an uniform to an array of float32 (stored as matrices)
  32039. * @param uniform defines the webGL uniform location where to store the value
  32040. * @param matrices defines the array of float32 to store
  32041. */
  32042. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32043. /**
  32044. * Set the value of an uniform to a matrix (3x3)
  32045. * @param uniform defines the webGL uniform location where to store the value
  32046. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32047. */
  32048. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32049. /**
  32050. * Set the value of an uniform to a matrix (2x2)
  32051. * @param uniform defines the webGL uniform location where to store the value
  32052. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32053. */
  32054. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32055. /**
  32056. * Set the value of an uniform to a number (int)
  32057. * @param uniform defines the webGL uniform location where to store the value
  32058. * @param value defines the int number to store
  32059. */
  32060. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32061. /**
  32062. * Set the value of an uniform to a number (float)
  32063. * @param uniform defines the webGL uniform location where to store the value
  32064. * @param value defines the float number to store
  32065. */
  32066. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32067. /**
  32068. * Set the value of an uniform to a vec2
  32069. * @param uniform defines the webGL uniform location where to store the value
  32070. * @param x defines the 1st component of the value
  32071. * @param y defines the 2nd component of the value
  32072. */
  32073. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32074. /**
  32075. * Set the value of an uniform to a vec3
  32076. * @param uniform defines the webGL uniform location where to store the value
  32077. * @param x defines the 1st component of the value
  32078. * @param y defines the 2nd component of the value
  32079. * @param z defines the 3rd component of the value
  32080. */
  32081. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32082. /**
  32083. * Set the value of an uniform to a boolean
  32084. * @param uniform defines the webGL uniform location where to store the value
  32085. * @param bool defines the boolean to store
  32086. */
  32087. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  32088. /**
  32089. * Set the value of an uniform to a vec4
  32090. * @param uniform defines the webGL uniform location where to store the value
  32091. * @param x defines the 1st component of the value
  32092. * @param y defines the 2nd component of the value
  32093. * @param z defines the 3rd component of the value
  32094. * @param w defines the 4th component of the value
  32095. */
  32096. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32097. /**
  32098. * Sets a Color4 on a uniform variable
  32099. * @param uniform defines the uniform location
  32100. * @param color4 defines the value to be set
  32101. */
  32102. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  32103. /**
  32104. * Set various states to the webGL context
  32105. * @param culling defines backface culling state
  32106. * @param zOffset defines the value to apply to zOffset (0 by default)
  32107. * @param force defines if states must be applied even if cache is up to date
  32108. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32109. */
  32110. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32111. /**
  32112. * Set the z offset to apply to current rendering
  32113. * @param value defines the offset to apply
  32114. */
  32115. setZOffset(value: number): void;
  32116. /**
  32117. * Gets the current value of the zOffset
  32118. * @returns the current zOffset state
  32119. */
  32120. getZOffset(): number;
  32121. /**
  32122. * Enable or disable depth buffering
  32123. * @param enable defines the state to set
  32124. */
  32125. setDepthBuffer(enable: boolean): void;
  32126. /**
  32127. * Gets a boolean indicating if depth writing is enabled
  32128. * @returns the current depth writing state
  32129. */
  32130. getDepthWrite(): boolean;
  32131. /**
  32132. * Enable or disable depth writing
  32133. * @param enable defines the state to set
  32134. */
  32135. setDepthWrite(enable: boolean): void;
  32136. /**
  32137. * Enable or disable color writing
  32138. * @param enable defines the state to set
  32139. */
  32140. setColorWrite(enable: boolean): void;
  32141. /**
  32142. * Gets a boolean indicating if color writing is enabled
  32143. * @returns the current color writing state
  32144. */
  32145. getColorWrite(): boolean;
  32146. /**
  32147. * Sets alpha constants used by some alpha blending modes
  32148. * @param r defines the red component
  32149. * @param g defines the green component
  32150. * @param b defines the blue component
  32151. * @param a defines the alpha component
  32152. */
  32153. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32154. /**
  32155. * Sets the current alpha mode
  32156. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32157. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32158. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32159. */
  32160. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32161. /**
  32162. * Gets the current alpha mode
  32163. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32164. * @returns the current alpha mode
  32165. */
  32166. getAlphaMode(): number;
  32167. /**
  32168. * Clears the list of texture accessible through engine.
  32169. * This can help preventing texture load conflict due to name collision.
  32170. */
  32171. clearInternalTexturesCache(): void;
  32172. /**
  32173. * Force the entire cache to be cleared
  32174. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32175. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32176. */
  32177. wipeCaches(bruteForce?: boolean): void;
  32178. /**
  32179. * Set the compressed texture format to use, based on the formats you have, and the formats
  32180. * supported by the hardware / browser.
  32181. *
  32182. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32183. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32184. * to API arguments needed to compressed textures. This puts the burden on the container
  32185. * generator to house the arcane code for determining these for current & future formats.
  32186. *
  32187. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32188. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32189. *
  32190. * Note: The result of this call is not taken into account when a texture is base64.
  32191. *
  32192. * @param formatsAvailable defines the list of those format families you have created
  32193. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32194. *
  32195. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32196. * @returns The extension selected.
  32197. */
  32198. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32199. /** @hidden */
  32200. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32201. min: number;
  32202. mag: number;
  32203. };
  32204. /** @hidden */
  32205. _createTexture(): WebGLTexture;
  32206. /**
  32207. * Usually called from Texture.ts.
  32208. * Passed information to create a WebGLTexture
  32209. * @param urlArg defines a value which contains one of the following:
  32210. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32211. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32212. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32213. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32214. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  32215. * @param scene needed for loading to the correct scene
  32216. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32217. * @param onLoad optional callback to be called upon successful completion
  32218. * @param onError optional callback to be called upon failure
  32219. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  32220. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32221. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32222. * @param forcedExtension defines the extension to use to pick the right loader
  32223. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32224. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32225. */
  32226. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32227. /**
  32228. * @hidden
  32229. * Rescales a texture
  32230. * @param source input texutre
  32231. * @param destination destination texture
  32232. * @param scene scene to use to render the resize
  32233. * @param internalFormat format to use when resizing
  32234. * @param onComplete callback to be called when resize has completed
  32235. */
  32236. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32237. private _unpackFlipYCached;
  32238. /**
  32239. * In case you are sharing the context with other applications, it might
  32240. * be interested to not cache the unpack flip y state to ensure a consistent
  32241. * value would be set.
  32242. */
  32243. enableUnpackFlipYCached: boolean;
  32244. /** @hidden */
  32245. _unpackFlipY(value: boolean): void;
  32246. /** @hidden */
  32247. _getUnpackAlignement(): number;
  32248. /**
  32249. * Creates a dynamic texture
  32250. * @param width defines the width of the texture
  32251. * @param height defines the height of the texture
  32252. * @param generateMipMaps defines if the engine should generate the mip levels
  32253. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32254. * @returns the dynamic texture inside an InternalTexture
  32255. */
  32256. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32257. /**
  32258. * Update the sampling mode of a given texture
  32259. * @param samplingMode defines the required sampling mode
  32260. * @param texture defines the texture to update
  32261. */
  32262. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32263. /**
  32264. * Update the content of a dynamic texture
  32265. * @param texture defines the texture to update
  32266. * @param canvas defines the canvas containing the source
  32267. * @param invertY defines if data must be stored with Y axis inverted
  32268. * @param premulAlpha defines if alpha is stored as premultiplied
  32269. * @param format defines the format of the data
  32270. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32271. */
  32272. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32273. /**
  32274. * Update a video texture
  32275. * @param texture defines the texture to update
  32276. * @param video defines the video element to use
  32277. * @param invertY defines if data must be stored with Y axis inverted
  32278. */
  32279. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32280. /**
  32281. * Updates a depth texture Comparison Mode and Function.
  32282. * If the comparison Function is equal to 0, the mode will be set to none.
  32283. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32284. * @param texture The texture to set the comparison function for
  32285. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32286. */
  32287. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32288. /** @hidden */
  32289. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32290. width: number;
  32291. height: number;
  32292. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32293. /**
  32294. * Creates a depth stencil texture.
  32295. * This is only available in WebGL 2 or with the depth texture extension available.
  32296. * @param size The size of face edge in the texture.
  32297. * @param options The options defining the texture.
  32298. * @returns The texture
  32299. */
  32300. createDepthStencilTexture(size: number | {
  32301. width: number;
  32302. height: number;
  32303. }, options: DepthTextureCreationOptions): InternalTexture;
  32304. /**
  32305. * Creates a depth stencil texture.
  32306. * This is only available in WebGL 2 or with the depth texture extension available.
  32307. * @param size The size of face edge in the texture.
  32308. * @param options The options defining the texture.
  32309. * @returns The texture
  32310. */
  32311. private _createDepthStencilTexture;
  32312. /**
  32313. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32314. * @param renderTarget The render target to set the frame buffer for
  32315. */
  32316. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32317. /**
  32318. * Creates a new render target texture
  32319. * @param size defines the size of the texture
  32320. * @param options defines the options used to create the texture
  32321. * @returns a new render target texture stored in an InternalTexture
  32322. */
  32323. createRenderTargetTexture(size: number | {
  32324. width: number;
  32325. height: number;
  32326. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32327. /** @hidden */
  32328. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32329. /**
  32330. * Updates the sample count of a render target texture
  32331. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32332. * @param texture defines the texture to update
  32333. * @param samples defines the sample count to set
  32334. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32335. */
  32336. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32337. /** @hidden */
  32338. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32339. /** @hidden */
  32340. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32341. /** @hidden */
  32342. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32343. /** @hidden */
  32344. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32345. /**
  32346. * @hidden
  32347. */
  32348. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32349. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32350. private _prepareWebGLTexture;
  32351. /** @hidden */
  32352. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32353. /** @hidden */
  32354. _releaseFramebufferObjects(texture: InternalTexture): void;
  32355. /** @hidden */
  32356. _releaseTexture(texture: InternalTexture): void;
  32357. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32358. protected _setProgram(program: WebGLProgram): void;
  32359. protected _boundUniforms: {
  32360. [key: number]: WebGLUniformLocation;
  32361. };
  32362. /**
  32363. * Binds an effect to the webGL context
  32364. * @param effect defines the effect to bind
  32365. */
  32366. bindSamplers(effect: Effect): void;
  32367. private _activateCurrentTexture;
  32368. /** @hidden */
  32369. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32370. /** @hidden */
  32371. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32372. /**
  32373. * Sets a texture to the webGL context from a postprocess
  32374. * @param channel defines the channel to use
  32375. * @param postProcess defines the source postprocess
  32376. */
  32377. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32378. /**
  32379. * Binds the output of the passed in post process to the texture channel specified
  32380. * @param channel The channel the texture should be bound to
  32381. * @param postProcess The post process which's output should be bound
  32382. */
  32383. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32384. /**
  32385. * Unbind all textures from the webGL context
  32386. */
  32387. unbindAllTextures(): void;
  32388. /**
  32389. * Sets a texture to the according uniform.
  32390. * @param channel The texture channel
  32391. * @param uniform The uniform to set
  32392. * @param texture The texture to apply
  32393. */
  32394. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32395. /**
  32396. * Sets a depth stencil texture from a render target to the according uniform.
  32397. * @param channel The texture channel
  32398. * @param uniform The uniform to set
  32399. * @param texture The render target texture containing the depth stencil texture to apply
  32400. */
  32401. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32402. private _bindSamplerUniformToChannel;
  32403. private _getTextureWrapMode;
  32404. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32405. /**
  32406. * Sets an array of texture to the webGL context
  32407. * @param channel defines the channel where the texture array must be set
  32408. * @param uniform defines the associated uniform location
  32409. * @param textures defines the array of textures to bind
  32410. */
  32411. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32412. /** @hidden */
  32413. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32414. private _setTextureParameterFloat;
  32415. private _setTextureParameterInteger;
  32416. /**
  32417. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32418. * @param x defines the x coordinate of the rectangle where pixels must be read
  32419. * @param y defines the y coordinate of the rectangle where pixels must be read
  32420. * @param width defines the width of the rectangle where pixels must be read
  32421. * @param height defines the height of the rectangle where pixels must be read
  32422. * @returns a Uint8Array containing RGBA colors
  32423. */
  32424. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32425. /**
  32426. * Add an externaly attached data from its key.
  32427. * This method call will fail and return false, if such key already exists.
  32428. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32429. * @param key the unique key that identifies the data
  32430. * @param data the data object to associate to the key for this Engine instance
  32431. * @return true if no such key were already present and the data was added successfully, false otherwise
  32432. */
  32433. addExternalData<T>(key: string, data: T): boolean;
  32434. /**
  32435. * Get an externaly attached data from its key
  32436. * @param key the unique key that identifies the data
  32437. * @return the associated data, if present (can be null), or undefined if not present
  32438. */
  32439. getExternalData<T>(key: string): T;
  32440. /**
  32441. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32442. * @param key the unique key that identifies the data
  32443. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32444. * @return the associated data, can be null if the factory returned null.
  32445. */
  32446. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32447. /**
  32448. * Remove an externaly attached data from the Engine instance
  32449. * @param key the unique key that identifies the data
  32450. * @return true if the data was successfully removed, false if it doesn't exist
  32451. */
  32452. removeExternalData(key: string): boolean;
  32453. /**
  32454. * Unbind all vertex attributes from the webGL context
  32455. */
  32456. unbindAllAttributes(): void;
  32457. /**
  32458. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  32459. */
  32460. releaseEffects(): void;
  32461. /**
  32462. * Dispose and release all associated resources
  32463. */
  32464. dispose(): void;
  32465. /**
  32466. * Display the loading screen
  32467. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32468. */
  32469. displayLoadingUI(): void;
  32470. /**
  32471. * Hide the loading screen
  32472. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32473. */
  32474. hideLoadingUI(): void;
  32475. /**
  32476. * Gets the current loading screen object
  32477. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32478. */
  32479. /**
  32480. * Sets the current loading screen object
  32481. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32482. */
  32483. loadingScreen: ILoadingScreen;
  32484. /**
  32485. * Sets the current loading screen text
  32486. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32487. */
  32488. loadingUIText: string;
  32489. /**
  32490. * Sets the current loading screen background color
  32491. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32492. */
  32493. loadingUIBackgroundColor: string;
  32494. /**
  32495. * Attach a new callback raised when context lost event is fired
  32496. * @param callback defines the callback to call
  32497. */
  32498. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32499. /**
  32500. * Attach a new callback raised when context restored event is fired
  32501. * @param callback defines the callback to call
  32502. */
  32503. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32504. /**
  32505. * Gets the source code of the vertex shader associated with a specific webGL program
  32506. * @param program defines the program to use
  32507. * @returns a string containing the source code of the vertex shader associated with the program
  32508. */
  32509. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32510. /**
  32511. * Gets the source code of the fragment shader associated with a specific webGL program
  32512. * @param program defines the program to use
  32513. * @returns a string containing the source code of the fragment shader associated with the program
  32514. */
  32515. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32516. /**
  32517. * Get the current error code of the webGL context
  32518. * @returns the error code
  32519. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32520. */
  32521. getError(): number;
  32522. /**
  32523. * Gets the current framerate
  32524. * @returns a number representing the framerate
  32525. */
  32526. getFps(): number;
  32527. /**
  32528. * Gets the time spent between current and previous frame
  32529. * @returns a number representing the delta time in ms
  32530. */
  32531. getDeltaTime(): number;
  32532. private _measureFps;
  32533. /** @hidden */
  32534. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32535. private _canRenderToFloatFramebuffer;
  32536. private _canRenderToHalfFloatFramebuffer;
  32537. private _canRenderToFramebuffer;
  32538. /** @hidden */
  32539. _getWebGLTextureType(type: number): number;
  32540. /** @hidden */
  32541. _getInternalFormat(format: number): number;
  32542. /** @hidden */
  32543. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32544. /** @hidden */
  32545. _getRGBAMultiSampleBufferFormat(type: number): number;
  32546. /** @hidden */
  32547. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  32548. /** @hidden */
  32549. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32550. /**
  32551. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32552. * @returns true if the engine can be created
  32553. * @ignorenaming
  32554. */
  32555. static isSupported(): boolean;
  32556. /**
  32557. * Find the next highest power of two.
  32558. * @param x Number to start search from.
  32559. * @return Next highest power of two.
  32560. */
  32561. static CeilingPOT(x: number): number;
  32562. /**
  32563. * Find the next lowest power of two.
  32564. * @param x Number to start search from.
  32565. * @return Next lowest power of two.
  32566. */
  32567. static FloorPOT(x: number): number;
  32568. /**
  32569. * Find the nearest power of two.
  32570. * @param x Number to start search from.
  32571. * @return Next nearest power of two.
  32572. */
  32573. static NearestPOT(x: number): number;
  32574. /**
  32575. * Get the closest exponent of two
  32576. * @param value defines the value to approximate
  32577. * @param max defines the maximum value to return
  32578. * @param mode defines how to define the closest value
  32579. * @returns closest exponent of two of the given value
  32580. */
  32581. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32582. /**
  32583. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32584. * @param func - the function to be called
  32585. * @param requester - the object that will request the next frame. Falls back to window.
  32586. * @returns frame number
  32587. */
  32588. static QueueNewFrame(func: () => void, requester?: any): number;
  32589. /**
  32590. * Ask the browser to promote the current element to pointerlock mode
  32591. * @param element defines the DOM element to promote
  32592. */
  32593. static _RequestPointerlock(element: HTMLElement): void;
  32594. /**
  32595. * Asks the browser to exit pointerlock mode
  32596. */
  32597. static _ExitPointerlock(): void;
  32598. /**
  32599. * Ask the browser to promote the current element to fullscreen rendering mode
  32600. * @param element defines the DOM element to promote
  32601. */
  32602. static _RequestFullscreen(element: HTMLElement): void;
  32603. /**
  32604. * Asks the browser to exit fullscreen mode
  32605. */
  32606. static _ExitFullscreen(): void;
  32607. }
  32608. }
  32609. declare module "babylonjs/Engines/engineStore" {
  32610. import { Nullable } from "babylonjs/types";
  32611. import { Engine } from "babylonjs/Engines/engine";
  32612. import { Scene } from "babylonjs/scene";
  32613. /**
  32614. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32615. * during the life time of the application.
  32616. */
  32617. export class EngineStore {
  32618. /** Gets the list of created engines */
  32619. static Instances: import("babylonjs/Engines/engine").Engine[];
  32620. /** @hidden */
  32621. static _LastCreatedScene: Nullable<Scene>;
  32622. /**
  32623. * Gets the latest created engine
  32624. */
  32625. static readonly LastCreatedEngine: Nullable<Engine>;
  32626. /**
  32627. * Gets the latest created scene
  32628. */
  32629. static readonly LastCreatedScene: Nullable<Scene>;
  32630. /**
  32631. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32632. * @ignorenaming
  32633. */
  32634. static UseFallbackTexture: boolean;
  32635. /**
  32636. * Texture content used if a texture cannot loaded
  32637. * @ignorenaming
  32638. */
  32639. static FallbackTexture: string;
  32640. }
  32641. }
  32642. declare module "babylonjs/Misc/promise" {
  32643. /**
  32644. * Helper class that provides a small promise polyfill
  32645. */
  32646. export class PromisePolyfill {
  32647. /**
  32648. * Static function used to check if the polyfill is required
  32649. * If this is the case then the function will inject the polyfill to window.Promise
  32650. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32651. */
  32652. static Apply(force?: boolean): void;
  32653. }
  32654. }
  32655. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32656. /**
  32657. * Interface for screenshot methods with describe argument called `size` as object with options
  32658. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32659. */
  32660. export interface IScreenshotSize {
  32661. /**
  32662. * number in pixels for canvas height
  32663. */
  32664. height?: number;
  32665. /**
  32666. * multiplier allowing render at a higher or lower resolution
  32667. * If value is defined then height and width will be ignored and taken from camera
  32668. */
  32669. precision?: number;
  32670. /**
  32671. * number in pixels for canvas width
  32672. */
  32673. width?: number;
  32674. }
  32675. }
  32676. declare module "babylonjs/Misc/tools" {
  32677. import { Nullable, float } from "babylonjs/types";
  32678. import { DomManagement } from "babylonjs/Misc/domManagement";
  32679. import { WebRequest } from "babylonjs/Misc/webRequest";
  32680. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32681. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32682. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32683. import { Camera } from "babylonjs/Cameras/camera";
  32684. import { Engine } from "babylonjs/Engines/engine";
  32685. interface IColor4Like {
  32686. r: float;
  32687. g: float;
  32688. b: float;
  32689. a: float;
  32690. }
  32691. /**
  32692. * Class containing a set of static utilities functions
  32693. */
  32694. export class Tools {
  32695. /**
  32696. * Gets or sets the base URL to use to load assets
  32697. */
  32698. static BaseUrl: string;
  32699. /**
  32700. * Enable/Disable Custom HTTP Request Headers globally.
  32701. * default = false
  32702. * @see CustomRequestHeaders
  32703. */
  32704. static UseCustomRequestHeaders: boolean;
  32705. /**
  32706. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32707. * i.e. when loading files, where the server/service expects an Authorization header
  32708. */
  32709. static CustomRequestHeaders: {
  32710. [key: string]: string;
  32711. };
  32712. /**
  32713. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32714. */
  32715. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32716. /**
  32717. * Default behaviour for cors in the application.
  32718. * It can be a string if the expected behavior is identical in the entire app.
  32719. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32720. */
  32721. static CorsBehavior: string | ((url: string | string[]) => string);
  32722. /**
  32723. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32724. * @ignorenaming
  32725. */
  32726. static UseFallbackTexture: boolean;
  32727. /**
  32728. * Use this object to register external classes like custom textures or material
  32729. * to allow the laoders to instantiate them
  32730. */
  32731. static RegisteredExternalClasses: {
  32732. [key: string]: Object;
  32733. };
  32734. /**
  32735. * Texture content used if a texture cannot loaded
  32736. * @ignorenaming
  32737. */
  32738. static fallbackTexture: string;
  32739. /**
  32740. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32741. * @param u defines the coordinate on X axis
  32742. * @param v defines the coordinate on Y axis
  32743. * @param width defines the width of the source data
  32744. * @param height defines the height of the source data
  32745. * @param pixels defines the source byte array
  32746. * @param color defines the output color
  32747. */
  32748. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32749. /**
  32750. * Interpolates between a and b via alpha
  32751. * @param a The lower value (returned when alpha = 0)
  32752. * @param b The upper value (returned when alpha = 1)
  32753. * @param alpha The interpolation-factor
  32754. * @return The mixed value
  32755. */
  32756. static Mix(a: number, b: number, alpha: number): number;
  32757. /**
  32758. * Tries to instantiate a new object from a given class name
  32759. * @param className defines the class name to instantiate
  32760. * @returns the new object or null if the system was not able to do the instantiation
  32761. */
  32762. static Instantiate(className: string): any;
  32763. /**
  32764. * Provides a slice function that will work even on IE
  32765. * @param data defines the array to slice
  32766. * @param start defines the start of the data (optional)
  32767. * @param end defines the end of the data (optional)
  32768. * @returns the new sliced array
  32769. */
  32770. static Slice<T>(data: T, start?: number, end?: number): T;
  32771. /**
  32772. * Polyfill for setImmediate
  32773. * @param action defines the action to execute after the current execution block
  32774. */
  32775. static SetImmediate(action: () => void): void;
  32776. /**
  32777. * Function indicating if a number is an exponent of 2
  32778. * @param value defines the value to test
  32779. * @returns true if the value is an exponent of 2
  32780. */
  32781. static IsExponentOfTwo(value: number): boolean;
  32782. private static _tmpFloatArray;
  32783. /**
  32784. * Returns the nearest 32-bit single precision float representation of a Number
  32785. * @param value A Number. If the parameter is of a different type, it will get converted
  32786. * to a number or to NaN if it cannot be converted
  32787. * @returns number
  32788. */
  32789. static FloatRound(value: number): number;
  32790. /**
  32791. * Extracts the filename from a path
  32792. * @param path defines the path to use
  32793. * @returns the filename
  32794. */
  32795. static GetFilename(path: string): string;
  32796. /**
  32797. * Extracts the "folder" part of a path (everything before the filename).
  32798. * @param uri The URI to extract the info from
  32799. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32800. * @returns The "folder" part of the path
  32801. */
  32802. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32803. /**
  32804. * Extracts text content from a DOM element hierarchy
  32805. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32806. */
  32807. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32808. /**
  32809. * Convert an angle in radians to degrees
  32810. * @param angle defines the angle to convert
  32811. * @returns the angle in degrees
  32812. */
  32813. static ToDegrees(angle: number): number;
  32814. /**
  32815. * Convert an angle in degrees to radians
  32816. * @param angle defines the angle to convert
  32817. * @returns the angle in radians
  32818. */
  32819. static ToRadians(angle: number): number;
  32820. /**
  32821. * Encode a buffer to a base64 string
  32822. * @param buffer defines the buffer to encode
  32823. * @returns the encoded string
  32824. */
  32825. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32826. /**
  32827. * Returns an array if obj is not an array
  32828. * @param obj defines the object to evaluate as an array
  32829. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32830. * @returns either obj directly if obj is an array or a new array containing obj
  32831. */
  32832. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32833. /**
  32834. * Gets the pointer prefix to use
  32835. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32836. */
  32837. static GetPointerPrefix(): string;
  32838. /**
  32839. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32840. * @param url define the url we are trying
  32841. * @param element define the dom element where to configure the cors policy
  32842. */
  32843. static SetCorsBehavior(url: string | string[], element: {
  32844. crossOrigin: string | null;
  32845. }): void;
  32846. /**
  32847. * Removes unwanted characters from an url
  32848. * @param url defines the url to clean
  32849. * @returns the cleaned url
  32850. */
  32851. static CleanUrl(url: string): string;
  32852. /**
  32853. * Gets or sets a function used to pre-process url before using them to load assets
  32854. */
  32855. static PreprocessUrl: (url: string) => string;
  32856. /**
  32857. * Loads an image as an HTMLImageElement.
  32858. * @param input url string, ArrayBuffer, or Blob to load
  32859. * @param onLoad callback called when the image successfully loads
  32860. * @param onError callback called when the image fails to load
  32861. * @param offlineProvider offline provider for caching
  32862. * @returns the HTMLImageElement of the loaded image
  32863. */
  32864. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32865. /**
  32866. * Loads a file
  32867. * @param url url string, ArrayBuffer, or Blob to load
  32868. * @param onSuccess callback called when the file successfully loads
  32869. * @param onProgress callback called while file is loading (if the server supports this mode)
  32870. * @param offlineProvider defines the offline provider for caching
  32871. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32872. * @param onError callback called when the file fails to load
  32873. * @returns a file request object
  32874. */
  32875. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  32876. /**
  32877. * Loads a file from a url
  32878. * @param url the file url to load
  32879. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32880. */
  32881. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32882. /**
  32883. * Load a script (identified by an url). When the url returns, the
  32884. * content of this file is added into a new script element, attached to the DOM (body element)
  32885. * @param scriptUrl defines the url of the script to laod
  32886. * @param onSuccess defines the callback called when the script is loaded
  32887. * @param onError defines the callback to call if an error occurs
  32888. * @param scriptId defines the id of the script element
  32889. */
  32890. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32891. /**
  32892. * Load an asynchronous script (identified by an url). When the url returns, the
  32893. * content of this file is added into a new script element, attached to the DOM (body element)
  32894. * @param scriptUrl defines the url of the script to laod
  32895. * @param scriptId defines the id of the script element
  32896. * @returns a promise request object
  32897. */
  32898. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32899. /**
  32900. * Loads a file from a blob
  32901. * @param fileToLoad defines the blob to use
  32902. * @param callback defines the callback to call when data is loaded
  32903. * @param progressCallback defines the callback to call during loading process
  32904. * @returns a file request object
  32905. */
  32906. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32907. /**
  32908. * Loads a file
  32909. * @param fileToLoad defines the file to load
  32910. * @param callback defines the callback to call when data is loaded
  32911. * @param progressCallBack defines the callback to call during loading process
  32912. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32913. * @returns a file request object
  32914. */
  32915. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32916. /**
  32917. * Creates a data url from a given string content
  32918. * @param content defines the content to convert
  32919. * @returns the new data url link
  32920. */
  32921. static FileAsURL(content: string): string;
  32922. /**
  32923. * Format the given number to a specific decimal format
  32924. * @param value defines the number to format
  32925. * @param decimals defines the number of decimals to use
  32926. * @returns the formatted string
  32927. */
  32928. static Format(value: number, decimals?: number): string;
  32929. /**
  32930. * Tries to copy an object by duplicating every property
  32931. * @param source defines the source object
  32932. * @param destination defines the target object
  32933. * @param doNotCopyList defines a list of properties to avoid
  32934. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32935. */
  32936. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32937. /**
  32938. * Gets a boolean indicating if the given object has no own property
  32939. * @param obj defines the object to test
  32940. * @returns true if object has no own property
  32941. */
  32942. static IsEmpty(obj: any): boolean;
  32943. /**
  32944. * Function used to register events at window level
  32945. * @param windowElement defines the Window object to use
  32946. * @param events defines the events to register
  32947. */
  32948. static RegisterTopRootEvents(windowElement: Window, events: {
  32949. name: string;
  32950. handler: Nullable<(e: FocusEvent) => any>;
  32951. }[]): void;
  32952. /**
  32953. * Function used to unregister events from window level
  32954. * @param windowElement defines the Window object to use
  32955. * @param events defines the events to unregister
  32956. */
  32957. static UnregisterTopRootEvents(windowElement: Window, events: {
  32958. name: string;
  32959. handler: Nullable<(e: FocusEvent) => any>;
  32960. }[]): void;
  32961. /**
  32962. * @ignore
  32963. */
  32964. static _ScreenshotCanvas: HTMLCanvasElement;
  32965. /**
  32966. * Dumps the current bound framebuffer
  32967. * @param width defines the rendering width
  32968. * @param height defines the rendering height
  32969. * @param engine defines the hosting engine
  32970. * @param successCallback defines the callback triggered once the data are available
  32971. * @param mimeType defines the mime type of the result
  32972. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32973. */
  32974. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32975. /**
  32976. * Converts the canvas data to blob.
  32977. * This acts as a polyfill for browsers not supporting the to blob function.
  32978. * @param canvas Defines the canvas to extract the data from
  32979. * @param successCallback Defines the callback triggered once the data are available
  32980. * @param mimeType Defines the mime type of the result
  32981. */
  32982. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32983. /**
  32984. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32985. * @param successCallback defines the callback triggered once the data are available
  32986. * @param mimeType defines the mime type of the result
  32987. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32988. */
  32989. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32990. /**
  32991. * Downloads a blob in the browser
  32992. * @param blob defines the blob to download
  32993. * @param fileName defines the name of the downloaded file
  32994. */
  32995. static Download(blob: Blob, fileName: string): void;
  32996. /**
  32997. * Captures a screenshot of the current rendering
  32998. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32999. * @param engine defines the rendering engine
  33000. * @param camera defines the source camera
  33001. * @param size This parameter can be set to a single number or to an object with the
  33002. * following (optional) properties: precision, width, height. If a single number is passed,
  33003. * it will be used for both width and height. If an object is passed, the screenshot size
  33004. * will be derived from the parameters. The precision property is a multiplier allowing
  33005. * rendering at a higher or lower resolution
  33006. * @param successCallback defines the callback receives a single parameter which contains the
  33007. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33008. * src parameter of an <img> to display it
  33009. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33010. * Check your browser for supported MIME types
  33011. */
  33012. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33013. /**
  33014. * Captures a screenshot of the current rendering
  33015. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33016. * @param engine defines the rendering engine
  33017. * @param camera defines the source camera
  33018. * @param size This parameter can be set to a single number or to an object with the
  33019. * following (optional) properties: precision, width, height. If a single number is passed,
  33020. * it will be used for both width and height. If an object is passed, the screenshot size
  33021. * will be derived from the parameters. The precision property is a multiplier allowing
  33022. * rendering at a higher or lower resolution
  33023. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33024. * Check your browser for supported MIME types
  33025. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33026. * to the src parameter of an <img> to display it
  33027. */
  33028. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33029. /**
  33030. * Generates an image screenshot from the specified camera.
  33031. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33032. * @param engine The engine to use for rendering
  33033. * @param camera The camera to use for rendering
  33034. * @param size This parameter can be set to a single number or to an object with the
  33035. * following (optional) properties: precision, width, height. If a single number is passed,
  33036. * it will be used for both width and height. If an object is passed, the screenshot size
  33037. * will be derived from the parameters. The precision property is a multiplier allowing
  33038. * rendering at a higher or lower resolution
  33039. * @param successCallback The callback receives a single parameter which contains the
  33040. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33041. * src parameter of an <img> to display it
  33042. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33043. * Check your browser for supported MIME types
  33044. * @param samples Texture samples (default: 1)
  33045. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33046. * @param fileName A name for for the downloaded file.
  33047. */
  33048. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33049. /**
  33050. * Generates an image screenshot from the specified camera.
  33051. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33052. * @param engine The engine to use for rendering
  33053. * @param camera The camera to use for rendering
  33054. * @param size This parameter can be set to a single number or to an object with the
  33055. * following (optional) properties: precision, width, height. If a single number is passed,
  33056. * it will be used for both width and height. If an object is passed, the screenshot size
  33057. * will be derived from the parameters. The precision property is a multiplier allowing
  33058. * rendering at a higher or lower resolution
  33059. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33060. * Check your browser for supported MIME types
  33061. * @param samples Texture samples (default: 1)
  33062. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33063. * @param fileName A name for for the downloaded file.
  33064. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33065. * to the src parameter of an <img> to display it
  33066. */
  33067. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33068. /**
  33069. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33070. * Be aware Math.random() could cause collisions, but:
  33071. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  33072. * @returns a pseudo random id
  33073. */
  33074. static RandomId(): string;
  33075. /**
  33076. * Test if the given uri is a base64 string
  33077. * @param uri The uri to test
  33078. * @return True if the uri is a base64 string or false otherwise
  33079. */
  33080. static IsBase64(uri: string): boolean;
  33081. /**
  33082. * Decode the given base64 uri.
  33083. * @param uri The uri to decode
  33084. * @return The decoded base64 data.
  33085. */
  33086. static DecodeBase64(uri: string): ArrayBuffer;
  33087. /**
  33088. * Gets the absolute url.
  33089. * @param url the input url
  33090. * @return the absolute url
  33091. */
  33092. static GetAbsoluteUrl(url: string): string;
  33093. /**
  33094. * No log
  33095. */
  33096. static readonly NoneLogLevel: number;
  33097. /**
  33098. * Only message logs
  33099. */
  33100. static readonly MessageLogLevel: number;
  33101. /**
  33102. * Only warning logs
  33103. */
  33104. static readonly WarningLogLevel: number;
  33105. /**
  33106. * Only error logs
  33107. */
  33108. static readonly ErrorLogLevel: number;
  33109. /**
  33110. * All logs
  33111. */
  33112. static readonly AllLogLevel: number;
  33113. /**
  33114. * Gets a value indicating the number of loading errors
  33115. * @ignorenaming
  33116. */
  33117. static readonly errorsCount: number;
  33118. /**
  33119. * Callback called when a new log is added
  33120. */
  33121. static OnNewCacheEntry: (entry: string) => void;
  33122. /**
  33123. * Log a message to the console
  33124. * @param message defines the message to log
  33125. */
  33126. static Log(message: string): void;
  33127. /**
  33128. * Write a warning message to the console
  33129. * @param message defines the message to log
  33130. */
  33131. static Warn(message: string): void;
  33132. /**
  33133. * Write an error message to the console
  33134. * @param message defines the message to log
  33135. */
  33136. static Error(message: string): void;
  33137. /**
  33138. * Gets current log cache (list of logs)
  33139. */
  33140. static readonly LogCache: string;
  33141. /**
  33142. * Clears the log cache
  33143. */
  33144. static ClearLogCache(): void;
  33145. /**
  33146. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33147. */
  33148. static LogLevels: number;
  33149. /**
  33150. * Checks if the window object exists
  33151. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33152. */
  33153. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33154. /**
  33155. * No performance log
  33156. */
  33157. static readonly PerformanceNoneLogLevel: number;
  33158. /**
  33159. * Use user marks to log performance
  33160. */
  33161. static readonly PerformanceUserMarkLogLevel: number;
  33162. /**
  33163. * Log performance to the console
  33164. */
  33165. static readonly PerformanceConsoleLogLevel: number;
  33166. private static _performance;
  33167. /**
  33168. * Sets the current performance log level
  33169. */
  33170. static PerformanceLogLevel: number;
  33171. private static _StartPerformanceCounterDisabled;
  33172. private static _EndPerformanceCounterDisabled;
  33173. private static _StartUserMark;
  33174. private static _EndUserMark;
  33175. private static _StartPerformanceConsole;
  33176. private static _EndPerformanceConsole;
  33177. /**
  33178. * Starts a performance counter
  33179. */
  33180. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33181. /**
  33182. * Ends a specific performance coutner
  33183. */
  33184. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33185. /**
  33186. * Gets either window.performance.now() if supported or Date.now() else
  33187. */
  33188. static readonly Now: number;
  33189. /**
  33190. * This method will return the name of the class used to create the instance of the given object.
  33191. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33192. * @param object the object to get the class name from
  33193. * @param isType defines if the object is actually a type
  33194. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33195. */
  33196. static GetClassName(object: any, isType?: boolean): string;
  33197. /**
  33198. * Gets the first element of an array satisfying a given predicate
  33199. * @param array defines the array to browse
  33200. * @param predicate defines the predicate to use
  33201. * @returns null if not found or the element
  33202. */
  33203. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33204. /**
  33205. * This method will return the name of the full name of the class, including its owning module (if any).
  33206. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).
  33207. * @param object the object to get the class name from
  33208. * @param isType defines if the object is actually a type
  33209. * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.
  33210. * @ignorenaming
  33211. */
  33212. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33213. /**
  33214. * Returns a promise that resolves after the given amount of time.
  33215. * @param delay Number of milliseconds to delay
  33216. * @returns Promise that resolves after the given amount of time
  33217. */
  33218. static DelayAsync(delay: number): Promise<void>;
  33219. }
  33220. /**
  33221. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33222. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33223. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33224. * @param name The name of the class, case should be preserved
  33225. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33226. */
  33227. export function className(name: string, module?: string): (target: Object) => void;
  33228. /**
  33229. * An implementation of a loop for asynchronous functions.
  33230. */
  33231. export class AsyncLoop {
  33232. /**
  33233. * Defines the number of iterations for the loop
  33234. */
  33235. iterations: number;
  33236. /**
  33237. * Defines the current index of the loop.
  33238. */
  33239. index: number;
  33240. private _done;
  33241. private _fn;
  33242. private _successCallback;
  33243. /**
  33244. * Constructor.
  33245. * @param iterations the number of iterations.
  33246. * @param func the function to run each iteration
  33247. * @param successCallback the callback that will be called upon succesful execution
  33248. * @param offset starting offset.
  33249. */
  33250. constructor(
  33251. /**
  33252. * Defines the number of iterations for the loop
  33253. */
  33254. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33255. /**
  33256. * Execute the next iteration. Must be called after the last iteration was finished.
  33257. */
  33258. executeNext(): void;
  33259. /**
  33260. * Break the loop and run the success callback.
  33261. */
  33262. breakLoop(): void;
  33263. /**
  33264. * Create and run an async loop.
  33265. * @param iterations the number of iterations.
  33266. * @param fn the function to run each iteration
  33267. * @param successCallback the callback that will be called upon succesful execution
  33268. * @param offset starting offset.
  33269. * @returns the created async loop object
  33270. */
  33271. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33272. /**
  33273. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33274. * @param iterations total number of iterations
  33275. * @param syncedIterations number of synchronous iterations in each async iteration.
  33276. * @param fn the function to call each iteration.
  33277. * @param callback a success call back that will be called when iterating stops.
  33278. * @param breakFunction a break condition (optional)
  33279. * @param timeout timeout settings for the setTimeout function. default - 0.
  33280. * @returns the created async loop object
  33281. */
  33282. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33283. }
  33284. }
  33285. declare module "babylonjs/Collisions/collisionCoordinator" {
  33286. import { Nullable } from "babylonjs/types";
  33287. import { Scene } from "babylonjs/scene";
  33288. import { Vector3 } from "babylonjs/Maths/math.vector";
  33289. import { Collider } from "babylonjs/Collisions/collider";
  33290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33291. /** @hidden */
  33292. export interface ICollisionCoordinator {
  33293. createCollider(): Collider;
  33294. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33295. init(scene: Scene): void;
  33296. }
  33297. /** @hidden */
  33298. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33299. private _scene;
  33300. private _scaledPosition;
  33301. private _scaledVelocity;
  33302. private _finalPosition;
  33303. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33304. createCollider(): Collider;
  33305. init(scene: Scene): void;
  33306. private _collideWithWorld;
  33307. }
  33308. }
  33309. declare module "babylonjs/Inputs/scene.inputManager" {
  33310. import { Nullable } from "babylonjs/types";
  33311. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33312. import { Vector2 } from "babylonjs/Maths/math.vector";
  33313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33314. import { Scene } from "babylonjs/scene";
  33315. /**
  33316. * Class used to manage all inputs for the scene.
  33317. */
  33318. export class InputManager {
  33319. /** The distance in pixel that you have to move to prevent some events */
  33320. static DragMovementThreshold: number;
  33321. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33322. static LongPressDelay: number;
  33323. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33324. static DoubleClickDelay: number;
  33325. /** If you need to check double click without raising a single click at first click, enable this flag */
  33326. static ExclusiveDoubleClickMode: boolean;
  33327. private _wheelEventName;
  33328. private _onPointerMove;
  33329. private _onPointerDown;
  33330. private _onPointerUp;
  33331. private _initClickEvent;
  33332. private _initActionManager;
  33333. private _delayedSimpleClick;
  33334. private _delayedSimpleClickTimeout;
  33335. private _previousDelayedSimpleClickTimeout;
  33336. private _meshPickProceed;
  33337. private _previousButtonPressed;
  33338. private _currentPickResult;
  33339. private _previousPickResult;
  33340. private _totalPointersPressed;
  33341. private _doubleClickOccured;
  33342. private _pointerOverMesh;
  33343. private _pickedDownMesh;
  33344. private _pickedUpMesh;
  33345. private _pointerX;
  33346. private _pointerY;
  33347. private _unTranslatedPointerX;
  33348. private _unTranslatedPointerY;
  33349. private _startingPointerPosition;
  33350. private _previousStartingPointerPosition;
  33351. private _startingPointerTime;
  33352. private _previousStartingPointerTime;
  33353. private _pointerCaptures;
  33354. private _onKeyDown;
  33355. private _onKeyUp;
  33356. private _onCanvasFocusObserver;
  33357. private _onCanvasBlurObserver;
  33358. private _scene;
  33359. /**
  33360. * Creates a new InputManager
  33361. * @param scene defines the hosting scene
  33362. */
  33363. constructor(scene: Scene);
  33364. /**
  33365. * Gets the mesh that is currently under the pointer
  33366. */
  33367. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33368. /**
  33369. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33370. */
  33371. readonly unTranslatedPointer: Vector2;
  33372. /**
  33373. * Gets or sets the current on-screen X position of the pointer
  33374. */
  33375. pointerX: number;
  33376. /**
  33377. * Gets or sets the current on-screen Y position of the pointer
  33378. */
  33379. pointerY: number;
  33380. private _updatePointerPosition;
  33381. private _processPointerMove;
  33382. private _setRayOnPointerInfo;
  33383. private _checkPrePointerObservable;
  33384. /**
  33385. * Use this method to simulate a pointer move on a mesh
  33386. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33387. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33388. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33389. */
  33390. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33391. /**
  33392. * Use this method to simulate a pointer down on a mesh
  33393. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33394. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33395. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33396. */
  33397. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33398. private _processPointerDown;
  33399. /** @hidden */
  33400. _isPointerSwiping(): boolean;
  33401. /**
  33402. * Use this method to simulate a pointer up on a mesh
  33403. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33404. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33405. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33406. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33407. */
  33408. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33409. private _processPointerUp;
  33410. /**
  33411. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33412. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33413. * @returns true if the pointer was captured
  33414. */
  33415. isPointerCaptured(pointerId?: number): boolean;
  33416. /**
  33417. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33418. * @param attachUp defines if you want to attach events to pointerup
  33419. * @param attachDown defines if you want to attach events to pointerdown
  33420. * @param attachMove defines if you want to attach events to pointermove
  33421. */
  33422. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33423. /**
  33424. * Detaches all event handlers
  33425. */
  33426. detachControl(): void;
  33427. /**
  33428. * Force the value of meshUnderPointer
  33429. * @param mesh defines the mesh to use
  33430. */
  33431. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33432. /**
  33433. * Gets the mesh under the pointer
  33434. * @returns a Mesh or null if no mesh is under the pointer
  33435. */
  33436. getPointerOverMesh(): Nullable<AbstractMesh>;
  33437. }
  33438. }
  33439. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33440. /**
  33441. * Helper class used to generate session unique ID
  33442. */
  33443. export class UniqueIdGenerator {
  33444. private static _UniqueIdCounter;
  33445. /**
  33446. * Gets an unique (relatively to the current scene) Id
  33447. */
  33448. static readonly UniqueId: number;
  33449. }
  33450. }
  33451. declare module "babylonjs/Animations/animationGroup" {
  33452. import { Animatable } from "babylonjs/Animations/animatable";
  33453. import { Animation } from "babylonjs/Animations/animation";
  33454. import { Scene, IDisposable } from "babylonjs/scene";
  33455. import { Observable } from "babylonjs/Misc/observable";
  33456. import { Nullable } from "babylonjs/types";
  33457. import "babylonjs/Animations/animatable";
  33458. /**
  33459. * This class defines the direct association between an animation and a target
  33460. */
  33461. export class TargetedAnimation {
  33462. /**
  33463. * Animation to perform
  33464. */
  33465. animation: Animation;
  33466. /**
  33467. * Target to animate
  33468. */
  33469. target: any;
  33470. /**
  33471. * Serialize the object
  33472. * @returns the JSON object representing the current entity
  33473. */
  33474. serialize(): any;
  33475. }
  33476. /**
  33477. * Use this class to create coordinated animations on multiple targets
  33478. */
  33479. export class AnimationGroup implements IDisposable {
  33480. /** The name of the animation group */
  33481. name: string;
  33482. private _scene;
  33483. private _targetedAnimations;
  33484. private _animatables;
  33485. private _from;
  33486. private _to;
  33487. private _isStarted;
  33488. private _isPaused;
  33489. private _speedRatio;
  33490. private _loopAnimation;
  33491. /**
  33492. * Gets or sets the unique id of the node
  33493. */
  33494. uniqueId: number;
  33495. /**
  33496. * This observable will notify when one animation have ended
  33497. */
  33498. onAnimationEndObservable: Observable<TargetedAnimation>;
  33499. /**
  33500. * Observer raised when one animation loops
  33501. */
  33502. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33503. /**
  33504. * This observable will notify when all animations have ended.
  33505. */
  33506. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33507. /**
  33508. * This observable will notify when all animations have paused.
  33509. */
  33510. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33511. /**
  33512. * This observable will notify when all animations are playing.
  33513. */
  33514. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33515. /**
  33516. * Gets the first frame
  33517. */
  33518. readonly from: number;
  33519. /**
  33520. * Gets the last frame
  33521. */
  33522. readonly to: number;
  33523. /**
  33524. * Define if the animations are started
  33525. */
  33526. readonly isStarted: boolean;
  33527. /**
  33528. * Gets a value indicating that the current group is playing
  33529. */
  33530. readonly isPlaying: boolean;
  33531. /**
  33532. * Gets or sets the speed ratio to use for all animations
  33533. */
  33534. /**
  33535. * Gets or sets the speed ratio to use for all animations
  33536. */
  33537. speedRatio: number;
  33538. /**
  33539. * Gets or sets if all animations should loop or not
  33540. */
  33541. loopAnimation: boolean;
  33542. /**
  33543. * Gets the targeted animations for this animation group
  33544. */
  33545. readonly targetedAnimations: Array<TargetedAnimation>;
  33546. /**
  33547. * returning the list of animatables controlled by this animation group.
  33548. */
  33549. readonly animatables: Array<Animatable>;
  33550. /**
  33551. * Instantiates a new Animation Group.
  33552. * This helps managing several animations at once.
  33553. * @see http://doc.babylonjs.com/how_to/group
  33554. * @param name Defines the name of the group
  33555. * @param scene Defines the scene the group belongs to
  33556. */
  33557. constructor(
  33558. /** The name of the animation group */
  33559. name: string, scene?: Nullable<Scene>);
  33560. /**
  33561. * Add an animation (with its target) in the group
  33562. * @param animation defines the animation we want to add
  33563. * @param target defines the target of the animation
  33564. * @returns the TargetedAnimation object
  33565. */
  33566. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33567. /**
  33568. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33569. * It can add constant keys at begin or end
  33570. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33571. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33572. * @returns the animation group
  33573. */
  33574. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33575. /**
  33576. * Start all animations on given targets
  33577. * @param loop defines if animations must loop
  33578. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33579. * @param from defines the from key (optional)
  33580. * @param to defines the to key (optional)
  33581. * @returns the current animation group
  33582. */
  33583. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33584. /**
  33585. * Pause all animations
  33586. * @returns the animation group
  33587. */
  33588. pause(): AnimationGroup;
  33589. /**
  33590. * Play all animations to initial state
  33591. * This function will start() the animations if they were not started or will restart() them if they were paused
  33592. * @param loop defines if animations must loop
  33593. * @returns the animation group
  33594. */
  33595. play(loop?: boolean): AnimationGroup;
  33596. /**
  33597. * Reset all animations to initial state
  33598. * @returns the animation group
  33599. */
  33600. reset(): AnimationGroup;
  33601. /**
  33602. * Restart animations from key 0
  33603. * @returns the animation group
  33604. */
  33605. restart(): AnimationGroup;
  33606. /**
  33607. * Stop all animations
  33608. * @returns the animation group
  33609. */
  33610. stop(): AnimationGroup;
  33611. /**
  33612. * Set animation weight for all animatables
  33613. * @param weight defines the weight to use
  33614. * @return the animationGroup
  33615. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33616. */
  33617. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33618. /**
  33619. * Synchronize and normalize all animatables with a source animatable
  33620. * @param root defines the root animatable to synchronize with
  33621. * @return the animationGroup
  33622. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33623. */
  33624. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33625. /**
  33626. * Goes to a specific frame in this animation group
  33627. * @param frame the frame number to go to
  33628. * @return the animationGroup
  33629. */
  33630. goToFrame(frame: number): AnimationGroup;
  33631. /**
  33632. * Dispose all associated resources
  33633. */
  33634. dispose(): void;
  33635. private _checkAnimationGroupEnded;
  33636. /**
  33637. * Clone the current animation group and returns a copy
  33638. * @param newName defines the name of the new group
  33639. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33640. * @returns the new aniamtion group
  33641. */
  33642. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33643. /**
  33644. * Serializes the animationGroup to an object
  33645. * @returns Serialized object
  33646. */
  33647. serialize(): any;
  33648. /**
  33649. * Returns a new AnimationGroup object parsed from the source provided.
  33650. * @param parsedAnimationGroup defines the source
  33651. * @param scene defines the scene that will receive the animationGroup
  33652. * @returns a new AnimationGroup
  33653. */
  33654. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33655. /**
  33656. * Returns the string "AnimationGroup"
  33657. * @returns "AnimationGroup"
  33658. */
  33659. getClassName(): string;
  33660. /**
  33661. * Creates a detailled string about the object
  33662. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33663. * @returns a string representing the object
  33664. */
  33665. toString(fullDetails?: boolean): string;
  33666. }
  33667. }
  33668. declare module "babylonjs/scene" {
  33669. import { Nullable } from "babylonjs/types";
  33670. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33671. import { Observable } from "babylonjs/Misc/observable";
  33672. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33673. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33674. import { Geometry } from "babylonjs/Meshes/geometry";
  33675. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33676. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33678. import { Mesh } from "babylonjs/Meshes/mesh";
  33679. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33680. import { Bone } from "babylonjs/Bones/bone";
  33681. import { Skeleton } from "babylonjs/Bones/skeleton";
  33682. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33683. import { Camera } from "babylonjs/Cameras/camera";
  33684. import { AbstractScene } from "babylonjs/abstractScene";
  33685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33686. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33687. import { Material } from "babylonjs/Materials/material";
  33688. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33689. import { Effect } from "babylonjs/Materials/effect";
  33690. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33691. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33692. import { Light } from "babylonjs/Lights/light";
  33693. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33694. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33695. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33696. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33697. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33698. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33699. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33700. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33701. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33702. import { Engine } from "babylonjs/Engines/engine";
  33703. import { Node } from "babylonjs/node";
  33704. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33705. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33706. import { WebRequest } from "babylonjs/Misc/webRequest";
  33707. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33708. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33709. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33710. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33711. import { Plane } from "babylonjs/Maths/math.plane";
  33712. import { Ray } from "babylonjs/Culling/ray";
  33713. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33714. import { Animation } from "babylonjs/Animations/animation";
  33715. import { Animatable } from "babylonjs/Animations/animatable";
  33716. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33717. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33718. import { Collider } from "babylonjs/Collisions/collider";
  33719. /**
  33720. * Define an interface for all classes that will hold resources
  33721. */
  33722. export interface IDisposable {
  33723. /**
  33724. * Releases all held resources
  33725. */
  33726. dispose(): void;
  33727. }
  33728. /** Interface defining initialization parameters for Scene class */
  33729. export interface SceneOptions {
  33730. /**
  33731. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33732. * It will improve performance when the number of geometries becomes important.
  33733. */
  33734. useGeometryUniqueIdsMap?: boolean;
  33735. /**
  33736. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33737. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33738. */
  33739. useMaterialMeshMap?: boolean;
  33740. /**
  33741. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33742. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33743. */
  33744. useClonedMeshhMap?: boolean;
  33745. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33746. virtual?: boolean;
  33747. }
  33748. /**
  33749. * Represents a scene to be rendered by the engine.
  33750. * @see http://doc.babylonjs.com/features/scene
  33751. */
  33752. export class Scene extends AbstractScene implements IAnimatable {
  33753. /** The fog is deactivated */
  33754. static readonly FOGMODE_NONE: number;
  33755. /** The fog density is following an exponential function */
  33756. static readonly FOGMODE_EXP: number;
  33757. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33758. static readonly FOGMODE_EXP2: number;
  33759. /** The fog density is following a linear function. */
  33760. static readonly FOGMODE_LINEAR: number;
  33761. /**
  33762. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33763. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33764. */
  33765. static MinDeltaTime: number;
  33766. /**
  33767. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33768. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33769. */
  33770. static MaxDeltaTime: number;
  33771. /**
  33772. * Factory used to create the default material.
  33773. * @param name The name of the material to create
  33774. * @param scene The scene to create the material for
  33775. * @returns The default material
  33776. */
  33777. static DefaultMaterialFactory(scene: Scene): Material;
  33778. /**
  33779. * Factory used to create the a collision coordinator.
  33780. * @returns The collision coordinator
  33781. */
  33782. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33783. /** @hidden */
  33784. _inputManager: InputManager;
  33785. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33786. cameraToUseForPointers: Nullable<Camera>;
  33787. /** @hidden */
  33788. readonly _isScene: boolean;
  33789. /**
  33790. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33791. */
  33792. autoClear: boolean;
  33793. /**
  33794. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33795. */
  33796. autoClearDepthAndStencil: boolean;
  33797. /**
  33798. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33799. */
  33800. clearColor: Color4;
  33801. /**
  33802. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33803. */
  33804. ambientColor: Color3;
  33805. /**
  33806. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33807. * It should only be one of the following (if not the default embedded one):
  33808. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33809. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33810. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33811. * The material properties need to be setup according to the type of texture in use.
  33812. */
  33813. environmentBRDFTexture: BaseTexture;
  33814. /** @hidden */
  33815. protected _environmentTexture: Nullable<BaseTexture>;
  33816. /**
  33817. * Texture used in all pbr material as the reflection texture.
  33818. * As in the majority of the scene they are the same (exception for multi room and so on),
  33819. * this is easier to reference from here than from all the materials.
  33820. */
  33821. /**
  33822. * Texture used in all pbr material as the reflection texture.
  33823. * As in the majority of the scene they are the same (exception for multi room and so on),
  33824. * this is easier to set here than in all the materials.
  33825. */
  33826. environmentTexture: Nullable<BaseTexture>;
  33827. /** @hidden */
  33828. protected _environmentIntensity: number;
  33829. /**
  33830. * Intensity of the environment in all pbr material.
  33831. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33832. * As in the majority of the scene they are the same (exception for multi room and so on),
  33833. * this is easier to reference from here than from all the materials.
  33834. */
  33835. /**
  33836. * Intensity of the environment in all pbr material.
  33837. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33838. * As in the majority of the scene they are the same (exception for multi room and so on),
  33839. * this is easier to set here than in all the materials.
  33840. */
  33841. environmentIntensity: number;
  33842. /** @hidden */
  33843. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33844. /**
  33845. * Default image processing configuration used either in the rendering
  33846. * Forward main pass or through the imageProcessingPostProcess if present.
  33847. * As in the majority of the scene they are the same (exception for multi camera),
  33848. * this is easier to reference from here than from all the materials and post process.
  33849. *
  33850. * No setter as we it is a shared configuration, you can set the values instead.
  33851. */
  33852. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33853. private _forceWireframe;
  33854. /**
  33855. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33856. */
  33857. forceWireframe: boolean;
  33858. private _forcePointsCloud;
  33859. /**
  33860. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33861. */
  33862. forcePointsCloud: boolean;
  33863. /**
  33864. * Gets or sets the active clipplane 1
  33865. */
  33866. clipPlane: Nullable<Plane>;
  33867. /**
  33868. * Gets or sets the active clipplane 2
  33869. */
  33870. clipPlane2: Nullable<Plane>;
  33871. /**
  33872. * Gets or sets the active clipplane 3
  33873. */
  33874. clipPlane3: Nullable<Plane>;
  33875. /**
  33876. * Gets or sets the active clipplane 4
  33877. */
  33878. clipPlane4: Nullable<Plane>;
  33879. /**
  33880. * Gets or sets a boolean indicating if animations are enabled
  33881. */
  33882. animationsEnabled: boolean;
  33883. private _animationPropertiesOverride;
  33884. /**
  33885. * Gets or sets the animation properties override
  33886. */
  33887. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33888. /**
  33889. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33890. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33891. */
  33892. useConstantAnimationDeltaTime: boolean;
  33893. /**
  33894. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33895. * Please note that it requires to run a ray cast through the scene on every frame
  33896. */
  33897. constantlyUpdateMeshUnderPointer: boolean;
  33898. /**
  33899. * Defines the HTML cursor to use when hovering over interactive elements
  33900. */
  33901. hoverCursor: string;
  33902. /**
  33903. * Defines the HTML default cursor to use (empty by default)
  33904. */
  33905. defaultCursor: string;
  33906. /**
  33907. * This is used to call preventDefault() on pointer down
  33908. * in order to block unwanted artifacts like system double clicks
  33909. */
  33910. preventDefaultOnPointerDown: boolean;
  33911. /**
  33912. * This is used to call preventDefault() on pointer up
  33913. * in order to block unwanted artifacts like system double clicks
  33914. */
  33915. preventDefaultOnPointerUp: boolean;
  33916. /**
  33917. * Gets or sets user defined metadata
  33918. */
  33919. metadata: any;
  33920. /**
  33921. * For internal use only. Please do not use.
  33922. */
  33923. reservedDataStore: any;
  33924. /**
  33925. * Gets the name of the plugin used to load this scene (null by default)
  33926. */
  33927. loadingPluginName: string;
  33928. /**
  33929. * Use this array to add regular expressions used to disable offline support for specific urls
  33930. */
  33931. disableOfflineSupportExceptionRules: RegExp[];
  33932. /**
  33933. * An event triggered when the scene is disposed.
  33934. */
  33935. onDisposeObservable: Observable<Scene>;
  33936. private _onDisposeObserver;
  33937. /** Sets a function to be executed when this scene is disposed. */
  33938. onDispose: () => void;
  33939. /**
  33940. * An event triggered before rendering the scene (right after animations and physics)
  33941. */
  33942. onBeforeRenderObservable: Observable<Scene>;
  33943. private _onBeforeRenderObserver;
  33944. /** Sets a function to be executed before rendering this scene */
  33945. beforeRender: Nullable<() => void>;
  33946. /**
  33947. * An event triggered after rendering the scene
  33948. */
  33949. onAfterRenderObservable: Observable<Scene>;
  33950. /**
  33951. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33952. */
  33953. onAfterRenderCameraObservable: Observable<Camera>;
  33954. private _onAfterRenderObserver;
  33955. /** Sets a function to be executed after rendering this scene */
  33956. afterRender: Nullable<() => void>;
  33957. /**
  33958. * An event triggered before animating the scene
  33959. */
  33960. onBeforeAnimationsObservable: Observable<Scene>;
  33961. /**
  33962. * An event triggered after animations processing
  33963. */
  33964. onAfterAnimationsObservable: Observable<Scene>;
  33965. /**
  33966. * An event triggered before draw calls are ready to be sent
  33967. */
  33968. onBeforeDrawPhaseObservable: Observable<Scene>;
  33969. /**
  33970. * An event triggered after draw calls have been sent
  33971. */
  33972. onAfterDrawPhaseObservable: Observable<Scene>;
  33973. /**
  33974. * An event triggered when the scene is ready
  33975. */
  33976. onReadyObservable: Observable<Scene>;
  33977. /**
  33978. * An event triggered before rendering a camera
  33979. */
  33980. onBeforeCameraRenderObservable: Observable<Camera>;
  33981. private _onBeforeCameraRenderObserver;
  33982. /** Sets a function to be executed before rendering a camera*/
  33983. beforeCameraRender: () => void;
  33984. /**
  33985. * An event triggered after rendering a camera
  33986. */
  33987. onAfterCameraRenderObservable: Observable<Camera>;
  33988. private _onAfterCameraRenderObserver;
  33989. /** Sets a function to be executed after rendering a camera*/
  33990. afterCameraRender: () => void;
  33991. /**
  33992. * An event triggered when active meshes evaluation is about to start
  33993. */
  33994. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33995. /**
  33996. * An event triggered when active meshes evaluation is done
  33997. */
  33998. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33999. /**
  34000. * An event triggered when particles rendering is about to start
  34001. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34002. */
  34003. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34004. /**
  34005. * An event triggered when particles rendering is done
  34006. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34007. */
  34008. onAfterParticlesRenderingObservable: Observable<Scene>;
  34009. /**
  34010. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34011. */
  34012. onDataLoadedObservable: Observable<Scene>;
  34013. /**
  34014. * An event triggered when a camera is created
  34015. */
  34016. onNewCameraAddedObservable: Observable<Camera>;
  34017. /**
  34018. * An event triggered when a camera is removed
  34019. */
  34020. onCameraRemovedObservable: Observable<Camera>;
  34021. /**
  34022. * An event triggered when a light is created
  34023. */
  34024. onNewLightAddedObservable: Observable<Light>;
  34025. /**
  34026. * An event triggered when a light is removed
  34027. */
  34028. onLightRemovedObservable: Observable<Light>;
  34029. /**
  34030. * An event triggered when a geometry is created
  34031. */
  34032. onNewGeometryAddedObservable: Observable<Geometry>;
  34033. /**
  34034. * An event triggered when a geometry is removed
  34035. */
  34036. onGeometryRemovedObservable: Observable<Geometry>;
  34037. /**
  34038. * An event triggered when a transform node is created
  34039. */
  34040. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34041. /**
  34042. * An event triggered when a transform node is removed
  34043. */
  34044. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34045. /**
  34046. * An event triggered when a mesh is created
  34047. */
  34048. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34049. /**
  34050. * An event triggered when a mesh is removed
  34051. */
  34052. onMeshRemovedObservable: Observable<AbstractMesh>;
  34053. /**
  34054. * An event triggered when a skeleton is created
  34055. */
  34056. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34057. /**
  34058. * An event triggered when a skeleton is removed
  34059. */
  34060. onSkeletonRemovedObservable: Observable<Skeleton>;
  34061. /**
  34062. * An event triggered when a material is created
  34063. */
  34064. onNewMaterialAddedObservable: Observable<Material>;
  34065. /**
  34066. * An event triggered when a material is removed
  34067. */
  34068. onMaterialRemovedObservable: Observable<Material>;
  34069. /**
  34070. * An event triggered when a texture is created
  34071. */
  34072. onNewTextureAddedObservable: Observable<BaseTexture>;
  34073. /**
  34074. * An event triggered when a texture is removed
  34075. */
  34076. onTextureRemovedObservable: Observable<BaseTexture>;
  34077. /**
  34078. * An event triggered when render targets are about to be rendered
  34079. * Can happen multiple times per frame.
  34080. */
  34081. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34082. /**
  34083. * An event triggered when render targets were rendered.
  34084. * Can happen multiple times per frame.
  34085. */
  34086. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34087. /**
  34088. * An event triggered before calculating deterministic simulation step
  34089. */
  34090. onBeforeStepObservable: Observable<Scene>;
  34091. /**
  34092. * An event triggered after calculating deterministic simulation step
  34093. */
  34094. onAfterStepObservable: Observable<Scene>;
  34095. /**
  34096. * An event triggered when the activeCamera property is updated
  34097. */
  34098. onActiveCameraChanged: Observable<Scene>;
  34099. /**
  34100. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34101. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34102. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  34103. */
  34104. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34105. /**
  34106. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34107. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34108. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  34109. */
  34110. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34111. /**
  34112. * This Observable will when a mesh has been imported into the scene.
  34113. */
  34114. onMeshImportedObservable: Observable<AbstractMesh>;
  34115. /**
  34116. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34117. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34118. */
  34119. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34120. /** @hidden */
  34121. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34122. /**
  34123. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34124. */
  34125. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34126. /**
  34127. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34128. */
  34129. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34130. /**
  34131. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34132. */
  34133. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34134. /** Callback called when a pointer move is detected */
  34135. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34136. /** Callback called when a pointer down is detected */
  34137. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34138. /** Callback called when a pointer up is detected */
  34139. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34140. /** Callback called when a pointer pick is detected */
  34141. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34142. /**
  34143. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  34144. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34145. */
  34146. onPrePointerObservable: Observable<PointerInfoPre>;
  34147. /**
  34148. * Observable event triggered each time an input event is received from the rendering canvas
  34149. */
  34150. onPointerObservable: Observable<PointerInfo>;
  34151. /**
  34152. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34153. */
  34154. readonly unTranslatedPointer: Vector2;
  34155. /**
  34156. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34157. */
  34158. static DragMovementThreshold: number;
  34159. /**
  34160. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34161. */
  34162. static LongPressDelay: number;
  34163. /**
  34164. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34165. */
  34166. static DoubleClickDelay: number;
  34167. /** If you need to check double click without raising a single click at first click, enable this flag */
  34168. static ExclusiveDoubleClickMode: boolean;
  34169. /** @hidden */
  34170. _mirroredCameraPosition: Nullable<Vector3>;
  34171. /**
  34172. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34173. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34174. */
  34175. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34176. /**
  34177. * Observable event triggered each time an keyboard event is received from the hosting window
  34178. */
  34179. onKeyboardObservable: Observable<KeyboardInfo>;
  34180. private _useRightHandedSystem;
  34181. /**
  34182. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34183. */
  34184. useRightHandedSystem: boolean;
  34185. private _timeAccumulator;
  34186. private _currentStepId;
  34187. private _currentInternalStep;
  34188. /**
  34189. * Sets the step Id used by deterministic lock step
  34190. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34191. * @param newStepId defines the step Id
  34192. */
  34193. setStepId(newStepId: number): void;
  34194. /**
  34195. * Gets the step Id used by deterministic lock step
  34196. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34197. * @returns the step Id
  34198. */
  34199. getStepId(): number;
  34200. /**
  34201. * Gets the internal step used by deterministic lock step
  34202. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34203. * @returns the internal step
  34204. */
  34205. getInternalStep(): number;
  34206. private _fogEnabled;
  34207. /**
  34208. * Gets or sets a boolean indicating if fog is enabled on this scene
  34209. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34210. * (Default is true)
  34211. */
  34212. fogEnabled: boolean;
  34213. private _fogMode;
  34214. /**
  34215. * Gets or sets the fog mode to use
  34216. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34217. * | mode | value |
  34218. * | --- | --- |
  34219. * | FOGMODE_NONE | 0 |
  34220. * | FOGMODE_EXP | 1 |
  34221. * | FOGMODE_EXP2 | 2 |
  34222. * | FOGMODE_LINEAR | 3 |
  34223. */
  34224. fogMode: number;
  34225. /**
  34226. * Gets or sets the fog color to use
  34227. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34228. * (Default is Color3(0.2, 0.2, 0.3))
  34229. */
  34230. fogColor: Color3;
  34231. /**
  34232. * Gets or sets the fog density to use
  34233. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34234. * (Default is 0.1)
  34235. */
  34236. fogDensity: number;
  34237. /**
  34238. * Gets or sets the fog start distance to use
  34239. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34240. * (Default is 0)
  34241. */
  34242. fogStart: number;
  34243. /**
  34244. * Gets or sets the fog end distance to use
  34245. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34246. * (Default is 1000)
  34247. */
  34248. fogEnd: number;
  34249. private _shadowsEnabled;
  34250. /**
  34251. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34252. */
  34253. shadowsEnabled: boolean;
  34254. private _lightsEnabled;
  34255. /**
  34256. * Gets or sets a boolean indicating if lights are enabled on this scene
  34257. */
  34258. lightsEnabled: boolean;
  34259. /** All of the active cameras added to this scene. */
  34260. activeCameras: Camera[];
  34261. /** @hidden */
  34262. _activeCamera: Nullable<Camera>;
  34263. /** Gets or sets the current active camera */
  34264. activeCamera: Nullable<Camera>;
  34265. private _defaultMaterial;
  34266. /** The default material used on meshes when no material is affected */
  34267. /** The default material used on meshes when no material is affected */
  34268. defaultMaterial: Material;
  34269. private _texturesEnabled;
  34270. /**
  34271. * Gets or sets a boolean indicating if textures are enabled on this scene
  34272. */
  34273. texturesEnabled: boolean;
  34274. /**
  34275. * Gets or sets a boolean indicating if particles are enabled on this scene
  34276. */
  34277. particlesEnabled: boolean;
  34278. /**
  34279. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34280. */
  34281. spritesEnabled: boolean;
  34282. private _skeletonsEnabled;
  34283. /**
  34284. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34285. */
  34286. skeletonsEnabled: boolean;
  34287. /**
  34288. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34289. */
  34290. lensFlaresEnabled: boolean;
  34291. /**
  34292. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34293. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34294. */
  34295. collisionsEnabled: boolean;
  34296. private _collisionCoordinator;
  34297. /** @hidden */
  34298. readonly collisionCoordinator: ICollisionCoordinator;
  34299. /**
  34300. * Defines the gravity applied to this scene (used only for collisions)
  34301. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34302. */
  34303. gravity: Vector3;
  34304. /**
  34305. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34306. */
  34307. postProcessesEnabled: boolean;
  34308. /**
  34309. * The list of postprocesses added to the scene
  34310. */
  34311. postProcesses: PostProcess[];
  34312. /**
  34313. * Gets the current postprocess manager
  34314. */
  34315. postProcessManager: PostProcessManager;
  34316. /**
  34317. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34318. */
  34319. renderTargetsEnabled: boolean;
  34320. /**
  34321. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34322. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34323. */
  34324. dumpNextRenderTargets: boolean;
  34325. /**
  34326. * The list of user defined render targets added to the scene
  34327. */
  34328. customRenderTargets: RenderTargetTexture[];
  34329. /**
  34330. * Defines if texture loading must be delayed
  34331. * If true, textures will only be loaded when they need to be rendered
  34332. */
  34333. useDelayedTextureLoading: boolean;
  34334. /**
  34335. * Gets the list of meshes imported to the scene through SceneLoader
  34336. */
  34337. importedMeshesFiles: String[];
  34338. /**
  34339. * Gets or sets a boolean indicating if probes are enabled on this scene
  34340. */
  34341. probesEnabled: boolean;
  34342. /**
  34343. * Gets or sets the current offline provider to use to store scene data
  34344. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34345. */
  34346. offlineProvider: IOfflineProvider;
  34347. /**
  34348. * Gets or sets the action manager associated with the scene
  34349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34350. */
  34351. actionManager: AbstractActionManager;
  34352. private _meshesForIntersections;
  34353. /**
  34354. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34355. */
  34356. proceduralTexturesEnabled: boolean;
  34357. private _engine;
  34358. private _totalVertices;
  34359. /** @hidden */
  34360. _activeIndices: PerfCounter;
  34361. /** @hidden */
  34362. _activeParticles: PerfCounter;
  34363. /** @hidden */
  34364. _activeBones: PerfCounter;
  34365. private _animationRatio;
  34366. /** @hidden */
  34367. _animationTimeLast: number;
  34368. /** @hidden */
  34369. _animationTime: number;
  34370. /**
  34371. * Gets or sets a general scale for animation speed
  34372. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34373. */
  34374. animationTimeScale: number;
  34375. /** @hidden */
  34376. _cachedMaterial: Nullable<Material>;
  34377. /** @hidden */
  34378. _cachedEffect: Nullable<Effect>;
  34379. /** @hidden */
  34380. _cachedVisibility: Nullable<number>;
  34381. private _renderId;
  34382. private _frameId;
  34383. private _executeWhenReadyTimeoutId;
  34384. private _intermediateRendering;
  34385. private _viewUpdateFlag;
  34386. private _projectionUpdateFlag;
  34387. /** @hidden */
  34388. _toBeDisposed: Nullable<IDisposable>[];
  34389. private _activeRequests;
  34390. /** @hidden */
  34391. _pendingData: any[];
  34392. private _isDisposed;
  34393. /**
  34394. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34395. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34396. */
  34397. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34398. private _activeMeshes;
  34399. private _processedMaterials;
  34400. private _renderTargets;
  34401. /** @hidden */
  34402. _activeParticleSystems: SmartArray<IParticleSystem>;
  34403. private _activeSkeletons;
  34404. private _softwareSkinnedMeshes;
  34405. private _renderingManager;
  34406. /** @hidden */
  34407. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34408. private _transformMatrix;
  34409. private _sceneUbo;
  34410. /** @hidden */
  34411. _viewMatrix: Matrix;
  34412. private _projectionMatrix;
  34413. /** @hidden */
  34414. _forcedViewPosition: Nullable<Vector3>;
  34415. /** @hidden */
  34416. _frustumPlanes: Plane[];
  34417. /**
  34418. * Gets the list of frustum planes (built from the active camera)
  34419. */
  34420. readonly frustumPlanes: Plane[];
  34421. /**
  34422. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34423. * This is useful if there are more lights that the maximum simulteanous authorized
  34424. */
  34425. requireLightSorting: boolean;
  34426. /** @hidden */
  34427. readonly useMaterialMeshMap: boolean;
  34428. /** @hidden */
  34429. readonly useClonedMeshhMap: boolean;
  34430. private _externalData;
  34431. private _uid;
  34432. /**
  34433. * @hidden
  34434. * Backing store of defined scene components.
  34435. */
  34436. _components: ISceneComponent[];
  34437. /**
  34438. * @hidden
  34439. * Backing store of defined scene components.
  34440. */
  34441. _serializableComponents: ISceneSerializableComponent[];
  34442. /**
  34443. * List of components to register on the next registration step.
  34444. */
  34445. private _transientComponents;
  34446. /**
  34447. * Registers the transient components if needed.
  34448. */
  34449. private _registerTransientComponents;
  34450. /**
  34451. * @hidden
  34452. * Add a component to the scene.
  34453. * Note that the ccomponent could be registered on th next frame if this is called after
  34454. * the register component stage.
  34455. * @param component Defines the component to add to the scene
  34456. */
  34457. _addComponent(component: ISceneComponent): void;
  34458. /**
  34459. * @hidden
  34460. * Gets a component from the scene.
  34461. * @param name defines the name of the component to retrieve
  34462. * @returns the component or null if not present
  34463. */
  34464. _getComponent(name: string): Nullable<ISceneComponent>;
  34465. /**
  34466. * @hidden
  34467. * Defines the actions happening before camera updates.
  34468. */
  34469. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34470. /**
  34471. * @hidden
  34472. * Defines the actions happening before clear the canvas.
  34473. */
  34474. _beforeClearStage: Stage<SimpleStageAction>;
  34475. /**
  34476. * @hidden
  34477. * Defines the actions when collecting render targets for the frame.
  34478. */
  34479. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34480. /**
  34481. * @hidden
  34482. * Defines the actions happening for one camera in the frame.
  34483. */
  34484. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34485. /**
  34486. * @hidden
  34487. * Defines the actions happening during the per mesh ready checks.
  34488. */
  34489. _isReadyForMeshStage: Stage<MeshStageAction>;
  34490. /**
  34491. * @hidden
  34492. * Defines the actions happening before evaluate active mesh checks.
  34493. */
  34494. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34495. /**
  34496. * @hidden
  34497. * Defines the actions happening during the evaluate sub mesh checks.
  34498. */
  34499. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34500. /**
  34501. * @hidden
  34502. * Defines the actions happening during the active mesh stage.
  34503. */
  34504. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34505. /**
  34506. * @hidden
  34507. * Defines the actions happening during the per camera render target step.
  34508. */
  34509. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34510. /**
  34511. * @hidden
  34512. * Defines the actions happening just before the active camera is drawing.
  34513. */
  34514. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34515. /**
  34516. * @hidden
  34517. * Defines the actions happening just before a render target is drawing.
  34518. */
  34519. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34520. /**
  34521. * @hidden
  34522. * Defines the actions happening just before a rendering group is drawing.
  34523. */
  34524. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34525. /**
  34526. * @hidden
  34527. * Defines the actions happening just before a mesh is drawing.
  34528. */
  34529. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34530. /**
  34531. * @hidden
  34532. * Defines the actions happening just after a mesh has been drawn.
  34533. */
  34534. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34535. /**
  34536. * @hidden
  34537. * Defines the actions happening just after a rendering group has been drawn.
  34538. */
  34539. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34540. /**
  34541. * @hidden
  34542. * Defines the actions happening just after the active camera has been drawn.
  34543. */
  34544. _afterCameraDrawStage: Stage<CameraStageAction>;
  34545. /**
  34546. * @hidden
  34547. * Defines the actions happening just after a render target has been drawn.
  34548. */
  34549. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34550. /**
  34551. * @hidden
  34552. * Defines the actions happening just after rendering all cameras and computing intersections.
  34553. */
  34554. _afterRenderStage: Stage<SimpleStageAction>;
  34555. /**
  34556. * @hidden
  34557. * Defines the actions happening when a pointer move event happens.
  34558. */
  34559. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34560. /**
  34561. * @hidden
  34562. * Defines the actions happening when a pointer down event happens.
  34563. */
  34564. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34565. /**
  34566. * @hidden
  34567. * Defines the actions happening when a pointer up event happens.
  34568. */
  34569. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34570. /**
  34571. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34572. */
  34573. private geometriesByUniqueId;
  34574. /**
  34575. * Creates a new Scene
  34576. * @param engine defines the engine to use to render this scene
  34577. * @param options defines the scene options
  34578. */
  34579. constructor(engine: Engine, options?: SceneOptions);
  34580. /**
  34581. * Gets a string idenfifying the name of the class
  34582. * @returns "Scene" string
  34583. */
  34584. getClassName(): string;
  34585. private _defaultMeshCandidates;
  34586. /**
  34587. * @hidden
  34588. */
  34589. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34590. private _defaultSubMeshCandidates;
  34591. /**
  34592. * @hidden
  34593. */
  34594. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34595. /**
  34596. * Sets the default candidate providers for the scene.
  34597. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34598. * and getCollidingSubMeshCandidates to their default function
  34599. */
  34600. setDefaultCandidateProviders(): void;
  34601. /**
  34602. * Gets the mesh that is currently under the pointer
  34603. */
  34604. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34605. /**
  34606. * Gets or sets the current on-screen X position of the pointer
  34607. */
  34608. pointerX: number;
  34609. /**
  34610. * Gets or sets the current on-screen Y position of the pointer
  34611. */
  34612. pointerY: number;
  34613. /**
  34614. * Gets the cached material (ie. the latest rendered one)
  34615. * @returns the cached material
  34616. */
  34617. getCachedMaterial(): Nullable<Material>;
  34618. /**
  34619. * Gets the cached effect (ie. the latest rendered one)
  34620. * @returns the cached effect
  34621. */
  34622. getCachedEffect(): Nullable<Effect>;
  34623. /**
  34624. * Gets the cached visibility state (ie. the latest rendered one)
  34625. * @returns the cached visibility state
  34626. */
  34627. getCachedVisibility(): Nullable<number>;
  34628. /**
  34629. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34630. * @param material defines the current material
  34631. * @param effect defines the current effect
  34632. * @param visibility defines the current visibility state
  34633. * @returns true if one parameter is not cached
  34634. */
  34635. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34636. /**
  34637. * Gets the engine associated with the scene
  34638. * @returns an Engine
  34639. */
  34640. getEngine(): Engine;
  34641. /**
  34642. * Gets the total number of vertices rendered per frame
  34643. * @returns the total number of vertices rendered per frame
  34644. */
  34645. getTotalVertices(): number;
  34646. /**
  34647. * Gets the performance counter for total vertices
  34648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34649. */
  34650. readonly totalVerticesPerfCounter: PerfCounter;
  34651. /**
  34652. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34653. * @returns the total number of active indices rendered per frame
  34654. */
  34655. getActiveIndices(): number;
  34656. /**
  34657. * Gets the performance counter for active indices
  34658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34659. */
  34660. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34661. /**
  34662. * Gets the total number of active particles rendered per frame
  34663. * @returns the total number of active particles rendered per frame
  34664. */
  34665. getActiveParticles(): number;
  34666. /**
  34667. * Gets the performance counter for active particles
  34668. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34669. */
  34670. readonly activeParticlesPerfCounter: PerfCounter;
  34671. /**
  34672. * Gets the total number of active bones rendered per frame
  34673. * @returns the total number of active bones rendered per frame
  34674. */
  34675. getActiveBones(): number;
  34676. /**
  34677. * Gets the performance counter for active bones
  34678. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34679. */
  34680. readonly activeBonesPerfCounter: PerfCounter;
  34681. /**
  34682. * Gets the array of active meshes
  34683. * @returns an array of AbstractMesh
  34684. */
  34685. getActiveMeshes(): SmartArray<AbstractMesh>;
  34686. /**
  34687. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34688. * @returns a number
  34689. */
  34690. getAnimationRatio(): number;
  34691. /**
  34692. * Gets an unique Id for the current render phase
  34693. * @returns a number
  34694. */
  34695. getRenderId(): number;
  34696. /**
  34697. * Gets an unique Id for the current frame
  34698. * @returns a number
  34699. */
  34700. getFrameId(): number;
  34701. /** Call this function if you want to manually increment the render Id*/
  34702. incrementRenderId(): void;
  34703. private _createUbo;
  34704. /**
  34705. * Use this method to simulate a pointer move on a mesh
  34706. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34707. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34708. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34709. * @returns the current scene
  34710. */
  34711. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34712. /**
  34713. * Use this method to simulate a pointer down on a mesh
  34714. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34715. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34716. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34717. * @returns the current scene
  34718. */
  34719. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34720. /**
  34721. * Use this method to simulate a pointer up on a mesh
  34722. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34723. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34724. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34725. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34726. * @returns the current scene
  34727. */
  34728. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34729. /**
  34730. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34731. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34732. * @returns true if the pointer was captured
  34733. */
  34734. isPointerCaptured(pointerId?: number): boolean;
  34735. /**
  34736. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34737. * @param attachUp defines if you want to attach events to pointerup
  34738. * @param attachDown defines if you want to attach events to pointerdown
  34739. * @param attachMove defines if you want to attach events to pointermove
  34740. */
  34741. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34742. /** Detaches all event handlers*/
  34743. detachControl(): void;
  34744. /**
  34745. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34746. * Delay loaded resources are not taking in account
  34747. * @return true if all required resources are ready
  34748. */
  34749. isReady(): boolean;
  34750. /** Resets all cached information relative to material (including effect and visibility) */
  34751. resetCachedMaterial(): void;
  34752. /**
  34753. * Registers a function to be called before every frame render
  34754. * @param func defines the function to register
  34755. */
  34756. registerBeforeRender(func: () => void): void;
  34757. /**
  34758. * Unregisters a function called before every frame render
  34759. * @param func defines the function to unregister
  34760. */
  34761. unregisterBeforeRender(func: () => void): void;
  34762. /**
  34763. * Registers a function to be called after every frame render
  34764. * @param func defines the function to register
  34765. */
  34766. registerAfterRender(func: () => void): void;
  34767. /**
  34768. * Unregisters a function called after every frame render
  34769. * @param func defines the function to unregister
  34770. */
  34771. unregisterAfterRender(func: () => void): void;
  34772. private _executeOnceBeforeRender;
  34773. /**
  34774. * The provided function will run before render once and will be disposed afterwards.
  34775. * A timeout delay can be provided so that the function will be executed in N ms.
  34776. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34777. * @param func The function to be executed.
  34778. * @param timeout optional delay in ms
  34779. */
  34780. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34781. /** @hidden */
  34782. _addPendingData(data: any): void;
  34783. /** @hidden */
  34784. _removePendingData(data: any): void;
  34785. /**
  34786. * Returns the number of items waiting to be loaded
  34787. * @returns the number of items waiting to be loaded
  34788. */
  34789. getWaitingItemsCount(): number;
  34790. /**
  34791. * Returns a boolean indicating if the scene is still loading data
  34792. */
  34793. readonly isLoading: boolean;
  34794. /**
  34795. * Registers a function to be executed when the scene is ready
  34796. * @param {Function} func - the function to be executed
  34797. */
  34798. executeWhenReady(func: () => void): void;
  34799. /**
  34800. * Returns a promise that resolves when the scene is ready
  34801. * @returns A promise that resolves when the scene is ready
  34802. */
  34803. whenReadyAsync(): Promise<void>;
  34804. /** @hidden */
  34805. _checkIsReady(): void;
  34806. /**
  34807. * Gets all animatable attached to the scene
  34808. */
  34809. readonly animatables: Animatable[];
  34810. /**
  34811. * Resets the last animation time frame.
  34812. * Useful to override when animations start running when loading a scene for the first time.
  34813. */
  34814. resetLastAnimationTimeFrame(): void;
  34815. /**
  34816. * Gets the current view matrix
  34817. * @returns a Matrix
  34818. */
  34819. getViewMatrix(): Matrix;
  34820. /**
  34821. * Gets the current projection matrix
  34822. * @returns a Matrix
  34823. */
  34824. getProjectionMatrix(): Matrix;
  34825. /**
  34826. * Gets the current transform matrix
  34827. * @returns a Matrix made of View * Projection
  34828. */
  34829. getTransformMatrix(): Matrix;
  34830. /**
  34831. * Sets the current transform matrix
  34832. * @param viewL defines the View matrix to use
  34833. * @param projectionL defines the Projection matrix to use
  34834. * @param viewR defines the right View matrix to use (if provided)
  34835. * @param projectionR defines the right Projection matrix to use (if provided)
  34836. */
  34837. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34838. /**
  34839. * Gets the uniform buffer used to store scene data
  34840. * @returns a UniformBuffer
  34841. */
  34842. getSceneUniformBuffer(): UniformBuffer;
  34843. /**
  34844. * Gets an unique (relatively to the current scene) Id
  34845. * @returns an unique number for the scene
  34846. */
  34847. getUniqueId(): number;
  34848. /**
  34849. * Add a mesh to the list of scene's meshes
  34850. * @param newMesh defines the mesh to add
  34851. * @param recursive if all child meshes should also be added to the scene
  34852. */
  34853. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34854. /**
  34855. * Remove a mesh for the list of scene's meshes
  34856. * @param toRemove defines the mesh to remove
  34857. * @param recursive if all child meshes should also be removed from the scene
  34858. * @returns the index where the mesh was in the mesh list
  34859. */
  34860. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34861. /**
  34862. * Add a transform node to the list of scene's transform nodes
  34863. * @param newTransformNode defines the transform node to add
  34864. */
  34865. addTransformNode(newTransformNode: TransformNode): void;
  34866. /**
  34867. * Remove a transform node for the list of scene's transform nodes
  34868. * @param toRemove defines the transform node to remove
  34869. * @returns the index where the transform node was in the transform node list
  34870. */
  34871. removeTransformNode(toRemove: TransformNode): number;
  34872. /**
  34873. * Remove a skeleton for the list of scene's skeletons
  34874. * @param toRemove defines the skeleton to remove
  34875. * @returns the index where the skeleton was in the skeleton list
  34876. */
  34877. removeSkeleton(toRemove: Skeleton): number;
  34878. /**
  34879. * Remove a morph target for the list of scene's morph targets
  34880. * @param toRemove defines the morph target to remove
  34881. * @returns the index where the morph target was in the morph target list
  34882. */
  34883. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34884. /**
  34885. * Remove a light for the list of scene's lights
  34886. * @param toRemove defines the light to remove
  34887. * @returns the index where the light was in the light list
  34888. */
  34889. removeLight(toRemove: Light): number;
  34890. /**
  34891. * Remove a camera for the list of scene's cameras
  34892. * @param toRemove defines the camera to remove
  34893. * @returns the index where the camera was in the camera list
  34894. */
  34895. removeCamera(toRemove: Camera): number;
  34896. /**
  34897. * Remove a particle system for the list of scene's particle systems
  34898. * @param toRemove defines the particle system to remove
  34899. * @returns the index where the particle system was in the particle system list
  34900. */
  34901. removeParticleSystem(toRemove: IParticleSystem): number;
  34902. /**
  34903. * Remove a animation for the list of scene's animations
  34904. * @param toRemove defines the animation to remove
  34905. * @returns the index where the animation was in the animation list
  34906. */
  34907. removeAnimation(toRemove: Animation): number;
  34908. /**
  34909. * Will stop the animation of the given target
  34910. * @param target - the target
  34911. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34912. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  34913. */
  34914. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34915. /**
  34916. * Removes the given animation group from this scene.
  34917. * @param toRemove The animation group to remove
  34918. * @returns The index of the removed animation group
  34919. */
  34920. removeAnimationGroup(toRemove: AnimationGroup): number;
  34921. /**
  34922. * Removes the given multi-material from this scene.
  34923. * @param toRemove The multi-material to remove
  34924. * @returns The index of the removed multi-material
  34925. */
  34926. removeMultiMaterial(toRemove: MultiMaterial): number;
  34927. /**
  34928. * Removes the given material from this scene.
  34929. * @param toRemove The material to remove
  34930. * @returns The index of the removed material
  34931. */
  34932. removeMaterial(toRemove: Material): number;
  34933. /**
  34934. * Removes the given action manager from this scene.
  34935. * @param toRemove The action manager to remove
  34936. * @returns The index of the removed action manager
  34937. */
  34938. removeActionManager(toRemove: AbstractActionManager): number;
  34939. /**
  34940. * Removes the given texture from this scene.
  34941. * @param toRemove The texture to remove
  34942. * @returns The index of the removed texture
  34943. */
  34944. removeTexture(toRemove: BaseTexture): number;
  34945. /**
  34946. * Adds the given light to this scene
  34947. * @param newLight The light to add
  34948. */
  34949. addLight(newLight: Light): void;
  34950. /**
  34951. * Sorts the list list based on light priorities
  34952. */
  34953. sortLightsByPriority(): void;
  34954. /**
  34955. * Adds the given camera to this scene
  34956. * @param newCamera The camera to add
  34957. */
  34958. addCamera(newCamera: Camera): void;
  34959. /**
  34960. * Adds the given skeleton to this scene
  34961. * @param newSkeleton The skeleton to add
  34962. */
  34963. addSkeleton(newSkeleton: Skeleton): void;
  34964. /**
  34965. * Adds the given particle system to this scene
  34966. * @param newParticleSystem The particle system to add
  34967. */
  34968. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34969. /**
  34970. * Adds the given animation to this scene
  34971. * @param newAnimation The animation to add
  34972. */
  34973. addAnimation(newAnimation: Animation): void;
  34974. /**
  34975. * Adds the given animation group to this scene.
  34976. * @param newAnimationGroup The animation group to add
  34977. */
  34978. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34979. /**
  34980. * Adds the given multi-material to this scene
  34981. * @param newMultiMaterial The multi-material to add
  34982. */
  34983. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34984. /**
  34985. * Adds the given material to this scene
  34986. * @param newMaterial The material to add
  34987. */
  34988. addMaterial(newMaterial: Material): void;
  34989. /**
  34990. * Adds the given morph target to this scene
  34991. * @param newMorphTargetManager The morph target to add
  34992. */
  34993. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34994. /**
  34995. * Adds the given geometry to this scene
  34996. * @param newGeometry The geometry to add
  34997. */
  34998. addGeometry(newGeometry: Geometry): void;
  34999. /**
  35000. * Adds the given action manager to this scene
  35001. * @param newActionManager The action manager to add
  35002. */
  35003. addActionManager(newActionManager: AbstractActionManager): void;
  35004. /**
  35005. * Adds the given texture to this scene.
  35006. * @param newTexture The texture to add
  35007. */
  35008. addTexture(newTexture: BaseTexture): void;
  35009. /**
  35010. * Switch active camera
  35011. * @param newCamera defines the new active camera
  35012. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35013. */
  35014. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35015. /**
  35016. * sets the active camera of the scene using its ID
  35017. * @param id defines the camera's ID
  35018. * @return the new active camera or null if none found.
  35019. */
  35020. setActiveCameraByID(id: string): Nullable<Camera>;
  35021. /**
  35022. * sets the active camera of the scene using its name
  35023. * @param name defines the camera's name
  35024. * @returns the new active camera or null if none found.
  35025. */
  35026. setActiveCameraByName(name: string): Nullable<Camera>;
  35027. /**
  35028. * get an animation group using its name
  35029. * @param name defines the material's name
  35030. * @return the animation group or null if none found.
  35031. */
  35032. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35033. /**
  35034. * Get a material using its unique id
  35035. * @param uniqueId defines the material's unique id
  35036. * @return the material or null if none found.
  35037. */
  35038. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35039. /**
  35040. * get a material using its id
  35041. * @param id defines the material's ID
  35042. * @return the material or null if none found.
  35043. */
  35044. getMaterialByID(id: string): Nullable<Material>;
  35045. /**
  35046. * Gets a the last added material using a given id
  35047. * @param id defines the material's ID
  35048. * @return the last material with the given id or null if none found.
  35049. */
  35050. getLastMaterialByID(id: string): Nullable<Material>;
  35051. /**
  35052. * Gets a material using its name
  35053. * @param name defines the material's name
  35054. * @return the material or null if none found.
  35055. */
  35056. getMaterialByName(name: string): Nullable<Material>;
  35057. /**
  35058. * Get a texture using its unique id
  35059. * @param uniqueId defines the texture's unique id
  35060. * @return the texture or null if none found.
  35061. */
  35062. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35063. /**
  35064. * Gets a camera using its id
  35065. * @param id defines the id to look for
  35066. * @returns the camera or null if not found
  35067. */
  35068. getCameraByID(id: string): Nullable<Camera>;
  35069. /**
  35070. * Gets a camera using its unique id
  35071. * @param uniqueId defines the unique id to look for
  35072. * @returns the camera or null if not found
  35073. */
  35074. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35075. /**
  35076. * Gets a camera using its name
  35077. * @param name defines the camera's name
  35078. * @return the camera or null if none found.
  35079. */
  35080. getCameraByName(name: string): Nullable<Camera>;
  35081. /**
  35082. * Gets a bone using its id
  35083. * @param id defines the bone's id
  35084. * @return the bone or null if not found
  35085. */
  35086. getBoneByID(id: string): Nullable<Bone>;
  35087. /**
  35088. * Gets a bone using its id
  35089. * @param name defines the bone's name
  35090. * @return the bone or null if not found
  35091. */
  35092. getBoneByName(name: string): Nullable<Bone>;
  35093. /**
  35094. * Gets a light node using its name
  35095. * @param name defines the the light's name
  35096. * @return the light or null if none found.
  35097. */
  35098. getLightByName(name: string): Nullable<Light>;
  35099. /**
  35100. * Gets a light node using its id
  35101. * @param id defines the light's id
  35102. * @return the light or null if none found.
  35103. */
  35104. getLightByID(id: string): Nullable<Light>;
  35105. /**
  35106. * Gets a light node using its scene-generated unique ID
  35107. * @param uniqueId defines the light's unique id
  35108. * @return the light or null if none found.
  35109. */
  35110. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35111. /**
  35112. * Gets a particle system by id
  35113. * @param id defines the particle system id
  35114. * @return the corresponding system or null if none found
  35115. */
  35116. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35117. /**
  35118. * Gets a geometry using its ID
  35119. * @param id defines the geometry's id
  35120. * @return the geometry or null if none found.
  35121. */
  35122. getGeometryByID(id: string): Nullable<Geometry>;
  35123. private _getGeometryByUniqueID;
  35124. /**
  35125. * Add a new geometry to this scene
  35126. * @param geometry defines the geometry to be added to the scene.
  35127. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35128. * @return a boolean defining if the geometry was added or not
  35129. */
  35130. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35131. /**
  35132. * Removes an existing geometry
  35133. * @param geometry defines the geometry to be removed from the scene
  35134. * @return a boolean defining if the geometry was removed or not
  35135. */
  35136. removeGeometry(geometry: Geometry): boolean;
  35137. /**
  35138. * Gets the list of geometries attached to the scene
  35139. * @returns an array of Geometry
  35140. */
  35141. getGeometries(): Geometry[];
  35142. /**
  35143. * Gets the first added mesh found of a given ID
  35144. * @param id defines the id to search for
  35145. * @return the mesh found or null if not found at all
  35146. */
  35147. getMeshByID(id: string): Nullable<AbstractMesh>;
  35148. /**
  35149. * Gets a list of meshes using their id
  35150. * @param id defines the id to search for
  35151. * @returns a list of meshes
  35152. */
  35153. getMeshesByID(id: string): Array<AbstractMesh>;
  35154. /**
  35155. * Gets the first added transform node found of a given ID
  35156. * @param id defines the id to search for
  35157. * @return the found transform node or null if not found at all.
  35158. */
  35159. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35160. /**
  35161. * Gets a transform node with its auto-generated unique id
  35162. * @param uniqueId efines the unique id to search for
  35163. * @return the found transform node or null if not found at all.
  35164. */
  35165. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35166. /**
  35167. * Gets a list of transform nodes using their id
  35168. * @param id defines the id to search for
  35169. * @returns a list of transform nodes
  35170. */
  35171. getTransformNodesByID(id: string): Array<TransformNode>;
  35172. /**
  35173. * Gets a mesh with its auto-generated unique id
  35174. * @param uniqueId defines the unique id to search for
  35175. * @return the found mesh or null if not found at all.
  35176. */
  35177. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35178. /**
  35179. * Gets a the last added mesh using a given id
  35180. * @param id defines the id to search for
  35181. * @return the found mesh or null if not found at all.
  35182. */
  35183. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35184. /**
  35185. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35186. * @param id defines the id to search for
  35187. * @return the found node or null if not found at all
  35188. */
  35189. getLastEntryByID(id: string): Nullable<Node>;
  35190. /**
  35191. * Gets a node (Mesh, Camera, Light) using a given id
  35192. * @param id defines the id to search for
  35193. * @return the found node or null if not found at all
  35194. */
  35195. getNodeByID(id: string): Nullable<Node>;
  35196. /**
  35197. * Gets a node (Mesh, Camera, Light) using a given name
  35198. * @param name defines the name to search for
  35199. * @return the found node or null if not found at all.
  35200. */
  35201. getNodeByName(name: string): Nullable<Node>;
  35202. /**
  35203. * Gets a mesh using a given name
  35204. * @param name defines the name to search for
  35205. * @return the found mesh or null if not found at all.
  35206. */
  35207. getMeshByName(name: string): Nullable<AbstractMesh>;
  35208. /**
  35209. * Gets a transform node using a given name
  35210. * @param name defines the name to search for
  35211. * @return the found transform node or null if not found at all.
  35212. */
  35213. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35214. /**
  35215. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35216. * @param id defines the id to search for
  35217. * @return the found skeleton or null if not found at all.
  35218. */
  35219. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35220. /**
  35221. * Gets a skeleton using a given auto generated unique id
  35222. * @param uniqueId defines the unique id to search for
  35223. * @return the found skeleton or null if not found at all.
  35224. */
  35225. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35226. /**
  35227. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35228. * @param id defines the id to search for
  35229. * @return the found skeleton or null if not found at all.
  35230. */
  35231. getSkeletonById(id: string): Nullable<Skeleton>;
  35232. /**
  35233. * Gets a skeleton using a given name
  35234. * @param name defines the name to search for
  35235. * @return the found skeleton or null if not found at all.
  35236. */
  35237. getSkeletonByName(name: string): Nullable<Skeleton>;
  35238. /**
  35239. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35240. * @param id defines the id to search for
  35241. * @return the found morph target manager or null if not found at all.
  35242. */
  35243. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35244. /**
  35245. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35246. * @param id defines the id to search for
  35247. * @return the found morph target or null if not found at all.
  35248. */
  35249. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35250. /**
  35251. * Gets a boolean indicating if the given mesh is active
  35252. * @param mesh defines the mesh to look for
  35253. * @returns true if the mesh is in the active list
  35254. */
  35255. isActiveMesh(mesh: AbstractMesh): boolean;
  35256. /**
  35257. * Return a unique id as a string which can serve as an identifier for the scene
  35258. */
  35259. readonly uid: string;
  35260. /**
  35261. * Add an externaly attached data from its key.
  35262. * This method call will fail and return false, if such key already exists.
  35263. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35264. * @param key the unique key that identifies the data
  35265. * @param data the data object to associate to the key for this Engine instance
  35266. * @return true if no such key were already present and the data was added successfully, false otherwise
  35267. */
  35268. addExternalData<T>(key: string, data: T): boolean;
  35269. /**
  35270. * Get an externaly attached data from its key
  35271. * @param key the unique key that identifies the data
  35272. * @return the associated data, if present (can be null), or undefined if not present
  35273. */
  35274. getExternalData<T>(key: string): Nullable<T>;
  35275. /**
  35276. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35277. * @param key the unique key that identifies the data
  35278. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35279. * @return the associated data, can be null if the factory returned null.
  35280. */
  35281. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35282. /**
  35283. * Remove an externaly attached data from the Engine instance
  35284. * @param key the unique key that identifies the data
  35285. * @return true if the data was successfully removed, false if it doesn't exist
  35286. */
  35287. removeExternalData(key: string): boolean;
  35288. private _evaluateSubMesh;
  35289. /**
  35290. * Clear the processed materials smart array preventing retention point in material dispose.
  35291. */
  35292. freeProcessedMaterials(): void;
  35293. private _preventFreeActiveMeshesAndRenderingGroups;
  35294. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35295. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35296. * when disposing several meshes in a row or a hierarchy of meshes.
  35297. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35298. */
  35299. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35300. /**
  35301. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35302. */
  35303. freeActiveMeshes(): void;
  35304. /**
  35305. * Clear the info related to rendering groups preventing retention points during dispose.
  35306. */
  35307. freeRenderingGroups(): void;
  35308. /** @hidden */
  35309. _isInIntermediateRendering(): boolean;
  35310. /**
  35311. * Lambda returning the list of potentially active meshes.
  35312. */
  35313. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35314. /**
  35315. * Lambda returning the list of potentially active sub meshes.
  35316. */
  35317. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35318. /**
  35319. * Lambda returning the list of potentially intersecting sub meshes.
  35320. */
  35321. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35322. /**
  35323. * Lambda returning the list of potentially colliding sub meshes.
  35324. */
  35325. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35326. private _activeMeshesFrozen;
  35327. /**
  35328. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35329. * @returns the current scene
  35330. */
  35331. freezeActiveMeshes(): Scene;
  35332. /**
  35333. * Use this function to restart evaluating active meshes on every frame
  35334. * @returns the current scene
  35335. */
  35336. unfreezeActiveMeshes(): Scene;
  35337. private _evaluateActiveMeshes;
  35338. private _activeMesh;
  35339. /**
  35340. * Update the transform matrix to update from the current active camera
  35341. * @param force defines a boolean used to force the update even if cache is up to date
  35342. */
  35343. updateTransformMatrix(force?: boolean): void;
  35344. private _bindFrameBuffer;
  35345. /** @hidden */
  35346. _allowPostProcessClearColor: boolean;
  35347. /** @hidden */
  35348. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35349. private _processSubCameras;
  35350. private _checkIntersections;
  35351. /** @hidden */
  35352. _advancePhysicsEngineStep(step: number): void;
  35353. /**
  35354. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35355. */
  35356. getDeterministicFrameTime: () => number;
  35357. /** @hidden */
  35358. _animate(): void;
  35359. /** Execute all animations (for a frame) */
  35360. animate(): void;
  35361. /**
  35362. * Render the scene
  35363. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35364. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35365. */
  35366. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35367. /**
  35368. * Freeze all materials
  35369. * A frozen material will not be updatable but should be faster to render
  35370. */
  35371. freezeMaterials(): void;
  35372. /**
  35373. * Unfreeze all materials
  35374. * A frozen material will not be updatable but should be faster to render
  35375. */
  35376. unfreezeMaterials(): void;
  35377. /**
  35378. * Releases all held ressources
  35379. */
  35380. dispose(): void;
  35381. /**
  35382. * Gets if the scene is already disposed
  35383. */
  35384. readonly isDisposed: boolean;
  35385. /**
  35386. * Call this function to reduce memory footprint of the scene.
  35387. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35388. */
  35389. clearCachedVertexData(): void;
  35390. /**
  35391. * This function will remove the local cached buffer data from texture.
  35392. * It will save memory but will prevent the texture from being rebuilt
  35393. */
  35394. cleanCachedTextureBuffer(): void;
  35395. /**
  35396. * Get the world extend vectors with an optional filter
  35397. *
  35398. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35399. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35400. */
  35401. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35402. min: Vector3;
  35403. max: Vector3;
  35404. };
  35405. /**
  35406. * Creates a ray that can be used to pick in the scene
  35407. * @param x defines the x coordinate of the origin (on-screen)
  35408. * @param y defines the y coordinate of the origin (on-screen)
  35409. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35410. * @param camera defines the camera to use for the picking
  35411. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35412. * @returns a Ray
  35413. */
  35414. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35415. /**
  35416. * Creates a ray that can be used to pick in the scene
  35417. * @param x defines the x coordinate of the origin (on-screen)
  35418. * @param y defines the y coordinate of the origin (on-screen)
  35419. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35420. * @param result defines the ray where to store the picking ray
  35421. * @param camera defines the camera to use for the picking
  35422. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35423. * @returns the current scene
  35424. */
  35425. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35426. /**
  35427. * Creates a ray that can be used to pick in the scene
  35428. * @param x defines the x coordinate of the origin (on-screen)
  35429. * @param y defines the y coordinate of the origin (on-screen)
  35430. * @param camera defines the camera to use for the picking
  35431. * @returns a Ray
  35432. */
  35433. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35434. /**
  35435. * Creates a ray that can be used to pick in the scene
  35436. * @param x defines the x coordinate of the origin (on-screen)
  35437. * @param y defines the y coordinate of the origin (on-screen)
  35438. * @param result defines the ray where to store the picking ray
  35439. * @param camera defines the camera to use for the picking
  35440. * @returns the current scene
  35441. */
  35442. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35443. /** Launch a ray to try to pick a mesh in the scene
  35444. * @param x position on screen
  35445. * @param y position on screen
  35446. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  35447. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35448. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35449. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35450. * @returns a PickingInfo
  35451. */
  35452. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35453. /** Use the given ray to pick a mesh in the scene
  35454. * @param ray The ray to use to pick meshes
  35455. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  35456. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35457. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35458. * @returns a PickingInfo
  35459. */
  35460. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35461. /**
  35462. * Launch a ray to try to pick a mesh in the scene
  35463. * @param x X position on screen
  35464. * @param y Y position on screen
  35465. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  35466. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35467. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35468. * @returns an array of PickingInfo
  35469. */
  35470. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35471. /**
  35472. * Launch a ray to try to pick a mesh in the scene
  35473. * @param ray Ray to use
  35474. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  35475. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35476. * @returns an array of PickingInfo
  35477. */
  35478. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35479. /**
  35480. * Force the value of meshUnderPointer
  35481. * @param mesh defines the mesh to use
  35482. */
  35483. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35484. /**
  35485. * Gets the mesh under the pointer
  35486. * @returns a Mesh or null if no mesh is under the pointer
  35487. */
  35488. getPointerOverMesh(): Nullable<AbstractMesh>;
  35489. /** @hidden */
  35490. _rebuildGeometries(): void;
  35491. /** @hidden */
  35492. _rebuildTextures(): void;
  35493. private _getByTags;
  35494. /**
  35495. * Get a list of meshes by tags
  35496. * @param tagsQuery defines the tags query to use
  35497. * @param forEach defines a predicate used to filter results
  35498. * @returns an array of Mesh
  35499. */
  35500. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35501. /**
  35502. * Get a list of cameras by tags
  35503. * @param tagsQuery defines the tags query to use
  35504. * @param forEach defines a predicate used to filter results
  35505. * @returns an array of Camera
  35506. */
  35507. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35508. /**
  35509. * Get a list of lights by tags
  35510. * @param tagsQuery defines the tags query to use
  35511. * @param forEach defines a predicate used to filter results
  35512. * @returns an array of Light
  35513. */
  35514. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35515. /**
  35516. * Get a list of materials by tags
  35517. * @param tagsQuery defines the tags query to use
  35518. * @param forEach defines a predicate used to filter results
  35519. * @returns an array of Material
  35520. */
  35521. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35522. /**
  35523. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35524. * This allowed control for front to back rendering or reversly depending of the special needs.
  35525. *
  35526. * @param renderingGroupId The rendering group id corresponding to its index
  35527. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35528. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35529. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35530. */
  35531. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  35532. /**
  35533. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35534. *
  35535. * @param renderingGroupId The rendering group id corresponding to its index
  35536. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35537. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35538. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35539. */
  35540. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35541. /**
  35542. * Gets the current auto clear configuration for one rendering group of the rendering
  35543. * manager.
  35544. * @param index the rendering group index to get the information for
  35545. * @returns The auto clear setup for the requested rendering group
  35546. */
  35547. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35548. private _blockMaterialDirtyMechanism;
  35549. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35550. blockMaterialDirtyMechanism: boolean;
  35551. /**
  35552. * Will flag all materials as dirty to trigger new shader compilation
  35553. * @param flag defines the flag used to specify which material part must be marked as dirty
  35554. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35555. */
  35556. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35557. /** @hidden */
  35558. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35559. /** @hidden */
  35560. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35561. }
  35562. }
  35563. declare module "babylonjs/assetContainer" {
  35564. import { AbstractScene } from "babylonjs/abstractScene";
  35565. import { Scene } from "babylonjs/scene";
  35566. import { Mesh } from "babylonjs/Meshes/mesh";
  35567. /**
  35568. * Set of assets to keep when moving a scene into an asset container.
  35569. */
  35570. export class KeepAssets extends AbstractScene {
  35571. }
  35572. /**
  35573. * Container with a set of assets that can be added or removed from a scene.
  35574. */
  35575. export class AssetContainer extends AbstractScene {
  35576. /**
  35577. * The scene the AssetContainer belongs to.
  35578. */
  35579. scene: Scene;
  35580. /**
  35581. * Instantiates an AssetContainer.
  35582. * @param scene The scene the AssetContainer belongs to.
  35583. */
  35584. constructor(scene: Scene);
  35585. /**
  35586. * Adds all the assets from the container to the scene.
  35587. */
  35588. addAllToScene(): void;
  35589. /**
  35590. * Removes all the assets in the container from the scene
  35591. */
  35592. removeAllFromScene(): void;
  35593. /**
  35594. * Disposes all the assets in the container
  35595. */
  35596. dispose(): void;
  35597. private _moveAssets;
  35598. /**
  35599. * Removes all the assets contained in the scene and adds them to the container.
  35600. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35601. */
  35602. moveAllFromScene(keepAssets?: KeepAssets): void;
  35603. /**
  35604. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  35605. * @returns the root mesh
  35606. */
  35607. createRootMesh(): Mesh;
  35608. }
  35609. }
  35610. declare module "babylonjs/abstractScene" {
  35611. import { Scene } from "babylonjs/scene";
  35612. import { Nullable } from "babylonjs/types";
  35613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35614. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35615. import { Geometry } from "babylonjs/Meshes/geometry";
  35616. import { Skeleton } from "babylonjs/Bones/skeleton";
  35617. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35618. import { AssetContainer } from "babylonjs/assetContainer";
  35619. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35620. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35622. import { Material } from "babylonjs/Materials/material";
  35623. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35624. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35625. import { Camera } from "babylonjs/Cameras/camera";
  35626. import { Light } from "babylonjs/Lights/light";
  35627. import { Node } from "babylonjs/node";
  35628. import { Animation } from "babylonjs/Animations/animation";
  35629. /**
  35630. * Defines how the parser contract is defined.
  35631. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35632. */
  35633. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35634. /**
  35635. * Defines how the individual parser contract is defined.
  35636. * These parser can parse an individual asset
  35637. */
  35638. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35639. /**
  35640. * Base class of the scene acting as a container for the different elements composing a scene.
  35641. * This class is dynamically extended by the different components of the scene increasing
  35642. * flexibility and reducing coupling
  35643. */
  35644. export abstract class AbstractScene {
  35645. /**
  35646. * Stores the list of available parsers in the application.
  35647. */
  35648. private static _BabylonFileParsers;
  35649. /**
  35650. * Stores the list of available individual parsers in the application.
  35651. */
  35652. private static _IndividualBabylonFileParsers;
  35653. /**
  35654. * Adds a parser in the list of available ones
  35655. * @param name Defines the name of the parser
  35656. * @param parser Defines the parser to add
  35657. */
  35658. static AddParser(name: string, parser: BabylonFileParser): void;
  35659. /**
  35660. * Gets a general parser from the list of avaialble ones
  35661. * @param name Defines the name of the parser
  35662. * @returns the requested parser or null
  35663. */
  35664. static GetParser(name: string): Nullable<BabylonFileParser>;
  35665. /**
  35666. * Adds n individual parser in the list of available ones
  35667. * @param name Defines the name of the parser
  35668. * @param parser Defines the parser to add
  35669. */
  35670. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35671. /**
  35672. * Gets an individual parser from the list of avaialble ones
  35673. * @param name Defines the name of the parser
  35674. * @returns the requested parser or null
  35675. */
  35676. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35677. /**
  35678. * Parser json data and populate both a scene and its associated container object
  35679. * @param jsonData Defines the data to parse
  35680. * @param scene Defines the scene to parse the data for
  35681. * @param container Defines the container attached to the parsing sequence
  35682. * @param rootUrl Defines the root url of the data
  35683. */
  35684. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35685. /**
  35686. * Gets the list of root nodes (ie. nodes with no parent)
  35687. */
  35688. rootNodes: Node[];
  35689. /** All of the cameras added to this scene
  35690. * @see http://doc.babylonjs.com/babylon101/cameras
  35691. */
  35692. cameras: Camera[];
  35693. /**
  35694. * All of the lights added to this scene
  35695. * @see http://doc.babylonjs.com/babylon101/lights
  35696. */
  35697. lights: Light[];
  35698. /**
  35699. * All of the (abstract) meshes added to this scene
  35700. */
  35701. meshes: AbstractMesh[];
  35702. /**
  35703. * The list of skeletons added to the scene
  35704. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35705. */
  35706. skeletons: Skeleton[];
  35707. /**
  35708. * All of the particle systems added to this scene
  35709. * @see http://doc.babylonjs.com/babylon101/particles
  35710. */
  35711. particleSystems: IParticleSystem[];
  35712. /**
  35713. * Gets a list of Animations associated with the scene
  35714. */
  35715. animations: Animation[];
  35716. /**
  35717. * All of the animation groups added to this scene
  35718. * @see http://doc.babylonjs.com/how_to/group
  35719. */
  35720. animationGroups: AnimationGroup[];
  35721. /**
  35722. * All of the multi-materials added to this scene
  35723. * @see http://doc.babylonjs.com/how_to/multi_materials
  35724. */
  35725. multiMaterials: MultiMaterial[];
  35726. /**
  35727. * All of the materials added to this scene
  35728. * In the context of a Scene, it is not supposed to be modified manually.
  35729. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35730. * Note also that the order of the Material wihin the array is not significant and might change.
  35731. * @see http://doc.babylonjs.com/babylon101/materials
  35732. */
  35733. materials: Material[];
  35734. /**
  35735. * The list of morph target managers added to the scene
  35736. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35737. */
  35738. morphTargetManagers: MorphTargetManager[];
  35739. /**
  35740. * The list of geometries used in the scene.
  35741. */
  35742. geometries: Geometry[];
  35743. /**
  35744. * All of the tranform nodes added to this scene
  35745. * In the context of a Scene, it is not supposed to be modified manually.
  35746. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35747. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35748. * @see http://doc.babylonjs.com/how_to/transformnode
  35749. */
  35750. transformNodes: TransformNode[];
  35751. /**
  35752. * ActionManagers available on the scene.
  35753. */
  35754. actionManagers: AbstractActionManager[];
  35755. /**
  35756. * Textures to keep.
  35757. */
  35758. textures: BaseTexture[];
  35759. /**
  35760. * Environment texture for the scene
  35761. */
  35762. environmentTexture: Nullable<BaseTexture>;
  35763. }
  35764. }
  35765. declare module "babylonjs/Audio/sound" {
  35766. import { Observable } from "babylonjs/Misc/observable";
  35767. import { Vector3 } from "babylonjs/Maths/math.vector";
  35768. import { Nullable } from "babylonjs/types";
  35769. import { Scene } from "babylonjs/scene";
  35770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35771. /**
  35772. * Interface used to define options for Sound class
  35773. */
  35774. export interface ISoundOptions {
  35775. /**
  35776. * Does the sound autoplay once loaded.
  35777. */
  35778. autoplay?: boolean;
  35779. /**
  35780. * Does the sound loop after it finishes playing once.
  35781. */
  35782. loop?: boolean;
  35783. /**
  35784. * Sound's volume
  35785. */
  35786. volume?: number;
  35787. /**
  35788. * Is it a spatial sound?
  35789. */
  35790. spatialSound?: boolean;
  35791. /**
  35792. * Maximum distance to hear that sound
  35793. */
  35794. maxDistance?: number;
  35795. /**
  35796. * Uses user defined attenuation function
  35797. */
  35798. useCustomAttenuation?: boolean;
  35799. /**
  35800. * Define the roll off factor of spatial sounds.
  35801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35802. */
  35803. rolloffFactor?: number;
  35804. /**
  35805. * Define the reference distance the sound should be heard perfectly.
  35806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35807. */
  35808. refDistance?: number;
  35809. /**
  35810. * Define the distance attenuation model the sound will follow.
  35811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35812. */
  35813. distanceModel?: string;
  35814. /**
  35815. * Defines the playback speed (1 by default)
  35816. */
  35817. playbackRate?: number;
  35818. /**
  35819. * Defines if the sound is from a streaming source
  35820. */
  35821. streaming?: boolean;
  35822. /**
  35823. * Defines an optional length (in seconds) inside the sound file
  35824. */
  35825. length?: number;
  35826. /**
  35827. * Defines an optional offset (in seconds) inside the sound file
  35828. */
  35829. offset?: number;
  35830. /**
  35831. * If true, URLs will not be required to state the audio file codec to use.
  35832. */
  35833. skipCodecCheck?: boolean;
  35834. }
  35835. /**
  35836. * Defines a sound that can be played in the application.
  35837. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35839. */
  35840. export class Sound {
  35841. /**
  35842. * The name of the sound in the scene.
  35843. */
  35844. name: string;
  35845. /**
  35846. * Does the sound autoplay once loaded.
  35847. */
  35848. autoplay: boolean;
  35849. /**
  35850. * Does the sound loop after it finishes playing once.
  35851. */
  35852. loop: boolean;
  35853. /**
  35854. * Does the sound use a custom attenuation curve to simulate the falloff
  35855. * happening when the source gets further away from the camera.
  35856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35857. */
  35858. useCustomAttenuation: boolean;
  35859. /**
  35860. * The sound track id this sound belongs to.
  35861. */
  35862. soundTrackId: number;
  35863. /**
  35864. * Is this sound currently played.
  35865. */
  35866. isPlaying: boolean;
  35867. /**
  35868. * Is this sound currently paused.
  35869. */
  35870. isPaused: boolean;
  35871. /**
  35872. * Does this sound enables spatial sound.
  35873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35874. */
  35875. spatialSound: boolean;
  35876. /**
  35877. * Define the reference distance the sound should be heard perfectly.
  35878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35879. */
  35880. refDistance: number;
  35881. /**
  35882. * Define the roll off factor of spatial sounds.
  35883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35884. */
  35885. rolloffFactor: number;
  35886. /**
  35887. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35889. */
  35890. maxDistance: number;
  35891. /**
  35892. * Define the distance attenuation model the sound will follow.
  35893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35894. */
  35895. distanceModel: string;
  35896. /**
  35897. * @hidden
  35898. * Back Compat
  35899. **/
  35900. onended: () => any;
  35901. /**
  35902. * Observable event when the current playing sound finishes.
  35903. */
  35904. onEndedObservable: Observable<Sound>;
  35905. private _panningModel;
  35906. private _playbackRate;
  35907. private _streaming;
  35908. private _startTime;
  35909. private _startOffset;
  35910. private _position;
  35911. /** @hidden */
  35912. _positionInEmitterSpace: boolean;
  35913. private _localDirection;
  35914. private _volume;
  35915. private _isReadyToPlay;
  35916. private _isDirectional;
  35917. private _readyToPlayCallback;
  35918. private _audioBuffer;
  35919. private _soundSource;
  35920. private _streamingSource;
  35921. private _soundPanner;
  35922. private _soundGain;
  35923. private _inputAudioNode;
  35924. private _outputAudioNode;
  35925. private _coneInnerAngle;
  35926. private _coneOuterAngle;
  35927. private _coneOuterGain;
  35928. private _scene;
  35929. private _connectedTransformNode;
  35930. private _customAttenuationFunction;
  35931. private _registerFunc;
  35932. private _isOutputConnected;
  35933. private _htmlAudioElement;
  35934. private _urlType;
  35935. private _length?;
  35936. private _offset?;
  35937. /** @hidden */
  35938. static _SceneComponentInitialization: (scene: Scene) => void;
  35939. /**
  35940. * Create a sound and attach it to a scene
  35941. * @param name Name of your sound
  35942. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35943. * @param scene defines the scene the sound belongs to
  35944. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35945. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35946. */
  35947. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35948. /**
  35949. * Release the sound and its associated resources
  35950. */
  35951. dispose(): void;
  35952. /**
  35953. * Gets if the sounds is ready to be played or not.
  35954. * @returns true if ready, otherwise false
  35955. */
  35956. isReady(): boolean;
  35957. private _soundLoaded;
  35958. /**
  35959. * Sets the data of the sound from an audiobuffer
  35960. * @param audioBuffer The audioBuffer containing the data
  35961. */
  35962. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35963. /**
  35964. * Updates the current sounds options such as maxdistance, loop...
  35965. * @param options A JSON object containing values named as the object properties
  35966. */
  35967. updateOptions(options: ISoundOptions): void;
  35968. private _createSpatialParameters;
  35969. private _updateSpatialParameters;
  35970. /**
  35971. * Switch the panning model to HRTF:
  35972. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35974. */
  35975. switchPanningModelToHRTF(): void;
  35976. /**
  35977. * Switch the panning model to Equal Power:
  35978. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35980. */
  35981. switchPanningModelToEqualPower(): void;
  35982. private _switchPanningModel;
  35983. /**
  35984. * Connect this sound to a sound track audio node like gain...
  35985. * @param soundTrackAudioNode the sound track audio node to connect to
  35986. */
  35987. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35988. /**
  35989. * Transform this sound into a directional source
  35990. * @param coneInnerAngle Size of the inner cone in degree
  35991. * @param coneOuterAngle Size of the outer cone in degree
  35992. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35993. */
  35994. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35995. /**
  35996. * Gets or sets the inner angle for the directional cone.
  35997. */
  35998. /**
  35999. * Gets or sets the inner angle for the directional cone.
  36000. */
  36001. directionalConeInnerAngle: number;
  36002. /**
  36003. * Gets or sets the outer angle for the directional cone.
  36004. */
  36005. /**
  36006. * Gets or sets the outer angle for the directional cone.
  36007. */
  36008. directionalConeOuterAngle: number;
  36009. /**
  36010. * Sets the position of the emitter if spatial sound is enabled
  36011. * @param newPosition Defines the new posisiton
  36012. */
  36013. setPosition(newPosition: Vector3): void;
  36014. /**
  36015. * Sets the local direction of the emitter if spatial sound is enabled
  36016. * @param newLocalDirection Defines the new local direction
  36017. */
  36018. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36019. private _updateDirection;
  36020. /** @hidden */
  36021. updateDistanceFromListener(): void;
  36022. /**
  36023. * Sets a new custom attenuation function for the sound.
  36024. * @param callback Defines the function used for the attenuation
  36025. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36026. */
  36027. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36028. /**
  36029. * Play the sound
  36030. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36031. * @param offset (optional) Start the sound at a specific time in seconds
  36032. * @param length (optional) Sound duration (in seconds)
  36033. */
  36034. play(time?: number, offset?: number, length?: number): void;
  36035. private _onended;
  36036. /**
  36037. * Stop the sound
  36038. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36039. */
  36040. stop(time?: number): void;
  36041. /**
  36042. * Put the sound in pause
  36043. */
  36044. pause(): void;
  36045. /**
  36046. * Sets a dedicated volume for this sounds
  36047. * @param newVolume Define the new volume of the sound
  36048. * @param time Define time for gradual change to new volume
  36049. */
  36050. setVolume(newVolume: number, time?: number): void;
  36051. /**
  36052. * Set the sound play back rate
  36053. * @param newPlaybackRate Define the playback rate the sound should be played at
  36054. */
  36055. setPlaybackRate(newPlaybackRate: number): void;
  36056. /**
  36057. * Gets the volume of the sound.
  36058. * @returns the volume of the sound
  36059. */
  36060. getVolume(): number;
  36061. /**
  36062. * Attach the sound to a dedicated mesh
  36063. * @param transformNode The transform node to connect the sound with
  36064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36065. */
  36066. attachToMesh(transformNode: TransformNode): void;
  36067. /**
  36068. * Detach the sound from the previously attached mesh
  36069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36070. */
  36071. detachFromMesh(): void;
  36072. private _onRegisterAfterWorldMatrixUpdate;
  36073. /**
  36074. * Clone the current sound in the scene.
  36075. * @returns the new sound clone
  36076. */
  36077. clone(): Nullable<Sound>;
  36078. /**
  36079. * Gets the current underlying audio buffer containing the data
  36080. * @returns the audio buffer
  36081. */
  36082. getAudioBuffer(): Nullable<AudioBuffer>;
  36083. /**
  36084. * Serializes the Sound in a JSON representation
  36085. * @returns the JSON representation of the sound
  36086. */
  36087. serialize(): any;
  36088. /**
  36089. * Parse a JSON representation of a sound to innstantiate in a given scene
  36090. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36091. * @param scene Define the scene the new parsed sound should be created in
  36092. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36093. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36094. * @returns the newly parsed sound
  36095. */
  36096. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36097. }
  36098. }
  36099. declare module "babylonjs/Actions/directAudioActions" {
  36100. import { Action } from "babylonjs/Actions/action";
  36101. import { Condition } from "babylonjs/Actions/condition";
  36102. import { Sound } from "babylonjs/Audio/sound";
  36103. /**
  36104. * This defines an action helpful to play a defined sound on a triggered action.
  36105. */
  36106. export class PlaySoundAction extends Action {
  36107. private _sound;
  36108. /**
  36109. * Instantiate the action
  36110. * @param triggerOptions defines the trigger options
  36111. * @param sound defines the sound to play
  36112. * @param condition defines the trigger related conditions
  36113. */
  36114. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36115. /** @hidden */
  36116. _prepare(): void;
  36117. /**
  36118. * Execute the action and play the sound.
  36119. */
  36120. execute(): void;
  36121. /**
  36122. * Serializes the actions and its related information.
  36123. * @param parent defines the object to serialize in
  36124. * @returns the serialized object
  36125. */
  36126. serialize(parent: any): any;
  36127. }
  36128. /**
  36129. * This defines an action helpful to stop a defined sound on a triggered action.
  36130. */
  36131. export class StopSoundAction extends Action {
  36132. private _sound;
  36133. /**
  36134. * Instantiate the action
  36135. * @param triggerOptions defines the trigger options
  36136. * @param sound defines the sound to stop
  36137. * @param condition defines the trigger related conditions
  36138. */
  36139. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36140. /** @hidden */
  36141. _prepare(): void;
  36142. /**
  36143. * Execute the action and stop the sound.
  36144. */
  36145. execute(): void;
  36146. /**
  36147. * Serializes the actions and its related information.
  36148. * @param parent defines the object to serialize in
  36149. * @returns the serialized object
  36150. */
  36151. serialize(parent: any): any;
  36152. }
  36153. }
  36154. declare module "babylonjs/Actions/interpolateValueAction" {
  36155. import { Action } from "babylonjs/Actions/action";
  36156. import { Condition } from "babylonjs/Actions/condition";
  36157. import { Observable } from "babylonjs/Misc/observable";
  36158. /**
  36159. * This defines an action responsible to change the value of a property
  36160. * by interpolating between its current value and the newly set one once triggered.
  36161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36162. */
  36163. export class InterpolateValueAction extends Action {
  36164. /**
  36165. * Defines the path of the property where the value should be interpolated
  36166. */
  36167. propertyPath: string;
  36168. /**
  36169. * Defines the target value at the end of the interpolation.
  36170. */
  36171. value: any;
  36172. /**
  36173. * Defines the time it will take for the property to interpolate to the value.
  36174. */
  36175. duration: number;
  36176. /**
  36177. * Defines if the other scene animations should be stopped when the action has been triggered
  36178. */
  36179. stopOtherAnimations?: boolean;
  36180. /**
  36181. * Defines a callback raised once the interpolation animation has been done.
  36182. */
  36183. onInterpolationDone?: () => void;
  36184. /**
  36185. * Observable triggered once the interpolation animation has been done.
  36186. */
  36187. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36188. private _target;
  36189. private _effectiveTarget;
  36190. private _property;
  36191. /**
  36192. * Instantiate the action
  36193. * @param triggerOptions defines the trigger options
  36194. * @param target defines the object containing the value to interpolate
  36195. * @param propertyPath defines the path to the property in the target object
  36196. * @param value defines the target value at the end of the interpolation
  36197. * @param duration deines the time it will take for the property to interpolate to the value.
  36198. * @param condition defines the trigger related conditions
  36199. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36200. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36201. */
  36202. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36203. /** @hidden */
  36204. _prepare(): void;
  36205. /**
  36206. * Execute the action starts the value interpolation.
  36207. */
  36208. execute(): void;
  36209. /**
  36210. * Serializes the actions and its related information.
  36211. * @param parent defines the object to serialize in
  36212. * @returns the serialized object
  36213. */
  36214. serialize(parent: any): any;
  36215. }
  36216. }
  36217. declare module "babylonjs/Actions/index" {
  36218. export * from "babylonjs/Actions/abstractActionManager";
  36219. export * from "babylonjs/Actions/action";
  36220. export * from "babylonjs/Actions/actionEvent";
  36221. export * from "babylonjs/Actions/actionManager";
  36222. export * from "babylonjs/Actions/condition";
  36223. export * from "babylonjs/Actions/directActions";
  36224. export * from "babylonjs/Actions/directAudioActions";
  36225. export * from "babylonjs/Actions/interpolateValueAction";
  36226. }
  36227. declare module "babylonjs/Animations/index" {
  36228. export * from "babylonjs/Animations/animatable";
  36229. export * from "babylonjs/Animations/animation";
  36230. export * from "babylonjs/Animations/animationGroup";
  36231. export * from "babylonjs/Animations/animationPropertiesOverride";
  36232. export * from "babylonjs/Animations/easing";
  36233. export * from "babylonjs/Animations/runtimeAnimation";
  36234. export * from "babylonjs/Animations/animationEvent";
  36235. export * from "babylonjs/Animations/animationGroup";
  36236. export * from "babylonjs/Animations/animationKey";
  36237. export * from "babylonjs/Animations/animationRange";
  36238. export * from "babylonjs/Animations/animatable.interface";
  36239. }
  36240. declare module "babylonjs/Audio/soundTrack" {
  36241. import { Sound } from "babylonjs/Audio/sound";
  36242. import { Analyser } from "babylonjs/Audio/analyser";
  36243. import { Scene } from "babylonjs/scene";
  36244. /**
  36245. * Options allowed during the creation of a sound track.
  36246. */
  36247. export interface ISoundTrackOptions {
  36248. /**
  36249. * The volume the sound track should take during creation
  36250. */
  36251. volume?: number;
  36252. /**
  36253. * Define if the sound track is the main sound track of the scene
  36254. */
  36255. mainTrack?: boolean;
  36256. }
  36257. /**
  36258. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36259. * It will be also used in a future release to apply effects on a specific track.
  36260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36261. */
  36262. export class SoundTrack {
  36263. /**
  36264. * The unique identifier of the sound track in the scene.
  36265. */
  36266. id: number;
  36267. /**
  36268. * The list of sounds included in the sound track.
  36269. */
  36270. soundCollection: Array<Sound>;
  36271. private _outputAudioNode;
  36272. private _scene;
  36273. private _isMainTrack;
  36274. private _connectedAnalyser;
  36275. private _options;
  36276. private _isInitialized;
  36277. /**
  36278. * Creates a new sound track.
  36279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36280. * @param scene Define the scene the sound track belongs to
  36281. * @param options
  36282. */
  36283. constructor(scene: Scene, options?: ISoundTrackOptions);
  36284. private _initializeSoundTrackAudioGraph;
  36285. /**
  36286. * Release the sound track and its associated resources
  36287. */
  36288. dispose(): void;
  36289. /**
  36290. * Adds a sound to this sound track
  36291. * @param sound define the cound to add
  36292. * @ignoreNaming
  36293. */
  36294. AddSound(sound: Sound): void;
  36295. /**
  36296. * Removes a sound to this sound track
  36297. * @param sound define the cound to remove
  36298. * @ignoreNaming
  36299. */
  36300. RemoveSound(sound: Sound): void;
  36301. /**
  36302. * Set a global volume for the full sound track.
  36303. * @param newVolume Define the new volume of the sound track
  36304. */
  36305. setVolume(newVolume: number): void;
  36306. /**
  36307. * Switch the panning model to HRTF:
  36308. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36310. */
  36311. switchPanningModelToHRTF(): void;
  36312. /**
  36313. * Switch the panning model to Equal Power:
  36314. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36316. */
  36317. switchPanningModelToEqualPower(): void;
  36318. /**
  36319. * Connect the sound track to an audio analyser allowing some amazing
  36320. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36322. * @param analyser The analyser to connect to the engine
  36323. */
  36324. connectToAnalyser(analyser: Analyser): void;
  36325. }
  36326. }
  36327. declare module "babylonjs/Audio/audioSceneComponent" {
  36328. import { Sound } from "babylonjs/Audio/sound";
  36329. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36330. import { Nullable } from "babylonjs/types";
  36331. import { Vector3 } from "babylonjs/Maths/math.vector";
  36332. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36333. import { Scene } from "babylonjs/scene";
  36334. import { AbstractScene } from "babylonjs/abstractScene";
  36335. import "babylonjs/Audio/audioEngine";
  36336. module "babylonjs/abstractScene" {
  36337. interface AbstractScene {
  36338. /**
  36339. * The list of sounds used in the scene.
  36340. */
  36341. sounds: Nullable<Array<Sound>>;
  36342. }
  36343. }
  36344. module "babylonjs/scene" {
  36345. interface Scene {
  36346. /**
  36347. * @hidden
  36348. * Backing field
  36349. */
  36350. _mainSoundTrack: SoundTrack;
  36351. /**
  36352. * The main sound track played by the scene.
  36353. * It cotains your primary collection of sounds.
  36354. */
  36355. mainSoundTrack: SoundTrack;
  36356. /**
  36357. * The list of sound tracks added to the scene
  36358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36359. */
  36360. soundTracks: Nullable<Array<SoundTrack>>;
  36361. /**
  36362. * Gets a sound using a given name
  36363. * @param name defines the name to search for
  36364. * @return the found sound or null if not found at all.
  36365. */
  36366. getSoundByName(name: string): Nullable<Sound>;
  36367. /**
  36368. * Gets or sets if audio support is enabled
  36369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36370. */
  36371. audioEnabled: boolean;
  36372. /**
  36373. * Gets or sets if audio will be output to headphones
  36374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36375. */
  36376. headphone: boolean;
  36377. /**
  36378. * Gets or sets custom audio listener position provider
  36379. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36380. */
  36381. audioListenerPositionProvider: Nullable<() => Vector3>;
  36382. }
  36383. }
  36384. /**
  36385. * Defines the sound scene component responsible to manage any sounds
  36386. * in a given scene.
  36387. */
  36388. export class AudioSceneComponent implements ISceneSerializableComponent {
  36389. /**
  36390. * The component name helpfull to identify the component in the list of scene components.
  36391. */
  36392. readonly name: string;
  36393. /**
  36394. * The scene the component belongs to.
  36395. */
  36396. scene: Scene;
  36397. private _audioEnabled;
  36398. /**
  36399. * Gets whether audio is enabled or not.
  36400. * Please use related enable/disable method to switch state.
  36401. */
  36402. readonly audioEnabled: boolean;
  36403. private _headphone;
  36404. /**
  36405. * Gets whether audio is outputing to headphone or not.
  36406. * Please use the according Switch methods to change output.
  36407. */
  36408. readonly headphone: boolean;
  36409. private _audioListenerPositionProvider;
  36410. /**
  36411. * Gets the current audio listener position provider
  36412. */
  36413. /**
  36414. * Sets a custom listener position for all sounds in the scene
  36415. * By default, this is the position of the first active camera
  36416. */
  36417. audioListenerPositionProvider: Nullable<() => Vector3>;
  36418. /**
  36419. * Creates a new instance of the component for the given scene
  36420. * @param scene Defines the scene to register the component in
  36421. */
  36422. constructor(scene: Scene);
  36423. /**
  36424. * Registers the component in a given scene
  36425. */
  36426. register(): void;
  36427. /**
  36428. * Rebuilds the elements related to this component in case of
  36429. * context lost for instance.
  36430. */
  36431. rebuild(): void;
  36432. /**
  36433. * Serializes the component data to the specified json object
  36434. * @param serializationObject The object to serialize to
  36435. */
  36436. serialize(serializationObject: any): void;
  36437. /**
  36438. * Adds all the elements from the container to the scene
  36439. * @param container the container holding the elements
  36440. */
  36441. addFromContainer(container: AbstractScene): void;
  36442. /**
  36443. * Removes all the elements in the container from the scene
  36444. * @param container contains the elements to remove
  36445. * @param dispose if the removed element should be disposed (default: false)
  36446. */
  36447. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36448. /**
  36449. * Disposes the component and the associated ressources.
  36450. */
  36451. dispose(): void;
  36452. /**
  36453. * Disables audio in the associated scene.
  36454. */
  36455. disableAudio(): void;
  36456. /**
  36457. * Enables audio in the associated scene.
  36458. */
  36459. enableAudio(): void;
  36460. /**
  36461. * Switch audio to headphone output.
  36462. */
  36463. switchAudioModeForHeadphones(): void;
  36464. /**
  36465. * Switch audio to normal speakers.
  36466. */
  36467. switchAudioModeForNormalSpeakers(): void;
  36468. private _afterRender;
  36469. }
  36470. }
  36471. declare module "babylonjs/Audio/weightedsound" {
  36472. import { Sound } from "babylonjs/Audio/sound";
  36473. /**
  36474. * Wraps one or more Sound objects and selects one with random weight for playback.
  36475. */
  36476. export class WeightedSound {
  36477. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36478. loop: boolean;
  36479. private _coneInnerAngle;
  36480. private _coneOuterAngle;
  36481. private _volume;
  36482. /** A Sound is currently playing. */
  36483. isPlaying: boolean;
  36484. /** A Sound is currently paused. */
  36485. isPaused: boolean;
  36486. private _sounds;
  36487. private _weights;
  36488. private _currentIndex?;
  36489. /**
  36490. * Creates a new WeightedSound from the list of sounds given.
  36491. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36492. * @param sounds Array of Sounds that will be selected from.
  36493. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36494. */
  36495. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36496. /**
  36497. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36498. */
  36499. /**
  36500. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36501. */
  36502. directionalConeInnerAngle: number;
  36503. /**
  36504. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36505. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36506. */
  36507. /**
  36508. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36509. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36510. */
  36511. directionalConeOuterAngle: number;
  36512. /**
  36513. * Playback volume.
  36514. */
  36515. /**
  36516. * Playback volume.
  36517. */
  36518. volume: number;
  36519. private _onended;
  36520. /**
  36521. * Suspend playback
  36522. */
  36523. pause(): void;
  36524. /**
  36525. * Stop playback
  36526. */
  36527. stop(): void;
  36528. /**
  36529. * Start playback.
  36530. * @param startOffset Position the clip head at a specific time in seconds.
  36531. */
  36532. play(startOffset?: number): void;
  36533. }
  36534. }
  36535. declare module "babylonjs/Audio/index" {
  36536. export * from "babylonjs/Audio/analyser";
  36537. export * from "babylonjs/Audio/audioEngine";
  36538. export * from "babylonjs/Audio/audioSceneComponent";
  36539. export * from "babylonjs/Audio/sound";
  36540. export * from "babylonjs/Audio/soundTrack";
  36541. export * from "babylonjs/Audio/weightedsound";
  36542. }
  36543. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36544. import { Behavior } from "babylonjs/Behaviors/behavior";
  36545. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36546. import { BackEase } from "babylonjs/Animations/easing";
  36547. /**
  36548. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36549. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36550. */
  36551. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36552. /**
  36553. * Gets the name of the behavior.
  36554. */
  36555. readonly name: string;
  36556. /**
  36557. * The easing function used by animations
  36558. */
  36559. static EasingFunction: BackEase;
  36560. /**
  36561. * The easing mode used by animations
  36562. */
  36563. static EasingMode: number;
  36564. /**
  36565. * The duration of the animation, in milliseconds
  36566. */
  36567. transitionDuration: number;
  36568. /**
  36569. * Length of the distance animated by the transition when lower radius is reached
  36570. */
  36571. lowerRadiusTransitionRange: number;
  36572. /**
  36573. * Length of the distance animated by the transition when upper radius is reached
  36574. */
  36575. upperRadiusTransitionRange: number;
  36576. private _autoTransitionRange;
  36577. /**
  36578. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36579. */
  36580. /**
  36581. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36582. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36583. */
  36584. autoTransitionRange: boolean;
  36585. private _attachedCamera;
  36586. private _onAfterCheckInputsObserver;
  36587. private _onMeshTargetChangedObserver;
  36588. /**
  36589. * Initializes the behavior.
  36590. */
  36591. init(): void;
  36592. /**
  36593. * Attaches the behavior to its arc rotate camera.
  36594. * @param camera Defines the camera to attach the behavior to
  36595. */
  36596. attach(camera: ArcRotateCamera): void;
  36597. /**
  36598. * Detaches the behavior from its current arc rotate camera.
  36599. */
  36600. detach(): void;
  36601. private _radiusIsAnimating;
  36602. private _radiusBounceTransition;
  36603. private _animatables;
  36604. private _cachedWheelPrecision;
  36605. /**
  36606. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36607. * @param radiusLimit The limit to check against.
  36608. * @return Bool to indicate if at limit.
  36609. */
  36610. private _isRadiusAtLimit;
  36611. /**
  36612. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36613. * @param radiusDelta The delta by which to animate to. Can be negative.
  36614. */
  36615. private _applyBoundRadiusAnimation;
  36616. /**
  36617. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36618. */
  36619. protected _clearAnimationLocks(): void;
  36620. /**
  36621. * Stops and removes all animations that have been applied to the camera
  36622. */
  36623. stopAllAnimations(): void;
  36624. }
  36625. }
  36626. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36627. import { Behavior } from "babylonjs/Behaviors/behavior";
  36628. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36629. import { ExponentialEase } from "babylonjs/Animations/easing";
  36630. import { Nullable } from "babylonjs/types";
  36631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36632. import { Vector3 } from "babylonjs/Maths/math.vector";
  36633. /**
  36634. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  36635. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36636. */
  36637. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36638. /**
  36639. * Gets the name of the behavior.
  36640. */
  36641. readonly name: string;
  36642. private _mode;
  36643. private _radiusScale;
  36644. private _positionScale;
  36645. private _defaultElevation;
  36646. private _elevationReturnTime;
  36647. private _elevationReturnWaitTime;
  36648. private _zoomStopsAnimation;
  36649. private _framingTime;
  36650. /**
  36651. * The easing function used by animations
  36652. */
  36653. static EasingFunction: ExponentialEase;
  36654. /**
  36655. * The easing mode used by animations
  36656. */
  36657. static EasingMode: number;
  36658. /**
  36659. * Sets the current mode used by the behavior
  36660. */
  36661. /**
  36662. * Gets current mode used by the behavior.
  36663. */
  36664. mode: number;
  36665. /**
  36666. * Sets the scale applied to the radius (1 by default)
  36667. */
  36668. /**
  36669. * Gets the scale applied to the radius
  36670. */
  36671. radiusScale: number;
  36672. /**
  36673. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36674. */
  36675. /**
  36676. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36677. */
  36678. positionScale: number;
  36679. /**
  36680. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36681. * behaviour is triggered, in radians.
  36682. */
  36683. /**
  36684. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36685. * behaviour is triggered, in radians.
  36686. */
  36687. defaultElevation: number;
  36688. /**
  36689. * Sets the time (in milliseconds) taken to return to the default beta position.
  36690. * Negative value indicates camera should not return to default.
  36691. */
  36692. /**
  36693. * Gets the time (in milliseconds) taken to return to the default beta position.
  36694. * Negative value indicates camera should not return to default.
  36695. */
  36696. elevationReturnTime: number;
  36697. /**
  36698. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36699. */
  36700. /**
  36701. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36702. */
  36703. elevationReturnWaitTime: number;
  36704. /**
  36705. * Sets the flag that indicates if user zooming should stop animation.
  36706. */
  36707. /**
  36708. * Gets the flag that indicates if user zooming should stop animation.
  36709. */
  36710. zoomStopsAnimation: boolean;
  36711. /**
  36712. * Sets the transition time when framing the mesh, in milliseconds
  36713. */
  36714. /**
  36715. * Gets the transition time when framing the mesh, in milliseconds
  36716. */
  36717. framingTime: number;
  36718. /**
  36719. * Define if the behavior should automatically change the configured
  36720. * camera limits and sensibilities.
  36721. */
  36722. autoCorrectCameraLimitsAndSensibility: boolean;
  36723. private _onPrePointerObservableObserver;
  36724. private _onAfterCheckInputsObserver;
  36725. private _onMeshTargetChangedObserver;
  36726. private _attachedCamera;
  36727. private _isPointerDown;
  36728. private _lastInteractionTime;
  36729. /**
  36730. * Initializes the behavior.
  36731. */
  36732. init(): void;
  36733. /**
  36734. * Attaches the behavior to its arc rotate camera.
  36735. * @param camera Defines the camera to attach the behavior to
  36736. */
  36737. attach(camera: ArcRotateCamera): void;
  36738. /**
  36739. * Detaches the behavior from its current arc rotate camera.
  36740. */
  36741. detach(): void;
  36742. private _animatables;
  36743. private _betaIsAnimating;
  36744. private _betaTransition;
  36745. private _radiusTransition;
  36746. private _vectorTransition;
  36747. /**
  36748. * Targets the given mesh and updates zoom level accordingly.
  36749. * @param mesh The mesh to target.
  36750. * @param radius Optional. If a cached radius position already exists, overrides default.
  36751. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36752. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36753. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36754. */
  36755. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36756. /**
  36757. * Targets the given mesh with its children and updates zoom level accordingly.
  36758. * @param mesh The mesh to target.
  36759. * @param radius Optional. If a cached radius position already exists, overrides default.
  36760. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36761. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36762. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36763. */
  36764. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36765. /**
  36766. * Targets the given meshes with their children and updates zoom level accordingly.
  36767. * @param meshes The mesh to target.
  36768. * @param radius Optional. If a cached radius position already exists, overrides default.
  36769. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36770. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36771. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36772. */
  36773. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36774. /**
  36775. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36776. * @param minimumWorld Determines the smaller position of the bounding box extend
  36777. * @param maximumWorld Determines the bigger position of the bounding box extend
  36778. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36779. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36780. */
  36781. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36782. /**
  36783. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36784. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36785. * frustum width.
  36786. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36787. * to fully enclose the mesh in the viewing frustum.
  36788. */
  36789. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36790. /**
  36791. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36792. * is automatically returned to its default position (expected to be above ground plane).
  36793. */
  36794. private _maintainCameraAboveGround;
  36795. /**
  36796. * Returns the frustum slope based on the canvas ratio and camera FOV
  36797. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36798. */
  36799. private _getFrustumSlope;
  36800. /**
  36801. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36802. */
  36803. private _clearAnimationLocks;
  36804. /**
  36805. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36806. */
  36807. private _applyUserInteraction;
  36808. /**
  36809. * Stops and removes all animations that have been applied to the camera
  36810. */
  36811. stopAllAnimations(): void;
  36812. /**
  36813. * Gets a value indicating if the user is moving the camera
  36814. */
  36815. readonly isUserIsMoving: boolean;
  36816. /**
  36817. * The camera can move all the way towards the mesh.
  36818. */
  36819. static IgnoreBoundsSizeMode: number;
  36820. /**
  36821. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36822. */
  36823. static FitFrustumSidesMode: number;
  36824. }
  36825. }
  36826. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36827. import { Nullable } from "babylonjs/types";
  36828. import { Camera } from "babylonjs/Cameras/camera";
  36829. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36830. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36831. /**
  36832. * Base class for Camera Pointer Inputs.
  36833. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36834. * for example usage.
  36835. */
  36836. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36837. /**
  36838. * Defines the camera the input is attached to.
  36839. */
  36840. abstract camera: Camera;
  36841. /**
  36842. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36843. */
  36844. protected _altKey: boolean;
  36845. protected _ctrlKey: boolean;
  36846. protected _metaKey: boolean;
  36847. protected _shiftKey: boolean;
  36848. /**
  36849. * Which mouse buttons were pressed at time of last mouse event.
  36850. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36851. */
  36852. protected _buttonsPressed: number;
  36853. /**
  36854. * Defines the buttons associated with the input to handle camera move.
  36855. */
  36856. buttons: number[];
  36857. /**
  36858. * Attach the input controls to a specific dom element to get the input from.
  36859. * @param element Defines the element the controls should be listened from
  36860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36861. */
  36862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36863. /**
  36864. * Detach the current controls from the specified dom element.
  36865. * @param element Defines the element to stop listening the inputs from
  36866. */
  36867. detachControl(element: Nullable<HTMLElement>): void;
  36868. /**
  36869. * Gets the class name of the current input.
  36870. * @returns the class name
  36871. */
  36872. getClassName(): string;
  36873. /**
  36874. * Get the friendly name associated with the input class.
  36875. * @returns the input friendly name
  36876. */
  36877. getSimpleName(): string;
  36878. /**
  36879. * Called on pointer POINTERDOUBLETAP event.
  36880. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36881. */
  36882. protected onDoubleTap(type: string): void;
  36883. /**
  36884. * Called on pointer POINTERMOVE event if only a single touch is active.
  36885. * Override this method to provide functionality.
  36886. */
  36887. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36888. /**
  36889. * Called on pointer POINTERMOVE event if multiple touches are active.
  36890. * Override this method to provide functionality.
  36891. */
  36892. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36893. /**
  36894. * Called on JS contextmenu event.
  36895. * Override this method to provide functionality.
  36896. */
  36897. protected onContextMenu(evt: PointerEvent): void;
  36898. /**
  36899. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36900. * press.
  36901. * Override this method to provide functionality.
  36902. */
  36903. protected onButtonDown(evt: PointerEvent): void;
  36904. /**
  36905. * Called each time a new POINTERUP event occurs. Ie, for each button
  36906. * release.
  36907. * Override this method to provide functionality.
  36908. */
  36909. protected onButtonUp(evt: PointerEvent): void;
  36910. /**
  36911. * Called when window becomes inactive.
  36912. * Override this method to provide functionality.
  36913. */
  36914. protected onLostFocus(): void;
  36915. private _pointerInput;
  36916. private _observer;
  36917. private _onLostFocus;
  36918. private pointA;
  36919. private pointB;
  36920. }
  36921. }
  36922. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36923. import { Nullable } from "babylonjs/types";
  36924. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36925. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36926. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36927. /**
  36928. * Manage the pointers inputs to control an arc rotate camera.
  36929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36930. */
  36931. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36932. /**
  36933. * Defines the camera the input is attached to.
  36934. */
  36935. camera: ArcRotateCamera;
  36936. /**
  36937. * Gets the class name of the current input.
  36938. * @returns the class name
  36939. */
  36940. getClassName(): string;
  36941. /**
  36942. * Defines the buttons associated with the input to handle camera move.
  36943. */
  36944. buttons: number[];
  36945. /**
  36946. * Defines the pointer angular sensibility along the X axis or how fast is
  36947. * the camera rotating.
  36948. */
  36949. angularSensibilityX: number;
  36950. /**
  36951. * Defines the pointer angular sensibility along the Y axis or how fast is
  36952. * the camera rotating.
  36953. */
  36954. angularSensibilityY: number;
  36955. /**
  36956. * Defines the pointer pinch precision or how fast is the camera zooming.
  36957. */
  36958. pinchPrecision: number;
  36959. /**
  36960. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36961. * from 0.
  36962. * It defines the percentage of current camera.radius to use as delta when
  36963. * pinch zoom is used.
  36964. */
  36965. pinchDeltaPercentage: number;
  36966. /**
  36967. * Defines the pointer panning sensibility or how fast is the camera moving.
  36968. */
  36969. panningSensibility: number;
  36970. /**
  36971. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36972. */
  36973. multiTouchPanning: boolean;
  36974. /**
  36975. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36976. * zoom (pinch) through multitouch.
  36977. */
  36978. multiTouchPanAndZoom: boolean;
  36979. /**
  36980. * Revers pinch action direction.
  36981. */
  36982. pinchInwards: boolean;
  36983. private _isPanClick;
  36984. private _twoFingerActivityCount;
  36985. private _isPinching;
  36986. /**
  36987. * Called on pointer POINTERMOVE event if only a single touch is active.
  36988. */
  36989. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36990. /**
  36991. * Called on pointer POINTERDOUBLETAP event.
  36992. */
  36993. protected onDoubleTap(type: string): void;
  36994. /**
  36995. * Called on pointer POINTERMOVE event if multiple touches are active.
  36996. */
  36997. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36998. /**
  36999. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37000. * press.
  37001. */
  37002. protected onButtonDown(evt: PointerEvent): void;
  37003. /**
  37004. * Called each time a new POINTERUP event occurs. Ie, for each button
  37005. * release.
  37006. */
  37007. protected onButtonUp(evt: PointerEvent): void;
  37008. /**
  37009. * Called when window becomes inactive.
  37010. */
  37011. protected onLostFocus(): void;
  37012. }
  37013. }
  37014. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37015. import { Nullable } from "babylonjs/types";
  37016. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37017. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37018. /**
  37019. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37021. */
  37022. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37023. /**
  37024. * Defines the camera the input is attached to.
  37025. */
  37026. camera: ArcRotateCamera;
  37027. /**
  37028. * Defines the list of key codes associated with the up action (increase alpha)
  37029. */
  37030. keysUp: number[];
  37031. /**
  37032. * Defines the list of key codes associated with the down action (decrease alpha)
  37033. */
  37034. keysDown: number[];
  37035. /**
  37036. * Defines the list of key codes associated with the left action (increase beta)
  37037. */
  37038. keysLeft: number[];
  37039. /**
  37040. * Defines the list of key codes associated with the right action (decrease beta)
  37041. */
  37042. keysRight: number[];
  37043. /**
  37044. * Defines the list of key codes associated with the reset action.
  37045. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37046. */
  37047. keysReset: number[];
  37048. /**
  37049. * Defines the panning sensibility of the inputs.
  37050. * (How fast is the camera paning)
  37051. */
  37052. panningSensibility: number;
  37053. /**
  37054. * Defines the zooming sensibility of the inputs.
  37055. * (How fast is the camera zooming)
  37056. */
  37057. zoomingSensibility: number;
  37058. /**
  37059. * Defines wether maintaining the alt key down switch the movement mode from
  37060. * orientation to zoom.
  37061. */
  37062. useAltToZoom: boolean;
  37063. /**
  37064. * Rotation speed of the camera
  37065. */
  37066. angularSpeed: number;
  37067. private _keys;
  37068. private _ctrlPressed;
  37069. private _altPressed;
  37070. private _onCanvasBlurObserver;
  37071. private _onKeyboardObserver;
  37072. private _engine;
  37073. private _scene;
  37074. /**
  37075. * Attach the input controls to a specific dom element to get the input from.
  37076. * @param element Defines the element the controls should be listened from
  37077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37078. */
  37079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37080. /**
  37081. * Detach the current controls from the specified dom element.
  37082. * @param element Defines the element to stop listening the inputs from
  37083. */
  37084. detachControl(element: Nullable<HTMLElement>): void;
  37085. /**
  37086. * Update the current camera state depending on the inputs that have been used this frame.
  37087. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37088. */
  37089. checkInputs(): void;
  37090. /**
  37091. * Gets the class name of the current intput.
  37092. * @returns the class name
  37093. */
  37094. getClassName(): string;
  37095. /**
  37096. * Get the friendly name associated with the input class.
  37097. * @returns the input friendly name
  37098. */
  37099. getSimpleName(): string;
  37100. }
  37101. }
  37102. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37103. import { Nullable } from "babylonjs/types";
  37104. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37105. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37106. /**
  37107. * Manage the mouse wheel inputs to control an arc rotate camera.
  37108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37109. */
  37110. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37111. /**
  37112. * Defines the camera the input is attached to.
  37113. */
  37114. camera: ArcRotateCamera;
  37115. /**
  37116. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37117. */
  37118. wheelPrecision: number;
  37119. /**
  37120. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37121. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37122. */
  37123. wheelDeltaPercentage: number;
  37124. private _wheel;
  37125. private _observer;
  37126. private computeDeltaFromMouseWheelLegacyEvent;
  37127. /**
  37128. * Attach the input controls to a specific dom element to get the input from.
  37129. * @param element Defines the element the controls should be listened from
  37130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37131. */
  37132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37133. /**
  37134. * Detach the current controls from the specified dom element.
  37135. * @param element Defines the element to stop listening the inputs from
  37136. */
  37137. detachControl(element: Nullable<HTMLElement>): void;
  37138. /**
  37139. * Gets the class name of the current intput.
  37140. * @returns the class name
  37141. */
  37142. getClassName(): string;
  37143. /**
  37144. * Get the friendly name associated with the input class.
  37145. * @returns the input friendly name
  37146. */
  37147. getSimpleName(): string;
  37148. }
  37149. }
  37150. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37151. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37152. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37153. /**
  37154. * Default Inputs manager for the ArcRotateCamera.
  37155. * It groups all the default supported inputs for ease of use.
  37156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37157. */
  37158. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37159. /**
  37160. * Instantiates a new ArcRotateCameraInputsManager.
  37161. * @param camera Defines the camera the inputs belong to
  37162. */
  37163. constructor(camera: ArcRotateCamera);
  37164. /**
  37165. * Add mouse wheel input support to the input manager.
  37166. * @returns the current input manager
  37167. */
  37168. addMouseWheel(): ArcRotateCameraInputsManager;
  37169. /**
  37170. * Add pointers input support to the input manager.
  37171. * @returns the current input manager
  37172. */
  37173. addPointers(): ArcRotateCameraInputsManager;
  37174. /**
  37175. * Add keyboard input support to the input manager.
  37176. * @returns the current input manager
  37177. */
  37178. addKeyboard(): ArcRotateCameraInputsManager;
  37179. }
  37180. }
  37181. declare module "babylonjs/Cameras/arcRotateCamera" {
  37182. import { Observable } from "babylonjs/Misc/observable";
  37183. import { Nullable } from "babylonjs/types";
  37184. import { Scene } from "babylonjs/scene";
  37185. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37187. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37188. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37189. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37190. import { Camera } from "babylonjs/Cameras/camera";
  37191. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37192. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37193. import { Collider } from "babylonjs/Collisions/collider";
  37194. /**
  37195. * This represents an orbital type of camera.
  37196. *
  37197. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  37198. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  37199. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37200. */
  37201. export class ArcRotateCamera extends TargetCamera {
  37202. /**
  37203. * Defines the rotation angle of the camera along the longitudinal axis.
  37204. */
  37205. alpha: number;
  37206. /**
  37207. * Defines the rotation angle of the camera along the latitudinal axis.
  37208. */
  37209. beta: number;
  37210. /**
  37211. * Defines the radius of the camera from it s target point.
  37212. */
  37213. radius: number;
  37214. protected _target: Vector3;
  37215. protected _targetHost: Nullable<AbstractMesh>;
  37216. /**
  37217. * Defines the target point of the camera.
  37218. * The camera looks towards it form the radius distance.
  37219. */
  37220. target: Vector3;
  37221. /**
  37222. * Define the current local position of the camera in the scene
  37223. */
  37224. position: Vector3;
  37225. protected _upVector: Vector3;
  37226. protected _upToYMatrix: Matrix;
  37227. protected _YToUpMatrix: Matrix;
  37228. /**
  37229. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37230. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37231. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37232. */
  37233. upVector: Vector3;
  37234. /**
  37235. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37236. */
  37237. setMatUp(): void;
  37238. /**
  37239. * Current inertia value on the longitudinal axis.
  37240. * The bigger this number the longer it will take for the camera to stop.
  37241. */
  37242. inertialAlphaOffset: number;
  37243. /**
  37244. * Current inertia value on the latitudinal axis.
  37245. * The bigger this number the longer it will take for the camera to stop.
  37246. */
  37247. inertialBetaOffset: number;
  37248. /**
  37249. * Current inertia value on the radius axis.
  37250. * The bigger this number the longer it will take for the camera to stop.
  37251. */
  37252. inertialRadiusOffset: number;
  37253. /**
  37254. * Minimum allowed angle on the longitudinal axis.
  37255. * This can help limiting how the Camera is able to move in the scene.
  37256. */
  37257. lowerAlphaLimit: Nullable<number>;
  37258. /**
  37259. * Maximum allowed angle on the longitudinal axis.
  37260. * This can help limiting how the Camera is able to move in the scene.
  37261. */
  37262. upperAlphaLimit: Nullable<number>;
  37263. /**
  37264. * Minimum allowed angle on the latitudinal axis.
  37265. * This can help limiting how the Camera is able to move in the scene.
  37266. */
  37267. lowerBetaLimit: number;
  37268. /**
  37269. * Maximum allowed angle on the latitudinal axis.
  37270. * This can help limiting how the Camera is able to move in the scene.
  37271. */
  37272. upperBetaLimit: number;
  37273. /**
  37274. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37275. * This can help limiting how the Camera is able to move in the scene.
  37276. */
  37277. lowerRadiusLimit: Nullable<number>;
  37278. /**
  37279. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37280. * This can help limiting how the Camera is able to move in the scene.
  37281. */
  37282. upperRadiusLimit: Nullable<number>;
  37283. /**
  37284. * Defines the current inertia value used during panning of the camera along the X axis.
  37285. */
  37286. inertialPanningX: number;
  37287. /**
  37288. * Defines the current inertia value used during panning of the camera along the Y axis.
  37289. */
  37290. inertialPanningY: number;
  37291. /**
  37292. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37293. * Basically if your fingers moves away from more than this distance you will be considered
  37294. * in pinch mode.
  37295. */
  37296. pinchToPanMaxDistance: number;
  37297. /**
  37298. * Defines the maximum distance the camera can pan.
  37299. * This could help keeping the cammera always in your scene.
  37300. */
  37301. panningDistanceLimit: Nullable<number>;
  37302. /**
  37303. * Defines the target of the camera before paning.
  37304. */
  37305. panningOriginTarget: Vector3;
  37306. /**
  37307. * Defines the value of the inertia used during panning.
  37308. * 0 would mean stop inertia and one would mean no decelleration at all.
  37309. */
  37310. panningInertia: number;
  37311. /**
  37312. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37313. */
  37314. angularSensibilityX: number;
  37315. /**
  37316. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37317. */
  37318. angularSensibilityY: number;
  37319. /**
  37320. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37321. */
  37322. pinchPrecision: number;
  37323. /**
  37324. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37325. * It will be used instead of pinchDeltaPrecision if different from 0.
  37326. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37327. */
  37328. pinchDeltaPercentage: number;
  37329. /**
  37330. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37331. */
  37332. panningSensibility: number;
  37333. /**
  37334. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37335. */
  37336. keysUp: number[];
  37337. /**
  37338. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37339. */
  37340. keysDown: number[];
  37341. /**
  37342. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37343. */
  37344. keysLeft: number[];
  37345. /**
  37346. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37347. */
  37348. keysRight: number[];
  37349. /**
  37350. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37351. */
  37352. wheelPrecision: number;
  37353. /**
  37354. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37355. * It will be used instead of pinchDeltaPrecision if different from 0.
  37356. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37357. */
  37358. wheelDeltaPercentage: number;
  37359. /**
  37360. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37361. */
  37362. zoomOnFactor: number;
  37363. /**
  37364. * Defines a screen offset for the camera position.
  37365. */
  37366. targetScreenOffset: Vector2;
  37367. /**
  37368. * Allows the camera to be completely reversed.
  37369. * If false the camera can not arrive upside down.
  37370. */
  37371. allowUpsideDown: boolean;
  37372. /**
  37373. * Define if double tap/click is used to restore the previously saved state of the camera.
  37374. */
  37375. useInputToRestoreState: boolean;
  37376. /** @hidden */
  37377. _viewMatrix: Matrix;
  37378. /** @hidden */
  37379. _useCtrlForPanning: boolean;
  37380. /** @hidden */
  37381. _panningMouseButton: number;
  37382. /**
  37383. * Defines the input associated to the camera.
  37384. */
  37385. inputs: ArcRotateCameraInputsManager;
  37386. /** @hidden */
  37387. _reset: () => void;
  37388. /**
  37389. * Defines the allowed panning axis.
  37390. */
  37391. panningAxis: Vector3;
  37392. protected _localDirection: Vector3;
  37393. protected _transformedDirection: Vector3;
  37394. private _bouncingBehavior;
  37395. /**
  37396. * Gets the bouncing behavior of the camera if it has been enabled.
  37397. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37398. */
  37399. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37400. /**
  37401. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37403. */
  37404. useBouncingBehavior: boolean;
  37405. private _framingBehavior;
  37406. /**
  37407. * Gets the framing behavior of the camera if it has been enabled.
  37408. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37409. */
  37410. readonly framingBehavior: Nullable<FramingBehavior>;
  37411. /**
  37412. * Defines if the framing behavior of the camera is enabled on the camera.
  37413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37414. */
  37415. useFramingBehavior: boolean;
  37416. private _autoRotationBehavior;
  37417. /**
  37418. * Gets the auto rotation behavior of the camera if it has been enabled.
  37419. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37420. */
  37421. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37422. /**
  37423. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37424. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37425. */
  37426. useAutoRotationBehavior: boolean;
  37427. /**
  37428. * Observable triggered when the mesh target has been changed on the camera.
  37429. */
  37430. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37431. /**
  37432. * Event raised when the camera is colliding with a mesh.
  37433. */
  37434. onCollide: (collidedMesh: AbstractMesh) => void;
  37435. /**
  37436. * Defines whether the camera should check collision with the objects oh the scene.
  37437. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37438. */
  37439. checkCollisions: boolean;
  37440. /**
  37441. * Defines the collision radius of the camera.
  37442. * This simulates a sphere around the camera.
  37443. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37444. */
  37445. collisionRadius: Vector3;
  37446. protected _collider: Collider;
  37447. protected _previousPosition: Vector3;
  37448. protected _collisionVelocity: Vector3;
  37449. protected _newPosition: Vector3;
  37450. protected _previousAlpha: number;
  37451. protected _previousBeta: number;
  37452. protected _previousRadius: number;
  37453. protected _collisionTriggered: boolean;
  37454. protected _targetBoundingCenter: Nullable<Vector3>;
  37455. private _computationVector;
  37456. /**
  37457. * Instantiates a new ArcRotateCamera in a given scene
  37458. * @param name Defines the name of the camera
  37459. * @param alpha Defines the camera rotation along the logitudinal axis
  37460. * @param beta Defines the camera rotation along the latitudinal axis
  37461. * @param radius Defines the camera distance from its target
  37462. * @param target Defines the camera target
  37463. * @param scene Defines the scene the camera belongs to
  37464. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37465. */
  37466. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37467. /** @hidden */
  37468. _initCache(): void;
  37469. /** @hidden */
  37470. _updateCache(ignoreParentClass?: boolean): void;
  37471. protected _getTargetPosition(): Vector3;
  37472. private _storedAlpha;
  37473. private _storedBeta;
  37474. private _storedRadius;
  37475. private _storedTarget;
  37476. private _storedTargetScreenOffset;
  37477. /**
  37478. * Stores the current state of the camera (alpha, beta, radius and target)
  37479. * @returns the camera itself
  37480. */
  37481. storeState(): Camera;
  37482. /**
  37483. * @hidden
  37484. * Restored camera state. You must call storeState() first
  37485. */
  37486. _restoreStateValues(): boolean;
  37487. /** @hidden */
  37488. _isSynchronizedViewMatrix(): boolean;
  37489. /**
  37490. * Attached controls to the current camera.
  37491. * @param element Defines the element the controls should be listened from
  37492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37493. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37494. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37495. */
  37496. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37497. /**
  37498. * Detach the current controls from the camera.
  37499. * The camera will stop reacting to inputs.
  37500. * @param element Defines the element to stop listening the inputs from
  37501. */
  37502. detachControl(element: HTMLElement): void;
  37503. /** @hidden */
  37504. _checkInputs(): void;
  37505. protected _checkLimits(): void;
  37506. /**
  37507. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37508. */
  37509. rebuildAnglesAndRadius(): void;
  37510. /**
  37511. * Use a position to define the current camera related information like aplha, beta and radius
  37512. * @param position Defines the position to set the camera at
  37513. */
  37514. setPosition(position: Vector3): void;
  37515. /**
  37516. * Defines the target the camera should look at.
  37517. * This will automatically adapt alpha beta and radius to fit within the new target.
  37518. * @param target Defines the new target as a Vector or a mesh
  37519. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37520. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37521. */
  37522. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37523. /** @hidden */
  37524. _getViewMatrix(): Matrix;
  37525. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37526. /**
  37527. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37528. * @param meshes Defines the mesh to zoom on
  37529. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  37530. */
  37531. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37532. /**
  37533. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37534. * The target will be changed but the radius
  37535. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37536. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  37537. */
  37538. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37539. min: Vector3;
  37540. max: Vector3;
  37541. distance: number;
  37542. }, doNotUpdateMaxZ?: boolean): void;
  37543. /**
  37544. * @override
  37545. * Override Camera.createRigCamera
  37546. */
  37547. createRigCamera(name: string, cameraIndex: number): Camera;
  37548. /**
  37549. * @hidden
  37550. * @override
  37551. * Override Camera._updateRigCameras
  37552. */
  37553. _updateRigCameras(): void;
  37554. /**
  37555. * Destroy the camera and release the current resources hold by it.
  37556. */
  37557. dispose(): void;
  37558. /**
  37559. * Gets the current object class name.
  37560. * @return the class name
  37561. */
  37562. getClassName(): string;
  37563. }
  37564. }
  37565. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37566. import { Behavior } from "babylonjs/Behaviors/behavior";
  37567. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37568. /**
  37569. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37570. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37571. */
  37572. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37573. /**
  37574. * Gets the name of the behavior.
  37575. */
  37576. readonly name: string;
  37577. private _zoomStopsAnimation;
  37578. private _idleRotationSpeed;
  37579. private _idleRotationWaitTime;
  37580. private _idleRotationSpinupTime;
  37581. /**
  37582. * Sets the flag that indicates if user zooming should stop animation.
  37583. */
  37584. /**
  37585. * Gets the flag that indicates if user zooming should stop animation.
  37586. */
  37587. zoomStopsAnimation: boolean;
  37588. /**
  37589. * Sets the default speed at which the camera rotates around the model.
  37590. */
  37591. /**
  37592. * Gets the default speed at which the camera rotates around the model.
  37593. */
  37594. idleRotationSpeed: number;
  37595. /**
  37596. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37597. */
  37598. /**
  37599. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37600. */
  37601. idleRotationWaitTime: number;
  37602. /**
  37603. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37604. */
  37605. /**
  37606. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37607. */
  37608. idleRotationSpinupTime: number;
  37609. /**
  37610. * Gets a value indicating if the camera is currently rotating because of this behavior
  37611. */
  37612. readonly rotationInProgress: boolean;
  37613. private _onPrePointerObservableObserver;
  37614. private _onAfterCheckInputsObserver;
  37615. private _attachedCamera;
  37616. private _isPointerDown;
  37617. private _lastFrameTime;
  37618. private _lastInteractionTime;
  37619. private _cameraRotationSpeed;
  37620. /**
  37621. * Initializes the behavior.
  37622. */
  37623. init(): void;
  37624. /**
  37625. * Attaches the behavior to its arc rotate camera.
  37626. * @param camera Defines the camera to attach the behavior to
  37627. */
  37628. attach(camera: ArcRotateCamera): void;
  37629. /**
  37630. * Detaches the behavior from its current arc rotate camera.
  37631. */
  37632. detach(): void;
  37633. /**
  37634. * Returns true if user is scrolling.
  37635. * @return true if user is scrolling.
  37636. */
  37637. private _userIsZooming;
  37638. private _lastFrameRadius;
  37639. private _shouldAnimationStopForInteraction;
  37640. /**
  37641. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37642. */
  37643. private _applyUserInteraction;
  37644. private _userIsMoving;
  37645. }
  37646. }
  37647. declare module "babylonjs/Behaviors/Cameras/index" {
  37648. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37649. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37650. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37651. }
  37652. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37653. import { Mesh } from "babylonjs/Meshes/mesh";
  37654. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37655. import { Behavior } from "babylonjs/Behaviors/behavior";
  37656. /**
  37657. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37658. */
  37659. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37660. private ui;
  37661. /**
  37662. * The name of the behavior
  37663. */
  37664. name: string;
  37665. /**
  37666. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37667. */
  37668. distanceAwayFromFace: number;
  37669. /**
  37670. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37671. */
  37672. distanceAwayFromBottomOfFace: number;
  37673. private _faceVectors;
  37674. private _target;
  37675. private _scene;
  37676. private _onRenderObserver;
  37677. private _tmpMatrix;
  37678. private _tmpVector;
  37679. /**
  37680. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37681. * @param ui The transform node that should be attched to the mesh
  37682. */
  37683. constructor(ui: TransformNode);
  37684. /**
  37685. * Initializes the behavior
  37686. */
  37687. init(): void;
  37688. private _closestFace;
  37689. private _zeroVector;
  37690. private _lookAtTmpMatrix;
  37691. private _lookAtToRef;
  37692. /**
  37693. * Attaches the AttachToBoxBehavior to the passed in mesh
  37694. * @param target The mesh that the specified node will be attached to
  37695. */
  37696. attach(target: Mesh): void;
  37697. /**
  37698. * Detaches the behavior from the mesh
  37699. */
  37700. detach(): void;
  37701. }
  37702. }
  37703. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37704. import { Behavior } from "babylonjs/Behaviors/behavior";
  37705. import { Mesh } from "babylonjs/Meshes/mesh";
  37706. /**
  37707. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37708. */
  37709. export class FadeInOutBehavior implements Behavior<Mesh> {
  37710. /**
  37711. * Time in milliseconds to delay before fading in (Default: 0)
  37712. */
  37713. delay: number;
  37714. /**
  37715. * Time in milliseconds for the mesh to fade in (Default: 300)
  37716. */
  37717. fadeInTime: number;
  37718. private _millisecondsPerFrame;
  37719. private _hovered;
  37720. private _hoverValue;
  37721. private _ownerNode;
  37722. /**
  37723. * Instatiates the FadeInOutBehavior
  37724. */
  37725. constructor();
  37726. /**
  37727. * The name of the behavior
  37728. */
  37729. readonly name: string;
  37730. /**
  37731. * Initializes the behavior
  37732. */
  37733. init(): void;
  37734. /**
  37735. * Attaches the fade behavior on the passed in mesh
  37736. * @param ownerNode The mesh that will be faded in/out once attached
  37737. */
  37738. attach(ownerNode: Mesh): void;
  37739. /**
  37740. * Detaches the behavior from the mesh
  37741. */
  37742. detach(): void;
  37743. /**
  37744. * Triggers the mesh to begin fading in or out
  37745. * @param value if the object should fade in or out (true to fade in)
  37746. */
  37747. fadeIn(value: boolean): void;
  37748. private _update;
  37749. private _setAllVisibility;
  37750. }
  37751. }
  37752. declare module "babylonjs/Misc/pivotTools" {
  37753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37754. /**
  37755. * Class containing a set of static utilities functions for managing Pivots
  37756. * @hidden
  37757. */
  37758. export class PivotTools {
  37759. private static _PivotCached;
  37760. private static _OldPivotPoint;
  37761. private static _PivotTranslation;
  37762. private static _PivotTmpVector;
  37763. /** @hidden */
  37764. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37765. /** @hidden */
  37766. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37767. }
  37768. }
  37769. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37770. import { Scene } from "babylonjs/scene";
  37771. import { Vector4 } from "babylonjs/Maths/math.vector";
  37772. import { Mesh } from "babylonjs/Meshes/mesh";
  37773. import { Nullable } from "babylonjs/types";
  37774. import { Plane } from "babylonjs/Maths/math.plane";
  37775. /**
  37776. * Class containing static functions to help procedurally build meshes
  37777. */
  37778. export class PlaneBuilder {
  37779. /**
  37780. * Creates a plane mesh
  37781. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37782. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37783. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37787. * @param name defines the name of the mesh
  37788. * @param options defines the options used to create the mesh
  37789. * @param scene defines the hosting scene
  37790. * @returns the plane mesh
  37791. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37792. */
  37793. static CreatePlane(name: string, options: {
  37794. size?: number;
  37795. width?: number;
  37796. height?: number;
  37797. sideOrientation?: number;
  37798. frontUVs?: Vector4;
  37799. backUVs?: Vector4;
  37800. updatable?: boolean;
  37801. sourcePlane?: Plane;
  37802. }, scene?: Nullable<Scene>): Mesh;
  37803. }
  37804. }
  37805. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37806. import { Behavior } from "babylonjs/Behaviors/behavior";
  37807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37808. import { Observable } from "babylonjs/Misc/observable";
  37809. import { Vector3 } from "babylonjs/Maths/math.vector";
  37810. import { Ray } from "babylonjs/Culling/ray";
  37811. import "babylonjs/Meshes/Builders/planeBuilder";
  37812. /**
  37813. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37814. */
  37815. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37816. private static _AnyMouseID;
  37817. /**
  37818. * Abstract mesh the behavior is set on
  37819. */
  37820. attachedNode: AbstractMesh;
  37821. private _dragPlane;
  37822. private _scene;
  37823. private _pointerObserver;
  37824. private _beforeRenderObserver;
  37825. private static _planeScene;
  37826. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37827. /**
  37828. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  37829. */
  37830. maxDragAngle: number;
  37831. /**
  37832. * @hidden
  37833. */
  37834. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37835. /**
  37836. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37837. */
  37838. currentDraggingPointerID: number;
  37839. /**
  37840. * The last position where the pointer hit the drag plane in world space
  37841. */
  37842. lastDragPosition: Vector3;
  37843. /**
  37844. * If the behavior is currently in a dragging state
  37845. */
  37846. dragging: boolean;
  37847. /**
  37848. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  37849. */
  37850. dragDeltaRatio: number;
  37851. /**
  37852. * If the drag plane orientation should be updated during the dragging (Default: true)
  37853. */
  37854. updateDragPlane: boolean;
  37855. private _debugMode;
  37856. private _moving;
  37857. /**
  37858. * Fires each time the attached mesh is dragged with the pointer
  37859. * * delta between last drag position and current drag position in world space
  37860. * * dragDistance along the drag axis
  37861. * * dragPlaneNormal normal of the current drag plane used during the drag
  37862. * * dragPlanePoint in world space where the drag intersects the drag plane
  37863. */
  37864. onDragObservable: Observable<{
  37865. delta: Vector3;
  37866. dragPlanePoint: Vector3;
  37867. dragPlaneNormal: Vector3;
  37868. dragDistance: number;
  37869. pointerId: number;
  37870. }>;
  37871. /**
  37872. * Fires each time a drag begins (eg. mouse down on mesh)
  37873. */
  37874. onDragStartObservable: Observable<{
  37875. dragPlanePoint: Vector3;
  37876. pointerId: number;
  37877. }>;
  37878. /**
  37879. * Fires each time a drag ends (eg. mouse release after drag)
  37880. */
  37881. onDragEndObservable: Observable<{
  37882. dragPlanePoint: Vector3;
  37883. pointerId: number;
  37884. }>;
  37885. /**
  37886. * If the attached mesh should be moved when dragged
  37887. */
  37888. moveAttached: boolean;
  37889. /**
  37890. * If the drag behavior will react to drag events (Default: true)
  37891. */
  37892. enabled: boolean;
  37893. /**
  37894. * If pointer events should start and release the drag (Default: true)
  37895. */
  37896. startAndReleaseDragOnPointerEvents: boolean;
  37897. /**
  37898. * If camera controls should be detached during the drag
  37899. */
  37900. detachCameraControls: boolean;
  37901. /**
  37902. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37903. */
  37904. useObjectOrienationForDragging: boolean;
  37905. private _options;
  37906. /**
  37907. * Creates a pointer drag behavior that can be attached to a mesh
  37908. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  37909. */
  37910. constructor(options?: {
  37911. dragAxis?: Vector3;
  37912. dragPlaneNormal?: Vector3;
  37913. });
  37914. /**
  37915. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37916. */
  37917. validateDrag: (targetPosition: Vector3) => boolean;
  37918. /**
  37919. * The name of the behavior
  37920. */
  37921. readonly name: string;
  37922. /**
  37923. * Initializes the behavior
  37924. */
  37925. init(): void;
  37926. private _tmpVector;
  37927. private _alternatePickedPoint;
  37928. private _worldDragAxis;
  37929. private _targetPosition;
  37930. private _attachedElement;
  37931. /**
  37932. * Attaches the drag behavior the passed in mesh
  37933. * @param ownerNode The mesh that will be dragged around once attached
  37934. * @param predicate Predicate to use for pick filtering
  37935. */
  37936. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37937. /**
  37938. * Force relase the drag action by code.
  37939. */
  37940. releaseDrag(): void;
  37941. private _startDragRay;
  37942. private _lastPointerRay;
  37943. /**
  37944. * Simulates the start of a pointer drag event on the behavior
  37945. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37946. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37947. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37948. */
  37949. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37950. private _startDrag;
  37951. private _dragDelta;
  37952. private _moveDrag;
  37953. private _pickWithRayOnDragPlane;
  37954. private _pointA;
  37955. private _pointB;
  37956. private _pointC;
  37957. private _lineA;
  37958. private _lineB;
  37959. private _localAxis;
  37960. private _lookAt;
  37961. private _updateDragPlanePosition;
  37962. /**
  37963. * Detaches the behavior from the mesh
  37964. */
  37965. detach(): void;
  37966. }
  37967. }
  37968. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37969. import { Mesh } from "babylonjs/Meshes/mesh";
  37970. import { Behavior } from "babylonjs/Behaviors/behavior";
  37971. /**
  37972. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37973. */
  37974. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37975. private _dragBehaviorA;
  37976. private _dragBehaviorB;
  37977. private _startDistance;
  37978. private _initialScale;
  37979. private _targetScale;
  37980. private _ownerNode;
  37981. private _sceneRenderObserver;
  37982. /**
  37983. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37984. */
  37985. constructor();
  37986. /**
  37987. * The name of the behavior
  37988. */
  37989. readonly name: string;
  37990. /**
  37991. * Initializes the behavior
  37992. */
  37993. init(): void;
  37994. private _getCurrentDistance;
  37995. /**
  37996. * Attaches the scale behavior the passed in mesh
  37997. * @param ownerNode The mesh that will be scaled around once attached
  37998. */
  37999. attach(ownerNode: Mesh): void;
  38000. /**
  38001. * Detaches the behavior from the mesh
  38002. */
  38003. detach(): void;
  38004. }
  38005. }
  38006. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38007. import { Behavior } from "babylonjs/Behaviors/behavior";
  38008. import { Mesh } from "babylonjs/Meshes/mesh";
  38009. import { Observable } from "babylonjs/Misc/observable";
  38010. /**
  38011. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  38012. */
  38013. export class SixDofDragBehavior implements Behavior<Mesh> {
  38014. private static _virtualScene;
  38015. private _ownerNode;
  38016. private _sceneRenderObserver;
  38017. private _scene;
  38018. private _targetPosition;
  38019. private _virtualOriginMesh;
  38020. private _virtualDragMesh;
  38021. private _pointerObserver;
  38022. private _moving;
  38023. private _startingOrientation;
  38024. /**
  38025. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  38026. */
  38027. private zDragFactor;
  38028. /**
  38029. * If the object should rotate to face the drag origin
  38030. */
  38031. rotateDraggedObject: boolean;
  38032. /**
  38033. * If the behavior is currently in a dragging state
  38034. */
  38035. dragging: boolean;
  38036. /**
  38037. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  38038. */
  38039. dragDeltaRatio: number;
  38040. /**
  38041. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38042. */
  38043. currentDraggingPointerID: number;
  38044. /**
  38045. * If camera controls should be detached during the drag
  38046. */
  38047. detachCameraControls: boolean;
  38048. /**
  38049. * Fires each time a drag starts
  38050. */
  38051. onDragStartObservable: Observable<{}>;
  38052. /**
  38053. * Fires each time a drag ends (eg. mouse release after drag)
  38054. */
  38055. onDragEndObservable: Observable<{}>;
  38056. /**
  38057. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  38058. */
  38059. constructor();
  38060. /**
  38061. * The name of the behavior
  38062. */
  38063. readonly name: string;
  38064. /**
  38065. * Initializes the behavior
  38066. */
  38067. init(): void;
  38068. /**
  38069. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38070. */
  38071. private readonly _pointerCamera;
  38072. /**
  38073. * Attaches the scale behavior the passed in mesh
  38074. * @param ownerNode The mesh that will be scaled around once attached
  38075. */
  38076. attach(ownerNode: Mesh): void;
  38077. /**
  38078. * Detaches the behavior from the mesh
  38079. */
  38080. detach(): void;
  38081. }
  38082. }
  38083. declare module "babylonjs/Behaviors/Meshes/index" {
  38084. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38085. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38086. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38087. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38088. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38089. }
  38090. declare module "babylonjs/Behaviors/index" {
  38091. export * from "babylonjs/Behaviors/behavior";
  38092. export * from "babylonjs/Behaviors/Cameras/index";
  38093. export * from "babylonjs/Behaviors/Meshes/index";
  38094. }
  38095. declare module "babylonjs/Bones/boneIKController" {
  38096. import { Bone } from "babylonjs/Bones/bone";
  38097. import { Vector3 } from "babylonjs/Maths/math.vector";
  38098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38099. import { Nullable } from "babylonjs/types";
  38100. /**
  38101. * Class used to apply inverse kinematics to bones
  38102. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38103. */
  38104. export class BoneIKController {
  38105. private static _tmpVecs;
  38106. private static _tmpQuat;
  38107. private static _tmpMats;
  38108. /**
  38109. * Gets or sets the target mesh
  38110. */
  38111. targetMesh: AbstractMesh;
  38112. /** Gets or sets the mesh used as pole */
  38113. poleTargetMesh: AbstractMesh;
  38114. /**
  38115. * Gets or sets the bone used as pole
  38116. */
  38117. poleTargetBone: Nullable<Bone>;
  38118. /**
  38119. * Gets or sets the target position
  38120. */
  38121. targetPosition: Vector3;
  38122. /**
  38123. * Gets or sets the pole target position
  38124. */
  38125. poleTargetPosition: Vector3;
  38126. /**
  38127. * Gets or sets the pole target local offset
  38128. */
  38129. poleTargetLocalOffset: Vector3;
  38130. /**
  38131. * Gets or sets the pole angle
  38132. */
  38133. poleAngle: number;
  38134. /**
  38135. * Gets or sets the mesh associated with the controller
  38136. */
  38137. mesh: AbstractMesh;
  38138. /**
  38139. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  38140. */
  38141. slerpAmount: number;
  38142. private _bone1Quat;
  38143. private _bone1Mat;
  38144. private _bone2Ang;
  38145. private _bone1;
  38146. private _bone2;
  38147. private _bone1Length;
  38148. private _bone2Length;
  38149. private _maxAngle;
  38150. private _maxReach;
  38151. private _rightHandedSystem;
  38152. private _bendAxis;
  38153. private _slerping;
  38154. private _adjustRoll;
  38155. /**
  38156. * Gets or sets maximum allowed angle
  38157. */
  38158. maxAngle: number;
  38159. /**
  38160. * Creates a new BoneIKController
  38161. * @param mesh defines the mesh to control
  38162. * @param bone defines the bone to control
  38163. * @param options defines options to set up the controller
  38164. */
  38165. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38166. targetMesh?: AbstractMesh;
  38167. poleTargetMesh?: AbstractMesh;
  38168. poleTargetBone?: Bone;
  38169. poleTargetLocalOffset?: Vector3;
  38170. poleAngle?: number;
  38171. bendAxis?: Vector3;
  38172. maxAngle?: number;
  38173. slerpAmount?: number;
  38174. });
  38175. private _setMaxAngle;
  38176. /**
  38177. * Force the controller to update the bones
  38178. */
  38179. update(): void;
  38180. }
  38181. }
  38182. declare module "babylonjs/Bones/boneLookController" {
  38183. import { Vector3 } from "babylonjs/Maths/math.vector";
  38184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38185. import { Bone } from "babylonjs/Bones/bone";
  38186. import { Space } from "babylonjs/Maths/math.axis";
  38187. /**
  38188. * Class used to make a bone look toward a point in space
  38189. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38190. */
  38191. export class BoneLookController {
  38192. private static _tmpVecs;
  38193. private static _tmpQuat;
  38194. private static _tmpMats;
  38195. /**
  38196. * The target Vector3 that the bone will look at
  38197. */
  38198. target: Vector3;
  38199. /**
  38200. * The mesh that the bone is attached to
  38201. */
  38202. mesh: AbstractMesh;
  38203. /**
  38204. * The bone that will be looking to the target
  38205. */
  38206. bone: Bone;
  38207. /**
  38208. * The up axis of the coordinate system that is used when the bone is rotated
  38209. */
  38210. upAxis: Vector3;
  38211. /**
  38212. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38213. */
  38214. upAxisSpace: Space;
  38215. /**
  38216. * Used to make an adjustment to the yaw of the bone
  38217. */
  38218. adjustYaw: number;
  38219. /**
  38220. * Used to make an adjustment to the pitch of the bone
  38221. */
  38222. adjustPitch: number;
  38223. /**
  38224. * Used to make an adjustment to the roll of the bone
  38225. */
  38226. adjustRoll: number;
  38227. /**
  38228. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  38229. */
  38230. slerpAmount: number;
  38231. private _minYaw;
  38232. private _maxYaw;
  38233. private _minPitch;
  38234. private _maxPitch;
  38235. private _minYawSin;
  38236. private _minYawCos;
  38237. private _maxYawSin;
  38238. private _maxYawCos;
  38239. private _midYawConstraint;
  38240. private _minPitchTan;
  38241. private _maxPitchTan;
  38242. private _boneQuat;
  38243. private _slerping;
  38244. private _transformYawPitch;
  38245. private _transformYawPitchInv;
  38246. private _firstFrameSkipped;
  38247. private _yawRange;
  38248. private _fowardAxis;
  38249. /**
  38250. * Gets or sets the minimum yaw angle that the bone can look to
  38251. */
  38252. minYaw: number;
  38253. /**
  38254. * Gets or sets the maximum yaw angle that the bone can look to
  38255. */
  38256. maxYaw: number;
  38257. /**
  38258. * Gets or sets the minimum pitch angle that the bone can look to
  38259. */
  38260. minPitch: number;
  38261. /**
  38262. * Gets or sets the maximum pitch angle that the bone can look to
  38263. */
  38264. maxPitch: number;
  38265. /**
  38266. * Create a BoneLookController
  38267. * @param mesh the mesh that the bone belongs to
  38268. * @param bone the bone that will be looking to the target
  38269. * @param target the target Vector3 to look at
  38270. * @param options optional settings:
  38271. * * maxYaw: the maximum angle the bone will yaw to
  38272. * * minYaw: the minimum angle the bone will yaw to
  38273. * * maxPitch: the maximum angle the bone will pitch to
  38274. * * minPitch: the minimum angle the bone will yaw to
  38275. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38276. * * upAxis: the up axis of the coordinate system
  38277. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38278. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38279. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38280. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38281. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38282. * * adjustRoll: used to make an adjustment to the roll of the bone
  38283. **/
  38284. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38285. maxYaw?: number;
  38286. minYaw?: number;
  38287. maxPitch?: number;
  38288. minPitch?: number;
  38289. slerpAmount?: number;
  38290. upAxis?: Vector3;
  38291. upAxisSpace?: Space;
  38292. yawAxis?: Vector3;
  38293. pitchAxis?: Vector3;
  38294. adjustYaw?: number;
  38295. adjustPitch?: number;
  38296. adjustRoll?: number;
  38297. });
  38298. /**
  38299. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38300. */
  38301. update(): void;
  38302. private _getAngleDiff;
  38303. private _getAngleBetween;
  38304. private _isAngleBetween;
  38305. }
  38306. }
  38307. declare module "babylonjs/Bones/index" {
  38308. export * from "babylonjs/Bones/bone";
  38309. export * from "babylonjs/Bones/boneIKController";
  38310. export * from "babylonjs/Bones/boneLookController";
  38311. export * from "babylonjs/Bones/skeleton";
  38312. }
  38313. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38314. import { Nullable } from "babylonjs/types";
  38315. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38316. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38317. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38318. /**
  38319. * Manage the gamepad inputs to control an arc rotate camera.
  38320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38321. */
  38322. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38323. /**
  38324. * Defines the camera the input is attached to.
  38325. */
  38326. camera: ArcRotateCamera;
  38327. /**
  38328. * Defines the gamepad the input is gathering event from.
  38329. */
  38330. gamepad: Nullable<Gamepad>;
  38331. /**
  38332. * Defines the gamepad rotation sensiblity.
  38333. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38334. */
  38335. gamepadRotationSensibility: number;
  38336. /**
  38337. * Defines the gamepad move sensiblity.
  38338. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38339. */
  38340. gamepadMoveSensibility: number;
  38341. private _onGamepadConnectedObserver;
  38342. private _onGamepadDisconnectedObserver;
  38343. /**
  38344. * Attach the input controls to a specific dom element to get the input from.
  38345. * @param element Defines the element the controls should be listened from
  38346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38347. */
  38348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38349. /**
  38350. * Detach the current controls from the specified dom element.
  38351. * @param element Defines the element to stop listening the inputs from
  38352. */
  38353. detachControl(element: Nullable<HTMLElement>): void;
  38354. /**
  38355. * Update the current camera state depending on the inputs that have been used this frame.
  38356. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38357. */
  38358. checkInputs(): void;
  38359. /**
  38360. * Gets the class name of the current intput.
  38361. * @returns the class name
  38362. */
  38363. getClassName(): string;
  38364. /**
  38365. * Get the friendly name associated with the input class.
  38366. * @returns the input friendly name
  38367. */
  38368. getSimpleName(): string;
  38369. }
  38370. }
  38371. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38372. import { Nullable } from "babylonjs/types";
  38373. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38374. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38375. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38376. interface ArcRotateCameraInputsManager {
  38377. /**
  38378. * Add orientation input support to the input manager.
  38379. * @returns the current input manager
  38380. */
  38381. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38382. }
  38383. }
  38384. /**
  38385. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38387. */
  38388. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38389. /**
  38390. * Defines the camera the input is attached to.
  38391. */
  38392. camera: ArcRotateCamera;
  38393. /**
  38394. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38395. */
  38396. alphaCorrection: number;
  38397. /**
  38398. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38399. */
  38400. gammaCorrection: number;
  38401. private _alpha;
  38402. private _gamma;
  38403. private _dirty;
  38404. private _deviceOrientationHandler;
  38405. /**
  38406. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38407. */
  38408. constructor();
  38409. /**
  38410. * Attach the input controls to a specific dom element to get the input from.
  38411. * @param element Defines the element the controls should be listened from
  38412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38413. */
  38414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38415. /** @hidden */
  38416. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38417. /**
  38418. * Update the current camera state depending on the inputs that have been used this frame.
  38419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38420. */
  38421. checkInputs(): void;
  38422. /**
  38423. * Detach the current controls from the specified dom element.
  38424. * @param element Defines the element to stop listening the inputs from
  38425. */
  38426. detachControl(element: Nullable<HTMLElement>): void;
  38427. /**
  38428. * Gets the class name of the current intput.
  38429. * @returns the class name
  38430. */
  38431. getClassName(): string;
  38432. /**
  38433. * Get the friendly name associated with the input class.
  38434. * @returns the input friendly name
  38435. */
  38436. getSimpleName(): string;
  38437. }
  38438. }
  38439. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38440. import { Nullable } from "babylonjs/types";
  38441. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38442. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38443. /**
  38444. * Listen to mouse events to control the camera.
  38445. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38446. */
  38447. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38448. /**
  38449. * Defines the camera the input is attached to.
  38450. */
  38451. camera: FlyCamera;
  38452. /**
  38453. * Defines if touch is enabled. (Default is true.)
  38454. */
  38455. touchEnabled: boolean;
  38456. /**
  38457. * Defines the buttons associated with the input to handle camera rotation.
  38458. */
  38459. buttons: number[];
  38460. /**
  38461. * Assign buttons for Yaw control.
  38462. */
  38463. buttonsYaw: number[];
  38464. /**
  38465. * Assign buttons for Pitch control.
  38466. */
  38467. buttonsPitch: number[];
  38468. /**
  38469. * Assign buttons for Roll control.
  38470. */
  38471. buttonsRoll: number[];
  38472. /**
  38473. * Detect if any button is being pressed while mouse is moved.
  38474. * -1 = Mouse locked.
  38475. * 0 = Left button.
  38476. * 1 = Middle Button.
  38477. * 2 = Right Button.
  38478. */
  38479. activeButton: number;
  38480. /**
  38481. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38482. * Higher values reduce its sensitivity.
  38483. */
  38484. angularSensibility: number;
  38485. private _mousemoveCallback;
  38486. private _observer;
  38487. private _rollObserver;
  38488. private previousPosition;
  38489. private noPreventDefault;
  38490. private element;
  38491. /**
  38492. * Listen to mouse events to control the camera.
  38493. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38494. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38495. */
  38496. constructor(touchEnabled?: boolean);
  38497. /**
  38498. * Attach the mouse control to the HTML DOM element.
  38499. * @param element Defines the element that listens to the input events.
  38500. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38501. */
  38502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38503. /**
  38504. * Detach the current controls from the specified dom element.
  38505. * @param element Defines the element to stop listening the inputs from
  38506. */
  38507. detachControl(element: Nullable<HTMLElement>): void;
  38508. /**
  38509. * Gets the class name of the current input.
  38510. * @returns the class name.
  38511. */
  38512. getClassName(): string;
  38513. /**
  38514. * Get the friendly name associated with the input class.
  38515. * @returns the input's friendly name.
  38516. */
  38517. getSimpleName(): string;
  38518. private _pointerInput;
  38519. private _onMouseMove;
  38520. /**
  38521. * Rotate camera by mouse offset.
  38522. */
  38523. private rotateCamera;
  38524. }
  38525. }
  38526. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38527. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38528. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38529. /**
  38530. * Default Inputs manager for the FlyCamera.
  38531. * It groups all the default supported inputs for ease of use.
  38532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38533. */
  38534. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38535. /**
  38536. * Instantiates a new FlyCameraInputsManager.
  38537. * @param camera Defines the camera the inputs belong to.
  38538. */
  38539. constructor(camera: FlyCamera);
  38540. /**
  38541. * Add keyboard input support to the input manager.
  38542. * @returns the new FlyCameraKeyboardMoveInput().
  38543. */
  38544. addKeyboard(): FlyCameraInputsManager;
  38545. /**
  38546. * Add mouse input support to the input manager.
  38547. * @param touchEnabled Enable touch screen support.
  38548. * @returns the new FlyCameraMouseInput().
  38549. */
  38550. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38551. }
  38552. }
  38553. declare module "babylonjs/Cameras/flyCamera" {
  38554. import { Scene } from "babylonjs/scene";
  38555. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38557. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38558. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38559. /**
  38560. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38561. * such as in a 3D Space Shooter or a Flight Simulator.
  38562. */
  38563. export class FlyCamera extends TargetCamera {
  38564. /**
  38565. * Define the collision ellipsoid of the camera.
  38566. * This is helpful for simulating a camera body, like a player's body.
  38567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38568. */
  38569. ellipsoid: Vector3;
  38570. /**
  38571. * Define an offset for the position of the ellipsoid around the camera.
  38572. * This can be helpful if the camera is attached away from the player's body center,
  38573. * such as at its head.
  38574. */
  38575. ellipsoidOffset: Vector3;
  38576. /**
  38577. * Enable or disable collisions of the camera with the rest of the scene objects.
  38578. */
  38579. checkCollisions: boolean;
  38580. /**
  38581. * Enable or disable gravity on the camera.
  38582. */
  38583. applyGravity: boolean;
  38584. /**
  38585. * Define the current direction the camera is moving to.
  38586. */
  38587. cameraDirection: Vector3;
  38588. /**
  38589. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38590. * This overrides and empties cameraRotation.
  38591. */
  38592. rotationQuaternion: Quaternion;
  38593. /**
  38594. * Track Roll to maintain the wanted Rolling when looking around.
  38595. */
  38596. _trackRoll: number;
  38597. /**
  38598. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38599. */
  38600. rollCorrect: number;
  38601. /**
  38602. * Mimic a banked turn, Rolling the camera when Yawing.
  38603. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38604. */
  38605. bankedTurn: boolean;
  38606. /**
  38607. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38608. */
  38609. bankedTurnLimit: number;
  38610. /**
  38611. * Value of 0 disables the banked Roll.
  38612. * Value of 1 is equal to the Yaw angle in radians.
  38613. */
  38614. bankedTurnMultiplier: number;
  38615. /**
  38616. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38617. */
  38618. inputs: FlyCameraInputsManager;
  38619. /**
  38620. * Gets the input sensibility for mouse input.
  38621. * Higher values reduce sensitivity.
  38622. */
  38623. /**
  38624. * Sets the input sensibility for a mouse input.
  38625. * Higher values reduce sensitivity.
  38626. */
  38627. angularSensibility: number;
  38628. /**
  38629. * Get the keys for camera movement forward.
  38630. */
  38631. /**
  38632. * Set the keys for camera movement forward.
  38633. */
  38634. keysForward: number[];
  38635. /**
  38636. * Get the keys for camera movement backward.
  38637. */
  38638. keysBackward: number[];
  38639. /**
  38640. * Get the keys for camera movement up.
  38641. */
  38642. /**
  38643. * Set the keys for camera movement up.
  38644. */
  38645. keysUp: number[];
  38646. /**
  38647. * Get the keys for camera movement down.
  38648. */
  38649. /**
  38650. * Set the keys for camera movement down.
  38651. */
  38652. keysDown: number[];
  38653. /**
  38654. * Get the keys for camera movement left.
  38655. */
  38656. /**
  38657. * Set the keys for camera movement left.
  38658. */
  38659. keysLeft: number[];
  38660. /**
  38661. * Set the keys for camera movement right.
  38662. */
  38663. /**
  38664. * Set the keys for camera movement right.
  38665. */
  38666. keysRight: number[];
  38667. /**
  38668. * Event raised when the camera collides with a mesh in the scene.
  38669. */
  38670. onCollide: (collidedMesh: AbstractMesh) => void;
  38671. private _collider;
  38672. private _needMoveForGravity;
  38673. private _oldPosition;
  38674. private _diffPosition;
  38675. private _newPosition;
  38676. /** @hidden */
  38677. _localDirection: Vector3;
  38678. /** @hidden */
  38679. _transformedDirection: Vector3;
  38680. /**
  38681. * Instantiates a FlyCamera.
  38682. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38683. * such as in a 3D Space Shooter or a Flight Simulator.
  38684. * @param name Define the name of the camera in the scene.
  38685. * @param position Define the starting position of the camera in the scene.
  38686. * @param scene Define the scene the camera belongs to.
  38687. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38688. */
  38689. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38690. /**
  38691. * Attach a control to the HTML DOM element.
  38692. * @param element Defines the element that listens to the input events.
  38693. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38694. */
  38695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38696. /**
  38697. * Detach a control from the HTML DOM element.
  38698. * The camera will stop reacting to that input.
  38699. * @param element Defines the element that listens to the input events.
  38700. */
  38701. detachControl(element: HTMLElement): void;
  38702. private _collisionMask;
  38703. /**
  38704. * Get the mask that the camera ignores in collision events.
  38705. */
  38706. /**
  38707. * Set the mask that the camera ignores in collision events.
  38708. */
  38709. collisionMask: number;
  38710. /** @hidden */
  38711. _collideWithWorld(displacement: Vector3): void;
  38712. /** @hidden */
  38713. private _onCollisionPositionChange;
  38714. /** @hidden */
  38715. _checkInputs(): void;
  38716. /** @hidden */
  38717. _decideIfNeedsToMove(): boolean;
  38718. /** @hidden */
  38719. _updatePosition(): void;
  38720. /**
  38721. * Restore the Roll to its target value at the rate specified.
  38722. * @param rate - Higher means slower restoring.
  38723. * @hidden
  38724. */
  38725. restoreRoll(rate: number): void;
  38726. /**
  38727. * Destroy the camera and release the current resources held by it.
  38728. */
  38729. dispose(): void;
  38730. /**
  38731. * Get the current object class name.
  38732. * @returns the class name.
  38733. */
  38734. getClassName(): string;
  38735. }
  38736. }
  38737. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38738. import { Nullable } from "babylonjs/types";
  38739. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38740. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38741. /**
  38742. * Listen to keyboard events to control the camera.
  38743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38744. */
  38745. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38746. /**
  38747. * Defines the camera the input is attached to.
  38748. */
  38749. camera: FlyCamera;
  38750. /**
  38751. * The list of keyboard keys used to control the forward move of the camera.
  38752. */
  38753. keysForward: number[];
  38754. /**
  38755. * The list of keyboard keys used to control the backward move of the camera.
  38756. */
  38757. keysBackward: number[];
  38758. /**
  38759. * The list of keyboard keys used to control the forward move of the camera.
  38760. */
  38761. keysUp: number[];
  38762. /**
  38763. * The list of keyboard keys used to control the backward move of the camera.
  38764. */
  38765. keysDown: number[];
  38766. /**
  38767. * The list of keyboard keys used to control the right strafe move of the camera.
  38768. */
  38769. keysRight: number[];
  38770. /**
  38771. * The list of keyboard keys used to control the left strafe move of the camera.
  38772. */
  38773. keysLeft: number[];
  38774. private _keys;
  38775. private _onCanvasBlurObserver;
  38776. private _onKeyboardObserver;
  38777. private _engine;
  38778. private _scene;
  38779. /**
  38780. * Attach the input controls to a specific dom element to get the input from.
  38781. * @param element Defines the element the controls should be listened from
  38782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38783. */
  38784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38785. /**
  38786. * Detach the current controls from the specified dom element.
  38787. * @param element Defines the element to stop listening the inputs from
  38788. */
  38789. detachControl(element: Nullable<HTMLElement>): void;
  38790. /**
  38791. * Gets the class name of the current intput.
  38792. * @returns the class name
  38793. */
  38794. getClassName(): string;
  38795. /** @hidden */
  38796. _onLostFocus(e: FocusEvent): void;
  38797. /**
  38798. * Get the friendly name associated with the input class.
  38799. * @returns the input friendly name
  38800. */
  38801. getSimpleName(): string;
  38802. /**
  38803. * Update the current camera state depending on the inputs that have been used this frame.
  38804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38805. */
  38806. checkInputs(): void;
  38807. }
  38808. }
  38809. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38810. import { Nullable } from "babylonjs/types";
  38811. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38812. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38813. /**
  38814. * Manage the mouse wheel inputs to control a follow camera.
  38815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38816. */
  38817. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38818. /**
  38819. * Defines the camera the input is attached to.
  38820. */
  38821. camera: FollowCamera;
  38822. /**
  38823. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38824. */
  38825. axisControlRadius: boolean;
  38826. /**
  38827. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38828. */
  38829. axisControlHeight: boolean;
  38830. /**
  38831. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38832. */
  38833. axisControlRotation: boolean;
  38834. /**
  38835. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38836. * relation to mouseWheel events.
  38837. */
  38838. wheelPrecision: number;
  38839. /**
  38840. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38841. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38842. */
  38843. wheelDeltaPercentage: number;
  38844. private _wheel;
  38845. private _observer;
  38846. /**
  38847. * Attach the input controls to a specific dom element to get the input from.
  38848. * @param element Defines the element the controls should be listened from
  38849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38850. */
  38851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38852. /**
  38853. * Detach the current controls from the specified dom element.
  38854. * @param element Defines the element to stop listening the inputs from
  38855. */
  38856. detachControl(element: Nullable<HTMLElement>): void;
  38857. /**
  38858. * Gets the class name of the current intput.
  38859. * @returns the class name
  38860. */
  38861. getClassName(): string;
  38862. /**
  38863. * Get the friendly name associated with the input class.
  38864. * @returns the input friendly name
  38865. */
  38866. getSimpleName(): string;
  38867. }
  38868. }
  38869. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38870. import { Nullable } from "babylonjs/types";
  38871. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38872. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38873. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38874. /**
  38875. * Manage the pointers inputs to control an follow camera.
  38876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38877. */
  38878. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38879. /**
  38880. * Defines the camera the input is attached to.
  38881. */
  38882. camera: FollowCamera;
  38883. /**
  38884. * Gets the class name of the current input.
  38885. * @returns the class name
  38886. */
  38887. getClassName(): string;
  38888. /**
  38889. * Defines the pointer angular sensibility along the X axis or how fast is
  38890. * the camera rotating.
  38891. * A negative number will reverse the axis direction.
  38892. */
  38893. angularSensibilityX: number;
  38894. /**
  38895. * Defines the pointer angular sensibility along the Y axis or how fast is
  38896. * the camera rotating.
  38897. * A negative number will reverse the axis direction.
  38898. */
  38899. angularSensibilityY: number;
  38900. /**
  38901. * Defines the pointer pinch precision or how fast is the camera zooming.
  38902. * A negative number will reverse the axis direction.
  38903. */
  38904. pinchPrecision: number;
  38905. /**
  38906. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38907. * from 0.
  38908. * It defines the percentage of current camera.radius to use as delta when
  38909. * pinch zoom is used.
  38910. */
  38911. pinchDeltaPercentage: number;
  38912. /**
  38913. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38914. */
  38915. axisXControlRadius: boolean;
  38916. /**
  38917. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38918. */
  38919. axisXControlHeight: boolean;
  38920. /**
  38921. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38922. */
  38923. axisXControlRotation: boolean;
  38924. /**
  38925. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38926. */
  38927. axisYControlRadius: boolean;
  38928. /**
  38929. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38930. */
  38931. axisYControlHeight: boolean;
  38932. /**
  38933. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38934. */
  38935. axisYControlRotation: boolean;
  38936. /**
  38937. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38938. */
  38939. axisPinchControlRadius: boolean;
  38940. /**
  38941. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38942. */
  38943. axisPinchControlHeight: boolean;
  38944. /**
  38945. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38946. */
  38947. axisPinchControlRotation: boolean;
  38948. /**
  38949. * Log error messages if basic misconfiguration has occurred.
  38950. */
  38951. warningEnable: boolean;
  38952. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38953. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38954. private _warningCounter;
  38955. private _warning;
  38956. }
  38957. }
  38958. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38959. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38960. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38961. /**
  38962. * Default Inputs manager for the FollowCamera.
  38963. * It groups all the default supported inputs for ease of use.
  38964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38965. */
  38966. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38967. /**
  38968. * Instantiates a new FollowCameraInputsManager.
  38969. * @param camera Defines the camera the inputs belong to
  38970. */
  38971. constructor(camera: FollowCamera);
  38972. /**
  38973. * Add keyboard input support to the input manager.
  38974. * @returns the current input manager
  38975. */
  38976. addKeyboard(): FollowCameraInputsManager;
  38977. /**
  38978. * Add mouse wheel input support to the input manager.
  38979. * @returns the current input manager
  38980. */
  38981. addMouseWheel(): FollowCameraInputsManager;
  38982. /**
  38983. * Add pointers input support to the input manager.
  38984. * @returns the current input manager
  38985. */
  38986. addPointers(): FollowCameraInputsManager;
  38987. /**
  38988. * Add orientation input support to the input manager.
  38989. * @returns the current input manager
  38990. */
  38991. addVRDeviceOrientation(): FollowCameraInputsManager;
  38992. }
  38993. }
  38994. declare module "babylonjs/Cameras/followCamera" {
  38995. import { Nullable } from "babylonjs/types";
  38996. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38997. import { Scene } from "babylonjs/scene";
  38998. import { Vector3 } from "babylonjs/Maths/math.vector";
  38999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39000. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39001. /**
  39002. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39003. * an arc rotate version arcFollowCamera are available.
  39004. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39005. */
  39006. export class FollowCamera extends TargetCamera {
  39007. /**
  39008. * Distance the follow camera should follow an object at
  39009. */
  39010. radius: number;
  39011. /**
  39012. * Minimum allowed distance of the camera to the axis of rotation
  39013. * (The camera can not get closer).
  39014. * This can help limiting how the Camera is able to move in the scene.
  39015. */
  39016. lowerRadiusLimit: Nullable<number>;
  39017. /**
  39018. * Maximum allowed distance of the camera to the axis of rotation
  39019. * (The camera can not get further).
  39020. * This can help limiting how the Camera is able to move in the scene.
  39021. */
  39022. upperRadiusLimit: Nullable<number>;
  39023. /**
  39024. * Define a rotation offset between the camera and the object it follows
  39025. */
  39026. rotationOffset: number;
  39027. /**
  39028. * Minimum allowed angle to camera position relative to target object.
  39029. * This can help limiting how the Camera is able to move in the scene.
  39030. */
  39031. lowerRotationOffsetLimit: Nullable<number>;
  39032. /**
  39033. * Maximum allowed angle to camera position relative to target object.
  39034. * This can help limiting how the Camera is able to move in the scene.
  39035. */
  39036. upperRotationOffsetLimit: Nullable<number>;
  39037. /**
  39038. * Define a height offset between the camera and the object it follows.
  39039. * It can help following an object from the top (like a car chaing a plane)
  39040. */
  39041. heightOffset: number;
  39042. /**
  39043. * Minimum allowed height of camera position relative to target object.
  39044. * This can help limiting how the Camera is able to move in the scene.
  39045. */
  39046. lowerHeightOffsetLimit: Nullable<number>;
  39047. /**
  39048. * Maximum allowed height of camera position relative to target object.
  39049. * This can help limiting how the Camera is able to move in the scene.
  39050. */
  39051. upperHeightOffsetLimit: Nullable<number>;
  39052. /**
  39053. * Define how fast the camera can accelerate to follow it s target.
  39054. */
  39055. cameraAcceleration: number;
  39056. /**
  39057. * Define the speed limit of the camera following an object.
  39058. */
  39059. maxCameraSpeed: number;
  39060. /**
  39061. * Define the target of the camera.
  39062. */
  39063. lockedTarget: Nullable<AbstractMesh>;
  39064. /**
  39065. * Defines the input associated with the camera.
  39066. */
  39067. inputs: FollowCameraInputsManager;
  39068. /**
  39069. * Instantiates the follow camera.
  39070. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39071. * @param name Define the name of the camera in the scene
  39072. * @param position Define the position of the camera
  39073. * @param scene Define the scene the camera belong to
  39074. * @param lockedTarget Define the target of the camera
  39075. */
  39076. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39077. private _follow;
  39078. /**
  39079. * Attached controls to the current camera.
  39080. * @param element Defines the element the controls should be listened from
  39081. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39082. */
  39083. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39084. /**
  39085. * Detach the current controls from the camera.
  39086. * The camera will stop reacting to inputs.
  39087. * @param element Defines the element to stop listening the inputs from
  39088. */
  39089. detachControl(element: HTMLElement): void;
  39090. /** @hidden */
  39091. _checkInputs(): void;
  39092. private _checkLimits;
  39093. /**
  39094. * Gets the camera class name.
  39095. * @returns the class name
  39096. */
  39097. getClassName(): string;
  39098. }
  39099. /**
  39100. * Arc Rotate version of the follow camera.
  39101. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39102. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39103. */
  39104. export class ArcFollowCamera extends TargetCamera {
  39105. /** The longitudinal angle of the camera */
  39106. alpha: number;
  39107. /** The latitudinal angle of the camera */
  39108. beta: number;
  39109. /** The radius of the camera from its target */
  39110. radius: number;
  39111. /** Define the camera target (the messh it should follow) */
  39112. target: Nullable<AbstractMesh>;
  39113. private _cartesianCoordinates;
  39114. /**
  39115. * Instantiates a new ArcFollowCamera
  39116. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39117. * @param name Define the name of the camera
  39118. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39119. * @param beta Define the rotation angle of the camera around the elevation axis
  39120. * @param radius Define the radius of the camera from its target point
  39121. * @param target Define the target of the camera
  39122. * @param scene Define the scene the camera belongs to
  39123. */
  39124. constructor(name: string,
  39125. /** The longitudinal angle of the camera */
  39126. alpha: number,
  39127. /** The latitudinal angle of the camera */
  39128. beta: number,
  39129. /** The radius of the camera from its target */
  39130. radius: number,
  39131. /** Define the camera target (the messh it should follow) */
  39132. target: Nullable<AbstractMesh>, scene: Scene);
  39133. private _follow;
  39134. /** @hidden */
  39135. _checkInputs(): void;
  39136. /**
  39137. * Returns the class name of the object.
  39138. * It is mostly used internally for serialization purposes.
  39139. */
  39140. getClassName(): string;
  39141. }
  39142. }
  39143. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39144. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39145. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39146. import { Nullable } from "babylonjs/types";
  39147. /**
  39148. * Manage the keyboard inputs to control the movement of a follow camera.
  39149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39150. */
  39151. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39152. /**
  39153. * Defines the camera the input is attached to.
  39154. */
  39155. camera: FollowCamera;
  39156. /**
  39157. * Defines the list of key codes associated with the up action (increase heightOffset)
  39158. */
  39159. keysHeightOffsetIncr: number[];
  39160. /**
  39161. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39162. */
  39163. keysHeightOffsetDecr: number[];
  39164. /**
  39165. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39166. */
  39167. keysHeightOffsetModifierAlt: boolean;
  39168. /**
  39169. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39170. */
  39171. keysHeightOffsetModifierCtrl: boolean;
  39172. /**
  39173. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39174. */
  39175. keysHeightOffsetModifierShift: boolean;
  39176. /**
  39177. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39178. */
  39179. keysRotationOffsetIncr: number[];
  39180. /**
  39181. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39182. */
  39183. keysRotationOffsetDecr: number[];
  39184. /**
  39185. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39186. */
  39187. keysRotationOffsetModifierAlt: boolean;
  39188. /**
  39189. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39190. */
  39191. keysRotationOffsetModifierCtrl: boolean;
  39192. /**
  39193. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39194. */
  39195. keysRotationOffsetModifierShift: boolean;
  39196. /**
  39197. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39198. */
  39199. keysRadiusIncr: number[];
  39200. /**
  39201. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39202. */
  39203. keysRadiusDecr: number[];
  39204. /**
  39205. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39206. */
  39207. keysRadiusModifierAlt: boolean;
  39208. /**
  39209. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39210. */
  39211. keysRadiusModifierCtrl: boolean;
  39212. /**
  39213. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39214. */
  39215. keysRadiusModifierShift: boolean;
  39216. /**
  39217. * Defines the rate of change of heightOffset.
  39218. */
  39219. heightSensibility: number;
  39220. /**
  39221. * Defines the rate of change of rotationOffset.
  39222. */
  39223. rotationSensibility: number;
  39224. /**
  39225. * Defines the rate of change of radius.
  39226. */
  39227. radiusSensibility: number;
  39228. private _keys;
  39229. private _ctrlPressed;
  39230. private _altPressed;
  39231. private _shiftPressed;
  39232. private _onCanvasBlurObserver;
  39233. private _onKeyboardObserver;
  39234. private _engine;
  39235. private _scene;
  39236. /**
  39237. * Attach the input controls to a specific dom element to get the input from.
  39238. * @param element Defines the element the controls should be listened from
  39239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39240. */
  39241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39242. /**
  39243. * Detach the current controls from the specified dom element.
  39244. * @param element Defines the element to stop listening the inputs from
  39245. */
  39246. detachControl(element: Nullable<HTMLElement>): void;
  39247. /**
  39248. * Update the current camera state depending on the inputs that have been used this frame.
  39249. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39250. */
  39251. checkInputs(): void;
  39252. /**
  39253. * Gets the class name of the current input.
  39254. * @returns the class name
  39255. */
  39256. getClassName(): string;
  39257. /**
  39258. * Get the friendly name associated with the input class.
  39259. * @returns the input friendly name
  39260. */
  39261. getSimpleName(): string;
  39262. /**
  39263. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39264. * allow modification of the heightOffset value.
  39265. */
  39266. private _modifierHeightOffset;
  39267. /**
  39268. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39269. * allow modification of the rotationOffset value.
  39270. */
  39271. private _modifierRotationOffset;
  39272. /**
  39273. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39274. * allow modification of the radius value.
  39275. */
  39276. private _modifierRadius;
  39277. }
  39278. }
  39279. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39280. import { Nullable } from "babylonjs/types";
  39281. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39282. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39283. import { Observable } from "babylonjs/Misc/observable";
  39284. module "babylonjs/Cameras/freeCameraInputsManager" {
  39285. interface FreeCameraInputsManager {
  39286. /**
  39287. * @hidden
  39288. */
  39289. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39290. /**
  39291. * Add orientation input support to the input manager.
  39292. * @returns the current input manager
  39293. */
  39294. addDeviceOrientation(): FreeCameraInputsManager;
  39295. }
  39296. }
  39297. /**
  39298. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39299. * Screen rotation is taken into account.
  39300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39301. */
  39302. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39303. private _camera;
  39304. private _screenOrientationAngle;
  39305. private _constantTranform;
  39306. private _screenQuaternion;
  39307. private _alpha;
  39308. private _beta;
  39309. private _gamma;
  39310. /**
  39311. * Can be used to detect if a device orientation sensor is availible on a device
  39312. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39313. * @returns a promise that will resolve on orientation change
  39314. */
  39315. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39316. /**
  39317. * @hidden
  39318. */
  39319. _onDeviceOrientationChangedObservable: Observable<void>;
  39320. /**
  39321. * Instantiates a new input
  39322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39323. */
  39324. constructor();
  39325. /**
  39326. * Define the camera controlled by the input.
  39327. */
  39328. camera: FreeCamera;
  39329. /**
  39330. * Attach the input controls to a specific dom element to get the input from.
  39331. * @param element Defines the element the controls should be listened from
  39332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39333. */
  39334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39335. private _orientationChanged;
  39336. private _deviceOrientation;
  39337. /**
  39338. * Detach the current controls from the specified dom element.
  39339. * @param element Defines the element to stop listening the inputs from
  39340. */
  39341. detachControl(element: Nullable<HTMLElement>): void;
  39342. /**
  39343. * Update the current camera state depending on the inputs that have been used this frame.
  39344. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39345. */
  39346. checkInputs(): void;
  39347. /**
  39348. * Gets the class name of the current intput.
  39349. * @returns the class name
  39350. */
  39351. getClassName(): string;
  39352. /**
  39353. * Get the friendly name associated with the input class.
  39354. * @returns the input friendly name
  39355. */
  39356. getSimpleName(): string;
  39357. }
  39358. }
  39359. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39360. import { Nullable } from "babylonjs/types";
  39361. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39362. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39363. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39364. /**
  39365. * Manage the gamepad inputs to control a free camera.
  39366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39367. */
  39368. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39369. /**
  39370. * Define the camera the input is attached to.
  39371. */
  39372. camera: FreeCamera;
  39373. /**
  39374. * Define the Gamepad controlling the input
  39375. */
  39376. gamepad: Nullable<Gamepad>;
  39377. /**
  39378. * Defines the gamepad rotation sensiblity.
  39379. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39380. */
  39381. gamepadAngularSensibility: number;
  39382. /**
  39383. * Defines the gamepad move sensiblity.
  39384. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39385. */
  39386. gamepadMoveSensibility: number;
  39387. private _onGamepadConnectedObserver;
  39388. private _onGamepadDisconnectedObserver;
  39389. private _cameraTransform;
  39390. private _deltaTransform;
  39391. private _vector3;
  39392. private _vector2;
  39393. /**
  39394. * Attach the input controls to a specific dom element to get the input from.
  39395. * @param element Defines the element the controls should be listened from
  39396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39397. */
  39398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39399. /**
  39400. * Detach the current controls from the specified dom element.
  39401. * @param element Defines the element to stop listening the inputs from
  39402. */
  39403. detachControl(element: Nullable<HTMLElement>): void;
  39404. /**
  39405. * Update the current camera state depending on the inputs that have been used this frame.
  39406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39407. */
  39408. checkInputs(): void;
  39409. /**
  39410. * Gets the class name of the current intput.
  39411. * @returns the class name
  39412. */
  39413. getClassName(): string;
  39414. /**
  39415. * Get the friendly name associated with the input class.
  39416. * @returns the input friendly name
  39417. */
  39418. getSimpleName(): string;
  39419. }
  39420. }
  39421. declare module "babylonjs/Misc/virtualJoystick" {
  39422. import { Nullable } from "babylonjs/types";
  39423. import { Vector3 } from "babylonjs/Maths/math.vector";
  39424. /**
  39425. * Defines the potential axis of a Joystick
  39426. */
  39427. export enum JoystickAxis {
  39428. /** X axis */
  39429. X = 0,
  39430. /** Y axis */
  39431. Y = 1,
  39432. /** Z axis */
  39433. Z = 2
  39434. }
  39435. /**
  39436. * Class used to define virtual joystick (used in touch mode)
  39437. */
  39438. export class VirtualJoystick {
  39439. /**
  39440. * Gets or sets a boolean indicating that left and right values must be inverted
  39441. */
  39442. reverseLeftRight: boolean;
  39443. /**
  39444. * Gets or sets a boolean indicating that up and down values must be inverted
  39445. */
  39446. reverseUpDown: boolean;
  39447. /**
  39448. * Gets the offset value for the position (ie. the change of the position value)
  39449. */
  39450. deltaPosition: Vector3;
  39451. /**
  39452. * Gets a boolean indicating if the virtual joystick was pressed
  39453. */
  39454. pressed: boolean;
  39455. /**
  39456. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39457. */
  39458. static Canvas: Nullable<HTMLCanvasElement>;
  39459. private static _globalJoystickIndex;
  39460. private static vjCanvasContext;
  39461. private static vjCanvasWidth;
  39462. private static vjCanvasHeight;
  39463. private static halfWidth;
  39464. private _action;
  39465. private _axisTargetedByLeftAndRight;
  39466. private _axisTargetedByUpAndDown;
  39467. private _joystickSensibility;
  39468. private _inversedSensibility;
  39469. private _joystickPointerID;
  39470. private _joystickColor;
  39471. private _joystickPointerPos;
  39472. private _joystickPreviousPointerPos;
  39473. private _joystickPointerStartPos;
  39474. private _deltaJoystickVector;
  39475. private _leftJoystick;
  39476. private _touches;
  39477. private _onPointerDownHandlerRef;
  39478. private _onPointerMoveHandlerRef;
  39479. private _onPointerUpHandlerRef;
  39480. private _onResize;
  39481. /**
  39482. * Creates a new virtual joystick
  39483. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39484. */
  39485. constructor(leftJoystick?: boolean);
  39486. /**
  39487. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39488. * @param newJoystickSensibility defines the new sensibility
  39489. */
  39490. setJoystickSensibility(newJoystickSensibility: number): void;
  39491. private _onPointerDown;
  39492. private _onPointerMove;
  39493. private _onPointerUp;
  39494. /**
  39495. * Change the color of the virtual joystick
  39496. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39497. */
  39498. setJoystickColor(newColor: string): void;
  39499. /**
  39500. * Defines a callback to call when the joystick is touched
  39501. * @param action defines the callback
  39502. */
  39503. setActionOnTouch(action: () => any): void;
  39504. /**
  39505. * Defines which axis you'd like to control for left & right
  39506. * @param axis defines the axis to use
  39507. */
  39508. setAxisForLeftRight(axis: JoystickAxis): void;
  39509. /**
  39510. * Defines which axis you'd like to control for up & down
  39511. * @param axis defines the axis to use
  39512. */
  39513. setAxisForUpDown(axis: JoystickAxis): void;
  39514. private _drawVirtualJoystick;
  39515. /**
  39516. * Release internal HTML canvas
  39517. */
  39518. releaseCanvas(): void;
  39519. }
  39520. }
  39521. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39522. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39523. import { Nullable } from "babylonjs/types";
  39524. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39525. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39526. module "babylonjs/Cameras/freeCameraInputsManager" {
  39527. interface FreeCameraInputsManager {
  39528. /**
  39529. * Add virtual joystick input support to the input manager.
  39530. * @returns the current input manager
  39531. */
  39532. addVirtualJoystick(): FreeCameraInputsManager;
  39533. }
  39534. }
  39535. /**
  39536. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39538. */
  39539. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39540. /**
  39541. * Defines the camera the input is attached to.
  39542. */
  39543. camera: FreeCamera;
  39544. private _leftjoystick;
  39545. private _rightjoystick;
  39546. /**
  39547. * Gets the left stick of the virtual joystick.
  39548. * @returns The virtual Joystick
  39549. */
  39550. getLeftJoystick(): VirtualJoystick;
  39551. /**
  39552. * Gets the right stick of the virtual joystick.
  39553. * @returns The virtual Joystick
  39554. */
  39555. getRightJoystick(): VirtualJoystick;
  39556. /**
  39557. * Update the current camera state depending on the inputs that have been used this frame.
  39558. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39559. */
  39560. checkInputs(): void;
  39561. /**
  39562. * Attach the input controls to a specific dom element to get the input from.
  39563. * @param element Defines the element the controls should be listened from
  39564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39565. */
  39566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39567. /**
  39568. * Detach the current controls from the specified dom element.
  39569. * @param element Defines the element to stop listening the inputs from
  39570. */
  39571. detachControl(element: Nullable<HTMLElement>): void;
  39572. /**
  39573. * Gets the class name of the current intput.
  39574. * @returns the class name
  39575. */
  39576. getClassName(): string;
  39577. /**
  39578. * Get the friendly name associated with the input class.
  39579. * @returns the input friendly name
  39580. */
  39581. getSimpleName(): string;
  39582. }
  39583. }
  39584. declare module "babylonjs/Cameras/Inputs/index" {
  39585. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39586. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39587. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39588. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39589. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39590. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39591. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39592. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39593. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39594. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39595. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39596. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39597. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39598. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39599. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39600. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39601. }
  39602. declare module "babylonjs/Cameras/touchCamera" {
  39603. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39604. import { Scene } from "babylonjs/scene";
  39605. import { Vector3 } from "babylonjs/Maths/math.vector";
  39606. /**
  39607. * This represents a FPS type of camera controlled by touch.
  39608. * This is like a universal camera minus the Gamepad controls.
  39609. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39610. */
  39611. export class TouchCamera extends FreeCamera {
  39612. /**
  39613. * Defines the touch sensibility for rotation.
  39614. * The higher the faster.
  39615. */
  39616. touchAngularSensibility: number;
  39617. /**
  39618. * Defines the touch sensibility for move.
  39619. * The higher the faster.
  39620. */
  39621. touchMoveSensibility: number;
  39622. /**
  39623. * Instantiates a new touch camera.
  39624. * This represents a FPS type of camera controlled by touch.
  39625. * This is like a universal camera minus the Gamepad controls.
  39626. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39627. * @param name Define the name of the camera in the scene
  39628. * @param position Define the start position of the camera in the scene
  39629. * @param scene Define the scene the camera belongs to
  39630. */
  39631. constructor(name: string, position: Vector3, scene: Scene);
  39632. /**
  39633. * Gets the current object class name.
  39634. * @return the class name
  39635. */
  39636. getClassName(): string;
  39637. /** @hidden */
  39638. _setupInputs(): void;
  39639. }
  39640. }
  39641. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39642. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39643. import { Scene } from "babylonjs/scene";
  39644. import { Vector3 } from "babylonjs/Maths/math.vector";
  39645. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39646. import { Axis } from "babylonjs/Maths/math.axis";
  39647. /**
  39648. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39649. * being tilted forward or back and left or right.
  39650. */
  39651. export class DeviceOrientationCamera extends FreeCamera {
  39652. private _initialQuaternion;
  39653. private _quaternionCache;
  39654. private _tmpDragQuaternion;
  39655. private _disablePointerInputWhenUsingDeviceOrientation;
  39656. /**
  39657. * Creates a new device orientation camera
  39658. * @param name The name of the camera
  39659. * @param position The start position camera
  39660. * @param scene The scene the camera belongs to
  39661. */
  39662. constructor(name: string, position: Vector3, scene: Scene);
  39663. /**
  39664. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39665. */
  39666. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39667. private _dragFactor;
  39668. /**
  39669. * Enabled turning on the y axis when the orientation sensor is active
  39670. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39671. */
  39672. enableHorizontalDragging(dragFactor?: number): void;
  39673. /**
  39674. * Gets the current instance class name ("DeviceOrientationCamera").
  39675. * This helps avoiding instanceof at run time.
  39676. * @returns the class name
  39677. */
  39678. getClassName(): string;
  39679. /**
  39680. * @hidden
  39681. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39682. */
  39683. _checkInputs(): void;
  39684. /**
  39685. * Reset the camera to its default orientation on the specified axis only.
  39686. * @param axis The axis to reset
  39687. */
  39688. resetToCurrentRotation(axis?: Axis): void;
  39689. }
  39690. }
  39691. declare module "babylonjs/Gamepads/xboxGamepad" {
  39692. import { Observable } from "babylonjs/Misc/observable";
  39693. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39694. /**
  39695. * Defines supported buttons for XBox360 compatible gamepads
  39696. */
  39697. export enum Xbox360Button {
  39698. /** A */
  39699. A = 0,
  39700. /** B */
  39701. B = 1,
  39702. /** X */
  39703. X = 2,
  39704. /** Y */
  39705. Y = 3,
  39706. /** Start */
  39707. Start = 4,
  39708. /** Back */
  39709. Back = 5,
  39710. /** Left button */
  39711. LB = 6,
  39712. /** Right button */
  39713. RB = 7,
  39714. /** Left stick */
  39715. LeftStick = 8,
  39716. /** Right stick */
  39717. RightStick = 9
  39718. }
  39719. /** Defines values for XBox360 DPad */
  39720. export enum Xbox360Dpad {
  39721. /** Up */
  39722. Up = 0,
  39723. /** Down */
  39724. Down = 1,
  39725. /** Left */
  39726. Left = 2,
  39727. /** Right */
  39728. Right = 3
  39729. }
  39730. /**
  39731. * Defines a XBox360 gamepad
  39732. */
  39733. export class Xbox360Pad extends Gamepad {
  39734. private _leftTrigger;
  39735. private _rightTrigger;
  39736. private _onlefttriggerchanged;
  39737. private _onrighttriggerchanged;
  39738. private _onbuttondown;
  39739. private _onbuttonup;
  39740. private _ondpaddown;
  39741. private _ondpadup;
  39742. /** Observable raised when a button is pressed */
  39743. onButtonDownObservable: Observable<Xbox360Button>;
  39744. /** Observable raised when a button is released */
  39745. onButtonUpObservable: Observable<Xbox360Button>;
  39746. /** Observable raised when a pad is pressed */
  39747. onPadDownObservable: Observable<Xbox360Dpad>;
  39748. /** Observable raised when a pad is released */
  39749. onPadUpObservable: Observable<Xbox360Dpad>;
  39750. private _buttonA;
  39751. private _buttonB;
  39752. private _buttonX;
  39753. private _buttonY;
  39754. private _buttonBack;
  39755. private _buttonStart;
  39756. private _buttonLB;
  39757. private _buttonRB;
  39758. private _buttonLeftStick;
  39759. private _buttonRightStick;
  39760. private _dPadUp;
  39761. private _dPadDown;
  39762. private _dPadLeft;
  39763. private _dPadRight;
  39764. private _isXboxOnePad;
  39765. /**
  39766. * Creates a new XBox360 gamepad object
  39767. * @param id defines the id of this gamepad
  39768. * @param index defines its index
  39769. * @param gamepad defines the internal HTML gamepad object
  39770. * @param xboxOne defines if it is a XBox One gamepad
  39771. */
  39772. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39773. /**
  39774. * Defines the callback to call when left trigger is pressed
  39775. * @param callback defines the callback to use
  39776. */
  39777. onlefttriggerchanged(callback: (value: number) => void): void;
  39778. /**
  39779. * Defines the callback to call when right trigger is pressed
  39780. * @param callback defines the callback to use
  39781. */
  39782. onrighttriggerchanged(callback: (value: number) => void): void;
  39783. /**
  39784. * Gets the left trigger value
  39785. */
  39786. /**
  39787. * Sets the left trigger value
  39788. */
  39789. leftTrigger: number;
  39790. /**
  39791. * Gets the right trigger value
  39792. */
  39793. /**
  39794. * Sets the right trigger value
  39795. */
  39796. rightTrigger: number;
  39797. /**
  39798. * Defines the callback to call when a button is pressed
  39799. * @param callback defines the callback to use
  39800. */
  39801. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39802. /**
  39803. * Defines the callback to call when a button is released
  39804. * @param callback defines the callback to use
  39805. */
  39806. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39807. /**
  39808. * Defines the callback to call when a pad is pressed
  39809. * @param callback defines the callback to use
  39810. */
  39811. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39812. /**
  39813. * Defines the callback to call when a pad is released
  39814. * @param callback defines the callback to use
  39815. */
  39816. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39817. private _setButtonValue;
  39818. private _setDPadValue;
  39819. /**
  39820. * Gets the value of the `A` button
  39821. */
  39822. /**
  39823. * Sets the value of the `A` button
  39824. */
  39825. buttonA: number;
  39826. /**
  39827. * Gets the value of the `B` button
  39828. */
  39829. /**
  39830. * Sets the value of the `B` button
  39831. */
  39832. buttonB: number;
  39833. /**
  39834. * Gets the value of the `X` button
  39835. */
  39836. /**
  39837. * Sets the value of the `X` button
  39838. */
  39839. buttonX: number;
  39840. /**
  39841. * Gets the value of the `Y` button
  39842. */
  39843. /**
  39844. * Sets the value of the `Y` button
  39845. */
  39846. buttonY: number;
  39847. /**
  39848. * Gets the value of the `Start` button
  39849. */
  39850. /**
  39851. * Sets the value of the `Start` button
  39852. */
  39853. buttonStart: number;
  39854. /**
  39855. * Gets the value of the `Back` button
  39856. */
  39857. /**
  39858. * Sets the value of the `Back` button
  39859. */
  39860. buttonBack: number;
  39861. /**
  39862. * Gets the value of the `Left` button
  39863. */
  39864. /**
  39865. * Sets the value of the `Left` button
  39866. */
  39867. buttonLB: number;
  39868. /**
  39869. * Gets the value of the `Right` button
  39870. */
  39871. /**
  39872. * Sets the value of the `Right` button
  39873. */
  39874. buttonRB: number;
  39875. /**
  39876. * Gets the value of the Left joystick
  39877. */
  39878. /**
  39879. * Sets the value of the Left joystick
  39880. */
  39881. buttonLeftStick: number;
  39882. /**
  39883. * Gets the value of the Right joystick
  39884. */
  39885. /**
  39886. * Sets the value of the Right joystick
  39887. */
  39888. buttonRightStick: number;
  39889. /**
  39890. * Gets the value of D-pad up
  39891. */
  39892. /**
  39893. * Sets the value of D-pad up
  39894. */
  39895. dPadUp: number;
  39896. /**
  39897. * Gets the value of D-pad down
  39898. */
  39899. /**
  39900. * Sets the value of D-pad down
  39901. */
  39902. dPadDown: number;
  39903. /**
  39904. * Gets the value of D-pad left
  39905. */
  39906. /**
  39907. * Sets the value of D-pad left
  39908. */
  39909. dPadLeft: number;
  39910. /**
  39911. * Gets the value of D-pad right
  39912. */
  39913. /**
  39914. * Sets the value of D-pad right
  39915. */
  39916. dPadRight: number;
  39917. /**
  39918. * Force the gamepad to synchronize with device values
  39919. */
  39920. update(): void;
  39921. /**
  39922. * Disposes the gamepad
  39923. */
  39924. dispose(): void;
  39925. }
  39926. }
  39927. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39928. import { Observable } from "babylonjs/Misc/observable";
  39929. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39930. /**
  39931. * Defines supported buttons for DualShock compatible gamepads
  39932. */
  39933. export enum DualShockButton {
  39934. /** Cross */
  39935. Cross = 0,
  39936. /** Circle */
  39937. Circle = 1,
  39938. /** Square */
  39939. Square = 2,
  39940. /** Triangle */
  39941. Triangle = 3,
  39942. /** Options */
  39943. Options = 4,
  39944. /** Share */
  39945. Share = 5,
  39946. /** L1 */
  39947. L1 = 6,
  39948. /** R1 */
  39949. R1 = 7,
  39950. /** Left stick */
  39951. LeftStick = 8,
  39952. /** Right stick */
  39953. RightStick = 9
  39954. }
  39955. /** Defines values for DualShock DPad */
  39956. export enum DualShockDpad {
  39957. /** Up */
  39958. Up = 0,
  39959. /** Down */
  39960. Down = 1,
  39961. /** Left */
  39962. Left = 2,
  39963. /** Right */
  39964. Right = 3
  39965. }
  39966. /**
  39967. * Defines a DualShock gamepad
  39968. */
  39969. export class DualShockPad extends Gamepad {
  39970. private _leftTrigger;
  39971. private _rightTrigger;
  39972. private _onlefttriggerchanged;
  39973. private _onrighttriggerchanged;
  39974. private _onbuttondown;
  39975. private _onbuttonup;
  39976. private _ondpaddown;
  39977. private _ondpadup;
  39978. /** Observable raised when a button is pressed */
  39979. onButtonDownObservable: Observable<DualShockButton>;
  39980. /** Observable raised when a button is released */
  39981. onButtonUpObservable: Observable<DualShockButton>;
  39982. /** Observable raised when a pad is pressed */
  39983. onPadDownObservable: Observable<DualShockDpad>;
  39984. /** Observable raised when a pad is released */
  39985. onPadUpObservable: Observable<DualShockDpad>;
  39986. private _buttonCross;
  39987. private _buttonCircle;
  39988. private _buttonSquare;
  39989. private _buttonTriangle;
  39990. private _buttonShare;
  39991. private _buttonOptions;
  39992. private _buttonL1;
  39993. private _buttonR1;
  39994. private _buttonLeftStick;
  39995. private _buttonRightStick;
  39996. private _dPadUp;
  39997. private _dPadDown;
  39998. private _dPadLeft;
  39999. private _dPadRight;
  40000. /**
  40001. * Creates a new DualShock gamepad object
  40002. * @param id defines the id of this gamepad
  40003. * @param index defines its index
  40004. * @param gamepad defines the internal HTML gamepad object
  40005. */
  40006. constructor(id: string, index: number, gamepad: any);
  40007. /**
  40008. * Defines the callback to call when left trigger is pressed
  40009. * @param callback defines the callback to use
  40010. */
  40011. onlefttriggerchanged(callback: (value: number) => void): void;
  40012. /**
  40013. * Defines the callback to call when right trigger is pressed
  40014. * @param callback defines the callback to use
  40015. */
  40016. onrighttriggerchanged(callback: (value: number) => void): void;
  40017. /**
  40018. * Gets the left trigger value
  40019. */
  40020. /**
  40021. * Sets the left trigger value
  40022. */
  40023. leftTrigger: number;
  40024. /**
  40025. * Gets the right trigger value
  40026. */
  40027. /**
  40028. * Sets the right trigger value
  40029. */
  40030. rightTrigger: number;
  40031. /**
  40032. * Defines the callback to call when a button is pressed
  40033. * @param callback defines the callback to use
  40034. */
  40035. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40036. /**
  40037. * Defines the callback to call when a button is released
  40038. * @param callback defines the callback to use
  40039. */
  40040. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40041. /**
  40042. * Defines the callback to call when a pad is pressed
  40043. * @param callback defines the callback to use
  40044. */
  40045. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40046. /**
  40047. * Defines the callback to call when a pad is released
  40048. * @param callback defines the callback to use
  40049. */
  40050. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40051. private _setButtonValue;
  40052. private _setDPadValue;
  40053. /**
  40054. * Gets the value of the `Cross` button
  40055. */
  40056. /**
  40057. * Sets the value of the `Cross` button
  40058. */
  40059. buttonCross: number;
  40060. /**
  40061. * Gets the value of the `Circle` button
  40062. */
  40063. /**
  40064. * Sets the value of the `Circle` button
  40065. */
  40066. buttonCircle: number;
  40067. /**
  40068. * Gets the value of the `Square` button
  40069. */
  40070. /**
  40071. * Sets the value of the `Square` button
  40072. */
  40073. buttonSquare: number;
  40074. /**
  40075. * Gets the value of the `Triangle` button
  40076. */
  40077. /**
  40078. * Sets the value of the `Triangle` button
  40079. */
  40080. buttonTriangle: number;
  40081. /**
  40082. * Gets the value of the `Options` button
  40083. */
  40084. /**
  40085. * Sets the value of the `Options` button
  40086. */
  40087. buttonOptions: number;
  40088. /**
  40089. * Gets the value of the `Share` button
  40090. */
  40091. /**
  40092. * Sets the value of the `Share` button
  40093. */
  40094. buttonShare: number;
  40095. /**
  40096. * Gets the value of the `L1` button
  40097. */
  40098. /**
  40099. * Sets the value of the `L1` button
  40100. */
  40101. buttonL1: number;
  40102. /**
  40103. * Gets the value of the `R1` button
  40104. */
  40105. /**
  40106. * Sets the value of the `R1` button
  40107. */
  40108. buttonR1: number;
  40109. /**
  40110. * Gets the value of the Left joystick
  40111. */
  40112. /**
  40113. * Sets the value of the Left joystick
  40114. */
  40115. buttonLeftStick: number;
  40116. /**
  40117. * Gets the value of the Right joystick
  40118. */
  40119. /**
  40120. * Sets the value of the Right joystick
  40121. */
  40122. buttonRightStick: number;
  40123. /**
  40124. * Gets the value of D-pad up
  40125. */
  40126. /**
  40127. * Sets the value of D-pad up
  40128. */
  40129. dPadUp: number;
  40130. /**
  40131. * Gets the value of D-pad down
  40132. */
  40133. /**
  40134. * Sets the value of D-pad down
  40135. */
  40136. dPadDown: number;
  40137. /**
  40138. * Gets the value of D-pad left
  40139. */
  40140. /**
  40141. * Sets the value of D-pad left
  40142. */
  40143. dPadLeft: number;
  40144. /**
  40145. * Gets the value of D-pad right
  40146. */
  40147. /**
  40148. * Sets the value of D-pad right
  40149. */
  40150. dPadRight: number;
  40151. /**
  40152. * Force the gamepad to synchronize with device values
  40153. */
  40154. update(): void;
  40155. /**
  40156. * Disposes the gamepad
  40157. */
  40158. dispose(): void;
  40159. }
  40160. }
  40161. declare module "babylonjs/Gamepads/gamepadManager" {
  40162. import { Observable } from "babylonjs/Misc/observable";
  40163. import { Nullable } from "babylonjs/types";
  40164. import { Scene } from "babylonjs/scene";
  40165. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40166. /**
  40167. * Manager for handling gamepads
  40168. */
  40169. export class GamepadManager {
  40170. private _scene?;
  40171. private _babylonGamepads;
  40172. private _oneGamepadConnected;
  40173. /** @hidden */
  40174. _isMonitoring: boolean;
  40175. private _gamepadEventSupported;
  40176. private _gamepadSupport;
  40177. /**
  40178. * observable to be triggered when the gamepad controller has been connected
  40179. */
  40180. onGamepadConnectedObservable: Observable<Gamepad>;
  40181. /**
  40182. * observable to be triggered when the gamepad controller has been disconnected
  40183. */
  40184. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40185. private _onGamepadConnectedEvent;
  40186. private _onGamepadDisconnectedEvent;
  40187. /**
  40188. * Initializes the gamepad manager
  40189. * @param _scene BabylonJS scene
  40190. */
  40191. constructor(_scene?: Scene | undefined);
  40192. /**
  40193. * The gamepads in the game pad manager
  40194. */
  40195. readonly gamepads: Gamepad[];
  40196. /**
  40197. * Get the gamepad controllers based on type
  40198. * @param type The type of gamepad controller
  40199. * @returns Nullable gamepad
  40200. */
  40201. getGamepadByType(type?: number): Nullable<Gamepad>;
  40202. /**
  40203. * Disposes the gamepad manager
  40204. */
  40205. dispose(): void;
  40206. private _addNewGamepad;
  40207. private _startMonitoringGamepads;
  40208. private _stopMonitoringGamepads;
  40209. /** @hidden */
  40210. _checkGamepadsStatus(): void;
  40211. private _updateGamepadObjects;
  40212. }
  40213. }
  40214. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40215. import { Nullable } from "babylonjs/types";
  40216. import { Scene } from "babylonjs/scene";
  40217. import { ISceneComponent } from "babylonjs/sceneComponent";
  40218. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40219. module "babylonjs/scene" {
  40220. interface Scene {
  40221. /** @hidden */
  40222. _gamepadManager: Nullable<GamepadManager>;
  40223. /**
  40224. * Gets the gamepad manager associated with the scene
  40225. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40226. */
  40227. gamepadManager: GamepadManager;
  40228. }
  40229. }
  40230. module "babylonjs/Cameras/freeCameraInputsManager" {
  40231. /**
  40232. * Interface representing a free camera inputs manager
  40233. */
  40234. interface FreeCameraInputsManager {
  40235. /**
  40236. * Adds gamepad input support to the FreeCameraInputsManager.
  40237. * @returns the FreeCameraInputsManager
  40238. */
  40239. addGamepad(): FreeCameraInputsManager;
  40240. }
  40241. }
  40242. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40243. /**
  40244. * Interface representing an arc rotate camera inputs manager
  40245. */
  40246. interface ArcRotateCameraInputsManager {
  40247. /**
  40248. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40249. * @returns the camera inputs manager
  40250. */
  40251. addGamepad(): ArcRotateCameraInputsManager;
  40252. }
  40253. }
  40254. /**
  40255. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40256. */
  40257. export class GamepadSystemSceneComponent implements ISceneComponent {
  40258. /**
  40259. * The component name helpfull to identify the component in the list of scene components.
  40260. */
  40261. readonly name: string;
  40262. /**
  40263. * The scene the component belongs to.
  40264. */
  40265. scene: Scene;
  40266. /**
  40267. * Creates a new instance of the component for the given scene
  40268. * @param scene Defines the scene to register the component in
  40269. */
  40270. constructor(scene: Scene);
  40271. /**
  40272. * Registers the component in a given scene
  40273. */
  40274. register(): void;
  40275. /**
  40276. * Rebuilds the elements related to this component in case of
  40277. * context lost for instance.
  40278. */
  40279. rebuild(): void;
  40280. /**
  40281. * Disposes the component and the associated ressources
  40282. */
  40283. dispose(): void;
  40284. private _beforeCameraUpdate;
  40285. }
  40286. }
  40287. declare module "babylonjs/Cameras/universalCamera" {
  40288. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40289. import { Scene } from "babylonjs/scene";
  40290. import { Vector3 } from "babylonjs/Maths/math.vector";
  40291. import "babylonjs/Gamepads/gamepadSceneComponent";
  40292. /**
  40293. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  40294. * which still works and will still be found in many Playgrounds.
  40295. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40296. */
  40297. export class UniversalCamera extends TouchCamera {
  40298. /**
  40299. * Defines the gamepad rotation sensiblity.
  40300. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40301. */
  40302. gamepadAngularSensibility: number;
  40303. /**
  40304. * Defines the gamepad move sensiblity.
  40305. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40306. */
  40307. gamepadMoveSensibility: number;
  40308. /**
  40309. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  40310. * which still works and will still be found in many Playgrounds.
  40311. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40312. * @param name Define the name of the camera in the scene
  40313. * @param position Define the start position of the camera in the scene
  40314. * @param scene Define the scene the camera belongs to
  40315. */
  40316. constructor(name: string, position: Vector3, scene: Scene);
  40317. /**
  40318. * Gets the current object class name.
  40319. * @return the class name
  40320. */
  40321. getClassName(): string;
  40322. }
  40323. }
  40324. declare module "babylonjs/Cameras/gamepadCamera" {
  40325. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40326. import { Scene } from "babylonjs/scene";
  40327. import { Vector3 } from "babylonjs/Maths/math.vector";
  40328. /**
  40329. * This represents a FPS type of camera. This is only here for back compat purpose.
  40330. * Please use the UniversalCamera instead as both are identical.
  40331. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40332. */
  40333. export class GamepadCamera extends UniversalCamera {
  40334. /**
  40335. * Instantiates a new Gamepad Camera
  40336. * This represents a FPS type of camera. This is only here for back compat purpose.
  40337. * Please use the UniversalCamera instead as both are identical.
  40338. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40339. * @param name Define the name of the camera in the scene
  40340. * @param position Define the start position of the camera in the scene
  40341. * @param scene Define the scene the camera belongs to
  40342. */
  40343. constructor(name: string, position: Vector3, scene: Scene);
  40344. /**
  40345. * Gets the current object class name.
  40346. * @return the class name
  40347. */
  40348. getClassName(): string;
  40349. }
  40350. }
  40351. declare module "babylonjs/Shaders/pass.fragment" {
  40352. /** @hidden */
  40353. export var passPixelShader: {
  40354. name: string;
  40355. shader: string;
  40356. };
  40357. }
  40358. declare module "babylonjs/Shaders/passCube.fragment" {
  40359. /** @hidden */
  40360. export var passCubePixelShader: {
  40361. name: string;
  40362. shader: string;
  40363. };
  40364. }
  40365. declare module "babylonjs/PostProcesses/passPostProcess" {
  40366. import { Nullable } from "babylonjs/types";
  40367. import { Camera } from "babylonjs/Cameras/camera";
  40368. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40369. import { Engine } from "babylonjs/Engines/engine";
  40370. import "babylonjs/Shaders/pass.fragment";
  40371. import "babylonjs/Shaders/passCube.fragment";
  40372. /**
  40373. * PassPostProcess which produces an output the same as it's input
  40374. */
  40375. export class PassPostProcess extends PostProcess {
  40376. /**
  40377. * Creates the PassPostProcess
  40378. * @param name The name of the effect.
  40379. * @param options The required width/height ratio to downsize to before computing the render pass.
  40380. * @param camera The camera to apply the render pass to.
  40381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40382. * @param engine The engine which the post process will be applied. (default: current engine)
  40383. * @param reusable If the post process can be reused on the same frame. (default: false)
  40384. * @param textureType The type of texture to be used when performing the post processing.
  40385. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  40386. */
  40387. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40388. }
  40389. /**
  40390. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40391. */
  40392. export class PassCubePostProcess extends PostProcess {
  40393. private _face;
  40394. /**
  40395. * Gets or sets the cube face to display.
  40396. * * 0 is +X
  40397. * * 1 is -X
  40398. * * 2 is +Y
  40399. * * 3 is -Y
  40400. * * 4 is +Z
  40401. * * 5 is -Z
  40402. */
  40403. face: number;
  40404. /**
  40405. * Creates the PassCubePostProcess
  40406. * @param name The name of the effect.
  40407. * @param options The required width/height ratio to downsize to before computing the render pass.
  40408. * @param camera The camera to apply the render pass to.
  40409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40410. * @param engine The engine which the post process will be applied. (default: current engine)
  40411. * @param reusable If the post process can be reused on the same frame. (default: false)
  40412. * @param textureType The type of texture to be used when performing the post processing.
  40413. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  40414. */
  40415. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40416. }
  40417. }
  40418. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40419. /** @hidden */
  40420. export var anaglyphPixelShader: {
  40421. name: string;
  40422. shader: string;
  40423. };
  40424. }
  40425. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40426. import { Engine } from "babylonjs/Engines/engine";
  40427. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40428. import { Camera } from "babylonjs/Cameras/camera";
  40429. import "babylonjs/Shaders/anaglyph.fragment";
  40430. /**
  40431. * Postprocess used to generate anaglyphic rendering
  40432. */
  40433. export class AnaglyphPostProcess extends PostProcess {
  40434. private _passedProcess;
  40435. /**
  40436. * Creates a new AnaglyphPostProcess
  40437. * @param name defines postprocess name
  40438. * @param options defines creation options or target ratio scale
  40439. * @param rigCameras defines cameras using this postprocess
  40440. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40441. * @param engine defines hosting engine
  40442. * @param reusable defines if the postprocess will be reused multiple times per frame
  40443. */
  40444. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40445. }
  40446. }
  40447. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40448. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40449. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40450. import { Scene } from "babylonjs/scene";
  40451. import { Vector3 } from "babylonjs/Maths/math.vector";
  40452. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40453. /**
  40454. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40455. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40456. */
  40457. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40458. /**
  40459. * Creates a new AnaglyphArcRotateCamera
  40460. * @param name defines camera name
  40461. * @param alpha defines alpha angle (in radians)
  40462. * @param beta defines beta angle (in radians)
  40463. * @param radius defines radius
  40464. * @param target defines camera target
  40465. * @param interaxialDistance defines distance between each color axis
  40466. * @param scene defines the hosting scene
  40467. */
  40468. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40469. /**
  40470. * Gets camera class name
  40471. * @returns AnaglyphArcRotateCamera
  40472. */
  40473. getClassName(): string;
  40474. }
  40475. }
  40476. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40477. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40478. import { Scene } from "babylonjs/scene";
  40479. import { Vector3 } from "babylonjs/Maths/math.vector";
  40480. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40481. /**
  40482. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40483. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40484. */
  40485. export class AnaglyphFreeCamera extends FreeCamera {
  40486. /**
  40487. * Creates a new AnaglyphFreeCamera
  40488. * @param name defines camera name
  40489. * @param position defines initial position
  40490. * @param interaxialDistance defines distance between each color axis
  40491. * @param scene defines the hosting scene
  40492. */
  40493. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40494. /**
  40495. * Gets camera class name
  40496. * @returns AnaglyphFreeCamera
  40497. */
  40498. getClassName(): string;
  40499. }
  40500. }
  40501. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40502. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40503. import { Scene } from "babylonjs/scene";
  40504. import { Vector3 } from "babylonjs/Maths/math.vector";
  40505. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40506. /**
  40507. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40508. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40509. */
  40510. export class AnaglyphGamepadCamera extends GamepadCamera {
  40511. /**
  40512. * Creates a new AnaglyphGamepadCamera
  40513. * @param name defines camera name
  40514. * @param position defines initial position
  40515. * @param interaxialDistance defines distance between each color axis
  40516. * @param scene defines the hosting scene
  40517. */
  40518. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40519. /**
  40520. * Gets camera class name
  40521. * @returns AnaglyphGamepadCamera
  40522. */
  40523. getClassName(): string;
  40524. }
  40525. }
  40526. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40527. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40528. import { Scene } from "babylonjs/scene";
  40529. import { Vector3 } from "babylonjs/Maths/math.vector";
  40530. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40531. /**
  40532. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40533. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40534. */
  40535. export class AnaglyphUniversalCamera extends UniversalCamera {
  40536. /**
  40537. * Creates a new AnaglyphUniversalCamera
  40538. * @param name defines camera name
  40539. * @param position defines initial position
  40540. * @param interaxialDistance defines distance between each color axis
  40541. * @param scene defines the hosting scene
  40542. */
  40543. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40544. /**
  40545. * Gets camera class name
  40546. * @returns AnaglyphUniversalCamera
  40547. */
  40548. getClassName(): string;
  40549. }
  40550. }
  40551. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40552. /** @hidden */
  40553. export var stereoscopicInterlacePixelShader: {
  40554. name: string;
  40555. shader: string;
  40556. };
  40557. }
  40558. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40559. import { Camera } from "babylonjs/Cameras/camera";
  40560. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40561. import { Engine } from "babylonjs/Engines/engine";
  40562. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40563. /**
  40564. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40565. */
  40566. export class StereoscopicInterlacePostProcess extends PostProcess {
  40567. private _stepSize;
  40568. private _passedProcess;
  40569. /**
  40570. * Initializes a StereoscopicInterlacePostProcess
  40571. * @param name The name of the effect.
  40572. * @param rigCameras The rig cameras to be appled to the post process
  40573. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40574. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40575. * @param engine The engine which the post process will be applied. (default: current engine)
  40576. * @param reusable If the post process can be reused on the same frame. (default: false)
  40577. */
  40578. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40579. }
  40580. }
  40581. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40582. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40583. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40584. import { Scene } from "babylonjs/scene";
  40585. import { Vector3 } from "babylonjs/Maths/math.vector";
  40586. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40587. /**
  40588. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40589. * @see http://doc.babylonjs.com/features/cameras
  40590. */
  40591. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40592. /**
  40593. * Creates a new StereoscopicArcRotateCamera
  40594. * @param name defines camera name
  40595. * @param alpha defines alpha angle (in radians)
  40596. * @param beta defines beta angle (in radians)
  40597. * @param radius defines radius
  40598. * @param target defines camera target
  40599. * @param interaxialDistance defines distance between each color axis
  40600. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40601. * @param scene defines the hosting scene
  40602. */
  40603. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40604. /**
  40605. * Gets camera class name
  40606. * @returns StereoscopicArcRotateCamera
  40607. */
  40608. getClassName(): string;
  40609. }
  40610. }
  40611. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40612. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40613. import { Scene } from "babylonjs/scene";
  40614. import { Vector3 } from "babylonjs/Maths/math.vector";
  40615. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40616. /**
  40617. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40618. * @see http://doc.babylonjs.com/features/cameras
  40619. */
  40620. export class StereoscopicFreeCamera extends FreeCamera {
  40621. /**
  40622. * Creates a new StereoscopicFreeCamera
  40623. * @param name defines camera name
  40624. * @param position defines initial position
  40625. * @param interaxialDistance defines distance between each color axis
  40626. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40627. * @param scene defines the hosting scene
  40628. */
  40629. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40630. /**
  40631. * Gets camera class name
  40632. * @returns StereoscopicFreeCamera
  40633. */
  40634. getClassName(): string;
  40635. }
  40636. }
  40637. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40638. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40639. import { Scene } from "babylonjs/scene";
  40640. import { Vector3 } from "babylonjs/Maths/math.vector";
  40641. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40642. /**
  40643. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40644. * @see http://doc.babylonjs.com/features/cameras
  40645. */
  40646. export class StereoscopicGamepadCamera extends GamepadCamera {
  40647. /**
  40648. * Creates a new StereoscopicGamepadCamera
  40649. * @param name defines camera name
  40650. * @param position defines initial position
  40651. * @param interaxialDistance defines distance between each color axis
  40652. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40653. * @param scene defines the hosting scene
  40654. */
  40655. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40656. /**
  40657. * Gets camera class name
  40658. * @returns StereoscopicGamepadCamera
  40659. */
  40660. getClassName(): string;
  40661. }
  40662. }
  40663. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40664. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40665. import { Scene } from "babylonjs/scene";
  40666. import { Vector3 } from "babylonjs/Maths/math.vector";
  40667. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40668. /**
  40669. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40670. * @see http://doc.babylonjs.com/features/cameras
  40671. */
  40672. export class StereoscopicUniversalCamera extends UniversalCamera {
  40673. /**
  40674. * Creates a new StereoscopicUniversalCamera
  40675. * @param name defines camera name
  40676. * @param position defines initial position
  40677. * @param interaxialDistance defines distance between each color axis
  40678. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40679. * @param scene defines the hosting scene
  40680. */
  40681. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40682. /**
  40683. * Gets camera class name
  40684. * @returns StereoscopicUniversalCamera
  40685. */
  40686. getClassName(): string;
  40687. }
  40688. }
  40689. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40690. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40691. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40692. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40693. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40694. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40695. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40696. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40697. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40698. }
  40699. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40700. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40701. import { Scene } from "babylonjs/scene";
  40702. import { Vector3 } from "babylonjs/Maths/math.vector";
  40703. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40704. /**
  40705. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40706. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40707. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40708. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40709. */
  40710. export class VirtualJoysticksCamera extends FreeCamera {
  40711. /**
  40712. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40713. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40714. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40715. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40716. * @param name Define the name of the camera in the scene
  40717. * @param position Define the start position of the camera in the scene
  40718. * @param scene Define the scene the camera belongs to
  40719. */
  40720. constructor(name: string, position: Vector3, scene: Scene);
  40721. /**
  40722. * Gets the current object class name.
  40723. * @return the class name
  40724. */
  40725. getClassName(): string;
  40726. }
  40727. }
  40728. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40729. import { Matrix } from "babylonjs/Maths/math.vector";
  40730. /**
  40731. * This represents all the required metrics to create a VR camera.
  40732. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40733. */
  40734. export class VRCameraMetrics {
  40735. /**
  40736. * Define the horizontal resolution off the screen.
  40737. */
  40738. hResolution: number;
  40739. /**
  40740. * Define the vertical resolution off the screen.
  40741. */
  40742. vResolution: number;
  40743. /**
  40744. * Define the horizontal screen size.
  40745. */
  40746. hScreenSize: number;
  40747. /**
  40748. * Define the vertical screen size.
  40749. */
  40750. vScreenSize: number;
  40751. /**
  40752. * Define the vertical screen center position.
  40753. */
  40754. vScreenCenter: number;
  40755. /**
  40756. * Define the distance of the eyes to the screen.
  40757. */
  40758. eyeToScreenDistance: number;
  40759. /**
  40760. * Define the distance between both lenses
  40761. */
  40762. lensSeparationDistance: number;
  40763. /**
  40764. * Define the distance between both viewer's eyes.
  40765. */
  40766. interpupillaryDistance: number;
  40767. /**
  40768. * Define the distortion factor of the VR postprocess.
  40769. * Please, touch with care.
  40770. */
  40771. distortionK: number[];
  40772. /**
  40773. * Define the chromatic aberration correction factors for the VR post process.
  40774. */
  40775. chromaAbCorrection: number[];
  40776. /**
  40777. * Define the scale factor of the post process.
  40778. * The smaller the better but the slower.
  40779. */
  40780. postProcessScaleFactor: number;
  40781. /**
  40782. * Define an offset for the lens center.
  40783. */
  40784. lensCenterOffset: number;
  40785. /**
  40786. * Define if the current vr camera should compensate the distortion of the lense or not.
  40787. */
  40788. compensateDistortion: boolean;
  40789. /**
  40790. * Defines if multiview should be enabled when rendering (Default: false)
  40791. */
  40792. multiviewEnabled: boolean;
  40793. /**
  40794. * Gets the rendering aspect ratio based on the provided resolutions.
  40795. */
  40796. readonly aspectRatio: number;
  40797. /**
  40798. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40799. */
  40800. readonly aspectRatioFov: number;
  40801. /**
  40802. * @hidden
  40803. */
  40804. readonly leftHMatrix: Matrix;
  40805. /**
  40806. * @hidden
  40807. */
  40808. readonly rightHMatrix: Matrix;
  40809. /**
  40810. * @hidden
  40811. */
  40812. readonly leftPreViewMatrix: Matrix;
  40813. /**
  40814. * @hidden
  40815. */
  40816. readonly rightPreViewMatrix: Matrix;
  40817. /**
  40818. * Get the default VRMetrics based on the most generic setup.
  40819. * @returns the default vr metrics
  40820. */
  40821. static GetDefault(): VRCameraMetrics;
  40822. }
  40823. }
  40824. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40825. /** @hidden */
  40826. export var vrDistortionCorrectionPixelShader: {
  40827. name: string;
  40828. shader: string;
  40829. };
  40830. }
  40831. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40832. import { Camera } from "babylonjs/Cameras/camera";
  40833. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40834. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40835. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40836. /**
  40837. * VRDistortionCorrectionPostProcess used for mobile VR
  40838. */
  40839. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40840. private _isRightEye;
  40841. private _distortionFactors;
  40842. private _postProcessScaleFactor;
  40843. private _lensCenterOffset;
  40844. private _scaleIn;
  40845. private _scaleFactor;
  40846. private _lensCenter;
  40847. /**
  40848. * Initializes the VRDistortionCorrectionPostProcess
  40849. * @param name The name of the effect.
  40850. * @param camera The camera to apply the render pass to.
  40851. * @param isRightEye If this is for the right eye distortion
  40852. * @param vrMetrics All the required metrics for the VR camera
  40853. */
  40854. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40855. }
  40856. }
  40857. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40858. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40859. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40860. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40861. import { Scene } from "babylonjs/scene";
  40862. import { Vector3 } from "babylonjs/Maths/math.vector";
  40863. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40864. import "babylonjs/Cameras/RigModes/vrRigMode";
  40865. /**
  40866. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40867. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40868. */
  40869. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40870. /**
  40871. * Creates a new VRDeviceOrientationArcRotateCamera
  40872. * @param name defines camera name
  40873. * @param alpha defines the camera rotation along the logitudinal axis
  40874. * @param beta defines the camera rotation along the latitudinal axis
  40875. * @param radius defines the camera distance from its target
  40876. * @param target defines the camera target
  40877. * @param scene defines the scene the camera belongs to
  40878. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40879. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40880. */
  40881. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40882. /**
  40883. * Gets camera class name
  40884. * @returns VRDeviceOrientationArcRotateCamera
  40885. */
  40886. getClassName(): string;
  40887. }
  40888. }
  40889. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40890. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40891. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40892. import { Scene } from "babylonjs/scene";
  40893. import { Vector3 } from "babylonjs/Maths/math.vector";
  40894. import "babylonjs/Cameras/RigModes/vrRigMode";
  40895. /**
  40896. * Camera used to simulate VR rendering (based on FreeCamera)
  40897. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40898. */
  40899. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40900. /**
  40901. * Creates a new VRDeviceOrientationFreeCamera
  40902. * @param name defines camera name
  40903. * @param position defines the start position of the camera
  40904. * @param scene defines the scene the camera belongs to
  40905. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40906. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40907. */
  40908. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40909. /**
  40910. * Gets camera class name
  40911. * @returns VRDeviceOrientationFreeCamera
  40912. */
  40913. getClassName(): string;
  40914. }
  40915. }
  40916. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40917. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40918. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40919. import { Scene } from "babylonjs/scene";
  40920. import { Vector3 } from "babylonjs/Maths/math.vector";
  40921. import "babylonjs/Gamepads/gamepadSceneComponent";
  40922. /**
  40923. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40924. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40925. */
  40926. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40927. /**
  40928. * Creates a new VRDeviceOrientationGamepadCamera
  40929. * @param name defines camera name
  40930. * @param position defines the start position of the camera
  40931. * @param scene defines the scene the camera belongs to
  40932. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40933. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40934. */
  40935. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40936. /**
  40937. * Gets camera class name
  40938. * @returns VRDeviceOrientationGamepadCamera
  40939. */
  40940. getClassName(): string;
  40941. }
  40942. }
  40943. declare module "babylonjs/Materials/pushMaterial" {
  40944. import { Nullable } from "babylonjs/types";
  40945. import { Scene } from "babylonjs/scene";
  40946. import { Matrix } from "babylonjs/Maths/math.vector";
  40947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40948. import { Mesh } from "babylonjs/Meshes/mesh";
  40949. import { Material } from "babylonjs/Materials/material";
  40950. import { Effect } from "babylonjs/Materials/effect";
  40951. /**
  40952. * Base class of materials working in push mode in babylon JS
  40953. * @hidden
  40954. */
  40955. export class PushMaterial extends Material {
  40956. protected _activeEffect: Effect;
  40957. protected _normalMatrix: Matrix;
  40958. /**
  40959. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40960. * This means that the material can keep using a previous shader while a new one is being compiled.
  40961. * This is mostly used when shader parallel compilation is supported (true by default)
  40962. */
  40963. allowShaderHotSwapping: boolean;
  40964. constructor(name: string, scene: Scene);
  40965. getEffect(): Effect;
  40966. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40967. /**
  40968. * Binds the given world matrix to the active effect
  40969. *
  40970. * @param world the matrix to bind
  40971. */
  40972. bindOnlyWorldMatrix(world: Matrix): void;
  40973. /**
  40974. * Binds the given normal matrix to the active effect
  40975. *
  40976. * @param normalMatrix the matrix to bind
  40977. */
  40978. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40979. bind(world: Matrix, mesh?: Mesh): void;
  40980. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40981. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40982. }
  40983. }
  40984. declare module "babylonjs/Materials/materialFlags" {
  40985. /**
  40986. * This groups all the flags used to control the materials channel.
  40987. */
  40988. export class MaterialFlags {
  40989. private static _DiffuseTextureEnabled;
  40990. /**
  40991. * Are diffuse textures enabled in the application.
  40992. */
  40993. static DiffuseTextureEnabled: boolean;
  40994. private static _AmbientTextureEnabled;
  40995. /**
  40996. * Are ambient textures enabled in the application.
  40997. */
  40998. static AmbientTextureEnabled: boolean;
  40999. private static _OpacityTextureEnabled;
  41000. /**
  41001. * Are opacity textures enabled in the application.
  41002. */
  41003. static OpacityTextureEnabled: boolean;
  41004. private static _ReflectionTextureEnabled;
  41005. /**
  41006. * Are reflection textures enabled in the application.
  41007. */
  41008. static ReflectionTextureEnabled: boolean;
  41009. private static _EmissiveTextureEnabled;
  41010. /**
  41011. * Are emissive textures enabled in the application.
  41012. */
  41013. static EmissiveTextureEnabled: boolean;
  41014. private static _SpecularTextureEnabled;
  41015. /**
  41016. * Are specular textures enabled in the application.
  41017. */
  41018. static SpecularTextureEnabled: boolean;
  41019. private static _BumpTextureEnabled;
  41020. /**
  41021. * Are bump textures enabled in the application.
  41022. */
  41023. static BumpTextureEnabled: boolean;
  41024. private static _LightmapTextureEnabled;
  41025. /**
  41026. * Are lightmap textures enabled in the application.
  41027. */
  41028. static LightmapTextureEnabled: boolean;
  41029. private static _RefractionTextureEnabled;
  41030. /**
  41031. * Are refraction textures enabled in the application.
  41032. */
  41033. static RefractionTextureEnabled: boolean;
  41034. private static _ColorGradingTextureEnabled;
  41035. /**
  41036. * Are color grading textures enabled in the application.
  41037. */
  41038. static ColorGradingTextureEnabled: boolean;
  41039. private static _FresnelEnabled;
  41040. /**
  41041. * Are fresnels enabled in the application.
  41042. */
  41043. static FresnelEnabled: boolean;
  41044. private static _ClearCoatTextureEnabled;
  41045. /**
  41046. * Are clear coat textures enabled in the application.
  41047. */
  41048. static ClearCoatTextureEnabled: boolean;
  41049. private static _ClearCoatBumpTextureEnabled;
  41050. /**
  41051. * Are clear coat bump textures enabled in the application.
  41052. */
  41053. static ClearCoatBumpTextureEnabled: boolean;
  41054. private static _ClearCoatTintTextureEnabled;
  41055. /**
  41056. * Are clear coat tint textures enabled in the application.
  41057. */
  41058. static ClearCoatTintTextureEnabled: boolean;
  41059. private static _SheenTextureEnabled;
  41060. /**
  41061. * Are sheen textures enabled in the application.
  41062. */
  41063. static SheenTextureEnabled: boolean;
  41064. private static _AnisotropicTextureEnabled;
  41065. /**
  41066. * Are anisotropic textures enabled in the application.
  41067. */
  41068. static AnisotropicTextureEnabled: boolean;
  41069. private static _ThicknessTextureEnabled;
  41070. /**
  41071. * Are thickness textures enabled in the application.
  41072. */
  41073. static ThicknessTextureEnabled: boolean;
  41074. }
  41075. }
  41076. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41077. /** @hidden */
  41078. export var defaultFragmentDeclaration: {
  41079. name: string;
  41080. shader: string;
  41081. };
  41082. }
  41083. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41084. /** @hidden */
  41085. export var defaultUboDeclaration: {
  41086. name: string;
  41087. shader: string;
  41088. };
  41089. }
  41090. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41091. /** @hidden */
  41092. export var lightFragmentDeclaration: {
  41093. name: string;
  41094. shader: string;
  41095. };
  41096. }
  41097. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41098. /** @hidden */
  41099. export var lightUboDeclaration: {
  41100. name: string;
  41101. shader: string;
  41102. };
  41103. }
  41104. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41105. /** @hidden */
  41106. export var lightsFragmentFunctions: {
  41107. name: string;
  41108. shader: string;
  41109. };
  41110. }
  41111. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41112. /** @hidden */
  41113. export var shadowsFragmentFunctions: {
  41114. name: string;
  41115. shader: string;
  41116. };
  41117. }
  41118. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41119. /** @hidden */
  41120. export var fresnelFunction: {
  41121. name: string;
  41122. shader: string;
  41123. };
  41124. }
  41125. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41126. /** @hidden */
  41127. export var reflectionFunction: {
  41128. name: string;
  41129. shader: string;
  41130. };
  41131. }
  41132. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41133. /** @hidden */
  41134. export var bumpFragmentFunctions: {
  41135. name: string;
  41136. shader: string;
  41137. };
  41138. }
  41139. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41140. /** @hidden */
  41141. export var logDepthDeclaration: {
  41142. name: string;
  41143. shader: string;
  41144. };
  41145. }
  41146. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41147. /** @hidden */
  41148. export var bumpFragment: {
  41149. name: string;
  41150. shader: string;
  41151. };
  41152. }
  41153. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41154. /** @hidden */
  41155. export var depthPrePass: {
  41156. name: string;
  41157. shader: string;
  41158. };
  41159. }
  41160. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41161. /** @hidden */
  41162. export var lightFragment: {
  41163. name: string;
  41164. shader: string;
  41165. };
  41166. }
  41167. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41168. /** @hidden */
  41169. export var logDepthFragment: {
  41170. name: string;
  41171. shader: string;
  41172. };
  41173. }
  41174. declare module "babylonjs/Shaders/default.fragment" {
  41175. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41176. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41177. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41178. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41179. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41180. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41181. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41182. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41183. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41184. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41185. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41186. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41187. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41188. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41189. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41190. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41191. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41192. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41193. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41194. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41195. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41196. /** @hidden */
  41197. export var defaultPixelShader: {
  41198. name: string;
  41199. shader: string;
  41200. };
  41201. }
  41202. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41203. /** @hidden */
  41204. export var defaultVertexDeclaration: {
  41205. name: string;
  41206. shader: string;
  41207. };
  41208. }
  41209. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41210. /** @hidden */
  41211. export var bumpVertexDeclaration: {
  41212. name: string;
  41213. shader: string;
  41214. };
  41215. }
  41216. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41217. /** @hidden */
  41218. export var bumpVertex: {
  41219. name: string;
  41220. shader: string;
  41221. };
  41222. }
  41223. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41224. /** @hidden */
  41225. export var fogVertex: {
  41226. name: string;
  41227. shader: string;
  41228. };
  41229. }
  41230. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41231. /** @hidden */
  41232. export var shadowsVertex: {
  41233. name: string;
  41234. shader: string;
  41235. };
  41236. }
  41237. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41238. /** @hidden */
  41239. export var pointCloudVertex: {
  41240. name: string;
  41241. shader: string;
  41242. };
  41243. }
  41244. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41245. /** @hidden */
  41246. export var logDepthVertex: {
  41247. name: string;
  41248. shader: string;
  41249. };
  41250. }
  41251. declare module "babylonjs/Shaders/default.vertex" {
  41252. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41253. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41254. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41255. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41256. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41257. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41258. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41259. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41260. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41261. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41262. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41263. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41264. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41265. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41266. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41267. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41268. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41269. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41270. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41271. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41272. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41273. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41274. /** @hidden */
  41275. export var defaultVertexShader: {
  41276. name: string;
  41277. shader: string;
  41278. };
  41279. }
  41280. declare module "babylonjs/Materials/standardMaterial" {
  41281. import { SmartArray } from "babylonjs/Misc/smartArray";
  41282. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41283. import { Nullable } from "babylonjs/types";
  41284. import { Scene } from "babylonjs/scene";
  41285. import { Matrix } from "babylonjs/Maths/math.vector";
  41286. import { Color3 } from "babylonjs/Maths/math.color";
  41287. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41289. import { Mesh } from "babylonjs/Meshes/mesh";
  41290. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41291. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41292. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41293. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41294. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41295. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41296. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41297. import "babylonjs/Shaders/default.fragment";
  41298. import "babylonjs/Shaders/default.vertex";
  41299. /** @hidden */
  41300. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41301. MAINUV1: boolean;
  41302. MAINUV2: boolean;
  41303. DIFFUSE: boolean;
  41304. DIFFUSEDIRECTUV: number;
  41305. AMBIENT: boolean;
  41306. AMBIENTDIRECTUV: number;
  41307. OPACITY: boolean;
  41308. OPACITYDIRECTUV: number;
  41309. OPACITYRGB: boolean;
  41310. REFLECTION: boolean;
  41311. EMISSIVE: boolean;
  41312. EMISSIVEDIRECTUV: number;
  41313. SPECULAR: boolean;
  41314. SPECULARDIRECTUV: number;
  41315. BUMP: boolean;
  41316. BUMPDIRECTUV: number;
  41317. PARALLAX: boolean;
  41318. PARALLAXOCCLUSION: boolean;
  41319. SPECULAROVERALPHA: boolean;
  41320. CLIPPLANE: boolean;
  41321. CLIPPLANE2: boolean;
  41322. CLIPPLANE3: boolean;
  41323. CLIPPLANE4: boolean;
  41324. ALPHATEST: boolean;
  41325. DEPTHPREPASS: boolean;
  41326. ALPHAFROMDIFFUSE: boolean;
  41327. POINTSIZE: boolean;
  41328. FOG: boolean;
  41329. SPECULARTERM: boolean;
  41330. DIFFUSEFRESNEL: boolean;
  41331. OPACITYFRESNEL: boolean;
  41332. REFLECTIONFRESNEL: boolean;
  41333. REFRACTIONFRESNEL: boolean;
  41334. EMISSIVEFRESNEL: boolean;
  41335. FRESNEL: boolean;
  41336. NORMAL: boolean;
  41337. UV1: boolean;
  41338. UV2: boolean;
  41339. VERTEXCOLOR: boolean;
  41340. VERTEXALPHA: boolean;
  41341. NUM_BONE_INFLUENCERS: number;
  41342. BonesPerMesh: number;
  41343. BONETEXTURE: boolean;
  41344. INSTANCES: boolean;
  41345. GLOSSINESS: boolean;
  41346. ROUGHNESS: boolean;
  41347. EMISSIVEASILLUMINATION: boolean;
  41348. LINKEMISSIVEWITHDIFFUSE: boolean;
  41349. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41350. LIGHTMAP: boolean;
  41351. LIGHTMAPDIRECTUV: number;
  41352. OBJECTSPACE_NORMALMAP: boolean;
  41353. USELIGHTMAPASSHADOWMAP: boolean;
  41354. REFLECTIONMAP_3D: boolean;
  41355. REFLECTIONMAP_SPHERICAL: boolean;
  41356. REFLECTIONMAP_PLANAR: boolean;
  41357. REFLECTIONMAP_CUBIC: boolean;
  41358. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41359. REFLECTIONMAP_PROJECTION: boolean;
  41360. REFLECTIONMAP_SKYBOX: boolean;
  41361. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41362. REFLECTIONMAP_EXPLICIT: boolean;
  41363. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41364. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41365. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41366. INVERTCUBICMAP: boolean;
  41367. LOGARITHMICDEPTH: boolean;
  41368. REFRACTION: boolean;
  41369. REFRACTIONMAP_3D: boolean;
  41370. REFLECTIONOVERALPHA: boolean;
  41371. TWOSIDEDLIGHTING: boolean;
  41372. SHADOWFLOAT: boolean;
  41373. MORPHTARGETS: boolean;
  41374. MORPHTARGETS_NORMAL: boolean;
  41375. MORPHTARGETS_TANGENT: boolean;
  41376. MORPHTARGETS_UV: boolean;
  41377. NUM_MORPH_INFLUENCERS: number;
  41378. NONUNIFORMSCALING: boolean;
  41379. PREMULTIPLYALPHA: boolean;
  41380. IMAGEPROCESSING: boolean;
  41381. VIGNETTE: boolean;
  41382. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41383. VIGNETTEBLENDMODEOPAQUE: boolean;
  41384. TONEMAPPING: boolean;
  41385. TONEMAPPING_ACES: boolean;
  41386. CONTRAST: boolean;
  41387. COLORCURVES: boolean;
  41388. COLORGRADING: boolean;
  41389. COLORGRADING3D: boolean;
  41390. SAMPLER3DGREENDEPTH: boolean;
  41391. SAMPLER3DBGRMAP: boolean;
  41392. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41393. MULTIVIEW: boolean;
  41394. /**
  41395. * If the reflection texture on this material is in linear color space
  41396. * @hidden
  41397. */
  41398. IS_REFLECTION_LINEAR: boolean;
  41399. /**
  41400. * If the refraction texture on this material is in linear color space
  41401. * @hidden
  41402. */
  41403. IS_REFRACTION_LINEAR: boolean;
  41404. EXPOSURE: boolean;
  41405. constructor();
  41406. setReflectionMode(modeToEnable: string): void;
  41407. }
  41408. /**
  41409. * This is the default material used in Babylon. It is the best trade off between quality
  41410. * and performances.
  41411. * @see http://doc.babylonjs.com/babylon101/materials
  41412. */
  41413. export class StandardMaterial extends PushMaterial {
  41414. private _diffuseTexture;
  41415. /**
  41416. * The basic texture of the material as viewed under a light.
  41417. */
  41418. diffuseTexture: Nullable<BaseTexture>;
  41419. private _ambientTexture;
  41420. /**
  41421. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41422. */
  41423. ambientTexture: Nullable<BaseTexture>;
  41424. private _opacityTexture;
  41425. /**
  41426. * Define the transparency of the material from a texture.
  41427. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41428. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41429. */
  41430. opacityTexture: Nullable<BaseTexture>;
  41431. private _reflectionTexture;
  41432. /**
  41433. * Define the texture used to display the reflection.
  41434. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41435. */
  41436. reflectionTexture: Nullable<BaseTexture>;
  41437. private _emissiveTexture;
  41438. /**
  41439. * Define texture of the material as if self lit.
  41440. * This will be mixed in the final result even in the absence of light.
  41441. */
  41442. emissiveTexture: Nullable<BaseTexture>;
  41443. private _specularTexture;
  41444. /**
  41445. * Define how the color and intensity of the highlight given by the light in the material.
  41446. */
  41447. specularTexture: Nullable<BaseTexture>;
  41448. private _bumpTexture;
  41449. /**
  41450. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41451. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  41452. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41453. */
  41454. bumpTexture: Nullable<BaseTexture>;
  41455. private _lightmapTexture;
  41456. /**
  41457. * Complex lighting can be computationally expensive to compute at runtime.
  41458. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41459. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41460. */
  41461. lightmapTexture: Nullable<BaseTexture>;
  41462. private _refractionTexture;
  41463. /**
  41464. * Define the texture used to display the refraction.
  41465. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41466. */
  41467. refractionTexture: Nullable<BaseTexture>;
  41468. /**
  41469. * The color of the material lit by the environmental background lighting.
  41470. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41471. */
  41472. ambientColor: Color3;
  41473. /**
  41474. * The basic color of the material as viewed under a light.
  41475. */
  41476. diffuseColor: Color3;
  41477. /**
  41478. * Define how the color and intensity of the highlight given by the light in the material.
  41479. */
  41480. specularColor: Color3;
  41481. /**
  41482. * Define the color of the material as if self lit.
  41483. * This will be mixed in the final result even in the absence of light.
  41484. */
  41485. emissiveColor: Color3;
  41486. /**
  41487. * Defines how sharp are the highlights in the material.
  41488. * The bigger the value the sharper giving a more glossy feeling to the result.
  41489. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41490. */
  41491. specularPower: number;
  41492. private _useAlphaFromDiffuseTexture;
  41493. /**
  41494. * Does the transparency come from the diffuse texture alpha channel.
  41495. */
  41496. useAlphaFromDiffuseTexture: boolean;
  41497. private _useEmissiveAsIllumination;
  41498. /**
  41499. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41500. */
  41501. useEmissiveAsIllumination: boolean;
  41502. private _linkEmissiveWithDiffuse;
  41503. /**
  41504. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41505. * the emissive level when the final color is close to one.
  41506. */
  41507. linkEmissiveWithDiffuse: boolean;
  41508. private _useSpecularOverAlpha;
  41509. /**
  41510. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41511. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41512. */
  41513. useSpecularOverAlpha: boolean;
  41514. private _useReflectionOverAlpha;
  41515. /**
  41516. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41517. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41518. */
  41519. useReflectionOverAlpha: boolean;
  41520. private _disableLighting;
  41521. /**
  41522. * Does lights from the scene impacts this material.
  41523. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41524. */
  41525. disableLighting: boolean;
  41526. private _useObjectSpaceNormalMap;
  41527. /**
  41528. * Allows using an object space normal map (instead of tangent space).
  41529. */
  41530. useObjectSpaceNormalMap: boolean;
  41531. private _useParallax;
  41532. /**
  41533. * Is parallax enabled or not.
  41534. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41535. */
  41536. useParallax: boolean;
  41537. private _useParallaxOcclusion;
  41538. /**
  41539. * Is parallax occlusion enabled or not.
  41540. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41541. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41542. */
  41543. useParallaxOcclusion: boolean;
  41544. /**
  41545. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  41546. */
  41547. parallaxScaleBias: number;
  41548. private _roughness;
  41549. /**
  41550. * Helps to define how blurry the reflections should appears in the material.
  41551. */
  41552. roughness: number;
  41553. /**
  41554. * In case of refraction, define the value of the index of refraction.
  41555. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41556. */
  41557. indexOfRefraction: number;
  41558. /**
  41559. * Invert the refraction texture alongside the y axis.
  41560. * It can be useful with procedural textures or probe for instance.
  41561. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41562. */
  41563. invertRefractionY: boolean;
  41564. /**
  41565. * Defines the alpha limits in alpha test mode.
  41566. */
  41567. alphaCutOff: number;
  41568. private _useLightmapAsShadowmap;
  41569. /**
  41570. * In case of light mapping, define whether the map contains light or shadow informations.
  41571. */
  41572. useLightmapAsShadowmap: boolean;
  41573. private _diffuseFresnelParameters;
  41574. /**
  41575. * Define the diffuse fresnel parameters of the material.
  41576. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41577. */
  41578. diffuseFresnelParameters: FresnelParameters;
  41579. private _opacityFresnelParameters;
  41580. /**
  41581. * Define the opacity fresnel parameters of the material.
  41582. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41583. */
  41584. opacityFresnelParameters: FresnelParameters;
  41585. private _reflectionFresnelParameters;
  41586. /**
  41587. * Define the reflection fresnel parameters of the material.
  41588. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41589. */
  41590. reflectionFresnelParameters: FresnelParameters;
  41591. private _refractionFresnelParameters;
  41592. /**
  41593. * Define the refraction fresnel parameters of the material.
  41594. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41595. */
  41596. refractionFresnelParameters: FresnelParameters;
  41597. private _emissiveFresnelParameters;
  41598. /**
  41599. * Define the emissive fresnel parameters of the material.
  41600. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41601. */
  41602. emissiveFresnelParameters: FresnelParameters;
  41603. private _useReflectionFresnelFromSpecular;
  41604. /**
  41605. * If true automatically deducts the fresnels values from the material specularity.
  41606. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41607. */
  41608. useReflectionFresnelFromSpecular: boolean;
  41609. private _useGlossinessFromSpecularMapAlpha;
  41610. /**
  41611. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41612. */
  41613. useGlossinessFromSpecularMapAlpha: boolean;
  41614. private _maxSimultaneousLights;
  41615. /**
  41616. * Defines the maximum number of lights that can be used in the material
  41617. */
  41618. maxSimultaneousLights: number;
  41619. private _invertNormalMapX;
  41620. /**
  41621. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41622. */
  41623. invertNormalMapX: boolean;
  41624. private _invertNormalMapY;
  41625. /**
  41626. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41627. */
  41628. invertNormalMapY: boolean;
  41629. private _twoSidedLighting;
  41630. /**
  41631. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41632. */
  41633. twoSidedLighting: boolean;
  41634. /**
  41635. * Default configuration related to image processing available in the standard Material.
  41636. */
  41637. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41638. /**
  41639. * Gets the image processing configuration used either in this material.
  41640. */
  41641. /**
  41642. * Sets the Default image processing configuration used either in the this material.
  41643. *
  41644. * If sets to null, the scene one is in use.
  41645. */
  41646. imageProcessingConfiguration: ImageProcessingConfiguration;
  41647. /**
  41648. * Keep track of the image processing observer to allow dispose and replace.
  41649. */
  41650. private _imageProcessingObserver;
  41651. /**
  41652. * Attaches a new image processing configuration to the Standard Material.
  41653. * @param configuration
  41654. */
  41655. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41656. /**
  41657. * Gets wether the color curves effect is enabled.
  41658. */
  41659. /**
  41660. * Sets wether the color curves effect is enabled.
  41661. */
  41662. cameraColorCurvesEnabled: boolean;
  41663. /**
  41664. * Gets wether the color grading effect is enabled.
  41665. */
  41666. /**
  41667. * Gets wether the color grading effect is enabled.
  41668. */
  41669. cameraColorGradingEnabled: boolean;
  41670. /**
  41671. * Gets wether tonemapping is enabled or not.
  41672. */
  41673. /**
  41674. * Sets wether tonemapping is enabled or not
  41675. */
  41676. cameraToneMappingEnabled: boolean;
  41677. /**
  41678. * The camera exposure used on this material.
  41679. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41680. * This corresponds to a photographic exposure.
  41681. */
  41682. /**
  41683. * The camera exposure used on this material.
  41684. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41685. * This corresponds to a photographic exposure.
  41686. */
  41687. cameraExposure: number;
  41688. /**
  41689. * Gets The camera contrast used on this material.
  41690. */
  41691. /**
  41692. * Sets The camera contrast used on this material.
  41693. */
  41694. cameraContrast: number;
  41695. /**
  41696. * Gets the Color Grading 2D Lookup Texture.
  41697. */
  41698. /**
  41699. * Sets the Color Grading 2D Lookup Texture.
  41700. */
  41701. cameraColorGradingTexture: Nullable<BaseTexture>;
  41702. /**
  41703. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41704. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41705. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  41706. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41707. */
  41708. /**
  41709. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41710. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41711. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  41712. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41713. */
  41714. cameraColorCurves: Nullable<ColorCurves>;
  41715. /**
  41716. * Custom callback helping to override the default shader used in the material.
  41717. */
  41718. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41719. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41720. protected _worldViewProjectionMatrix: Matrix;
  41721. protected _globalAmbientColor: Color3;
  41722. protected _useLogarithmicDepth: boolean;
  41723. protected _rebuildInParallel: boolean;
  41724. /**
  41725. * Instantiates a new standard material.
  41726. * This is the default material used in Babylon. It is the best trade off between quality
  41727. * and performances.
  41728. * @see http://doc.babylonjs.com/babylon101/materials
  41729. * @param name Define the name of the material in the scene
  41730. * @param scene Define the scene the material belong to
  41731. */
  41732. constructor(name: string, scene: Scene);
  41733. /**
  41734. * Gets a boolean indicating that current material needs to register RTT
  41735. */
  41736. readonly hasRenderTargetTextures: boolean;
  41737. /**
  41738. * Gets the current class name of the material e.g. "StandardMaterial"
  41739. * Mainly use in serialization.
  41740. * @returns the class name
  41741. */
  41742. getClassName(): string;
  41743. /**
  41744. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41745. * You can try switching to logarithmic depth.
  41746. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41747. */
  41748. useLogarithmicDepth: boolean;
  41749. /**
  41750. * Specifies if the material will require alpha blending
  41751. * @returns a boolean specifying if alpha blending is needed
  41752. */
  41753. needAlphaBlending(): boolean;
  41754. /**
  41755. * Specifies if this material should be rendered in alpha test mode
  41756. * @returns a boolean specifying if an alpha test is needed.
  41757. */
  41758. needAlphaTesting(): boolean;
  41759. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41760. /**
  41761. * Get the texture used for alpha test purpose.
  41762. * @returns the diffuse texture in case of the standard material.
  41763. */
  41764. getAlphaTestTexture(): Nullable<BaseTexture>;
  41765. /**
  41766. * Get if the submesh is ready to be used and all its information available.
  41767. * Child classes can use it to update shaders
  41768. * @param mesh defines the mesh to check
  41769. * @param subMesh defines which submesh to check
  41770. * @param useInstances specifies that instances should be used
  41771. * @returns a boolean indicating that the submesh is ready or not
  41772. */
  41773. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41774. /**
  41775. * Builds the material UBO layouts.
  41776. * Used internally during the effect preparation.
  41777. */
  41778. buildUniformLayout(): void;
  41779. /**
  41780. * Unbinds the material from the mesh
  41781. */
  41782. unbind(): void;
  41783. /**
  41784. * Binds the submesh to this material by preparing the effect and shader to draw
  41785. * @param world defines the world transformation matrix
  41786. * @param mesh defines the mesh containing the submesh
  41787. * @param subMesh defines the submesh to bind the material to
  41788. */
  41789. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41790. /**
  41791. * Get the list of animatables in the material.
  41792. * @returns the list of animatables object used in the material
  41793. */
  41794. getAnimatables(): IAnimatable[];
  41795. /**
  41796. * Gets the active textures from the material
  41797. * @returns an array of textures
  41798. */
  41799. getActiveTextures(): BaseTexture[];
  41800. /**
  41801. * Specifies if the material uses a texture
  41802. * @param texture defines the texture to check against the material
  41803. * @returns a boolean specifying if the material uses the texture
  41804. */
  41805. hasTexture(texture: BaseTexture): boolean;
  41806. /**
  41807. * Disposes the material
  41808. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41809. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41810. */
  41811. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41812. /**
  41813. * Makes a duplicate of the material, and gives it a new name
  41814. * @param name defines the new name for the duplicated material
  41815. * @returns the cloned material
  41816. */
  41817. clone(name: string): StandardMaterial;
  41818. /**
  41819. * Serializes this material in a JSON representation
  41820. * @returns the serialized material object
  41821. */
  41822. serialize(): any;
  41823. /**
  41824. * Creates a standard material from parsed material data
  41825. * @param source defines the JSON representation of the material
  41826. * @param scene defines the hosting scene
  41827. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41828. * @returns a new standard material
  41829. */
  41830. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41831. /**
  41832. * Are diffuse textures enabled in the application.
  41833. */
  41834. static DiffuseTextureEnabled: boolean;
  41835. /**
  41836. * Are ambient textures enabled in the application.
  41837. */
  41838. static AmbientTextureEnabled: boolean;
  41839. /**
  41840. * Are opacity textures enabled in the application.
  41841. */
  41842. static OpacityTextureEnabled: boolean;
  41843. /**
  41844. * Are reflection textures enabled in the application.
  41845. */
  41846. static ReflectionTextureEnabled: boolean;
  41847. /**
  41848. * Are emissive textures enabled in the application.
  41849. */
  41850. static EmissiveTextureEnabled: boolean;
  41851. /**
  41852. * Are specular textures enabled in the application.
  41853. */
  41854. static SpecularTextureEnabled: boolean;
  41855. /**
  41856. * Are bump textures enabled in the application.
  41857. */
  41858. static BumpTextureEnabled: boolean;
  41859. /**
  41860. * Are lightmap textures enabled in the application.
  41861. */
  41862. static LightmapTextureEnabled: boolean;
  41863. /**
  41864. * Are refraction textures enabled in the application.
  41865. */
  41866. static RefractionTextureEnabled: boolean;
  41867. /**
  41868. * Are color grading textures enabled in the application.
  41869. */
  41870. static ColorGradingTextureEnabled: boolean;
  41871. /**
  41872. * Are fresnels enabled in the application.
  41873. */
  41874. static FresnelEnabled: boolean;
  41875. }
  41876. }
  41877. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41878. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41879. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41880. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41881. /** @hidden */
  41882. export var imageProcessingPixelShader: {
  41883. name: string;
  41884. shader: string;
  41885. };
  41886. }
  41887. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41888. import { Nullable } from "babylonjs/types";
  41889. import { Color4 } from "babylonjs/Maths/math.color";
  41890. import { Camera } from "babylonjs/Cameras/camera";
  41891. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41892. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41893. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41894. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41895. import { Engine } from "babylonjs/Engines/engine";
  41896. import "babylonjs/Shaders/imageProcessing.fragment";
  41897. import "babylonjs/Shaders/postprocess.vertex";
  41898. /**
  41899. * ImageProcessingPostProcess
  41900. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41901. */
  41902. export class ImageProcessingPostProcess extends PostProcess {
  41903. /**
  41904. * Default configuration related to image processing available in the PBR Material.
  41905. */
  41906. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41907. /**
  41908. * Gets the image processing configuration used either in this material.
  41909. */
  41910. /**
  41911. * Sets the Default image processing configuration used either in the this material.
  41912. *
  41913. * If sets to null, the scene one is in use.
  41914. */
  41915. imageProcessingConfiguration: ImageProcessingConfiguration;
  41916. /**
  41917. * Keep track of the image processing observer to allow dispose and replace.
  41918. */
  41919. private _imageProcessingObserver;
  41920. /**
  41921. * Attaches a new image processing configuration to the PBR Material.
  41922. * @param configuration
  41923. */
  41924. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41925. /**
  41926. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41927. */
  41928. /**
  41929. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41930. */
  41931. colorCurves: Nullable<ColorCurves>;
  41932. /**
  41933. * Gets wether the color curves effect is enabled.
  41934. */
  41935. /**
  41936. * Sets wether the color curves effect is enabled.
  41937. */
  41938. colorCurvesEnabled: boolean;
  41939. /**
  41940. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41941. */
  41942. /**
  41943. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41944. */
  41945. colorGradingTexture: Nullable<BaseTexture>;
  41946. /**
  41947. * Gets wether the color grading effect is enabled.
  41948. */
  41949. /**
  41950. * Gets wether the color grading effect is enabled.
  41951. */
  41952. colorGradingEnabled: boolean;
  41953. /**
  41954. * Gets exposure used in the effect.
  41955. */
  41956. /**
  41957. * Sets exposure used in the effect.
  41958. */
  41959. exposure: number;
  41960. /**
  41961. * Gets wether tonemapping is enabled or not.
  41962. */
  41963. /**
  41964. * Sets wether tonemapping is enabled or not
  41965. */
  41966. toneMappingEnabled: boolean;
  41967. /**
  41968. * Gets the type of tone mapping effect.
  41969. */
  41970. /**
  41971. * Sets the type of tone mapping effect.
  41972. */
  41973. toneMappingType: number;
  41974. /**
  41975. * Gets contrast used in the effect.
  41976. */
  41977. /**
  41978. * Sets contrast used in the effect.
  41979. */
  41980. contrast: number;
  41981. /**
  41982. * Gets Vignette stretch size.
  41983. */
  41984. /**
  41985. * Sets Vignette stretch size.
  41986. */
  41987. vignetteStretch: number;
  41988. /**
  41989. * Gets Vignette centre X Offset.
  41990. */
  41991. /**
  41992. * Sets Vignette centre X Offset.
  41993. */
  41994. vignetteCentreX: number;
  41995. /**
  41996. * Gets Vignette centre Y Offset.
  41997. */
  41998. /**
  41999. * Sets Vignette centre Y Offset.
  42000. */
  42001. vignetteCentreY: number;
  42002. /**
  42003. * Gets Vignette weight or intensity of the vignette effect.
  42004. */
  42005. /**
  42006. * Sets Vignette weight or intensity of the vignette effect.
  42007. */
  42008. vignetteWeight: number;
  42009. /**
  42010. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42011. * if vignetteEnabled is set to true.
  42012. */
  42013. /**
  42014. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42015. * if vignetteEnabled is set to true.
  42016. */
  42017. vignetteColor: Color4;
  42018. /**
  42019. * Gets Camera field of view used by the Vignette effect.
  42020. */
  42021. /**
  42022. * Sets Camera field of view used by the Vignette effect.
  42023. */
  42024. vignetteCameraFov: number;
  42025. /**
  42026. * Gets the vignette blend mode allowing different kind of effect.
  42027. */
  42028. /**
  42029. * Sets the vignette blend mode allowing different kind of effect.
  42030. */
  42031. vignetteBlendMode: number;
  42032. /**
  42033. * Gets wether the vignette effect is enabled.
  42034. */
  42035. /**
  42036. * Sets wether the vignette effect is enabled.
  42037. */
  42038. vignetteEnabled: boolean;
  42039. private _fromLinearSpace;
  42040. /**
  42041. * Gets wether the input of the processing is in Gamma or Linear Space.
  42042. */
  42043. /**
  42044. * Sets wether the input of the processing is in Gamma or Linear Space.
  42045. */
  42046. fromLinearSpace: boolean;
  42047. /**
  42048. * Defines cache preventing GC.
  42049. */
  42050. private _defines;
  42051. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42052. /**
  42053. * "ImageProcessingPostProcess"
  42054. * @returns "ImageProcessingPostProcess"
  42055. */
  42056. getClassName(): string;
  42057. protected _updateParameters(): void;
  42058. dispose(camera?: Camera): void;
  42059. }
  42060. }
  42061. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42062. import { Scene } from "babylonjs/scene";
  42063. import { Color3 } from "babylonjs/Maths/math.color";
  42064. import { Mesh } from "babylonjs/Meshes/mesh";
  42065. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42066. import { Nullable } from "babylonjs/types";
  42067. /**
  42068. * Class containing static functions to help procedurally build meshes
  42069. */
  42070. export class GroundBuilder {
  42071. /**
  42072. * Creates a ground mesh
  42073. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42074. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42076. * @param name defines the name of the mesh
  42077. * @param options defines the options used to create the mesh
  42078. * @param scene defines the hosting scene
  42079. * @returns the ground mesh
  42080. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42081. */
  42082. static CreateGround(name: string, options: {
  42083. width?: number;
  42084. height?: number;
  42085. subdivisions?: number;
  42086. subdivisionsX?: number;
  42087. subdivisionsY?: number;
  42088. updatable?: boolean;
  42089. }, scene: any): Mesh;
  42090. /**
  42091. * Creates a tiled ground mesh
  42092. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42093. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42094. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  42095. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  42096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42097. * @param name defines the name of the mesh
  42098. * @param options defines the options used to create the mesh
  42099. * @param scene defines the hosting scene
  42100. * @returns the tiled ground mesh
  42101. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42102. */
  42103. static CreateTiledGround(name: string, options: {
  42104. xmin: number;
  42105. zmin: number;
  42106. xmax: number;
  42107. zmax: number;
  42108. subdivisions?: {
  42109. w: number;
  42110. h: number;
  42111. };
  42112. precision?: {
  42113. w: number;
  42114. h: number;
  42115. };
  42116. updatable?: boolean;
  42117. }, scene?: Nullable<Scene>): Mesh;
  42118. /**
  42119. * Creates a ground mesh from a height map
  42120. * * The parameter `url` sets the URL of the height map image resource.
  42121. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42122. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42123. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42124. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42125. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  42126. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  42127. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42129. * @param name defines the name of the mesh
  42130. * @param url defines the url to the height map
  42131. * @param options defines the options used to create the mesh
  42132. * @param scene defines the hosting scene
  42133. * @returns the ground mesh
  42134. * @see https://doc.babylonjs.com/babylon101/height_map
  42135. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42136. */
  42137. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42138. width?: number;
  42139. height?: number;
  42140. subdivisions?: number;
  42141. minHeight?: number;
  42142. maxHeight?: number;
  42143. colorFilter?: Color3;
  42144. alphaFilter?: number;
  42145. updatable?: boolean;
  42146. onReady?: (mesh: GroundMesh) => void;
  42147. }, scene?: Nullable<Scene>): GroundMesh;
  42148. }
  42149. }
  42150. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42151. import { Vector4 } from "babylonjs/Maths/math.vector";
  42152. import { Mesh } from "babylonjs/Meshes/mesh";
  42153. /**
  42154. * Class containing static functions to help procedurally build meshes
  42155. */
  42156. export class TorusBuilder {
  42157. /**
  42158. * Creates a torus mesh
  42159. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42160. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42161. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42165. * @param name defines the name of the mesh
  42166. * @param options defines the options used to create the mesh
  42167. * @param scene defines the hosting scene
  42168. * @returns the torus mesh
  42169. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42170. */
  42171. static CreateTorus(name: string, options: {
  42172. diameter?: number;
  42173. thickness?: number;
  42174. tessellation?: number;
  42175. updatable?: boolean;
  42176. sideOrientation?: number;
  42177. frontUVs?: Vector4;
  42178. backUVs?: Vector4;
  42179. }, scene: any): Mesh;
  42180. }
  42181. }
  42182. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42183. import { Vector4 } from "babylonjs/Maths/math.vector";
  42184. import { Color4 } from "babylonjs/Maths/math.color";
  42185. import { Mesh } from "babylonjs/Meshes/mesh";
  42186. /**
  42187. * Class containing static functions to help procedurally build meshes
  42188. */
  42189. export class CylinderBuilder {
  42190. /**
  42191. * Creates a cylinder or a cone mesh
  42192. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42193. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42194. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  42195. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42196. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42197. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42198. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42199. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  42200. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42201. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  42202. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  42203. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42204. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  42205. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  42206. * * If `enclose` is false, a ring surface is one element.
  42207. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42208. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  42209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42212. * @param name defines the name of the mesh
  42213. * @param options defines the options used to create the mesh
  42214. * @param scene defines the hosting scene
  42215. * @returns the cylinder mesh
  42216. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42217. */
  42218. static CreateCylinder(name: string, options: {
  42219. height?: number;
  42220. diameterTop?: number;
  42221. diameterBottom?: number;
  42222. diameter?: number;
  42223. tessellation?: number;
  42224. subdivisions?: number;
  42225. arc?: number;
  42226. faceColors?: Color4[];
  42227. faceUV?: Vector4[];
  42228. updatable?: boolean;
  42229. hasRings?: boolean;
  42230. enclose?: boolean;
  42231. cap?: number;
  42232. sideOrientation?: number;
  42233. frontUVs?: Vector4;
  42234. backUVs?: Vector4;
  42235. }, scene: any): Mesh;
  42236. }
  42237. }
  42238. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42239. import { Observable } from "babylonjs/Misc/observable";
  42240. import { Nullable } from "babylonjs/types";
  42241. import { Camera } from "babylonjs/Cameras/camera";
  42242. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42243. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42244. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42245. import { Scene } from "babylonjs/scene";
  42246. import { Vector3 } from "babylonjs/Maths/math.vector";
  42247. import { Color3 } from "babylonjs/Maths/math.color";
  42248. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42250. import { Mesh } from "babylonjs/Meshes/mesh";
  42251. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42252. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42253. import "babylonjs/Meshes/Builders/groundBuilder";
  42254. import "babylonjs/Meshes/Builders/torusBuilder";
  42255. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42256. import "babylonjs/Gamepads/gamepadSceneComponent";
  42257. import "babylonjs/Animations/animatable";
  42258. /**
  42259. * Options to modify the vr teleportation behavior.
  42260. */
  42261. export interface VRTeleportationOptions {
  42262. /**
  42263. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42264. */
  42265. floorMeshName?: string;
  42266. /**
  42267. * A list of meshes to be used as the teleportation floor. (default: empty)
  42268. */
  42269. floorMeshes?: Mesh[];
  42270. }
  42271. /**
  42272. * Options to modify the vr experience helper's behavior.
  42273. */
  42274. export interface VRExperienceHelperOptions extends WebVROptions {
  42275. /**
  42276. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42277. */
  42278. createDeviceOrientationCamera?: boolean;
  42279. /**
  42280. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42281. */
  42282. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42283. /**
  42284. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42285. */
  42286. laserToggle?: boolean;
  42287. /**
  42288. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42289. */
  42290. floorMeshes?: Mesh[];
  42291. /**
  42292. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42293. */
  42294. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42295. }
  42296. /**
  42297. * Event containing information after VR has been entered
  42298. */
  42299. export class OnAfterEnteringVRObservableEvent {
  42300. /**
  42301. * If entering vr was successful
  42302. */
  42303. success: boolean;
  42304. }
  42305. /**
  42306. * Helps to quickly add VR support to an existing scene.
  42307. * See http://doc.babylonjs.com/how_to/webvr_helper
  42308. */
  42309. export class VRExperienceHelper {
  42310. /** Options to modify the vr experience helper's behavior. */
  42311. webVROptions: VRExperienceHelperOptions;
  42312. private _scene;
  42313. private _position;
  42314. private _btnVR;
  42315. private _btnVRDisplayed;
  42316. private _webVRsupported;
  42317. private _webVRready;
  42318. private _webVRrequesting;
  42319. private _webVRpresenting;
  42320. private _hasEnteredVR;
  42321. private _fullscreenVRpresenting;
  42322. private _canvas;
  42323. private _webVRCamera;
  42324. private _vrDeviceOrientationCamera;
  42325. private _deviceOrientationCamera;
  42326. private _existingCamera;
  42327. private _onKeyDown;
  42328. private _onVrDisplayPresentChange;
  42329. private _onVRDisplayChanged;
  42330. private _onVRRequestPresentStart;
  42331. private _onVRRequestPresentComplete;
  42332. /**
  42333. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  42334. */
  42335. enableGazeEvenWhenNoPointerLock: boolean;
  42336. /**
  42337. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42338. */
  42339. exitVROnDoubleTap: boolean;
  42340. /**
  42341. * Observable raised right before entering VR.
  42342. */
  42343. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42344. /**
  42345. * Observable raised when entering VR has completed.
  42346. */
  42347. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42348. /**
  42349. * Observable raised when exiting VR.
  42350. */
  42351. onExitingVRObservable: Observable<VRExperienceHelper>;
  42352. /**
  42353. * Observable raised when controller mesh is loaded.
  42354. */
  42355. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42356. /** Return this.onEnteringVRObservable
  42357. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42358. */
  42359. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42360. /** Return this.onExitingVRObservable
  42361. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42362. */
  42363. readonly onExitingVR: Observable<VRExperienceHelper>;
  42364. /** Return this.onControllerMeshLoadedObservable
  42365. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42366. */
  42367. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42368. private _rayLength;
  42369. private _useCustomVRButton;
  42370. private _teleportationRequested;
  42371. private _teleportActive;
  42372. private _floorMeshName;
  42373. private _floorMeshesCollection;
  42374. private _rotationAllowed;
  42375. private _teleportBackwardsVector;
  42376. private _teleportationTarget;
  42377. private _isDefaultTeleportationTarget;
  42378. private _postProcessMove;
  42379. private _teleportationFillColor;
  42380. private _teleportationBorderColor;
  42381. private _rotationAngle;
  42382. private _haloCenter;
  42383. private _cameraGazer;
  42384. private _padSensibilityUp;
  42385. private _padSensibilityDown;
  42386. private _leftController;
  42387. private _rightController;
  42388. /**
  42389. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42390. */
  42391. onNewMeshSelected: Observable<AbstractMesh>;
  42392. /**
  42393. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42394. * This observable will provide the mesh and the controller used to select the mesh
  42395. */
  42396. onMeshSelectedWithController: Observable<{
  42397. mesh: AbstractMesh;
  42398. controller: WebVRController;
  42399. }>;
  42400. /**
  42401. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42402. */
  42403. onNewMeshPicked: Observable<PickingInfo>;
  42404. private _circleEase;
  42405. /**
  42406. * Observable raised before camera teleportation
  42407. */
  42408. onBeforeCameraTeleport: Observable<Vector3>;
  42409. /**
  42410. * Observable raised after camera teleportation
  42411. */
  42412. onAfterCameraTeleport: Observable<Vector3>;
  42413. /**
  42414. * Observable raised when current selected mesh gets unselected
  42415. */
  42416. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42417. private _raySelectionPredicate;
  42418. /**
  42419. * To be optionaly changed by user to define custom ray selection
  42420. */
  42421. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42422. /**
  42423. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42424. */
  42425. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42426. /**
  42427. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42428. */
  42429. teleportationEnabled: boolean;
  42430. private _defaultHeight;
  42431. private _teleportationInitialized;
  42432. private _interactionsEnabled;
  42433. private _interactionsRequested;
  42434. private _displayGaze;
  42435. private _displayLaserPointer;
  42436. /**
  42437. * The mesh used to display where the user is going to teleport.
  42438. */
  42439. /**
  42440. * Sets the mesh to be used to display where the user is going to teleport.
  42441. */
  42442. teleportationTarget: Mesh;
  42443. /**
  42444. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  42445. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42446. * See http://doc.babylonjs.com/resources/baking_transformations
  42447. */
  42448. gazeTrackerMesh: Mesh;
  42449. /**
  42450. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42451. */
  42452. updateGazeTrackerScale: boolean;
  42453. /**
  42454. * If the gaze trackers color should be updated when selecting meshes
  42455. */
  42456. updateGazeTrackerColor: boolean;
  42457. /**
  42458. * If the controller laser color should be updated when selecting meshes
  42459. */
  42460. updateControllerLaserColor: boolean;
  42461. /**
  42462. * The gaze tracking mesh corresponding to the left controller
  42463. */
  42464. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42465. /**
  42466. * The gaze tracking mesh corresponding to the right controller
  42467. */
  42468. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42469. /**
  42470. * If the ray of the gaze should be displayed.
  42471. */
  42472. /**
  42473. * Sets if the ray of the gaze should be displayed.
  42474. */
  42475. displayGaze: boolean;
  42476. /**
  42477. * If the ray of the LaserPointer should be displayed.
  42478. */
  42479. /**
  42480. * Sets if the ray of the LaserPointer should be displayed.
  42481. */
  42482. displayLaserPointer: boolean;
  42483. /**
  42484. * The deviceOrientationCamera used as the camera when not in VR.
  42485. */
  42486. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42487. /**
  42488. * Based on the current WebVR support, returns the current VR camera used.
  42489. */
  42490. readonly currentVRCamera: Nullable<Camera>;
  42491. /**
  42492. * The webVRCamera which is used when in VR.
  42493. */
  42494. readonly webVRCamera: WebVRFreeCamera;
  42495. /**
  42496. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42497. */
  42498. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42499. /**
  42500. * The html button that is used to trigger entering into VR.
  42501. */
  42502. readonly vrButton: Nullable<HTMLButtonElement>;
  42503. private readonly _teleportationRequestInitiated;
  42504. /**
  42505. * Defines wether or not Pointer lock should be requested when switching to
  42506. * full screen.
  42507. */
  42508. requestPointerLockOnFullScreen: boolean;
  42509. /**
  42510. * Instantiates a VRExperienceHelper.
  42511. * Helps to quickly add VR support to an existing scene.
  42512. * @param scene The scene the VRExperienceHelper belongs to.
  42513. * @param webVROptions Options to modify the vr experience helper's behavior.
  42514. */
  42515. constructor(scene: Scene,
  42516. /** Options to modify the vr experience helper's behavior. */
  42517. webVROptions?: VRExperienceHelperOptions);
  42518. private _onDefaultMeshLoaded;
  42519. private _onResize;
  42520. private _onFullscreenChange;
  42521. /**
  42522. * Gets a value indicating if we are currently in VR mode.
  42523. */
  42524. readonly isInVRMode: boolean;
  42525. private onVrDisplayPresentChange;
  42526. private onVRDisplayChanged;
  42527. private moveButtonToBottomRight;
  42528. private displayVRButton;
  42529. private updateButtonVisibility;
  42530. private _cachedAngularSensibility;
  42531. /**
  42532. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42533. * Otherwise, will use the fullscreen API.
  42534. */
  42535. enterVR(): void;
  42536. /**
  42537. * Attempt to exit VR, or fullscreen.
  42538. */
  42539. exitVR(): void;
  42540. /**
  42541. * The position of the vr experience helper.
  42542. */
  42543. /**
  42544. * Sets the position of the vr experience helper.
  42545. */
  42546. position: Vector3;
  42547. /**
  42548. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42549. */
  42550. enableInteractions(): void;
  42551. private readonly _noControllerIsActive;
  42552. private beforeRender;
  42553. private _isTeleportationFloor;
  42554. /**
  42555. * Adds a floor mesh to be used for teleportation.
  42556. * @param floorMesh the mesh to be used for teleportation.
  42557. */
  42558. addFloorMesh(floorMesh: Mesh): void;
  42559. /**
  42560. * Removes a floor mesh from being used for teleportation.
  42561. * @param floorMesh the mesh to be removed.
  42562. */
  42563. removeFloorMesh(floorMesh: Mesh): void;
  42564. /**
  42565. * Enables interactions and teleportation using the VR controllers and gaze.
  42566. * @param vrTeleportationOptions options to modify teleportation behavior.
  42567. */
  42568. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42569. private _onNewGamepadConnected;
  42570. private _tryEnableInteractionOnController;
  42571. private _onNewGamepadDisconnected;
  42572. private _enableInteractionOnController;
  42573. private _checkTeleportWithRay;
  42574. private _checkRotate;
  42575. private _checkTeleportBackwards;
  42576. private _enableTeleportationOnController;
  42577. private _createTeleportationCircles;
  42578. private _displayTeleportationTarget;
  42579. private _hideTeleportationTarget;
  42580. private _rotateCamera;
  42581. private _moveTeleportationSelectorTo;
  42582. private _workingVector;
  42583. private _workingQuaternion;
  42584. private _workingMatrix;
  42585. /**
  42586. * Teleports the users feet to the desired location
  42587. * @param location The location where the user's feet should be placed
  42588. */
  42589. teleportCamera(location: Vector3): void;
  42590. private _convertNormalToDirectionOfRay;
  42591. private _castRayAndSelectObject;
  42592. private _notifySelectedMeshUnselected;
  42593. /**
  42594. * Sets the color of the laser ray from the vr controllers.
  42595. * @param color new color for the ray.
  42596. */
  42597. changeLaserColor(color: Color3): void;
  42598. /**
  42599. * Sets the color of the ray from the vr headsets gaze.
  42600. * @param color new color for the ray.
  42601. */
  42602. changeGazeColor(color: Color3): void;
  42603. /**
  42604. * Exits VR and disposes of the vr experience helper
  42605. */
  42606. dispose(): void;
  42607. /**
  42608. * Gets the name of the VRExperienceHelper class
  42609. * @returns "VRExperienceHelper"
  42610. */
  42611. getClassName(): string;
  42612. }
  42613. }
  42614. declare module "babylonjs/Cameras/VR/index" {
  42615. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42616. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42617. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42618. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42619. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42620. export * from "babylonjs/Cameras/VR/webVRCamera";
  42621. }
  42622. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42623. import { Observable } from "babylonjs/Misc/observable";
  42624. import { Nullable } from "babylonjs/types";
  42625. import { IDisposable, Scene } from "babylonjs/scene";
  42626. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42627. /**
  42628. * Manages an XRSession to work with Babylon's engine
  42629. * @see https://doc.babylonjs.com/how_to/webxr
  42630. */
  42631. export class WebXRSessionManager implements IDisposable {
  42632. private scene;
  42633. /**
  42634. * Fires every time a new xrFrame arrives which can be used to update the camera
  42635. */
  42636. onXRFrameObservable: Observable<any>;
  42637. /**
  42638. * Fires when the xr session is ended either by the device or manually done
  42639. */
  42640. onXRSessionEnded: Observable<any>;
  42641. /**
  42642. * Underlying xr session
  42643. */
  42644. session: XRSession;
  42645. /**
  42646. * Type of reference space used when creating the session
  42647. */
  42648. referenceSpace: XRReferenceSpace;
  42649. /** @hidden */
  42650. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42651. /**
  42652. * Current XR frame
  42653. */
  42654. currentFrame: Nullable<XRFrame>;
  42655. private _xrNavigator;
  42656. private baseLayer;
  42657. /**
  42658. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42659. * @param scene The scene which the session should be created for
  42660. */
  42661. constructor(scene: Scene);
  42662. /**
  42663. * Initializes the manager
  42664. * After initialization enterXR can be called to start an XR session
  42665. * @returns Promise which resolves after it is initialized
  42666. */
  42667. initializeAsync(): Promise<void>;
  42668. /**
  42669. * Initializes an xr session
  42670. * @param xrSessionMode mode to initialize
  42671. * @returns a promise which will resolve once the session has been initialized
  42672. */
  42673. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42674. /**
  42675. * Sets the reference space on the xr session
  42676. * @param referenceSpace space to set
  42677. * @returns a promise that will resolve once the reference space has been set
  42678. */
  42679. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42680. /**
  42681. * Updates the render state of the session
  42682. * @param state state to set
  42683. * @returns a promise that resolves once the render state has been updated
  42684. */
  42685. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42686. /**
  42687. * Starts rendering to the xr layer
  42688. * @returns a promise that will resolve once rendering has started
  42689. */
  42690. startRenderingToXRAsync(): Promise<void>;
  42691. /**
  42692. * Stops the xrSession and restores the renderloop
  42693. * @returns Promise which resolves after it exits XR
  42694. */
  42695. exitXRAsync(): Promise<unknown>;
  42696. /**
  42697. * Checks if a session would be supported for the creation options specified
  42698. * @param sessionMode session mode to check if supported eg. immersive-vr
  42699. * @returns true if supported
  42700. */
  42701. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42702. /**
  42703. * @hidden
  42704. * Converts the render layer of xrSession to a render target
  42705. * @param session session to create render target for
  42706. * @param scene scene the new render target should be created for
  42707. */
  42708. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42709. /**
  42710. * Disposes of the session manager
  42711. */
  42712. dispose(): void;
  42713. }
  42714. }
  42715. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42716. import { Scene } from "babylonjs/scene";
  42717. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42718. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42719. /**
  42720. * WebXR Camera which holds the views for the xrSession
  42721. * @see https://doc.babylonjs.com/how_to/webxr
  42722. */
  42723. export class WebXRCamera extends FreeCamera {
  42724. private static _TmpMatrix;
  42725. /**
  42726. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42727. * @param name the name of the camera
  42728. * @param scene the scene to add the camera to
  42729. */
  42730. constructor(name: string, scene: Scene);
  42731. private _updateNumberOfRigCameras;
  42732. /** @hidden */
  42733. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42734. /**
  42735. * Updates the cameras position from the current pose information of the XR session
  42736. * @param xrSessionManager the session containing pose information
  42737. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42738. */
  42739. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42740. }
  42741. }
  42742. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42743. import { Nullable } from "babylonjs/types";
  42744. import { IDisposable } from "babylonjs/scene";
  42745. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42746. /**
  42747. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42748. */
  42749. export class WebXRManagedOutputCanvas implements IDisposable {
  42750. private helper;
  42751. private _canvas;
  42752. /**
  42753. * xrpresent context of the canvas which can be used to display/mirror xr content
  42754. */
  42755. canvasContext: WebGLRenderingContext;
  42756. /**
  42757. * xr layer for the canvas
  42758. */
  42759. xrLayer: Nullable<XRWebGLLayer>;
  42760. /**
  42761. * Initializes the xr layer for the session
  42762. * @param xrSession xr session
  42763. * @returns a promise that will resolve once the XR Layer has been created
  42764. */
  42765. initializeXRLayerAsync(xrSession: any): any;
  42766. /**
  42767. * Initializes the canvas to be added/removed upon entering/exiting xr
  42768. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42769. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42770. */
  42771. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42772. /**
  42773. * Disposes of the object
  42774. */
  42775. dispose(): void;
  42776. private _setManagedOutputCanvas;
  42777. private _addCanvas;
  42778. private _removeCanvas;
  42779. }
  42780. }
  42781. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42782. import { Observable } from "babylonjs/Misc/observable";
  42783. import { IDisposable, Scene } from "babylonjs/scene";
  42784. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42786. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42787. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42788. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42789. /**
  42790. * States of the webXR experience
  42791. */
  42792. export enum WebXRState {
  42793. /**
  42794. * Transitioning to being in XR mode
  42795. */
  42796. ENTERING_XR = 0,
  42797. /**
  42798. * Transitioning to non XR mode
  42799. */
  42800. EXITING_XR = 1,
  42801. /**
  42802. * In XR mode and presenting
  42803. */
  42804. IN_XR = 2,
  42805. /**
  42806. * Not entered XR mode
  42807. */
  42808. NOT_IN_XR = 3
  42809. }
  42810. /**
  42811. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42812. * @see https://doc.babylonjs.com/how_to/webxr
  42813. */
  42814. export class WebXRExperienceHelper implements IDisposable {
  42815. private scene;
  42816. /**
  42817. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  42818. */
  42819. container: AbstractMesh;
  42820. /**
  42821. * Camera used to render xr content
  42822. */
  42823. camera: WebXRCamera;
  42824. /**
  42825. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42826. */
  42827. state: WebXRState;
  42828. private _setState;
  42829. private static _TmpVector;
  42830. /**
  42831. * Fires when the state of the experience helper has changed
  42832. */
  42833. onStateChangedObservable: Observable<WebXRState>;
  42834. /** Session manager used to keep track of xr session */
  42835. sessionManager: WebXRSessionManager;
  42836. private _nonVRCamera;
  42837. private _originalSceneAutoClear;
  42838. private _supported;
  42839. /**
  42840. * Creates the experience helper
  42841. * @param scene the scene to attach the experience helper to
  42842. * @returns a promise for the experience helper
  42843. */
  42844. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42845. /**
  42846. * Creates a WebXRExperienceHelper
  42847. * @param scene The scene the helper should be created in
  42848. */
  42849. private constructor();
  42850. /**
  42851. * Exits XR mode and returns the scene to its original state
  42852. * @returns promise that resolves after xr mode has exited
  42853. */
  42854. exitXRAsync(): Promise<unknown>;
  42855. /**
  42856. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42857. * @param sessionCreationOptions options for the XR session
  42858. * @param referenceSpaceType frame of reference of the XR session
  42859. * @param outputCanvas the output canvas that will be used to enter XR mode
  42860. * @returns promise that resolves after xr mode has entered
  42861. */
  42862. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42863. /**
  42864. * Updates the global position of the camera by moving the camera's container
  42865. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42866. * @param position The desired global position of the camera
  42867. */
  42868. setPositionOfCameraUsingContainer(position: Vector3): void;
  42869. /**
  42870. * Rotates the xr camera by rotating the camera's container around the camera's position
  42871. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42872. * @param rotation the desired quaternion rotation to apply to the camera
  42873. */
  42874. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42875. /**
  42876. * Disposes of the experience helper
  42877. */
  42878. dispose(): void;
  42879. }
  42880. }
  42881. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42882. import { Nullable } from "babylonjs/types";
  42883. import { Observable } from "babylonjs/Misc/observable";
  42884. import { IDisposable, Scene } from "babylonjs/scene";
  42885. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42886. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42887. /**
  42888. * Button which can be used to enter a different mode of XR
  42889. */
  42890. export class WebXREnterExitUIButton {
  42891. /** button element */
  42892. element: HTMLElement;
  42893. /** XR initialization options for the button */
  42894. sessionMode: XRSessionMode;
  42895. /** Reference space type */
  42896. referenceSpaceType: XRReferenceSpaceType;
  42897. /**
  42898. * Creates a WebXREnterExitUIButton
  42899. * @param element button element
  42900. * @param sessionMode XR initialization session mode
  42901. * @param referenceSpaceType the type of reference space to be used
  42902. */
  42903. constructor(
  42904. /** button element */
  42905. element: HTMLElement,
  42906. /** XR initialization options for the button */
  42907. sessionMode: XRSessionMode,
  42908. /** Reference space type */
  42909. referenceSpaceType: XRReferenceSpaceType);
  42910. /**
  42911. * Overwritable function which can be used to update the button's visuals when the state changes
  42912. * @param activeButton the current active button in the UI
  42913. */
  42914. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42915. }
  42916. /**
  42917. * Options to create the webXR UI
  42918. */
  42919. export class WebXREnterExitUIOptions {
  42920. /**
  42921. * Context to enter xr with
  42922. */
  42923. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42924. /**
  42925. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42926. */
  42927. customButtons?: Array<WebXREnterExitUIButton>;
  42928. }
  42929. /**
  42930. * UI to allow the user to enter/exit XR mode
  42931. */
  42932. export class WebXREnterExitUI implements IDisposable {
  42933. private scene;
  42934. private _overlay;
  42935. private _buttons;
  42936. private _activeButton;
  42937. /**
  42938. * Fired every time the active button is changed.
  42939. *
  42940. * When xr is entered via a button that launches xr that button will be the callback parameter
  42941. *
  42942. * When exiting xr the callback parameter will be null)
  42943. */
  42944. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42945. /**
  42946. * Creates UI to allow the user to enter/exit XR mode
  42947. * @param scene the scene to add the ui to
  42948. * @param helper the xr experience helper to enter/exit xr with
  42949. * @param options options to configure the UI
  42950. * @returns the created ui
  42951. */
  42952. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42953. private constructor();
  42954. private _updateButtons;
  42955. /**
  42956. * Disposes of the object
  42957. */
  42958. dispose(): void;
  42959. }
  42960. }
  42961. declare module "babylonjs/Cameras/XR/webXRController" {
  42962. import { Nullable } from "babylonjs/types";
  42963. import { Observable } from "babylonjs/Misc/observable";
  42964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42965. import { Ray } from "babylonjs/Culling/ray";
  42966. import { Scene } from "babylonjs/scene";
  42967. /**
  42968. * Represents an XR input
  42969. */
  42970. export class WebXRController {
  42971. private scene;
  42972. /** The underlying input source for the controller */
  42973. inputSource: XRInputSource;
  42974. private parentContainer;
  42975. /**
  42976. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  42977. */
  42978. grip?: AbstractMesh;
  42979. /**
  42980. * Pointer which can be used to select objects or attach a visible laser to
  42981. */
  42982. pointer: AbstractMesh;
  42983. /**
  42984. * Event that fires when the controller is removed/disposed
  42985. */
  42986. onDisposeObservable: Observable<{}>;
  42987. private _tmpMatrix;
  42988. private _tmpQuaternion;
  42989. private _tmpVector;
  42990. /**
  42991. * Creates the controller
  42992. * @see https://doc.babylonjs.com/how_to/webxr
  42993. * @param scene the scene which the controller should be associated to
  42994. * @param inputSource the underlying input source for the controller
  42995. * @param parentContainer parent that the controller meshes should be children of
  42996. */
  42997. constructor(scene: Scene,
  42998. /** The underlying input source for the controller */
  42999. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43000. /**
  43001. * Updates the controller pose based on the given XRFrame
  43002. * @param xrFrame xr frame to update the pose with
  43003. * @param referenceSpace reference space to use
  43004. */
  43005. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43006. /**
  43007. * Gets a world space ray coming from the controller
  43008. * @param result the resulting ray
  43009. */
  43010. getWorldPointerRayToRef(result: Ray): void;
  43011. /**
  43012. * Disposes of the object
  43013. */
  43014. dispose(): void;
  43015. }
  43016. }
  43017. declare module "babylonjs/Cameras/XR/webXRInput" {
  43018. import { Observable } from "babylonjs/Misc/observable";
  43019. import { IDisposable } from "babylonjs/scene";
  43020. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43021. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43022. /**
  43023. * XR input used to track XR inputs such as controllers/rays
  43024. */
  43025. export class WebXRInput implements IDisposable {
  43026. /**
  43027. * Base experience the input listens to
  43028. */
  43029. baseExperience: WebXRExperienceHelper;
  43030. /**
  43031. * XR controllers being tracked
  43032. */
  43033. controllers: Array<WebXRController>;
  43034. private _frameObserver;
  43035. private _stateObserver;
  43036. /**
  43037. * Event when a controller has been connected/added
  43038. */
  43039. onControllerAddedObservable: Observable<WebXRController>;
  43040. /**
  43041. * Event when a controller has been removed/disconnected
  43042. */
  43043. onControllerRemovedObservable: Observable<WebXRController>;
  43044. /**
  43045. * Initializes the WebXRInput
  43046. * @param baseExperience experience helper which the input should be created for
  43047. */
  43048. constructor(
  43049. /**
  43050. * Base experience the input listens to
  43051. */
  43052. baseExperience: WebXRExperienceHelper);
  43053. private _onInputSourcesChange;
  43054. private _addAndRemoveControllers;
  43055. /**
  43056. * Disposes of the object
  43057. */
  43058. dispose(): void;
  43059. }
  43060. }
  43061. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43063. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43064. /**
  43065. * Enables teleportation
  43066. */
  43067. export class WebXRControllerTeleportation {
  43068. private _teleportationFillColor;
  43069. private _teleportationBorderColor;
  43070. private _tmpRay;
  43071. private _tmpVector;
  43072. /**
  43073. * Creates a WebXRControllerTeleportation
  43074. * @param input input manager to add teleportation to
  43075. * @param floorMeshes floormeshes which can be teleported to
  43076. */
  43077. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43078. }
  43079. }
  43080. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43081. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43082. /**
  43083. * Handles pointer input automatically for the pointer of XR controllers
  43084. */
  43085. export class WebXRControllerPointerSelection {
  43086. private static _idCounter;
  43087. private _tmpRay;
  43088. /**
  43089. * Creates a WebXRControllerPointerSelection
  43090. * @param input input manager to setup pointer selection
  43091. */
  43092. constructor(input: WebXRInput);
  43093. private _convertNormalToDirectionOfRay;
  43094. private _updatePointerDistance;
  43095. }
  43096. }
  43097. declare module "babylonjs/Loading/sceneLoader" {
  43098. import { Observable } from "babylonjs/Misc/observable";
  43099. import { Nullable } from "babylonjs/types";
  43100. import { Scene } from "babylonjs/scene";
  43101. import { Engine } from "babylonjs/Engines/engine";
  43102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43103. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43104. import { AssetContainer } from "babylonjs/assetContainer";
  43105. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43106. import { Skeleton } from "babylonjs/Bones/skeleton";
  43107. /**
  43108. * Class used to represent data loading progression
  43109. */
  43110. export class SceneLoaderProgressEvent {
  43111. /** defines if data length to load can be evaluated */
  43112. readonly lengthComputable: boolean;
  43113. /** defines the loaded data length */
  43114. readonly loaded: number;
  43115. /** defines the data length to load */
  43116. readonly total: number;
  43117. /**
  43118. * Create a new progress event
  43119. * @param lengthComputable defines if data length to load can be evaluated
  43120. * @param loaded defines the loaded data length
  43121. * @param total defines the data length to load
  43122. */
  43123. constructor(
  43124. /** defines if data length to load can be evaluated */
  43125. lengthComputable: boolean,
  43126. /** defines the loaded data length */
  43127. loaded: number,
  43128. /** defines the data length to load */
  43129. total: number);
  43130. /**
  43131. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43132. * @param event defines the source event
  43133. * @returns a new SceneLoaderProgressEvent
  43134. */
  43135. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43136. }
  43137. /**
  43138. * Interface used by SceneLoader plugins to define supported file extensions
  43139. */
  43140. export interface ISceneLoaderPluginExtensions {
  43141. /**
  43142. * Defines the list of supported extensions
  43143. */
  43144. [extension: string]: {
  43145. isBinary: boolean;
  43146. };
  43147. }
  43148. /**
  43149. * Interface used by SceneLoader plugin factory
  43150. */
  43151. export interface ISceneLoaderPluginFactory {
  43152. /**
  43153. * Defines the name of the factory
  43154. */
  43155. name: string;
  43156. /**
  43157. * Function called to create a new plugin
  43158. * @return the new plugin
  43159. */
  43160. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43161. /**
  43162. * Boolean indicating if the plugin can direct load specific data
  43163. */
  43164. canDirectLoad?: (data: string) => boolean;
  43165. }
  43166. /**
  43167. * Interface used to define a SceneLoader plugin
  43168. */
  43169. export interface ISceneLoaderPlugin {
  43170. /**
  43171. * The friendly name of this plugin.
  43172. */
  43173. name: string;
  43174. /**
  43175. * The file extensions supported by this plugin.
  43176. */
  43177. extensions: string | ISceneLoaderPluginExtensions;
  43178. /**
  43179. * Import meshes into a scene.
  43180. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43181. * @param scene The scene to import into
  43182. * @param data The data to import
  43183. * @param rootUrl The root url for scene and resources
  43184. * @param meshes The meshes array to import into
  43185. * @param particleSystems The particle systems array to import into
  43186. * @param skeletons The skeletons array to import into
  43187. * @param onError The callback when import fails
  43188. * @returns True if successful or false otherwise
  43189. */
  43190. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43191. /**
  43192. * Load into a scene.
  43193. * @param scene The scene to load into
  43194. * @param data The data to import
  43195. * @param rootUrl The root url for scene and resources
  43196. * @param onError The callback when import fails
  43197. * @returns true if successful or false otherwise
  43198. */
  43199. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43200. /**
  43201. * The callback that returns true if the data can be directly loaded.
  43202. */
  43203. canDirectLoad?: (data: string) => boolean;
  43204. /**
  43205. * The callback that allows custom handling of the root url based on the response url.
  43206. */
  43207. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43208. /**
  43209. * Load into an asset container.
  43210. * @param scene The scene to load into
  43211. * @param data The data to import
  43212. * @param rootUrl The root url for scene and resources
  43213. * @param onError The callback when import fails
  43214. * @returns The loaded asset container
  43215. */
  43216. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43217. }
  43218. /**
  43219. * Interface used to define an async SceneLoader plugin
  43220. */
  43221. export interface ISceneLoaderPluginAsync {
  43222. /**
  43223. * The friendly name of this plugin.
  43224. */
  43225. name: string;
  43226. /**
  43227. * The file extensions supported by this plugin.
  43228. */
  43229. extensions: string | ISceneLoaderPluginExtensions;
  43230. /**
  43231. * Import meshes into a scene.
  43232. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43233. * @param scene The scene to import into
  43234. * @param data The data to import
  43235. * @param rootUrl The root url for scene and resources
  43236. * @param onProgress The callback when the load progresses
  43237. * @param fileName Defines the name of the file to load
  43238. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43239. */
  43240. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43241. meshes: AbstractMesh[];
  43242. particleSystems: IParticleSystem[];
  43243. skeletons: Skeleton[];
  43244. animationGroups: AnimationGroup[];
  43245. }>;
  43246. /**
  43247. * Load into a scene.
  43248. * @param scene The scene to load into
  43249. * @param data The data to import
  43250. * @param rootUrl The root url for scene and resources
  43251. * @param onProgress The callback when the load progresses
  43252. * @param fileName Defines the name of the file to load
  43253. * @returns Nothing
  43254. */
  43255. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43256. /**
  43257. * The callback that returns true if the data can be directly loaded.
  43258. */
  43259. canDirectLoad?: (data: string) => boolean;
  43260. /**
  43261. * The callback that allows custom handling of the root url based on the response url.
  43262. */
  43263. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43264. /**
  43265. * Load into an asset container.
  43266. * @param scene The scene to load into
  43267. * @param data The data to import
  43268. * @param rootUrl The root url for scene and resources
  43269. * @param onProgress The callback when the load progresses
  43270. * @param fileName Defines the name of the file to load
  43271. * @returns The loaded asset container
  43272. */
  43273. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43274. }
  43275. /**
  43276. * Class used to load scene from various file formats using registered plugins
  43277. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43278. */
  43279. export class SceneLoader {
  43280. /**
  43281. * No logging while loading
  43282. */
  43283. static readonly NO_LOGGING: number;
  43284. /**
  43285. * Minimal logging while loading
  43286. */
  43287. static readonly MINIMAL_LOGGING: number;
  43288. /**
  43289. * Summary logging while loading
  43290. */
  43291. static readonly SUMMARY_LOGGING: number;
  43292. /**
  43293. * Detailled logging while loading
  43294. */
  43295. static readonly DETAILED_LOGGING: number;
  43296. /**
  43297. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43298. */
  43299. static ForceFullSceneLoadingForIncremental: boolean;
  43300. /**
  43301. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43302. */
  43303. static ShowLoadingScreen: boolean;
  43304. /**
  43305. * Defines the current logging level (while loading the scene)
  43306. * @ignorenaming
  43307. */
  43308. static loggingLevel: number;
  43309. /**
  43310. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43311. */
  43312. static CleanBoneMatrixWeights: boolean;
  43313. /**
  43314. * Event raised when a plugin is used to load a scene
  43315. */
  43316. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43317. private static _registeredPlugins;
  43318. private static _getDefaultPlugin;
  43319. private static _getPluginForExtension;
  43320. private static _getPluginForDirectLoad;
  43321. private static _getPluginForFilename;
  43322. private static _getDirectLoad;
  43323. private static _loadData;
  43324. private static _getFileInfo;
  43325. /**
  43326. * Gets a plugin that can load the given extension
  43327. * @param extension defines the extension to load
  43328. * @returns a plugin or null if none works
  43329. */
  43330. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43331. /**
  43332. * Gets a boolean indicating that the given extension can be loaded
  43333. * @param extension defines the extension to load
  43334. * @returns true if the extension is supported
  43335. */
  43336. static IsPluginForExtensionAvailable(extension: string): boolean;
  43337. /**
  43338. * Adds a new plugin to the list of registered plugins
  43339. * @param plugin defines the plugin to add
  43340. */
  43341. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43342. /**
  43343. * Import meshes into a scene
  43344. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43345. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43346. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43347. * @param scene the instance of BABYLON.Scene to append to
  43348. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43349. * @param onProgress a callback with a progress event for each file being loaded
  43350. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43351. * @param pluginExtension the extension used to determine the plugin
  43352. * @returns The loaded plugin
  43353. */
  43354. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43355. /**
  43356. * Import meshes into a scene
  43357. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43358. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43359. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43360. * @param scene the instance of BABYLON.Scene to append to
  43361. * @param onProgress a callback with a progress event for each file being loaded
  43362. * @param pluginExtension the extension used to determine the plugin
  43363. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43364. */
  43365. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43366. meshes: AbstractMesh[];
  43367. particleSystems: IParticleSystem[];
  43368. skeletons: Skeleton[];
  43369. animationGroups: AnimationGroup[];
  43370. }>;
  43371. /**
  43372. * Load a scene
  43373. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43374. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43375. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43376. * @param onSuccess a callback with the scene when import succeeds
  43377. * @param onProgress a callback with a progress event for each file being loaded
  43378. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43379. * @param pluginExtension the extension used to determine the plugin
  43380. * @returns The loaded plugin
  43381. */
  43382. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43383. /**
  43384. * Load a scene
  43385. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43386. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43387. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43388. * @param onProgress a callback with a progress event for each file being loaded
  43389. * @param pluginExtension the extension used to determine the plugin
  43390. * @returns The loaded scene
  43391. */
  43392. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43393. /**
  43394. * Append a scene
  43395. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43396. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43397. * @param scene is the instance of BABYLON.Scene to append to
  43398. * @param onSuccess a callback with the scene when import succeeds
  43399. * @param onProgress a callback with a progress event for each file being loaded
  43400. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43401. * @param pluginExtension the extension used to determine the plugin
  43402. * @returns The loaded plugin
  43403. */
  43404. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43405. /**
  43406. * Append a scene
  43407. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43408. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43409. * @param scene is the instance of BABYLON.Scene to append to
  43410. * @param onProgress a callback with a progress event for each file being loaded
  43411. * @param pluginExtension the extension used to determine the plugin
  43412. * @returns The given scene
  43413. */
  43414. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43415. /**
  43416. * Load a scene into an asset container
  43417. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43418. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43419. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43420. * @param onSuccess a callback with the scene when import succeeds
  43421. * @param onProgress a callback with a progress event for each file being loaded
  43422. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43423. * @param pluginExtension the extension used to determine the plugin
  43424. * @returns The loaded plugin
  43425. */
  43426. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43427. /**
  43428. * Load a scene into an asset container
  43429. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43430. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  43431. * @param scene is the instance of Scene to append to
  43432. * @param onProgress a callback with a progress event for each file being loaded
  43433. * @param pluginExtension the extension used to determine the plugin
  43434. * @returns The loaded asset container
  43435. */
  43436. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43437. }
  43438. }
  43439. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43440. import { Scene } from "babylonjs/scene";
  43441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43442. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43443. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43444. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43445. /**
  43446. * Generic Controller
  43447. */
  43448. export class GenericController extends WebVRController {
  43449. /**
  43450. * Base Url for the controller model.
  43451. */
  43452. static readonly MODEL_BASE_URL: string;
  43453. /**
  43454. * File name for the controller model.
  43455. */
  43456. static readonly MODEL_FILENAME: string;
  43457. /**
  43458. * Creates a new GenericController from a gamepad
  43459. * @param vrGamepad the gamepad that the controller should be created from
  43460. */
  43461. constructor(vrGamepad: any);
  43462. /**
  43463. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43464. * @param scene scene in which to add meshes
  43465. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43466. */
  43467. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43468. /**
  43469. * Called once for each button that changed state since the last frame
  43470. * @param buttonIdx Which button index changed
  43471. * @param state New state of the button
  43472. * @param changes Which properties on the state changed since last frame
  43473. */
  43474. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43475. }
  43476. }
  43477. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43478. import { Observable } from "babylonjs/Misc/observable";
  43479. import { Scene } from "babylonjs/scene";
  43480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43481. import { Ray } from "babylonjs/Culling/ray";
  43482. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43483. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43484. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43485. /**
  43486. * Defines the WindowsMotionController object that the state of the windows motion controller
  43487. */
  43488. export class WindowsMotionController extends WebVRController {
  43489. /**
  43490. * The base url used to load the left and right controller models
  43491. */
  43492. static MODEL_BASE_URL: string;
  43493. /**
  43494. * The name of the left controller model file
  43495. */
  43496. static MODEL_LEFT_FILENAME: string;
  43497. /**
  43498. * The name of the right controller model file
  43499. */
  43500. static MODEL_RIGHT_FILENAME: string;
  43501. /**
  43502. * The controller name prefix for this controller type
  43503. */
  43504. static readonly GAMEPAD_ID_PREFIX: string;
  43505. /**
  43506. * The controller id pattern for this controller type
  43507. */
  43508. private static readonly GAMEPAD_ID_PATTERN;
  43509. private _loadedMeshInfo;
  43510. private readonly _mapping;
  43511. /**
  43512. * Fired when the trackpad on this controller is clicked
  43513. */
  43514. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43515. /**
  43516. * Fired when the trackpad on this controller is modified
  43517. */
  43518. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43519. /**
  43520. * The current x and y values of this controller's trackpad
  43521. */
  43522. trackpad: StickValues;
  43523. /**
  43524. * Creates a new WindowsMotionController from a gamepad
  43525. * @param vrGamepad the gamepad that the controller should be created from
  43526. */
  43527. constructor(vrGamepad: any);
  43528. /**
  43529. * Fired when the trigger on this controller is modified
  43530. */
  43531. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43532. /**
  43533. * Fired when the menu button on this controller is modified
  43534. */
  43535. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43536. /**
  43537. * Fired when the grip button on this controller is modified
  43538. */
  43539. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43540. /**
  43541. * Fired when the thumbstick button on this controller is modified
  43542. */
  43543. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43544. /**
  43545. * Fired when the touchpad button on this controller is modified
  43546. */
  43547. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43548. /**
  43549. * Fired when the touchpad values on this controller are modified
  43550. */
  43551. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43552. private _updateTrackpad;
  43553. /**
  43554. * Called once per frame by the engine.
  43555. */
  43556. update(): void;
  43557. /**
  43558. * Called once for each button that changed state since the last frame
  43559. * @param buttonIdx Which button index changed
  43560. * @param state New state of the button
  43561. * @param changes Which properties on the state changed since last frame
  43562. */
  43563. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43564. /**
  43565. * Moves the buttons on the controller mesh based on their current state
  43566. * @param buttonName the name of the button to move
  43567. * @param buttonValue the value of the button which determines the buttons new position
  43568. */
  43569. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43570. /**
  43571. * Moves the axis on the controller mesh based on its current state
  43572. * @param axis the index of the axis
  43573. * @param axisValue the value of the axis which determines the meshes new position
  43574. * @hidden
  43575. */
  43576. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43577. /**
  43578. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43579. * @param scene scene in which to add meshes
  43580. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43581. */
  43582. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43583. /**
  43584. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43585. * can be transformed by button presses and axes values, based on this._mapping.
  43586. *
  43587. * @param scene scene in which the meshes exist
  43588. * @param meshes list of meshes that make up the controller model to process
  43589. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43590. */
  43591. private processModel;
  43592. private createMeshInfo;
  43593. /**
  43594. * Gets the ray of the controller in the direction the controller is pointing
  43595. * @param length the length the resulting ray should be
  43596. * @returns a ray in the direction the controller is pointing
  43597. */
  43598. getForwardRay(length?: number): Ray;
  43599. /**
  43600. * Disposes of the controller
  43601. */
  43602. dispose(): void;
  43603. }
  43604. }
  43605. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43606. import { Observable } from "babylonjs/Misc/observable";
  43607. import { Scene } from "babylonjs/scene";
  43608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43609. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43610. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43611. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43612. /**
  43613. * Oculus Touch Controller
  43614. */
  43615. export class OculusTouchController extends WebVRController {
  43616. /**
  43617. * Base Url for the controller model.
  43618. */
  43619. static MODEL_BASE_URL: string;
  43620. /**
  43621. * File name for the left controller model.
  43622. */
  43623. static MODEL_LEFT_FILENAME: string;
  43624. /**
  43625. * File name for the right controller model.
  43626. */
  43627. static MODEL_RIGHT_FILENAME: string;
  43628. /**
  43629. * Base Url for the Quest controller model.
  43630. */
  43631. static QUEST_MODEL_BASE_URL: string;
  43632. /**
  43633. * @hidden
  43634. * If the controllers are running on a device that needs the updated Quest controller models
  43635. */
  43636. static _IsQuest: boolean;
  43637. /**
  43638. * Fired when the secondary trigger on this controller is modified
  43639. */
  43640. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43641. /**
  43642. * Fired when the thumb rest on this controller is modified
  43643. */
  43644. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43645. /**
  43646. * Creates a new OculusTouchController from a gamepad
  43647. * @param vrGamepad the gamepad that the controller should be created from
  43648. */
  43649. constructor(vrGamepad: any);
  43650. /**
  43651. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43652. * @param scene scene in which to add meshes
  43653. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43654. */
  43655. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43656. /**
  43657. * Fired when the A button on this controller is modified
  43658. */
  43659. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43660. /**
  43661. * Fired when the B button on this controller is modified
  43662. */
  43663. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43664. /**
  43665. * Fired when the X button on this controller is modified
  43666. */
  43667. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43668. /**
  43669. * Fired when the Y button on this controller is modified
  43670. */
  43671. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43672. /**
  43673. * Called once for each button that changed state since the last frame
  43674. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43675. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43676. * 2) secondary trigger (same)
  43677. * 3) A (right) X (left), touch, pressed = value
  43678. * 4) B / Y
  43679. * 5) thumb rest
  43680. * @param buttonIdx Which button index changed
  43681. * @param state New state of the button
  43682. * @param changes Which properties on the state changed since last frame
  43683. */
  43684. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43685. }
  43686. }
  43687. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43688. import { Scene } from "babylonjs/scene";
  43689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43690. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43691. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43692. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43693. import { Observable } from "babylonjs/Misc/observable";
  43694. /**
  43695. * Vive Controller
  43696. */
  43697. export class ViveController extends WebVRController {
  43698. /**
  43699. * Base Url for the controller model.
  43700. */
  43701. static MODEL_BASE_URL: string;
  43702. /**
  43703. * File name for the controller model.
  43704. */
  43705. static MODEL_FILENAME: string;
  43706. /**
  43707. * Creates a new ViveController from a gamepad
  43708. * @param vrGamepad the gamepad that the controller should be created from
  43709. */
  43710. constructor(vrGamepad: any);
  43711. /**
  43712. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43713. * @param scene scene in which to add meshes
  43714. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43715. */
  43716. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43717. /**
  43718. * Fired when the left button on this controller is modified
  43719. */
  43720. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43721. /**
  43722. * Fired when the right button on this controller is modified
  43723. */
  43724. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43725. /**
  43726. * Fired when the menu button on this controller is modified
  43727. */
  43728. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43729. /**
  43730. * Called once for each button that changed state since the last frame
  43731. * Vive mapping:
  43732. * 0: touchpad
  43733. * 1: trigger
  43734. * 2: left AND right buttons
  43735. * 3: menu button
  43736. * @param buttonIdx Which button index changed
  43737. * @param state New state of the button
  43738. * @param changes Which properties on the state changed since last frame
  43739. */
  43740. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43741. }
  43742. }
  43743. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43744. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43745. /**
  43746. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43747. */
  43748. export class WebXRControllerModelLoader {
  43749. /**
  43750. * Creates the WebXRControllerModelLoader
  43751. * @param input xr input that creates the controllers
  43752. */
  43753. constructor(input: WebXRInput);
  43754. }
  43755. }
  43756. declare module "babylonjs/Cameras/XR/index" {
  43757. export * from "babylonjs/Cameras/XR/webXRCamera";
  43758. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43759. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43760. export * from "babylonjs/Cameras/XR/webXRInput";
  43761. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43762. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43763. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43764. export * from "babylonjs/Cameras/XR/webXRController";
  43765. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43766. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43767. }
  43768. declare module "babylonjs/Cameras/RigModes/index" {
  43769. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43770. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43771. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43772. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43773. }
  43774. declare module "babylonjs/Cameras/index" {
  43775. export * from "babylonjs/Cameras/Inputs/index";
  43776. export * from "babylonjs/Cameras/cameraInputsManager";
  43777. export * from "babylonjs/Cameras/camera";
  43778. export * from "babylonjs/Cameras/targetCamera";
  43779. export * from "babylonjs/Cameras/freeCamera";
  43780. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43781. export * from "babylonjs/Cameras/touchCamera";
  43782. export * from "babylonjs/Cameras/arcRotateCamera";
  43783. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43784. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43785. export * from "babylonjs/Cameras/flyCamera";
  43786. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43787. export * from "babylonjs/Cameras/followCamera";
  43788. export * from "babylonjs/Cameras/followCameraInputsManager";
  43789. export * from "babylonjs/Cameras/gamepadCamera";
  43790. export * from "babylonjs/Cameras/Stereoscopic/index";
  43791. export * from "babylonjs/Cameras/universalCamera";
  43792. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43793. export * from "babylonjs/Cameras/VR/index";
  43794. export * from "babylonjs/Cameras/XR/index";
  43795. export * from "babylonjs/Cameras/RigModes/index";
  43796. }
  43797. declare module "babylonjs/Collisions/index" {
  43798. export * from "babylonjs/Collisions/collider";
  43799. export * from "babylonjs/Collisions/collisionCoordinator";
  43800. export * from "babylonjs/Collisions/pickingInfo";
  43801. export * from "babylonjs/Collisions/intersectionInfo";
  43802. export * from "babylonjs/Collisions/meshCollisionData";
  43803. }
  43804. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43805. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43806. import { Vector3 } from "babylonjs/Maths/math.vector";
  43807. import { Ray } from "babylonjs/Culling/ray";
  43808. import { Plane } from "babylonjs/Maths/math.plane";
  43809. /**
  43810. * Contains an array of blocks representing the octree
  43811. */
  43812. export interface IOctreeContainer<T> {
  43813. /**
  43814. * Blocks within the octree
  43815. */
  43816. blocks: Array<OctreeBlock<T>>;
  43817. }
  43818. /**
  43819. * Class used to store a cell in an octree
  43820. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43821. */
  43822. export class OctreeBlock<T> {
  43823. /**
  43824. * Gets the content of the current block
  43825. */
  43826. entries: T[];
  43827. /**
  43828. * Gets the list of block children
  43829. */
  43830. blocks: Array<OctreeBlock<T>>;
  43831. private _depth;
  43832. private _maxDepth;
  43833. private _capacity;
  43834. private _minPoint;
  43835. private _maxPoint;
  43836. private _boundingVectors;
  43837. private _creationFunc;
  43838. /**
  43839. * Creates a new block
  43840. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43841. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43842. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43843. * @param depth defines the current depth of this block in the octree
  43844. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43845. * @param creationFunc defines a callback to call when an element is added to the block
  43846. */
  43847. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43848. /**
  43849. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43850. */
  43851. readonly capacity: number;
  43852. /**
  43853. * Gets the minimum vector (in world space) of the block's bounding box
  43854. */
  43855. readonly minPoint: Vector3;
  43856. /**
  43857. * Gets the maximum vector (in world space) of the block's bounding box
  43858. */
  43859. readonly maxPoint: Vector3;
  43860. /**
  43861. * Add a new element to this block
  43862. * @param entry defines the element to add
  43863. */
  43864. addEntry(entry: T): void;
  43865. /**
  43866. * Remove an element from this block
  43867. * @param entry defines the element to remove
  43868. */
  43869. removeEntry(entry: T): void;
  43870. /**
  43871. * Add an array of elements to this block
  43872. * @param entries defines the array of elements to add
  43873. */
  43874. addEntries(entries: T[]): void;
  43875. /**
  43876. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43877. * @param frustumPlanes defines the frustum planes to test
  43878. * @param selection defines the array to store current content if selection is positive
  43879. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43880. */
  43881. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43882. /**
  43883. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43884. * @param sphereCenter defines the bounding sphere center
  43885. * @param sphereRadius defines the bounding sphere radius
  43886. * @param selection defines the array to store current content if selection is positive
  43887. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43888. */
  43889. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43890. /**
  43891. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43892. * @param ray defines the ray to test with
  43893. * @param selection defines the array to store current content if selection is positive
  43894. */
  43895. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43896. /**
  43897. * Subdivide the content into child blocks (this block will then be empty)
  43898. */
  43899. createInnerBlocks(): void;
  43900. /**
  43901. * @hidden
  43902. */
  43903. static _CreateBlocks<T>(worldMin: Vector3, worldMax: Vector3, entries: T[], maxBlockCapacity: number, currentDepth: number, maxDepth: number, target: IOctreeContainer<T>, creationFunc: (entry: T, block: OctreeBlock<T>) => void): void;
  43904. }
  43905. }
  43906. declare module "babylonjs/Culling/Octrees/octree" {
  43907. import { SmartArray } from "babylonjs/Misc/smartArray";
  43908. import { Vector3 } from "babylonjs/Maths/math.vector";
  43909. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43911. import { Ray } from "babylonjs/Culling/ray";
  43912. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43913. import { Plane } from "babylonjs/Maths/math.plane";
  43914. /**
  43915. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43916. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43917. */
  43918. export class Octree<T> {
  43919. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  43920. maxDepth: number;
  43921. /**
  43922. * Blocks within the octree containing objects
  43923. */
  43924. blocks: Array<OctreeBlock<T>>;
  43925. /**
  43926. * Content stored in the octree
  43927. */
  43928. dynamicContent: T[];
  43929. private _maxBlockCapacity;
  43930. private _selectionContent;
  43931. private _creationFunc;
  43932. /**
  43933. * Creates a octree
  43934. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43935. * @param creationFunc function to be used to instatiate the octree
  43936. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43937. * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
  43938. */
  43939. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43940. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  43941. maxDepth?: number);
  43942. /**
  43943. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43944. * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  43945. * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  43946. * @param entries meshes to be added to the octree blocks
  43947. */
  43948. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43949. /**
  43950. * Adds a mesh to the octree
  43951. * @param entry Mesh to add to the octree
  43952. */
  43953. addMesh(entry: T): void;
  43954. /**
  43955. * Remove an element from the octree
  43956. * @param entry defines the element to remove
  43957. */
  43958. removeMesh(entry: T): void;
  43959. /**
  43960. * Selects an array of meshes within the frustum
  43961. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43962. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43963. * @returns array of meshes within the frustum
  43964. */
  43965. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43966. /**
  43967. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43968. * @param sphereCenter defines the bounding sphere center
  43969. * @param sphereRadius defines the bounding sphere radius
  43970. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43971. * @returns an array of objects that intersect the sphere
  43972. */
  43973. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43974. /**
  43975. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43976. * @param ray defines the ray to test with
  43977. * @returns array of intersected objects
  43978. */
  43979. intersectsRay(ray: Ray): SmartArray<T>;
  43980. /**
  43981. * Adds a mesh into the octree block if it intersects the block
  43982. */
  43983. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43984. /**
  43985. * Adds a submesh into the octree block if it intersects the block
  43986. */
  43987. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43988. }
  43989. }
  43990. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43991. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43992. import { Scene } from "babylonjs/scene";
  43993. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43995. import { Ray } from "babylonjs/Culling/ray";
  43996. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43997. import { Collider } from "babylonjs/Collisions/collider";
  43998. module "babylonjs/scene" {
  43999. interface Scene {
  44000. /**
  44001. * @hidden
  44002. * Backing Filed
  44003. */
  44004. _selectionOctree: Octree<AbstractMesh>;
  44005. /**
  44006. * Gets the octree used to boost mesh selection (picking)
  44007. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44008. */
  44009. selectionOctree: Octree<AbstractMesh>;
  44010. /**
  44011. * Creates or updates the octree used to boost selection (picking)
  44012. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44013. * @param maxCapacity defines the maximum capacity per leaf
  44014. * @param maxDepth defines the maximum depth of the octree
  44015. * @returns an octree of AbstractMesh
  44016. */
  44017. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44018. }
  44019. }
  44020. module "babylonjs/Meshes/abstractMesh" {
  44021. interface AbstractMesh {
  44022. /**
  44023. * @hidden
  44024. * Backing Field
  44025. */
  44026. _submeshesOctree: Octree<SubMesh>;
  44027. /**
  44028. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44029. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44030. * @param maxCapacity defines the maximum size of each block (64 by default)
  44031. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44032. * @returns the new octree
  44033. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44034. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44035. */
  44036. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44037. }
  44038. }
  44039. /**
  44040. * Defines the octree scene component responsible to manage any octrees
  44041. * in a given scene.
  44042. */
  44043. export class OctreeSceneComponent {
  44044. /**
  44045. * The component name help to identify the component in the list of scene components.
  44046. */
  44047. readonly name: string;
  44048. /**
  44049. * The scene the component belongs to.
  44050. */
  44051. scene: Scene;
  44052. /**
  44053. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44054. */
  44055. readonly checksIsEnabled: boolean;
  44056. /**
  44057. * Creates a new instance of the component for the given scene
  44058. * @param scene Defines the scene to register the component in
  44059. */
  44060. constructor(scene: Scene);
  44061. /**
  44062. * Registers the component in a given scene
  44063. */
  44064. register(): void;
  44065. /**
  44066. * Return the list of active meshes
  44067. * @returns the list of active meshes
  44068. */
  44069. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44070. /**
  44071. * Return the list of active sub meshes
  44072. * @param mesh The mesh to get the candidates sub meshes from
  44073. * @returns the list of active sub meshes
  44074. */
  44075. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44076. private _tempRay;
  44077. /**
  44078. * Return the list of sub meshes intersecting with a given local ray
  44079. * @param mesh defines the mesh to find the submesh for
  44080. * @param localRay defines the ray in local space
  44081. * @returns the list of intersecting sub meshes
  44082. */
  44083. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44084. /**
  44085. * Return the list of sub meshes colliding with a collider
  44086. * @param mesh defines the mesh to find the submesh for
  44087. * @param collider defines the collider to evaluate the collision against
  44088. * @returns the list of colliding sub meshes
  44089. */
  44090. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44091. /**
  44092. * Rebuilds the elements related to this component in case of
  44093. * context lost for instance.
  44094. */
  44095. rebuild(): void;
  44096. /**
  44097. * Disposes the component and the associated ressources.
  44098. */
  44099. dispose(): void;
  44100. }
  44101. }
  44102. declare module "babylonjs/Culling/Octrees/index" {
  44103. export * from "babylonjs/Culling/Octrees/octree";
  44104. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44105. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44106. }
  44107. declare module "babylonjs/Culling/index" {
  44108. export * from "babylonjs/Culling/boundingBox";
  44109. export * from "babylonjs/Culling/boundingInfo";
  44110. export * from "babylonjs/Culling/boundingSphere";
  44111. export * from "babylonjs/Culling/Octrees/index";
  44112. export * from "babylonjs/Culling/ray";
  44113. }
  44114. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44115. import { IDisposable, Scene } from "babylonjs/scene";
  44116. import { Nullable } from "babylonjs/types";
  44117. import { Observable } from "babylonjs/Misc/observable";
  44118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44119. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44120. import { Camera } from "babylonjs/Cameras/camera";
  44121. /**
  44122. * Renders a layer on top of an existing scene
  44123. */
  44124. export class UtilityLayerRenderer implements IDisposable {
  44125. /** the original scene that will be rendered on top of */
  44126. originalScene: Scene;
  44127. private _pointerCaptures;
  44128. private _lastPointerEvents;
  44129. private static _DefaultUtilityLayer;
  44130. private static _DefaultKeepDepthUtilityLayer;
  44131. private _sharedGizmoLight;
  44132. private _renderCamera;
  44133. /**
  44134. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44135. * @returns the camera that is used when rendering the utility layer
  44136. */
  44137. getRenderCamera(): Nullable<Camera>;
  44138. /**
  44139. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44140. * @param cam the camera that should be used when rendering the utility layer
  44141. */
  44142. setRenderCamera(cam: Nullable<Camera>): void;
  44143. /**
  44144. * @hidden
  44145. * Light which used by gizmos to get light shading
  44146. */
  44147. _getSharedGizmoLight(): HemisphericLight;
  44148. /**
  44149. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44150. */
  44151. pickUtilitySceneFirst: boolean;
  44152. /**
  44153. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  44154. */
  44155. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44156. /**
  44157. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  44158. */
  44159. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44160. /**
  44161. * The scene that is rendered on top of the original scene
  44162. */
  44163. utilityLayerScene: Scene;
  44164. /**
  44165. * If the utility layer should automatically be rendered on top of existing scene
  44166. */
  44167. shouldRender: boolean;
  44168. /**
  44169. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44170. */
  44171. onlyCheckPointerDownEvents: boolean;
  44172. /**
  44173. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44174. */
  44175. processAllEvents: boolean;
  44176. /**
  44177. * Observable raised when the pointer move from the utility layer scene to the main scene
  44178. */
  44179. onPointerOutObservable: Observable<number>;
  44180. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44181. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44182. private _afterRenderObserver;
  44183. private _sceneDisposeObserver;
  44184. private _originalPointerObserver;
  44185. /**
  44186. * Instantiates a UtilityLayerRenderer
  44187. * @param originalScene the original scene that will be rendered on top of
  44188. * @param handleEvents boolean indicating if the utility layer should handle events
  44189. */
  44190. constructor(
  44191. /** the original scene that will be rendered on top of */
  44192. originalScene: Scene, handleEvents?: boolean);
  44193. private _notifyObservers;
  44194. /**
  44195. * Renders the utility layers scene on top of the original scene
  44196. */
  44197. render(): void;
  44198. /**
  44199. * Disposes of the renderer
  44200. */
  44201. dispose(): void;
  44202. private _updateCamera;
  44203. }
  44204. }
  44205. declare module "babylonjs/Gizmos/gizmo" {
  44206. import { Nullable } from "babylonjs/types";
  44207. import { IDisposable } from "babylonjs/scene";
  44208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44209. import { Mesh } from "babylonjs/Meshes/mesh";
  44210. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44211. /**
  44212. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44213. */
  44214. export class Gizmo implements IDisposable {
  44215. /** The utility layer the gizmo will be added to */
  44216. gizmoLayer: UtilityLayerRenderer;
  44217. /**
  44218. * The root mesh of the gizmo
  44219. */
  44220. _rootMesh: Mesh;
  44221. private _attachedMesh;
  44222. /**
  44223. * Ratio for the scale of the gizmo (Default: 1)
  44224. */
  44225. scaleRatio: number;
  44226. /**
  44227. * If a custom mesh has been set (Default: false)
  44228. */
  44229. protected _customMeshSet: boolean;
  44230. /**
  44231. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44232. * * When set, interactions will be enabled
  44233. */
  44234. attachedMesh: Nullable<AbstractMesh>;
  44235. /**
  44236. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44237. * @param mesh The mesh to replace the default mesh of the gizmo
  44238. */
  44239. setCustomMesh(mesh: Mesh): void;
  44240. /**
  44241. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44242. */
  44243. updateGizmoRotationToMatchAttachedMesh: boolean;
  44244. /**
  44245. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44246. */
  44247. updateGizmoPositionToMatchAttachedMesh: boolean;
  44248. /**
  44249. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44250. */
  44251. updateScale: boolean;
  44252. protected _interactionsEnabled: boolean;
  44253. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44254. private _beforeRenderObserver;
  44255. private _tempVector;
  44256. /**
  44257. * Creates a gizmo
  44258. * @param gizmoLayer The utility layer the gizmo will be added to
  44259. */
  44260. constructor(
  44261. /** The utility layer the gizmo will be added to */
  44262. gizmoLayer?: UtilityLayerRenderer);
  44263. /**
  44264. * Updates the gizmo to match the attached mesh's position/rotation
  44265. */
  44266. protected _update(): void;
  44267. /**
  44268. * Disposes of the gizmo
  44269. */
  44270. dispose(): void;
  44271. }
  44272. }
  44273. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44274. import { Observable } from "babylonjs/Misc/observable";
  44275. import { Nullable } from "babylonjs/types";
  44276. import { Vector3 } from "babylonjs/Maths/math.vector";
  44277. import { Color3 } from "babylonjs/Maths/math.color";
  44278. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44280. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44281. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44282. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44283. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44284. import { Scene } from "babylonjs/scene";
  44285. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44286. /**
  44287. * Single plane drag gizmo
  44288. */
  44289. export class PlaneDragGizmo extends Gizmo {
  44290. /**
  44291. * Drag behavior responsible for the gizmos dragging interactions
  44292. */
  44293. dragBehavior: PointerDragBehavior;
  44294. private _pointerObserver;
  44295. /**
  44296. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44297. */
  44298. snapDistance: number;
  44299. /**
  44300. * Event that fires each time the gizmo snaps to a new location.
  44301. * * snapDistance is the the change in distance
  44302. */
  44303. onSnapObservable: Observable<{
  44304. snapDistance: number;
  44305. }>;
  44306. private _plane;
  44307. private _coloredMaterial;
  44308. private _hoverMaterial;
  44309. private _isEnabled;
  44310. private _parent;
  44311. /** @hidden */
  44312. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44313. /** @hidden */
  44314. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44315. /**
  44316. * Creates a PlaneDragGizmo
  44317. * @param gizmoLayer The utility layer the gizmo will be added to
  44318. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44319. * @param color The color of the gizmo
  44320. */
  44321. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44322. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44323. /**
  44324. * If the gizmo is enabled
  44325. */
  44326. isEnabled: boolean;
  44327. /**
  44328. * Disposes of the gizmo
  44329. */
  44330. dispose(): void;
  44331. }
  44332. }
  44333. declare module "babylonjs/Gizmos/positionGizmo" {
  44334. import { Observable } from "babylonjs/Misc/observable";
  44335. import { Nullable } from "babylonjs/types";
  44336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44337. import { Mesh } from "babylonjs/Meshes/mesh";
  44338. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44339. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44340. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44341. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44342. /**
  44343. * Gizmo that enables dragging a mesh along 3 axis
  44344. */
  44345. export class PositionGizmo extends Gizmo {
  44346. /**
  44347. * Internal gizmo used for interactions on the x axis
  44348. */
  44349. xGizmo: AxisDragGizmo;
  44350. /**
  44351. * Internal gizmo used for interactions on the y axis
  44352. */
  44353. yGizmo: AxisDragGizmo;
  44354. /**
  44355. * Internal gizmo used for interactions on the z axis
  44356. */
  44357. zGizmo: AxisDragGizmo;
  44358. /**
  44359. * Internal gizmo used for interactions on the yz plane
  44360. */
  44361. xPlaneGizmo: PlaneDragGizmo;
  44362. /**
  44363. * Internal gizmo used for interactions on the xz plane
  44364. */
  44365. yPlaneGizmo: PlaneDragGizmo;
  44366. /**
  44367. * Internal gizmo used for interactions on the xy plane
  44368. */
  44369. zPlaneGizmo: PlaneDragGizmo;
  44370. /**
  44371. * private variables
  44372. */
  44373. private _meshAttached;
  44374. private _updateGizmoRotationToMatchAttachedMesh;
  44375. private _snapDistance;
  44376. private _scaleRatio;
  44377. /** Fires an event when any of it's sub gizmos are dragged */
  44378. onDragStartObservable: Observable<unknown>;
  44379. /** Fires an event when any of it's sub gizmos are released from dragging */
  44380. onDragEndObservable: Observable<unknown>;
  44381. /**
  44382. * If set to true, planar drag is enabled
  44383. */
  44384. private _planarGizmoEnabled;
  44385. attachedMesh: Nullable<AbstractMesh>;
  44386. /**
  44387. * Creates a PositionGizmo
  44388. * @param gizmoLayer The utility layer the gizmo will be added to
  44389. */
  44390. constructor(gizmoLayer?: UtilityLayerRenderer);
  44391. /**
  44392. * If the planar drag gizmo is enabled
  44393. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44394. */
  44395. planarGizmoEnabled: boolean;
  44396. updateGizmoRotationToMatchAttachedMesh: boolean;
  44397. /**
  44398. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44399. */
  44400. snapDistance: number;
  44401. /**
  44402. * Ratio for the scale of the gizmo (Default: 1)
  44403. */
  44404. scaleRatio: number;
  44405. /**
  44406. * Disposes of the gizmo
  44407. */
  44408. dispose(): void;
  44409. /**
  44410. * CustomMeshes are not supported by this gizmo
  44411. * @param mesh The mesh to replace the default mesh of the gizmo
  44412. */
  44413. setCustomMesh(mesh: Mesh): void;
  44414. }
  44415. }
  44416. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44417. import { Observable } from "babylonjs/Misc/observable";
  44418. import { Nullable } from "babylonjs/types";
  44419. import { Vector3 } from "babylonjs/Maths/math.vector";
  44420. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44422. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44423. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44424. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44425. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44426. import { Scene } from "babylonjs/scene";
  44427. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44428. import { Color3 } from "babylonjs/Maths/math.color";
  44429. /**
  44430. * Single axis drag gizmo
  44431. */
  44432. export class AxisDragGizmo extends Gizmo {
  44433. /**
  44434. * Drag behavior responsible for the gizmos dragging interactions
  44435. */
  44436. dragBehavior: PointerDragBehavior;
  44437. private _pointerObserver;
  44438. /**
  44439. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44440. */
  44441. snapDistance: number;
  44442. /**
  44443. * Event that fires each time the gizmo snaps to a new location.
  44444. * * snapDistance is the the change in distance
  44445. */
  44446. onSnapObservable: Observable<{
  44447. snapDistance: number;
  44448. }>;
  44449. private _isEnabled;
  44450. private _parent;
  44451. private _arrow;
  44452. private _coloredMaterial;
  44453. private _hoverMaterial;
  44454. /** @hidden */
  44455. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44456. /** @hidden */
  44457. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44458. /**
  44459. * Creates an AxisDragGizmo
  44460. * @param gizmoLayer The utility layer the gizmo will be added to
  44461. * @param dragAxis The axis which the gizmo will be able to drag on
  44462. * @param color The color of the gizmo
  44463. */
  44464. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44465. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44466. /**
  44467. * If the gizmo is enabled
  44468. */
  44469. isEnabled: boolean;
  44470. /**
  44471. * Disposes of the gizmo
  44472. */
  44473. dispose(): void;
  44474. }
  44475. }
  44476. declare module "babylonjs/Debug/axesViewer" {
  44477. import { Vector3 } from "babylonjs/Maths/math.vector";
  44478. import { Nullable } from "babylonjs/types";
  44479. import { Scene } from "babylonjs/scene";
  44480. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44481. /**
  44482. * The Axes viewer will show 3 axes in a specific point in space
  44483. */
  44484. export class AxesViewer {
  44485. private _xAxis;
  44486. private _yAxis;
  44487. private _zAxis;
  44488. private _scaleLinesFactor;
  44489. private _instanced;
  44490. /**
  44491. * Gets the hosting scene
  44492. */
  44493. scene: Scene;
  44494. /**
  44495. * Gets or sets a number used to scale line length
  44496. */
  44497. scaleLines: number;
  44498. /** Gets the node hierarchy used to render x-axis */
  44499. readonly xAxis: TransformNode;
  44500. /** Gets the node hierarchy used to render y-axis */
  44501. readonly yAxis: TransformNode;
  44502. /** Gets the node hierarchy used to render z-axis */
  44503. readonly zAxis: TransformNode;
  44504. /**
  44505. * Creates a new AxesViewer
  44506. * @param scene defines the hosting scene
  44507. * @param scaleLines defines a number used to scale line length (1 by default)
  44508. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44509. * @param xAxis defines the node hierarchy used to render the x-axis
  44510. * @param yAxis defines the node hierarchy used to render the y-axis
  44511. * @param zAxis defines the node hierarchy used to render the z-axis
  44512. */
  44513. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44514. /**
  44515. * Force the viewer to update
  44516. * @param position defines the position of the viewer
  44517. * @param xaxis defines the x axis of the viewer
  44518. * @param yaxis defines the y axis of the viewer
  44519. * @param zaxis defines the z axis of the viewer
  44520. */
  44521. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44522. /**
  44523. * Creates an instance of this axes viewer.
  44524. * @returns a new axes viewer with instanced meshes
  44525. */
  44526. createInstance(): AxesViewer;
  44527. /** Releases resources */
  44528. dispose(): void;
  44529. private static _SetRenderingGroupId;
  44530. }
  44531. }
  44532. declare module "babylonjs/Debug/boneAxesViewer" {
  44533. import { Nullable } from "babylonjs/types";
  44534. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44535. import { Vector3 } from "babylonjs/Maths/math.vector";
  44536. import { Mesh } from "babylonjs/Meshes/mesh";
  44537. import { Bone } from "babylonjs/Bones/bone";
  44538. import { Scene } from "babylonjs/scene";
  44539. /**
  44540. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44541. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44542. */
  44543. export class BoneAxesViewer extends AxesViewer {
  44544. /**
  44545. * Gets or sets the target mesh where to display the axes viewer
  44546. */
  44547. mesh: Nullable<Mesh>;
  44548. /**
  44549. * Gets or sets the target bone where to display the axes viewer
  44550. */
  44551. bone: Nullable<Bone>;
  44552. /** Gets current position */
  44553. pos: Vector3;
  44554. /** Gets direction of X axis */
  44555. xaxis: Vector3;
  44556. /** Gets direction of Y axis */
  44557. yaxis: Vector3;
  44558. /** Gets direction of Z axis */
  44559. zaxis: Vector3;
  44560. /**
  44561. * Creates a new BoneAxesViewer
  44562. * @param scene defines the hosting scene
  44563. * @param bone defines the target bone
  44564. * @param mesh defines the target mesh
  44565. * @param scaleLines defines a scaling factor for line length (1 by default)
  44566. */
  44567. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44568. /**
  44569. * Force the viewer to update
  44570. */
  44571. update(): void;
  44572. /** Releases resources */
  44573. dispose(): void;
  44574. }
  44575. }
  44576. declare module "babylonjs/Debug/debugLayer" {
  44577. import { Scene } from "babylonjs/scene";
  44578. /**
  44579. * Interface used to define scene explorer extensibility option
  44580. */
  44581. export interface IExplorerExtensibilityOption {
  44582. /**
  44583. * Define the option label
  44584. */
  44585. label: string;
  44586. /**
  44587. * Defines the action to execute on click
  44588. */
  44589. action: (entity: any) => void;
  44590. }
  44591. /**
  44592. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44593. */
  44594. export interface IExplorerExtensibilityGroup {
  44595. /**
  44596. * Defines a predicate to test if a given type mut be extended
  44597. */
  44598. predicate: (entity: any) => boolean;
  44599. /**
  44600. * Gets the list of options added to a type
  44601. */
  44602. entries: IExplorerExtensibilityOption[];
  44603. }
  44604. /**
  44605. * Interface used to define the options to use to create the Inspector
  44606. */
  44607. export interface IInspectorOptions {
  44608. /**
  44609. * Display in overlay mode (default: false)
  44610. */
  44611. overlay?: boolean;
  44612. /**
  44613. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44614. */
  44615. globalRoot?: HTMLElement;
  44616. /**
  44617. * Display the Scene explorer
  44618. */
  44619. showExplorer?: boolean;
  44620. /**
  44621. * Display the property inspector
  44622. */
  44623. showInspector?: boolean;
  44624. /**
  44625. * Display in embed mode (both panes on the right)
  44626. */
  44627. embedMode?: boolean;
  44628. /**
  44629. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44630. */
  44631. handleResize?: boolean;
  44632. /**
  44633. * Allow the panes to popup (default: true)
  44634. */
  44635. enablePopup?: boolean;
  44636. /**
  44637. * Allow the panes to be closed by users (default: true)
  44638. */
  44639. enableClose?: boolean;
  44640. /**
  44641. * Optional list of extensibility entries
  44642. */
  44643. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44644. /**
  44645. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44646. */
  44647. inspectorURL?: string;
  44648. }
  44649. module "babylonjs/scene" {
  44650. interface Scene {
  44651. /**
  44652. * @hidden
  44653. * Backing field
  44654. */
  44655. _debugLayer: DebugLayer;
  44656. /**
  44657. * Gets the debug layer (aka Inspector) associated with the scene
  44658. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44659. */
  44660. debugLayer: DebugLayer;
  44661. }
  44662. }
  44663. /**
  44664. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44665. * what is happening in your scene
  44666. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44667. */
  44668. export class DebugLayer {
  44669. /**
  44670. * Define the url to get the inspector script from.
  44671. * By default it uses the babylonjs CDN.
  44672. * @ignoreNaming
  44673. */
  44674. static InspectorURL: string;
  44675. private _scene;
  44676. private BJSINSPECTOR;
  44677. private _onPropertyChangedObservable?;
  44678. /**
  44679. * Observable triggered when a property is changed through the inspector.
  44680. */
  44681. readonly onPropertyChangedObservable: any;
  44682. /**
  44683. * Instantiates a new debug layer.
  44684. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44685. * what is happening in your scene
  44686. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44687. * @param scene Defines the scene to inspect
  44688. */
  44689. constructor(scene: Scene);
  44690. /** Creates the inspector window. */
  44691. private _createInspector;
  44692. /**
  44693. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44694. * @param entity defines the entity to select
  44695. * @param lineContainerTitle defines the specific block to highlight
  44696. */
  44697. select(entity: any, lineContainerTitle?: string): void;
  44698. /** Get the inspector from bundle or global */
  44699. private _getGlobalInspector;
  44700. /**
  44701. * Get if the inspector is visible or not.
  44702. * @returns true if visible otherwise, false
  44703. */
  44704. isVisible(): boolean;
  44705. /**
  44706. * Hide the inspector and close its window.
  44707. */
  44708. hide(): void;
  44709. /**
  44710. * Launch the debugLayer.
  44711. * @param config Define the configuration of the inspector
  44712. * @return a promise fulfilled when the debug layer is visible
  44713. */
  44714. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44715. }
  44716. }
  44717. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44718. import { Nullable } from "babylonjs/types";
  44719. import { Scene } from "babylonjs/scene";
  44720. import { Vector4 } from "babylonjs/Maths/math.vector";
  44721. import { Color4 } from "babylonjs/Maths/math.color";
  44722. import { Mesh } from "babylonjs/Meshes/mesh";
  44723. /**
  44724. * Class containing static functions to help procedurally build meshes
  44725. */
  44726. export class BoxBuilder {
  44727. /**
  44728. * Creates a box mesh
  44729. * * The parameter `size` sets the size (float) of each box side (default 1)
  44730. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44731. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  44732. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44736. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44737. * @param name defines the name of the mesh
  44738. * @param options defines the options used to create the mesh
  44739. * @param scene defines the hosting scene
  44740. * @returns the box mesh
  44741. */
  44742. static CreateBox(name: string, options: {
  44743. size?: number;
  44744. width?: number;
  44745. height?: number;
  44746. depth?: number;
  44747. faceUV?: Vector4[];
  44748. faceColors?: Color4[];
  44749. sideOrientation?: number;
  44750. frontUVs?: Vector4;
  44751. backUVs?: Vector4;
  44752. wrap?: boolean;
  44753. topBaseAt?: number;
  44754. bottomBaseAt?: number;
  44755. updatable?: boolean;
  44756. }, scene?: Nullable<Scene>): Mesh;
  44757. }
  44758. }
  44759. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44760. import { Vector4 } from "babylonjs/Maths/math.vector";
  44761. import { Mesh } from "babylonjs/Meshes/mesh";
  44762. import { Scene } from "babylonjs/scene";
  44763. import { Nullable } from "babylonjs/types";
  44764. /**
  44765. * Class containing static functions to help procedurally build meshes
  44766. */
  44767. export class SphereBuilder {
  44768. /**
  44769. * Creates a sphere mesh
  44770. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44771. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  44772. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44773. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  44774. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  44775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44778. * @param name defines the name of the mesh
  44779. * @param options defines the options used to create the mesh
  44780. * @param scene defines the hosting scene
  44781. * @returns the sphere mesh
  44782. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44783. */
  44784. static CreateSphere(name: string, options: {
  44785. segments?: number;
  44786. diameter?: number;
  44787. diameterX?: number;
  44788. diameterY?: number;
  44789. diameterZ?: number;
  44790. arc?: number;
  44791. slice?: number;
  44792. sideOrientation?: number;
  44793. frontUVs?: Vector4;
  44794. backUVs?: Vector4;
  44795. updatable?: boolean;
  44796. }, scene?: Nullable<Scene>): Mesh;
  44797. }
  44798. }
  44799. declare module "babylonjs/Debug/physicsViewer" {
  44800. import { Nullable } from "babylonjs/types";
  44801. import { Scene } from "babylonjs/scene";
  44802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44803. import { Mesh } from "babylonjs/Meshes/mesh";
  44804. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44805. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44806. /**
  44807. * Used to show the physics impostor around the specific mesh
  44808. */
  44809. export class PhysicsViewer {
  44810. /** @hidden */
  44811. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44812. /** @hidden */
  44813. protected _meshes: Array<Nullable<AbstractMesh>>;
  44814. /** @hidden */
  44815. protected _scene: Nullable<Scene>;
  44816. /** @hidden */
  44817. protected _numMeshes: number;
  44818. /** @hidden */
  44819. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44820. private _renderFunction;
  44821. private _utilityLayer;
  44822. private _debugBoxMesh;
  44823. private _debugSphereMesh;
  44824. private _debugCylinderMesh;
  44825. private _debugMaterial;
  44826. private _debugMeshMeshes;
  44827. /**
  44828. * Creates a new PhysicsViewer
  44829. * @param scene defines the hosting scene
  44830. */
  44831. constructor(scene: Scene);
  44832. /** @hidden */
  44833. protected _updateDebugMeshes(): void;
  44834. /**
  44835. * Renders a specified physic impostor
  44836. * @param impostor defines the impostor to render
  44837. * @param targetMesh defines the mesh represented by the impostor
  44838. * @returns the new debug mesh used to render the impostor
  44839. */
  44840. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44841. /**
  44842. * Hides a specified physic impostor
  44843. * @param impostor defines the impostor to hide
  44844. */
  44845. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44846. private _getDebugMaterial;
  44847. private _getDebugBoxMesh;
  44848. private _getDebugSphereMesh;
  44849. private _getDebugCylinderMesh;
  44850. private _getDebugMeshMesh;
  44851. private _getDebugMesh;
  44852. /** Releases all resources */
  44853. dispose(): void;
  44854. }
  44855. }
  44856. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44857. import { Vector3 } from "babylonjs/Maths/math.vector";
  44858. import { Color4 } from "babylonjs/Maths/math.color";
  44859. import { Nullable } from "babylonjs/types";
  44860. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44861. import { Scene } from "babylonjs/scene";
  44862. /**
  44863. * Class containing static functions to help procedurally build meshes
  44864. */
  44865. export class LinesBuilder {
  44866. /**
  44867. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44868. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  44869. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44870. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44871. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44872. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44873. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44874. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  44875. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44878. * @param name defines the name of the new line system
  44879. * @param options defines the options used to create the line system
  44880. * @param scene defines the hosting scene
  44881. * @returns a new line system mesh
  44882. */
  44883. static CreateLineSystem(name: string, options: {
  44884. lines: Vector3[][];
  44885. updatable?: boolean;
  44886. instance?: Nullable<LinesMesh>;
  44887. colors?: Nullable<Color4[][]>;
  44888. useVertexAlpha?: boolean;
  44889. }, scene: Nullable<Scene>): LinesMesh;
  44890. /**
  44891. * Creates a line mesh
  44892. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  44893. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44894. * * The parameter `points` is an array successive Vector3
  44895. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  44896. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44897. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44898. * * When updating an instance, remember that only point positions can change, not the number of points
  44899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44901. * @param name defines the name of the new line system
  44902. * @param options defines the options used to create the line system
  44903. * @param scene defines the hosting scene
  44904. * @returns a new line mesh
  44905. */
  44906. static CreateLines(name: string, options: {
  44907. points: Vector3[];
  44908. updatable?: boolean;
  44909. instance?: Nullable<LinesMesh>;
  44910. colors?: Color4[];
  44911. useVertexAlpha?: boolean;
  44912. }, scene?: Nullable<Scene>): LinesMesh;
  44913. /**
  44914. * Creates a dashed line mesh
  44915. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  44916. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44917. * * The parameter `points` is an array successive Vector3
  44918. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44919. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44920. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44921. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  44922. * * When updating an instance, remember that only point positions can change, not the number of points
  44923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44924. * @param name defines the name of the mesh
  44925. * @param options defines the options used to create the mesh
  44926. * @param scene defines the hosting scene
  44927. * @returns the dashed line mesh
  44928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44929. */
  44930. static CreateDashedLines(name: string, options: {
  44931. points: Vector3[];
  44932. dashSize?: number;
  44933. gapSize?: number;
  44934. dashNb?: number;
  44935. updatable?: boolean;
  44936. instance?: LinesMesh;
  44937. }, scene?: Nullable<Scene>): LinesMesh;
  44938. }
  44939. }
  44940. declare module "babylonjs/Debug/rayHelper" {
  44941. import { Nullable } from "babylonjs/types";
  44942. import { Ray } from "babylonjs/Culling/ray";
  44943. import { Vector3 } from "babylonjs/Maths/math.vector";
  44944. import { Color3 } from "babylonjs/Maths/math.color";
  44945. import { Scene } from "babylonjs/scene";
  44946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44947. import "babylonjs/Meshes/Builders/linesBuilder";
  44948. /**
  44949. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44950. * in order to better appreciate the issue one might have.
  44951. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44952. */
  44953. export class RayHelper {
  44954. /**
  44955. * Defines the ray we are currently tryin to visualize.
  44956. */
  44957. ray: Nullable<Ray>;
  44958. private _renderPoints;
  44959. private _renderLine;
  44960. private _renderFunction;
  44961. private _scene;
  44962. private _updateToMeshFunction;
  44963. private _attachedToMesh;
  44964. private _meshSpaceDirection;
  44965. private _meshSpaceOrigin;
  44966. /**
  44967. * Helper function to create a colored helper in a scene in one line.
  44968. * @param ray Defines the ray we are currently tryin to visualize
  44969. * @param scene Defines the scene the ray is used in
  44970. * @param color Defines the color we want to see the ray in
  44971. * @returns The newly created ray helper.
  44972. */
  44973. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44974. /**
  44975. * Instantiate a new ray helper.
  44976. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44977. * in order to better appreciate the issue one might have.
  44978. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44979. * @param ray Defines the ray we are currently tryin to visualize
  44980. */
  44981. constructor(ray: Ray);
  44982. /**
  44983. * Shows the ray we are willing to debug.
  44984. * @param scene Defines the scene the ray needs to be rendered in
  44985. * @param color Defines the color the ray needs to be rendered in
  44986. */
  44987. show(scene: Scene, color?: Color3): void;
  44988. /**
  44989. * Hides the ray we are debugging.
  44990. */
  44991. hide(): void;
  44992. private _render;
  44993. /**
  44994. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44995. * @param mesh Defines the mesh we want the helper attached to
  44996. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44997. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44998. * @param length Defines the length of the ray
  44999. */
  45000. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45001. /**
  45002. * Detach the ray helper from the mesh it has previously been attached to.
  45003. */
  45004. detachFromMesh(): void;
  45005. private _updateToMesh;
  45006. /**
  45007. * Dispose the helper and release its associated resources.
  45008. */
  45009. dispose(): void;
  45010. }
  45011. }
  45012. declare module "babylonjs/Debug/skeletonViewer" {
  45013. import { Color3 } from "babylonjs/Maths/math.color";
  45014. import { Scene } from "babylonjs/scene";
  45015. import { Nullable } from "babylonjs/types";
  45016. import { Skeleton } from "babylonjs/Bones/skeleton";
  45017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45018. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45019. /**
  45020. * Class used to render a debug view of a given skeleton
  45021. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45022. */
  45023. export class SkeletonViewer {
  45024. /** defines the skeleton to render */
  45025. skeleton: Skeleton;
  45026. /** defines the mesh attached to the skeleton */
  45027. mesh: AbstractMesh;
  45028. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45029. autoUpdateBonesMatrices: boolean;
  45030. /** defines the rendering group id to use with the viewer */
  45031. renderingGroupId: number;
  45032. /** Gets or sets the color used to render the skeleton */
  45033. color: Color3;
  45034. private _scene;
  45035. private _debugLines;
  45036. private _debugMesh;
  45037. private _isEnabled;
  45038. private _renderFunction;
  45039. private _utilityLayer;
  45040. /**
  45041. * Returns the mesh used to render the bones
  45042. */
  45043. readonly debugMesh: Nullable<LinesMesh>;
  45044. /**
  45045. * Creates a new SkeletonViewer
  45046. * @param skeleton defines the skeleton to render
  45047. * @param mesh defines the mesh attached to the skeleton
  45048. * @param scene defines the hosting scene
  45049. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45050. * @param renderingGroupId defines the rendering group id to use with the viewer
  45051. */
  45052. constructor(
  45053. /** defines the skeleton to render */
  45054. skeleton: Skeleton,
  45055. /** defines the mesh attached to the skeleton */
  45056. mesh: AbstractMesh, scene: Scene,
  45057. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45058. autoUpdateBonesMatrices?: boolean,
  45059. /** defines the rendering group id to use with the viewer */
  45060. renderingGroupId?: number);
  45061. /** Gets or sets a boolean indicating if the viewer is enabled */
  45062. isEnabled: boolean;
  45063. private _getBonePosition;
  45064. private _getLinesForBonesWithLength;
  45065. private _getLinesForBonesNoLength;
  45066. /** Update the viewer to sync with current skeleton state */
  45067. update(): void;
  45068. /** Release associated resources */
  45069. dispose(): void;
  45070. }
  45071. }
  45072. declare module "babylonjs/Debug/index" {
  45073. export * from "babylonjs/Debug/axesViewer";
  45074. export * from "babylonjs/Debug/boneAxesViewer";
  45075. export * from "babylonjs/Debug/debugLayer";
  45076. export * from "babylonjs/Debug/physicsViewer";
  45077. export * from "babylonjs/Debug/rayHelper";
  45078. export * from "babylonjs/Debug/skeletonViewer";
  45079. }
  45080. declare module "babylonjs/Engines/nullEngine" {
  45081. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45082. import { Scene } from "babylonjs/scene";
  45083. import { Engine } from "babylonjs/Engines/engine";
  45084. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45085. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45086. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45087. import { Effect } from "babylonjs/Materials/effect";
  45088. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45089. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45090. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45091. /**
  45092. * Options to create the null engine
  45093. */
  45094. export class NullEngineOptions {
  45095. /**
  45096. * Render width (Default: 512)
  45097. */
  45098. renderWidth: number;
  45099. /**
  45100. * Render height (Default: 256)
  45101. */
  45102. renderHeight: number;
  45103. /**
  45104. * Texture size (Default: 512)
  45105. */
  45106. textureSize: number;
  45107. /**
  45108. * If delta time between frames should be constant
  45109. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45110. */
  45111. deterministicLockstep: boolean;
  45112. /**
  45113. * Maximum about of steps between frames (Default: 4)
  45114. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45115. */
  45116. lockstepMaxSteps: number;
  45117. }
  45118. /**
  45119. * The null engine class provides support for headless version of babylon.js.
  45120. * This can be used in server side scenario or for testing purposes
  45121. */
  45122. export class NullEngine extends Engine {
  45123. private _options;
  45124. /**
  45125. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45126. */
  45127. isDeterministicLockStep(): boolean;
  45128. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45129. getLockstepMaxSteps(): number;
  45130. /**
  45131. * Sets hardware scaling, used to save performance if needed
  45132. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45133. */
  45134. getHardwareScalingLevel(): number;
  45135. constructor(options?: NullEngineOptions);
  45136. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45137. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45138. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45139. getRenderWidth(useScreen?: boolean): number;
  45140. getRenderHeight(useScreen?: boolean): number;
  45141. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45142. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45143. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45144. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45145. bindSamplers(effect: Effect): void;
  45146. enableEffect(effect: Effect): void;
  45147. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45148. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45149. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45150. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45151. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45152. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45153. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45154. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45155. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45156. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45157. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45158. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45159. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45160. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45161. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45162. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45163. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45164. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45165. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45166. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45167. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45168. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45169. bindBuffers(vertexBuffers: {
  45170. [key: string]: VertexBuffer;
  45171. }, indexBuffer: DataBuffer, effect: Effect): void;
  45172. wipeCaches(bruteForce?: boolean): void;
  45173. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45174. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45175. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45176. /** @hidden */
  45177. _createTexture(): WebGLTexture;
  45178. /** @hidden */
  45179. _releaseTexture(texture: InternalTexture): void;
  45180. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  45181. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45182. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45183. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45184. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45185. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45186. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45187. areAllEffectsReady(): boolean;
  45188. /**
  45189. * @hidden
  45190. * Get the current error code of the webGL context
  45191. * @returns the error code
  45192. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45193. */
  45194. getError(): number;
  45195. /** @hidden */
  45196. _getUnpackAlignement(): number;
  45197. /** @hidden */
  45198. _unpackFlipY(value: boolean): void;
  45199. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45200. /**
  45201. * Updates a dynamic vertex buffer.
  45202. * @param vertexBuffer the vertex buffer to update
  45203. * @param data the data used to update the vertex buffer
  45204. * @param byteOffset the byte offset of the data (optional)
  45205. * @param byteLength the byte length of the data (optional)
  45206. */
  45207. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45208. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45209. /** @hidden */
  45210. _bindTexture(channel: number, texture: InternalTexture): void;
  45211. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45212. releaseEffects(): void;
  45213. displayLoadingUI(): void;
  45214. hideLoadingUI(): void;
  45215. /** @hidden */
  45216. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45217. /** @hidden */
  45218. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45219. /** @hidden */
  45220. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45221. /** @hidden */
  45222. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45223. }
  45224. }
  45225. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45226. import { Nullable, int } from "babylonjs/types";
  45227. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45228. /** @hidden */
  45229. export class _OcclusionDataStorage {
  45230. /** @hidden */
  45231. occlusionInternalRetryCounter: number;
  45232. /** @hidden */
  45233. isOcclusionQueryInProgress: boolean;
  45234. /** @hidden */
  45235. isOccluded: boolean;
  45236. /** @hidden */
  45237. occlusionRetryCount: number;
  45238. /** @hidden */
  45239. occlusionType: number;
  45240. /** @hidden */
  45241. occlusionQueryAlgorithmType: number;
  45242. }
  45243. module "babylonjs/Engines/engine" {
  45244. interface Engine {
  45245. /**
  45246. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45247. * @return the new query
  45248. */
  45249. createQuery(): WebGLQuery;
  45250. /**
  45251. * Delete and release a webGL query
  45252. * @param query defines the query to delete
  45253. * @return the current engine
  45254. */
  45255. deleteQuery(query: WebGLQuery): Engine;
  45256. /**
  45257. * Check if a given query has resolved and got its value
  45258. * @param query defines the query to check
  45259. * @returns true if the query got its value
  45260. */
  45261. isQueryResultAvailable(query: WebGLQuery): boolean;
  45262. /**
  45263. * Gets the value of a given query
  45264. * @param query defines the query to check
  45265. * @returns the value of the query
  45266. */
  45267. getQueryResult(query: WebGLQuery): number;
  45268. /**
  45269. * Initiates an occlusion query
  45270. * @param algorithmType defines the algorithm to use
  45271. * @param query defines the query to use
  45272. * @returns the current engine
  45273. * @see http://doc.babylonjs.com/features/occlusionquery
  45274. */
  45275. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45276. /**
  45277. * Ends an occlusion query
  45278. * @see http://doc.babylonjs.com/features/occlusionquery
  45279. * @param algorithmType defines the algorithm to use
  45280. * @returns the current engine
  45281. */
  45282. endOcclusionQuery(algorithmType: number): Engine;
  45283. /**
  45284. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45285. * Please note that only one query can be issued at a time
  45286. * @returns a time token used to track the time span
  45287. */
  45288. startTimeQuery(): Nullable<_TimeToken>;
  45289. /**
  45290. * Ends a time query
  45291. * @param token defines the token used to measure the time span
  45292. * @returns the time spent (in ns)
  45293. */
  45294. endTimeQuery(token: _TimeToken): int;
  45295. /** @hidden */
  45296. _currentNonTimestampToken: Nullable<_TimeToken>;
  45297. /** @hidden */
  45298. _createTimeQuery(): WebGLQuery;
  45299. /** @hidden */
  45300. _deleteTimeQuery(query: WebGLQuery): void;
  45301. /** @hidden */
  45302. _getGlAlgorithmType(algorithmType: number): number;
  45303. /** @hidden */
  45304. _getTimeQueryResult(query: WebGLQuery): any;
  45305. /** @hidden */
  45306. _getTimeQueryAvailability(query: WebGLQuery): any;
  45307. }
  45308. }
  45309. module "babylonjs/Meshes/abstractMesh" {
  45310. interface AbstractMesh {
  45311. /**
  45312. * Backing filed
  45313. * @hidden
  45314. */
  45315. __occlusionDataStorage: _OcclusionDataStorage;
  45316. /**
  45317. * Access property
  45318. * @hidden
  45319. */
  45320. _occlusionDataStorage: _OcclusionDataStorage;
  45321. /**
  45322. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
  45323. * The default value is -1 which means don't break the query and wait till the result
  45324. * @see http://doc.babylonjs.com/features/occlusionquery
  45325. */
  45326. occlusionRetryCount: number;
  45327. /**
  45328. * This property is responsible for starting the occlusion query within the Mesh or not, this property is also used to determine what should happen when the occlusionRetryCount is reached. It has supports 3 values:
  45329. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45330. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45331. * * OCCLUSION_TYPE_STRICT: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken restore the last state of the mesh occlusion if the mesh was visible then show the mesh if was hidden then hide don't show.
  45332. * @see http://doc.babylonjs.com/features/occlusionquery
  45333. */
  45334. occlusionType: number;
  45335. /**
  45336. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45337. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45338. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE (Default Value) which is mapped to GL_ANY_SAMPLES_PASSED_CONSERVATIVE which is a false positive algorithm that is faster than GL_ANY_SAMPLES_PASSED but less accurate.
  45339. * @see http://doc.babylonjs.com/features/occlusionquery
  45340. */
  45341. occlusionQueryAlgorithmType: number;
  45342. /**
  45343. * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
  45344. * @see http://doc.babylonjs.com/features/occlusionquery
  45345. */
  45346. isOccluded: boolean;
  45347. /**
  45348. * Flag to check the progress status of the query
  45349. * @see http://doc.babylonjs.com/features/occlusionquery
  45350. */
  45351. isOcclusionQueryInProgress: boolean;
  45352. }
  45353. }
  45354. }
  45355. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45356. import { Nullable } from "babylonjs/types";
  45357. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45358. /** @hidden */
  45359. export var _forceTransformFeedbackToBundle: boolean;
  45360. module "babylonjs/Engines/engine" {
  45361. interface Engine {
  45362. /**
  45363. * Creates a webGL transform feedback object
  45364. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45365. * @returns the webGL transform feedback object
  45366. */
  45367. createTransformFeedback(): WebGLTransformFeedback;
  45368. /**
  45369. * Delete a webGL transform feedback object
  45370. * @param value defines the webGL transform feedback object to delete
  45371. */
  45372. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45373. /**
  45374. * Bind a webGL transform feedback object to the webgl context
  45375. * @param value defines the webGL transform feedback object to bind
  45376. */
  45377. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45378. /**
  45379. * Begins a transform feedback operation
  45380. * @param usePoints defines if points or triangles must be used
  45381. */
  45382. beginTransformFeedback(usePoints: boolean): void;
  45383. /**
  45384. * Ends a transform feedback operation
  45385. */
  45386. endTransformFeedback(): void;
  45387. /**
  45388. * Specify the varyings to use with transform feedback
  45389. * @param program defines the associated webGL program
  45390. * @param value defines the list of strings representing the varying names
  45391. */
  45392. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45393. /**
  45394. * Bind a webGL buffer for a transform feedback operation
  45395. * @param value defines the webGL buffer to bind
  45396. */
  45397. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45398. }
  45399. }
  45400. }
  45401. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45402. import { Scene } from "babylonjs/scene";
  45403. import { Engine } from "babylonjs/Engines/engine";
  45404. import { Texture } from "babylonjs/Materials/Textures/texture";
  45405. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45406. import "babylonjs/Engines/Extensions/engine.multiRender";
  45407. /**
  45408. * Creation options of the multi render target texture.
  45409. */
  45410. export interface IMultiRenderTargetOptions {
  45411. /**
  45412. * Define if the texture needs to create mip maps after render.
  45413. */
  45414. generateMipMaps?: boolean;
  45415. /**
  45416. * Define the types of all the draw buffers we want to create
  45417. */
  45418. types?: number[];
  45419. /**
  45420. * Define the sampling modes of all the draw buffers we want to create
  45421. */
  45422. samplingModes?: number[];
  45423. /**
  45424. * Define if a depth buffer is required
  45425. */
  45426. generateDepthBuffer?: boolean;
  45427. /**
  45428. * Define if a stencil buffer is required
  45429. */
  45430. generateStencilBuffer?: boolean;
  45431. /**
  45432. * Define if a depth texture is required instead of a depth buffer
  45433. */
  45434. generateDepthTexture?: boolean;
  45435. /**
  45436. * Define the number of desired draw buffers
  45437. */
  45438. textureCount?: number;
  45439. /**
  45440. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45441. */
  45442. doNotChangeAspectRatio?: boolean;
  45443. /**
  45444. * Define the default type of the buffers we are creating
  45445. */
  45446. defaultType?: number;
  45447. }
  45448. /**
  45449. * A multi render target, like a render target provides the ability to render to a texture.
  45450. * Unlike the render target, it can render to several draw buffers in one draw.
  45451. * This is specially interesting in deferred rendering or for any effects requiring more than
  45452. * just one color from a single pass.
  45453. */
  45454. export class MultiRenderTarget extends RenderTargetTexture {
  45455. private _internalTextures;
  45456. private _textures;
  45457. private _multiRenderTargetOptions;
  45458. /**
  45459. * Get if draw buffers are currently supported by the used hardware and browser.
  45460. */
  45461. readonly isSupported: boolean;
  45462. /**
  45463. * Get the list of textures generated by the multi render target.
  45464. */
  45465. readonly textures: Texture[];
  45466. /**
  45467. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45468. */
  45469. readonly depthTexture: Texture;
  45470. /**
  45471. * Set the wrapping mode on U of all the textures we are rendering to.
  45472. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45473. */
  45474. wrapU: number;
  45475. /**
  45476. * Set the wrapping mode on V of all the textures we are rendering to.
  45477. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45478. */
  45479. wrapV: number;
  45480. /**
  45481. * Instantiate a new multi render target texture.
  45482. * A multi render target, like a render target provides the ability to render to a texture.
  45483. * Unlike the render target, it can render to several draw buffers in one draw.
  45484. * This is specially interesting in deferred rendering or for any effects requiring more than
  45485. * just one color from a single pass.
  45486. * @param name Define the name of the texture
  45487. * @param size Define the size of the buffers to render to
  45488. * @param count Define the number of target we are rendering into
  45489. * @param scene Define the scene the texture belongs to
  45490. * @param options Define the options used to create the multi render target
  45491. */
  45492. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45493. /** @hidden */
  45494. _rebuild(): void;
  45495. private _createInternalTextures;
  45496. private _createTextures;
  45497. /**
  45498. * Define the number of samples used if MSAA is enabled.
  45499. */
  45500. samples: number;
  45501. /**
  45502. * Resize all the textures in the multi render target.
  45503. * Be carrefull as it will recreate all the data in the new texture.
  45504. * @param size Define the new size
  45505. */
  45506. resize(size: any): void;
  45507. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45508. /**
  45509. * Dispose the render targets and their associated resources
  45510. */
  45511. dispose(): void;
  45512. /**
  45513. * Release all the underlying texture used as draw buffers.
  45514. */
  45515. releaseInternalTextures(): void;
  45516. }
  45517. }
  45518. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45520. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45521. import { Nullable } from "babylonjs/types";
  45522. module "babylonjs/Engines/engine" {
  45523. interface Engine {
  45524. /**
  45525. * Unbind a list of render target textures from the webGL context
  45526. * This is used only when drawBuffer extension or webGL2 are active
  45527. * @param textures defines the render target textures to unbind
  45528. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45529. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45530. */
  45531. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45532. /**
  45533. * Create a multi render target texture
  45534. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45535. * @param size defines the size of the texture
  45536. * @param options defines the creation options
  45537. * @returns the cube texture as an InternalTexture
  45538. */
  45539. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45540. /**
  45541. * Update the sample count for a given multiple render target texture
  45542. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45543. * @param textures defines the textures to update
  45544. * @param samples defines the sample count to set
  45545. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45546. */
  45547. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45548. }
  45549. }
  45550. }
  45551. declare module "babylonjs/Engines/Extensions/index" {
  45552. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45553. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45554. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45555. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45556. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45557. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45558. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45559. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45560. }
  45561. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  45562. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45563. /** @hidden */
  45564. export var rgbdEncodePixelShader: {
  45565. name: string;
  45566. shader: string;
  45567. };
  45568. }
  45569. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45570. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45571. /** @hidden */
  45572. export var rgbdDecodePixelShader: {
  45573. name: string;
  45574. shader: string;
  45575. };
  45576. }
  45577. declare module "babylonjs/Misc/environmentTextureTools" {
  45578. import { Nullable } from "babylonjs/types";
  45579. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45580. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45581. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  45582. import "babylonjs/Engines/Extensions/engine.renderTarget";
  45583. import "babylonjs/Shaders/rgbdEncode.fragment";
  45584. import "babylonjs/Shaders/rgbdDecode.fragment";
  45585. /**
  45586. * Raw texture data and descriptor sufficient for WebGL texture upload
  45587. */
  45588. export interface EnvironmentTextureInfo {
  45589. /**
  45590. * Version of the environment map
  45591. */
  45592. version: number;
  45593. /**
  45594. * Width of image
  45595. */
  45596. width: number;
  45597. /**
  45598. * Irradiance information stored in the file.
  45599. */
  45600. irradiance: any;
  45601. /**
  45602. * Specular information stored in the file.
  45603. */
  45604. specular: any;
  45605. }
  45606. /**
  45607. * Defines One Image in the file. It requires only the position in the file
  45608. * as well as the length.
  45609. */
  45610. interface BufferImageData {
  45611. /**
  45612. * Length of the image data.
  45613. */
  45614. length: number;
  45615. /**
  45616. * Position of the data from the null terminator delimiting the end of the JSON.
  45617. */
  45618. position: number;
  45619. }
  45620. /**
  45621. * Defines the specular data enclosed in the file.
  45622. * This corresponds to the version 1 of the data.
  45623. */
  45624. export interface EnvironmentTextureSpecularInfoV1 {
  45625. /**
  45626. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45627. */
  45628. specularDataPosition?: number;
  45629. /**
  45630. * This contains all the images data needed to reconstruct the cubemap.
  45631. */
  45632. mipmaps: Array<BufferImageData>;
  45633. /**
  45634. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45635. */
  45636. lodGenerationScale: number;
  45637. }
  45638. /**
  45639. * Sets of helpers addressing the serialization and deserialization of environment texture
  45640. * stored in a BabylonJS env file.
  45641. * Those files are usually stored as .env files.
  45642. */
  45643. export class EnvironmentTextureTools {
  45644. /**
  45645. * Magic number identifying the env file.
  45646. */
  45647. private static _MagicBytes;
  45648. /**
  45649. * Gets the environment info from an env file.
  45650. * @param data The array buffer containing the .env bytes.
  45651. * @returns the environment file info (the json header) if successfully parsed.
  45652. */
  45653. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45654. /**
  45655. * Creates an environment texture from a loaded cube texture.
  45656. * @param texture defines the cube texture to convert in env file
  45657. * @return a promise containing the environment data if succesfull.
  45658. */
  45659. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45660. /**
  45661. * Creates a JSON representation of the spherical data.
  45662. * @param texture defines the texture containing the polynomials
  45663. * @return the JSON representation of the spherical info
  45664. */
  45665. private static _CreateEnvTextureIrradiance;
  45666. /**
  45667. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45668. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45669. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45670. * @return the views described by info providing access to the underlying buffer
  45671. */
  45672. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45673. /**
  45674. * Uploads the texture info contained in the env file to the GPU.
  45675. * @param texture defines the internal texture to upload to
  45676. * @param arrayBuffer defines the buffer cotaining the data to load
  45677. * @param info defines the texture info retrieved through the GetEnvInfo method
  45678. * @returns a promise
  45679. */
  45680. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45681. /**
  45682. * Uploads the levels of image data to the GPU.
  45683. * @param texture defines the internal texture to upload to
  45684. * @param imageData defines the array buffer views of image data [mipmap][face]
  45685. * @returns a promise
  45686. */
  45687. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45688. /**
  45689. * Uploads spherical polynomials information to the texture.
  45690. * @param texture defines the texture we are trying to upload the information to
  45691. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45692. */
  45693. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45694. /** @hidden */
  45695. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45696. }
  45697. }
  45698. declare module "babylonjs/Maths/math.vertexFormat" {
  45699. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  45700. /**
  45701. * Contains position and normal vectors for a vertex
  45702. */
  45703. export class PositionNormalVertex {
  45704. /** the position of the vertex (defaut: 0,0,0) */
  45705. position: Vector3;
  45706. /** the normal of the vertex (defaut: 0,1,0) */
  45707. normal: Vector3;
  45708. /**
  45709. * Creates a PositionNormalVertex
  45710. * @param position the position of the vertex (defaut: 0,0,0)
  45711. * @param normal the normal of the vertex (defaut: 0,1,0)
  45712. */
  45713. constructor(
  45714. /** the position of the vertex (defaut: 0,0,0) */
  45715. position?: Vector3,
  45716. /** the normal of the vertex (defaut: 0,1,0) */
  45717. normal?: Vector3);
  45718. /**
  45719. * Clones the PositionNormalVertex
  45720. * @returns the cloned PositionNormalVertex
  45721. */
  45722. clone(): PositionNormalVertex;
  45723. }
  45724. /**
  45725. * Contains position, normal and uv vectors for a vertex
  45726. */
  45727. export class PositionNormalTextureVertex {
  45728. /** the position of the vertex (defaut: 0,0,0) */
  45729. position: Vector3;
  45730. /** the normal of the vertex (defaut: 0,1,0) */
  45731. normal: Vector3;
  45732. /** the uv of the vertex (default: 0,0) */
  45733. uv: Vector2;
  45734. /**
  45735. * Creates a PositionNormalTextureVertex
  45736. * @param position the position of the vertex (defaut: 0,0,0)
  45737. * @param normal the normal of the vertex (defaut: 0,1,0)
  45738. * @param uv the uv of the vertex (default: 0,0)
  45739. */
  45740. constructor(
  45741. /** the position of the vertex (defaut: 0,0,0) */
  45742. position?: Vector3,
  45743. /** the normal of the vertex (defaut: 0,1,0) */
  45744. normal?: Vector3,
  45745. /** the uv of the vertex (default: 0,0) */
  45746. uv?: Vector2);
  45747. /**
  45748. * Clones the PositionNormalTextureVertex
  45749. * @returns the cloned PositionNormalTextureVertex
  45750. */
  45751. clone(): PositionNormalTextureVertex;
  45752. }
  45753. }
  45754. declare module "babylonjs/Maths/math" {
  45755. export * from "babylonjs/Maths/math.axis";
  45756. export * from "babylonjs/Maths/math.color";
  45757. export * from "babylonjs/Maths/math.constants";
  45758. export * from "babylonjs/Maths/math.frustum";
  45759. export * from "babylonjs/Maths/math.path";
  45760. export * from "babylonjs/Maths/math.plane";
  45761. export * from "babylonjs/Maths/math.size";
  45762. export * from "babylonjs/Maths/math.vector";
  45763. export * from "babylonjs/Maths/math.vertexFormat";
  45764. export * from "babylonjs/Maths/math.viewport";
  45765. }
  45766. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  45767. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45768. /** @hidden */
  45769. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45770. private _genericAttributeLocation;
  45771. private _varyingLocationCount;
  45772. private _varyingLocationMap;
  45773. private _replacements;
  45774. private _textureCount;
  45775. private _uniforms;
  45776. lineProcessor(line: string): string;
  45777. attributeProcessor(attribute: string): string;
  45778. varyingProcessor(varying: string, isFragment: boolean): string;
  45779. uniformProcessor(uniform: string): string;
  45780. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45781. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45782. }
  45783. }
  45784. declare module "babylonjs/Engines/nativeEngine" {
  45785. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  45786. import { Engine } from "babylonjs/Engines/engine";
  45787. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45788. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45790. import { Effect } from "babylonjs/Materials/effect";
  45791. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45792. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  45793. import { Scene } from "babylonjs/scene";
  45794. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45795. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45796. /**
  45797. * Container for accessors for natively-stored mesh data buffers.
  45798. */
  45799. class NativeDataBuffer extends DataBuffer {
  45800. /**
  45801. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45802. */
  45803. nativeIndexBuffer?: any;
  45804. /**
  45805. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45806. */
  45807. nativeVertexBuffer?: any;
  45808. }
  45809. /** @hidden */
  45810. export class NativeEngine extends Engine {
  45811. private readonly _native;
  45812. getHardwareScalingLevel(): number;
  45813. constructor();
  45814. /**
  45815. * Can be used to override the current requestAnimationFrame requester.
  45816. * @hidden
  45817. */
  45818. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  45819. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45820. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45821. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45822. recordVertexArrayObject(vertexBuffers: {
  45823. [key: string]: VertexBuffer;
  45824. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45825. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45826. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45827. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45828. /**
  45829. * Draw a list of indexed primitives
  45830. * @param fillMode defines the primitive to use
  45831. * @param indexStart defines the starting index
  45832. * @param indexCount defines the number of index to draw
  45833. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45834. */
  45835. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45836. /**
  45837. * Draw a list of unindexed primitives
  45838. * @param fillMode defines the primitive to use
  45839. * @param verticesStart defines the index of first vertex to draw
  45840. * @param verticesCount defines the count of vertices to draw
  45841. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45842. */
  45843. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45844. createPipelineContext(): IPipelineContext;
  45845. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45846. /** @hidden */
  45847. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45848. /** @hidden */
  45849. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45850. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45851. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45852. protected _setProgram(program: WebGLProgram): void;
  45853. _releaseEffect(effect: Effect): void;
  45854. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45855. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45856. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45857. bindSamplers(effect: Effect): void;
  45858. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45859. getRenderWidth(useScreen?: boolean): number;
  45860. getRenderHeight(useScreen?: boolean): number;
  45861. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45862. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45863. /**
  45864. * Set the z offset to apply to current rendering
  45865. * @param value defines the offset to apply
  45866. */
  45867. setZOffset(value: number): void;
  45868. /**
  45869. * Gets the current value of the zOffset
  45870. * @returns the current zOffset state
  45871. */
  45872. getZOffset(): number;
  45873. /**
  45874. * Enable or disable depth buffering
  45875. * @param enable defines the state to set
  45876. */
  45877. setDepthBuffer(enable: boolean): void;
  45878. /**
  45879. * Gets a boolean indicating if depth writing is enabled
  45880. * @returns the current depth writing state
  45881. */
  45882. getDepthWrite(): boolean;
  45883. /**
  45884. * Enable or disable depth writing
  45885. * @param enable defines the state to set
  45886. */
  45887. setDepthWrite(enable: boolean): void;
  45888. /**
  45889. * Enable or disable color writing
  45890. * @param enable defines the state to set
  45891. */
  45892. setColorWrite(enable: boolean): void;
  45893. /**
  45894. * Gets a boolean indicating if color writing is enabled
  45895. * @returns the current color writing state
  45896. */
  45897. getColorWrite(): boolean;
  45898. /**
  45899. * Sets alpha constants used by some alpha blending modes
  45900. * @param r defines the red component
  45901. * @param g defines the green component
  45902. * @param b defines the blue component
  45903. * @param a defines the alpha component
  45904. */
  45905. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45906. /**
  45907. * Sets the current alpha mode
  45908. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  45909. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45910. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45911. */
  45912. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45913. /**
  45914. * Gets the current alpha mode
  45915. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45916. * @returns the current alpha mode
  45917. */
  45918. getAlphaMode(): number;
  45919. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45920. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45921. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45922. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45923. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45924. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45925. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45926. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45927. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45928. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45929. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45930. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45931. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45932. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45933. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45934. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45935. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45936. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45937. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45938. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45939. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45940. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45941. wipeCaches(bruteForce?: boolean): void;
  45942. _createTexture(): WebGLTexture;
  45943. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45944. /**
  45945. * Usually called from BABYLON.Texture.ts.
  45946. * Passed information to create a WebGLTexture
  45947. * @param urlArg defines a value which contains one of the following:
  45948. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45949. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45950. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45951. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45952. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45953. * @param scene needed for loading to the correct scene
  45954. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45955. * @param onLoad optional callback to be called upon successful completion
  45956. * @param onError optional callback to be called upon failure
  45957. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45958. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45959. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45960. * @param forcedExtension defines the extension to use to pick the right loader
  45961. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45962. */
  45963. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  45964. /**
  45965. * Creates a cube texture
  45966. * @param rootUrl defines the url where the files to load is located
  45967. * @param scene defines the current scene
  45968. * @param files defines the list of files to load (1 per face)
  45969. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45970. * @param onLoad defines an optional callback raised when the texture is loaded
  45971. * @param onError defines an optional callback raised if there is an issue to load the texture
  45972. * @param format defines the format of the data
  45973. * @param forcedExtension defines the extension to use to pick the right loader
  45974. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45975. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45976. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45977. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45978. * @returns the cube texture as an InternalTexture
  45979. */
  45980. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  45981. private _getSamplingFilter;
  45982. private static _GetNativeTextureFormat;
  45983. createRenderTargetTexture(size: number | {
  45984. width: number;
  45985. height: number;
  45986. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45987. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45988. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45989. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45990. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45991. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45992. /**
  45993. * Updates a dynamic vertex buffer.
  45994. * @param vertexBuffer the vertex buffer to update
  45995. * @param data the data used to update the vertex buffer
  45996. * @param byteOffset the byte offset of the data (optional)
  45997. * @param byteLength the byte length of the data (optional)
  45998. */
  45999. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46000. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46001. private _updateAnisotropicLevel;
  46002. private _getAddressMode;
  46003. /** @hidden */
  46004. _bindTexture(channel: number, texture: InternalTexture): void;
  46005. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46006. releaseEffects(): void;
  46007. /** @hidden */
  46008. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46009. /** @hidden */
  46010. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46011. /** @hidden */
  46012. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46013. /** @hidden */
  46014. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46015. }
  46016. }
  46017. declare module "babylonjs/Engines/index" {
  46018. export * from "babylonjs/Engines/constants";
  46019. export * from "babylonjs/Engines/engine";
  46020. export * from "babylonjs/Engines/engineStore";
  46021. export * from "babylonjs/Engines/nullEngine";
  46022. export * from "babylonjs/Engines/Extensions/index";
  46023. export * from "babylonjs/Engines/IPipelineContext";
  46024. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46025. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46026. export * from "babylonjs/Engines/nativeEngine";
  46027. }
  46028. declare module "babylonjs/Events/clipboardEvents" {
  46029. /**
  46030. * Gather the list of clipboard event types as constants.
  46031. */
  46032. export class ClipboardEventTypes {
  46033. /**
  46034. * The clipboard event is fired when a copy command is active (pressed).
  46035. */
  46036. static readonly COPY: number;
  46037. /**
  46038. * The clipboard event is fired when a cut command is active (pressed).
  46039. */
  46040. static readonly CUT: number;
  46041. /**
  46042. * The clipboard event is fired when a paste command is active (pressed).
  46043. */
  46044. static readonly PASTE: number;
  46045. }
  46046. /**
  46047. * This class is used to store clipboard related info for the onClipboardObservable event.
  46048. */
  46049. export class ClipboardInfo {
  46050. /**
  46051. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46052. */
  46053. type: number;
  46054. /**
  46055. * Defines the related dom event
  46056. */
  46057. event: ClipboardEvent;
  46058. /**
  46059. *Creates an instance of ClipboardInfo.
  46060. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46061. * @param event Defines the related dom event
  46062. */
  46063. constructor(
  46064. /**
  46065. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46066. */
  46067. type: number,
  46068. /**
  46069. * Defines the related dom event
  46070. */
  46071. event: ClipboardEvent);
  46072. /**
  46073. * Get the clipboard event's type from the keycode.
  46074. * @param keyCode Defines the keyCode for the current keyboard event.
  46075. * @return {number}
  46076. */
  46077. static GetTypeFromCharacter(keyCode: number): number;
  46078. }
  46079. }
  46080. declare module "babylonjs/Events/index" {
  46081. export * from "babylonjs/Events/keyboardEvents";
  46082. export * from "babylonjs/Events/pointerEvents";
  46083. export * from "babylonjs/Events/clipboardEvents";
  46084. }
  46085. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46086. import { Scene } from "babylonjs/scene";
  46087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46088. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46089. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46090. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46091. /**
  46092. * Google Daydream controller
  46093. */
  46094. export class DaydreamController extends WebVRController {
  46095. /**
  46096. * Base Url for the controller model.
  46097. */
  46098. static MODEL_BASE_URL: string;
  46099. /**
  46100. * File name for the controller model.
  46101. */
  46102. static MODEL_FILENAME: string;
  46103. /**
  46104. * Gamepad Id prefix used to identify Daydream Controller.
  46105. */
  46106. static readonly GAMEPAD_ID_PREFIX: string;
  46107. /**
  46108. * Creates a new DaydreamController from a gamepad
  46109. * @param vrGamepad the gamepad that the controller should be created from
  46110. */
  46111. constructor(vrGamepad: any);
  46112. /**
  46113. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46114. * @param scene scene in which to add meshes
  46115. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46116. */
  46117. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46118. /**
  46119. * Called once for each button that changed state since the last frame
  46120. * @param buttonIdx Which button index changed
  46121. * @param state New state of the button
  46122. * @param changes Which properties on the state changed since last frame
  46123. */
  46124. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46125. }
  46126. }
  46127. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46128. import { Scene } from "babylonjs/scene";
  46129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46130. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46131. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46132. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46133. /**
  46134. * Gear VR Controller
  46135. */
  46136. export class GearVRController extends WebVRController {
  46137. /**
  46138. * Base Url for the controller model.
  46139. */
  46140. static MODEL_BASE_URL: string;
  46141. /**
  46142. * File name for the controller model.
  46143. */
  46144. static MODEL_FILENAME: string;
  46145. /**
  46146. * Gamepad Id prefix used to identify this controller.
  46147. */
  46148. static readonly GAMEPAD_ID_PREFIX: string;
  46149. private readonly _buttonIndexToObservableNameMap;
  46150. /**
  46151. * Creates a new GearVRController from a gamepad
  46152. * @param vrGamepad the gamepad that the controller should be created from
  46153. */
  46154. constructor(vrGamepad: any);
  46155. /**
  46156. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46157. * @param scene scene in which to add meshes
  46158. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46159. */
  46160. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46161. /**
  46162. * Called once for each button that changed state since the last frame
  46163. * @param buttonIdx Which button index changed
  46164. * @param state New state of the button
  46165. * @param changes Which properties on the state changed since last frame
  46166. */
  46167. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46168. }
  46169. }
  46170. declare module "babylonjs/Gamepads/Controllers/index" {
  46171. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46172. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46173. export * from "babylonjs/Gamepads/Controllers/genericController";
  46174. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46175. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46176. export * from "babylonjs/Gamepads/Controllers/viveController";
  46177. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46178. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46179. }
  46180. declare module "babylonjs/Gamepads/index" {
  46181. export * from "babylonjs/Gamepads/Controllers/index";
  46182. export * from "babylonjs/Gamepads/gamepad";
  46183. export * from "babylonjs/Gamepads/gamepadManager";
  46184. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46185. export * from "babylonjs/Gamepads/xboxGamepad";
  46186. export * from "babylonjs/Gamepads/dualShockGamepad";
  46187. }
  46188. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46189. import { Scene } from "babylonjs/scene";
  46190. import { Vector4 } from "babylonjs/Maths/math.vector";
  46191. import { Color4 } from "babylonjs/Maths/math.color";
  46192. import { Mesh } from "babylonjs/Meshes/mesh";
  46193. import { Nullable } from "babylonjs/types";
  46194. /**
  46195. * Class containing static functions to help procedurally build meshes
  46196. */
  46197. export class PolyhedronBuilder {
  46198. /**
  46199. * Creates a polyhedron mesh
  46200. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  46201. * * The parameter `size` (positive float, default 1) sets the polygon size
  46202. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46203. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  46204. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  46205. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  46206. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46207. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  46208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46211. * @param name defines the name of the mesh
  46212. * @param options defines the options used to create the mesh
  46213. * @param scene defines the hosting scene
  46214. * @returns the polyhedron mesh
  46215. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46216. */
  46217. static CreatePolyhedron(name: string, options: {
  46218. type?: number;
  46219. size?: number;
  46220. sizeX?: number;
  46221. sizeY?: number;
  46222. sizeZ?: number;
  46223. custom?: any;
  46224. faceUV?: Vector4[];
  46225. faceColors?: Color4[];
  46226. flat?: boolean;
  46227. updatable?: boolean;
  46228. sideOrientation?: number;
  46229. frontUVs?: Vector4;
  46230. backUVs?: Vector4;
  46231. }, scene?: Nullable<Scene>): Mesh;
  46232. }
  46233. }
  46234. declare module "babylonjs/Gizmos/scaleGizmo" {
  46235. import { Observable } from "babylonjs/Misc/observable";
  46236. import { Nullable } from "babylonjs/types";
  46237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46238. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46239. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46240. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46241. /**
  46242. * Gizmo that enables scaling a mesh along 3 axis
  46243. */
  46244. export class ScaleGizmo extends Gizmo {
  46245. /**
  46246. * Internal gizmo used for interactions on the x axis
  46247. */
  46248. xGizmo: AxisScaleGizmo;
  46249. /**
  46250. * Internal gizmo used for interactions on the y axis
  46251. */
  46252. yGizmo: AxisScaleGizmo;
  46253. /**
  46254. * Internal gizmo used for interactions on the z axis
  46255. */
  46256. zGizmo: AxisScaleGizmo;
  46257. /**
  46258. * Internal gizmo used to scale all axis equally
  46259. */
  46260. uniformScaleGizmo: AxisScaleGizmo;
  46261. private _meshAttached;
  46262. private _updateGizmoRotationToMatchAttachedMesh;
  46263. private _snapDistance;
  46264. private _scaleRatio;
  46265. private _uniformScalingMesh;
  46266. private _octahedron;
  46267. /** Fires an event when any of it's sub gizmos are dragged */
  46268. onDragStartObservable: Observable<unknown>;
  46269. /** Fires an event when any of it's sub gizmos are released from dragging */
  46270. onDragEndObservable: Observable<unknown>;
  46271. attachedMesh: Nullable<AbstractMesh>;
  46272. /**
  46273. * Creates a ScaleGizmo
  46274. * @param gizmoLayer The utility layer the gizmo will be added to
  46275. */
  46276. constructor(gizmoLayer?: UtilityLayerRenderer);
  46277. updateGizmoRotationToMatchAttachedMesh: boolean;
  46278. /**
  46279. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46280. */
  46281. snapDistance: number;
  46282. /**
  46283. * Ratio for the scale of the gizmo (Default: 1)
  46284. */
  46285. scaleRatio: number;
  46286. /**
  46287. * Disposes of the gizmo
  46288. */
  46289. dispose(): void;
  46290. }
  46291. }
  46292. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46293. import { Observable } from "babylonjs/Misc/observable";
  46294. import { Nullable } from "babylonjs/types";
  46295. import { Vector3 } from "babylonjs/Maths/math.vector";
  46296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46297. import { Mesh } from "babylonjs/Meshes/mesh";
  46298. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46299. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46300. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46301. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46302. import { Color3 } from "babylonjs/Maths/math.color";
  46303. /**
  46304. * Single axis scale gizmo
  46305. */
  46306. export class AxisScaleGizmo extends Gizmo {
  46307. /**
  46308. * Drag behavior responsible for the gizmos dragging interactions
  46309. */
  46310. dragBehavior: PointerDragBehavior;
  46311. private _pointerObserver;
  46312. /**
  46313. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46314. */
  46315. snapDistance: number;
  46316. /**
  46317. * Event that fires each time the gizmo snaps to a new location.
  46318. * * snapDistance is the the change in distance
  46319. */
  46320. onSnapObservable: Observable<{
  46321. snapDistance: number;
  46322. }>;
  46323. /**
  46324. * If the scaling operation should be done on all axis (default: false)
  46325. */
  46326. uniformScaling: boolean;
  46327. private _isEnabled;
  46328. private _parent;
  46329. private _arrow;
  46330. private _coloredMaterial;
  46331. private _hoverMaterial;
  46332. /**
  46333. * Creates an AxisScaleGizmo
  46334. * @param gizmoLayer The utility layer the gizmo will be added to
  46335. * @param dragAxis The axis which the gizmo will be able to scale on
  46336. * @param color The color of the gizmo
  46337. */
  46338. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46339. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46340. /**
  46341. * If the gizmo is enabled
  46342. */
  46343. isEnabled: boolean;
  46344. /**
  46345. * Disposes of the gizmo
  46346. */
  46347. dispose(): void;
  46348. /**
  46349. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46350. * @param mesh The mesh to replace the default mesh of the gizmo
  46351. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46352. */
  46353. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46354. }
  46355. }
  46356. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46357. import { Observable } from "babylonjs/Misc/observable";
  46358. import { Nullable } from "babylonjs/types";
  46359. import { Vector3 } from "babylonjs/Maths/math.vector";
  46360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46361. import { Mesh } from "babylonjs/Meshes/mesh";
  46362. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46363. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46364. import { Color3 } from "babylonjs/Maths/math.color";
  46365. import "babylonjs/Meshes/Builders/boxBuilder";
  46366. /**
  46367. * Bounding box gizmo
  46368. */
  46369. export class BoundingBoxGizmo extends Gizmo {
  46370. private _lineBoundingBox;
  46371. private _rotateSpheresParent;
  46372. private _scaleBoxesParent;
  46373. private _boundingDimensions;
  46374. private _renderObserver;
  46375. private _pointerObserver;
  46376. private _scaleDragSpeed;
  46377. private _tmpQuaternion;
  46378. private _tmpVector;
  46379. private _tmpRotationMatrix;
  46380. /**
  46381. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  46382. */
  46383. ignoreChildren: boolean;
  46384. /**
  46385. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  46386. */
  46387. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46388. /**
  46389. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46390. */
  46391. rotationSphereSize: number;
  46392. /**
  46393. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46394. */
  46395. scaleBoxSize: number;
  46396. /**
  46397. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  46398. */
  46399. fixedDragMeshScreenSize: boolean;
  46400. /**
  46401. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46402. */
  46403. fixedDragMeshScreenSizeDistanceFactor: number;
  46404. /**
  46405. * Fired when a rotation sphere or scale box is dragged
  46406. */
  46407. onDragStartObservable: Observable<{}>;
  46408. /**
  46409. * Fired when a scale box is dragged
  46410. */
  46411. onScaleBoxDragObservable: Observable<{}>;
  46412. /**
  46413. * Fired when a scale box drag is ended
  46414. */
  46415. onScaleBoxDragEndObservable: Observable<{}>;
  46416. /**
  46417. * Fired when a rotation sphere is dragged
  46418. */
  46419. onRotationSphereDragObservable: Observable<{}>;
  46420. /**
  46421. * Fired when a rotation sphere drag is ended
  46422. */
  46423. onRotationSphereDragEndObservable: Observable<{}>;
  46424. /**
  46425. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  46426. */
  46427. scalePivot: Nullable<Vector3>;
  46428. /**
  46429. * Mesh used as a pivot to rotate the attached mesh
  46430. */
  46431. private _anchorMesh;
  46432. private _existingMeshScale;
  46433. private _dragMesh;
  46434. private pointerDragBehavior;
  46435. private coloredMaterial;
  46436. private hoverColoredMaterial;
  46437. /**
  46438. * Sets the color of the bounding box gizmo
  46439. * @param color the color to set
  46440. */
  46441. setColor(color: Color3): void;
  46442. /**
  46443. * Creates an BoundingBoxGizmo
  46444. * @param gizmoLayer The utility layer the gizmo will be added to
  46445. * @param color The color of the gizmo
  46446. */
  46447. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46448. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46449. private _selectNode;
  46450. /**
  46451. * Updates the bounding box information for the Gizmo
  46452. */
  46453. updateBoundingBox(): void;
  46454. private _updateRotationSpheres;
  46455. private _updateScaleBoxes;
  46456. /**
  46457. * Enables rotation on the specified axis and disables rotation on the others
  46458. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46459. */
  46460. setEnabledRotationAxis(axis: string): void;
  46461. /**
  46462. * Enables/disables scaling
  46463. * @param enable if scaling should be enabled
  46464. */
  46465. setEnabledScaling(enable: boolean): void;
  46466. private _updateDummy;
  46467. /**
  46468. * Enables a pointer drag behavior on the bounding box of the gizmo
  46469. */
  46470. enableDragBehavior(): void;
  46471. /**
  46472. * Disposes of the gizmo
  46473. */
  46474. dispose(): void;
  46475. /**
  46476. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  46477. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46478. * @returns the bounding box mesh with the passed in mesh as a child
  46479. */
  46480. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46481. /**
  46482. * CustomMeshes are not supported by this gizmo
  46483. * @param mesh The mesh to replace the default mesh of the gizmo
  46484. */
  46485. setCustomMesh(mesh: Mesh): void;
  46486. }
  46487. }
  46488. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  46489. import { Observable } from "babylonjs/Misc/observable";
  46490. import { Nullable } from "babylonjs/types";
  46491. import { Vector3 } from "babylonjs/Maths/math.vector";
  46492. import { Color3 } from "babylonjs/Maths/math.color";
  46493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46494. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46495. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46496. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46497. import "babylonjs/Meshes/Builders/linesBuilder";
  46498. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46499. /**
  46500. * Single plane rotation gizmo
  46501. */
  46502. export class PlaneRotationGizmo extends Gizmo {
  46503. /**
  46504. * Drag behavior responsible for the gizmos dragging interactions
  46505. */
  46506. dragBehavior: PointerDragBehavior;
  46507. private _pointerObserver;
  46508. /**
  46509. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46510. */
  46511. snapDistance: number;
  46512. /**
  46513. * Event that fires each time the gizmo snaps to a new location.
  46514. * * snapDistance is the the change in distance
  46515. */
  46516. onSnapObservable: Observable<{
  46517. snapDistance: number;
  46518. }>;
  46519. private _isEnabled;
  46520. private _parent;
  46521. /**
  46522. * Creates a PlaneRotationGizmo
  46523. * @param gizmoLayer The utility layer the gizmo will be added to
  46524. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46525. * @param color The color of the gizmo
  46526. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46527. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46528. */
  46529. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46530. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46531. /**
  46532. * If the gizmo is enabled
  46533. */
  46534. isEnabled: boolean;
  46535. /**
  46536. * Disposes of the gizmo
  46537. */
  46538. dispose(): void;
  46539. }
  46540. }
  46541. declare module "babylonjs/Gizmos/rotationGizmo" {
  46542. import { Observable } from "babylonjs/Misc/observable";
  46543. import { Nullable } from "babylonjs/types";
  46544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46545. import { Mesh } from "babylonjs/Meshes/mesh";
  46546. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46547. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46548. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46549. /**
  46550. * Gizmo that enables rotating a mesh along 3 axis
  46551. */
  46552. export class RotationGizmo extends Gizmo {
  46553. /**
  46554. * Internal gizmo used for interactions on the x axis
  46555. */
  46556. xGizmo: PlaneRotationGizmo;
  46557. /**
  46558. * Internal gizmo used for interactions on the y axis
  46559. */
  46560. yGizmo: PlaneRotationGizmo;
  46561. /**
  46562. * Internal gizmo used for interactions on the z axis
  46563. */
  46564. zGizmo: PlaneRotationGizmo;
  46565. /** Fires an event when any of it's sub gizmos are dragged */
  46566. onDragStartObservable: Observable<unknown>;
  46567. /** Fires an event when any of it's sub gizmos are released from dragging */
  46568. onDragEndObservable: Observable<unknown>;
  46569. private _meshAttached;
  46570. attachedMesh: Nullable<AbstractMesh>;
  46571. /**
  46572. * Creates a RotationGizmo
  46573. * @param gizmoLayer The utility layer the gizmo will be added to
  46574. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46575. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46576. */
  46577. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46578. updateGizmoRotationToMatchAttachedMesh: boolean;
  46579. /**
  46580. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46581. */
  46582. snapDistance: number;
  46583. /**
  46584. * Ratio for the scale of the gizmo (Default: 1)
  46585. */
  46586. scaleRatio: number;
  46587. /**
  46588. * Disposes of the gizmo
  46589. */
  46590. dispose(): void;
  46591. /**
  46592. * CustomMeshes are not supported by this gizmo
  46593. * @param mesh The mesh to replace the default mesh of the gizmo
  46594. */
  46595. setCustomMesh(mesh: Mesh): void;
  46596. }
  46597. }
  46598. declare module "babylonjs/Gizmos/gizmoManager" {
  46599. import { Observable } from "babylonjs/Misc/observable";
  46600. import { Nullable } from "babylonjs/types";
  46601. import { Scene, IDisposable } from "babylonjs/scene";
  46602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46603. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46604. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46605. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46606. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46607. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46608. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46609. /**
  46610. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46611. */
  46612. export class GizmoManager implements IDisposable {
  46613. private scene;
  46614. /**
  46615. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46616. */
  46617. gizmos: {
  46618. positionGizmo: Nullable<PositionGizmo>;
  46619. rotationGizmo: Nullable<RotationGizmo>;
  46620. scaleGizmo: Nullable<ScaleGizmo>;
  46621. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46622. };
  46623. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46624. clearGizmoOnEmptyPointerEvent: boolean;
  46625. /** Fires an event when the manager is attached to a mesh */
  46626. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46627. private _gizmosEnabled;
  46628. private _pointerObserver;
  46629. private _attachedMesh;
  46630. private _boundingBoxColor;
  46631. private _defaultUtilityLayer;
  46632. private _defaultKeepDepthUtilityLayer;
  46633. /**
  46634. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46635. */
  46636. boundingBoxDragBehavior: SixDofDragBehavior;
  46637. /**
  46638. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46639. */
  46640. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46641. /**
  46642. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46643. */
  46644. usePointerToAttachGizmos: boolean;
  46645. /**
  46646. * Utility layer that the bounding box gizmo belongs to
  46647. */
  46648. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46649. /**
  46650. * Utility layer that all gizmos besides bounding box belong to
  46651. */
  46652. readonly utilityLayer: UtilityLayerRenderer;
  46653. /**
  46654. * Instatiates a gizmo manager
  46655. * @param scene the scene to overlay the gizmos on top of
  46656. */
  46657. constructor(scene: Scene);
  46658. /**
  46659. * Attaches a set of gizmos to the specified mesh
  46660. * @param mesh The mesh the gizmo's should be attached to
  46661. */
  46662. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46663. /**
  46664. * If the position gizmo is enabled
  46665. */
  46666. positionGizmoEnabled: boolean;
  46667. /**
  46668. * If the rotation gizmo is enabled
  46669. */
  46670. rotationGizmoEnabled: boolean;
  46671. /**
  46672. * If the scale gizmo is enabled
  46673. */
  46674. scaleGizmoEnabled: boolean;
  46675. /**
  46676. * If the boundingBox gizmo is enabled
  46677. */
  46678. boundingBoxGizmoEnabled: boolean;
  46679. /**
  46680. * Disposes of the gizmo manager
  46681. */
  46682. dispose(): void;
  46683. }
  46684. }
  46685. declare module "babylonjs/Lights/directionalLight" {
  46686. import { Camera } from "babylonjs/Cameras/camera";
  46687. import { Scene } from "babylonjs/scene";
  46688. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46690. import { Light } from "babylonjs/Lights/light";
  46691. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46692. import { Effect } from "babylonjs/Materials/effect";
  46693. /**
  46694. * A directional light is defined by a direction (what a surprise!).
  46695. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46696. * An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object.
  46697. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46698. */
  46699. export class DirectionalLight extends ShadowLight {
  46700. private _shadowFrustumSize;
  46701. /**
  46702. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46703. */
  46704. /**
  46705. * Specifies a fix frustum size for the shadow generation.
  46706. */
  46707. shadowFrustumSize: number;
  46708. private _shadowOrthoScale;
  46709. /**
  46710. * Gets the shadow projection scale against the optimal computed one.
  46711. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46712. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46713. */
  46714. /**
  46715. * Sets the shadow projection scale against the optimal computed one.
  46716. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46717. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46718. */
  46719. shadowOrthoScale: number;
  46720. /**
  46721. * Automatically compute the projection matrix to best fit (including all the casters)
  46722. * on each frame.
  46723. */
  46724. autoUpdateExtends: boolean;
  46725. private _orthoLeft;
  46726. private _orthoRight;
  46727. private _orthoTop;
  46728. private _orthoBottom;
  46729. /**
  46730. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46731. * The directional light is emitted from everywhere in the given direction.
  46732. * It can cast shadows.
  46733. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46734. * @param name The friendly name of the light
  46735. * @param direction The direction of the light
  46736. * @param scene The scene the light belongs to
  46737. */
  46738. constructor(name: string, direction: Vector3, scene: Scene);
  46739. /**
  46740. * Returns the string "DirectionalLight".
  46741. * @return The class name
  46742. */
  46743. getClassName(): string;
  46744. /**
  46745. * Returns the integer 1.
  46746. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46747. */
  46748. getTypeID(): number;
  46749. /**
  46750. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46751. * Returns the DirectionalLight Shadow projection matrix.
  46752. */
  46753. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46754. /**
  46755. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46756. * Returns the DirectionalLight Shadow projection matrix.
  46757. */
  46758. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46759. /**
  46760. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46761. * Returns the DirectionalLight Shadow projection matrix.
  46762. */
  46763. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46764. protected _buildUniformLayout(): void;
  46765. /**
  46766. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46767. * @param effect The effect to update
  46768. * @param lightIndex The index of the light in the effect to update
  46769. * @returns The directional light
  46770. */
  46771. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46772. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46773. /**
  46774. * Gets the minZ used for shadow according to both the scene and the light.
  46775. *
  46776. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46777. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46778. * @param activeCamera The camera we are returning the min for
  46779. * @returns the depth min z
  46780. */
  46781. getDepthMinZ(activeCamera: Camera): number;
  46782. /**
  46783. * Gets the maxZ used for shadow according to both the scene and the light.
  46784. *
  46785. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46786. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46787. * @param activeCamera The camera we are returning the max for
  46788. * @returns the depth max z
  46789. */
  46790. getDepthMaxZ(activeCamera: Camera): number;
  46791. /**
  46792. * Prepares the list of defines specific to the light type.
  46793. * @param defines the list of defines
  46794. * @param lightIndex defines the index of the light for the effect
  46795. */
  46796. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46797. }
  46798. }
  46799. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46800. import { Mesh } from "babylonjs/Meshes/mesh";
  46801. /**
  46802. * Class containing static functions to help procedurally build meshes
  46803. */
  46804. export class HemisphereBuilder {
  46805. /**
  46806. * Creates a hemisphere mesh
  46807. * @param name defines the name of the mesh
  46808. * @param options defines the options used to create the mesh
  46809. * @param scene defines the hosting scene
  46810. * @returns the hemisphere mesh
  46811. */
  46812. static CreateHemisphere(name: string, options: {
  46813. segments?: number;
  46814. diameter?: number;
  46815. sideOrientation?: number;
  46816. }, scene: any): Mesh;
  46817. }
  46818. }
  46819. declare module "babylonjs/Lights/spotLight" {
  46820. import { Nullable } from "babylonjs/types";
  46821. import { Scene } from "babylonjs/scene";
  46822. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46824. import { Effect } from "babylonjs/Materials/effect";
  46825. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46826. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46827. /**
  46828. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46829. * These values define a cone of light starting from the position, emitting toward the direction.
  46830. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46831. * and the exponent defines the speed of the decay of the light with distance (reach).
  46832. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46833. */
  46834. export class SpotLight extends ShadowLight {
  46835. private _angle;
  46836. private _innerAngle;
  46837. private _cosHalfAngle;
  46838. private _lightAngleScale;
  46839. private _lightAngleOffset;
  46840. /**
  46841. * Gets the cone angle of the spot light in Radians.
  46842. */
  46843. /**
  46844. * Sets the cone angle of the spot light in Radians.
  46845. */
  46846. angle: number;
  46847. /**
  46848. * Only used in gltf falloff mode, this defines the angle where
  46849. * the directional falloff will start before cutting at angle which could be seen
  46850. * as outer angle.
  46851. */
  46852. /**
  46853. * Only used in gltf falloff mode, this defines the angle where
  46854. * the directional falloff will start before cutting at angle which could be seen
  46855. * as outer angle.
  46856. */
  46857. innerAngle: number;
  46858. private _shadowAngleScale;
  46859. /**
  46860. * Allows scaling the angle of the light for shadow generation only.
  46861. */
  46862. /**
  46863. * Allows scaling the angle of the light for shadow generation only.
  46864. */
  46865. shadowAngleScale: number;
  46866. /**
  46867. * The light decay speed with the distance from the emission spot.
  46868. */
  46869. exponent: number;
  46870. private _projectionTextureMatrix;
  46871. /**
  46872. * Allows reading the projecton texture
  46873. */
  46874. readonly projectionTextureMatrix: Matrix;
  46875. protected _projectionTextureLightNear: number;
  46876. /**
  46877. * Gets the near clip of the Spotlight for texture projection.
  46878. */
  46879. /**
  46880. * Sets the near clip of the Spotlight for texture projection.
  46881. */
  46882. projectionTextureLightNear: number;
  46883. protected _projectionTextureLightFar: number;
  46884. /**
  46885. * Gets the far clip of the Spotlight for texture projection.
  46886. */
  46887. /**
  46888. * Sets the far clip of the Spotlight for texture projection.
  46889. */
  46890. projectionTextureLightFar: number;
  46891. protected _projectionTextureUpDirection: Vector3;
  46892. /**
  46893. * Gets the Up vector of the Spotlight for texture projection.
  46894. */
  46895. /**
  46896. * Sets the Up vector of the Spotlight for texture projection.
  46897. */
  46898. projectionTextureUpDirection: Vector3;
  46899. private _projectionTexture;
  46900. /**
  46901. * Gets the projection texture of the light.
  46902. */
  46903. /**
  46904. * Sets the projection texture of the light.
  46905. */
  46906. projectionTexture: Nullable<BaseTexture>;
  46907. private _projectionTextureViewLightDirty;
  46908. private _projectionTextureProjectionLightDirty;
  46909. private _projectionTextureDirty;
  46910. private _projectionTextureViewTargetVector;
  46911. private _projectionTextureViewLightMatrix;
  46912. private _projectionTextureProjectionLightMatrix;
  46913. private _projectionTextureScalingMatrix;
  46914. /**
  46915. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46916. * It can cast shadows.
  46917. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46918. * @param name The light friendly name
  46919. * @param position The position of the spot light in the scene
  46920. * @param direction The direction of the light in the scene
  46921. * @param angle The cone angle of the light in Radians
  46922. * @param exponent The light decay speed with the distance from the emission spot
  46923. * @param scene The scene the lights belongs to
  46924. */
  46925. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46926. /**
  46927. * Returns the string "SpotLight".
  46928. * @returns the class name
  46929. */
  46930. getClassName(): string;
  46931. /**
  46932. * Returns the integer 2.
  46933. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46934. */
  46935. getTypeID(): number;
  46936. /**
  46937. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46938. */
  46939. protected _setDirection(value: Vector3): void;
  46940. /**
  46941. * Overrides the position setter to recompute the projection texture view light Matrix.
  46942. */
  46943. protected _setPosition(value: Vector3): void;
  46944. /**
  46945. * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.
  46946. * Returns the SpotLight.
  46947. */
  46948. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46949. protected _computeProjectionTextureViewLightMatrix(): void;
  46950. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46951. /**
  46952. * Main function for light texture projection matrix computing.
  46953. */
  46954. protected _computeProjectionTextureMatrix(): void;
  46955. protected _buildUniformLayout(): void;
  46956. private _computeAngleValues;
  46957. /**
  46958. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46959. * @param effect The effect to update
  46960. * @param lightIndex The index of the light in the effect to update
  46961. * @returns The spot light
  46962. */
  46963. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46964. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46965. /**
  46966. * Disposes the light and the associated resources.
  46967. */
  46968. dispose(): void;
  46969. /**
  46970. * Prepares the list of defines specific to the light type.
  46971. * @param defines the list of defines
  46972. * @param lightIndex defines the index of the light for the effect
  46973. */
  46974. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46975. }
  46976. }
  46977. declare module "babylonjs/Gizmos/lightGizmo" {
  46978. import { Nullable } from "babylonjs/types";
  46979. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46980. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46981. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46982. import { Light } from "babylonjs/Lights/light";
  46983. /**
  46984. * Gizmo that enables viewing a light
  46985. */
  46986. export class LightGizmo extends Gizmo {
  46987. private _lightMesh;
  46988. private _material;
  46989. private cachedPosition;
  46990. private cachedForward;
  46991. /**
  46992. * Creates a LightGizmo
  46993. * @param gizmoLayer The utility layer the gizmo will be added to
  46994. */
  46995. constructor(gizmoLayer?: UtilityLayerRenderer);
  46996. private _light;
  46997. /**
  46998. * The light that the gizmo is attached to
  46999. */
  47000. light: Nullable<Light>;
  47001. /**
  47002. * Gets the material used to render the light gizmo
  47003. */
  47004. readonly material: StandardMaterial;
  47005. /**
  47006. * @hidden
  47007. * Updates the gizmo to match the attached mesh's position/rotation
  47008. */
  47009. protected _update(): void;
  47010. private static _Scale;
  47011. /**
  47012. * Creates the lines for a light mesh
  47013. */
  47014. private static _createLightLines;
  47015. /**
  47016. * Disposes of the light gizmo
  47017. */
  47018. dispose(): void;
  47019. private static _CreateHemisphericLightMesh;
  47020. private static _CreatePointLightMesh;
  47021. private static _CreateSpotLightMesh;
  47022. private static _CreateDirectionalLightMesh;
  47023. }
  47024. }
  47025. declare module "babylonjs/Gizmos/index" {
  47026. export * from "babylonjs/Gizmos/axisDragGizmo";
  47027. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47028. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47029. export * from "babylonjs/Gizmos/gizmo";
  47030. export * from "babylonjs/Gizmos/gizmoManager";
  47031. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47032. export * from "babylonjs/Gizmos/positionGizmo";
  47033. export * from "babylonjs/Gizmos/rotationGizmo";
  47034. export * from "babylonjs/Gizmos/scaleGizmo";
  47035. export * from "babylonjs/Gizmos/lightGizmo";
  47036. export * from "babylonjs/Gizmos/planeDragGizmo";
  47037. }
  47038. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47039. /** @hidden */
  47040. export var backgroundFragmentDeclaration: {
  47041. name: string;
  47042. shader: string;
  47043. };
  47044. }
  47045. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47046. /** @hidden */
  47047. export var backgroundUboDeclaration: {
  47048. name: string;
  47049. shader: string;
  47050. };
  47051. }
  47052. declare module "babylonjs/Shaders/background.fragment" {
  47053. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47054. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47055. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47056. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47057. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47058. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47059. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47060. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47061. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47062. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47063. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47064. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47065. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47066. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47067. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47068. /** @hidden */
  47069. export var backgroundPixelShader: {
  47070. name: string;
  47071. shader: string;
  47072. };
  47073. }
  47074. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47075. /** @hidden */
  47076. export var backgroundVertexDeclaration: {
  47077. name: string;
  47078. shader: string;
  47079. };
  47080. }
  47081. declare module "babylonjs/Shaders/background.vertex" {
  47082. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47083. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47084. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47085. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47086. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47087. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47088. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47089. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47090. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47091. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47092. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47093. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47094. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47095. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47096. /** @hidden */
  47097. export var backgroundVertexShader: {
  47098. name: string;
  47099. shader: string;
  47100. };
  47101. }
  47102. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47103. import { Nullable, int, float } from "babylonjs/types";
  47104. import { Scene } from "babylonjs/scene";
  47105. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47106. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47108. import { Mesh } from "babylonjs/Meshes/mesh";
  47109. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47110. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47111. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47112. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47113. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47114. import { Color3 } from "babylonjs/Maths/math.color";
  47115. import "babylonjs/Shaders/background.fragment";
  47116. import "babylonjs/Shaders/background.vertex";
  47117. /**
  47118. * Background material used to create an efficient environement around your scene.
  47119. */
  47120. export class BackgroundMaterial extends PushMaterial {
  47121. /**
  47122. * Standard reflectance value at parallel view angle.
  47123. */
  47124. static StandardReflectance0: number;
  47125. /**
  47126. * Standard reflectance value at grazing angle.
  47127. */
  47128. static StandardReflectance90: number;
  47129. protected _primaryColor: Color3;
  47130. /**
  47131. * Key light Color (multiply against the environement texture)
  47132. */
  47133. primaryColor: Color3;
  47134. protected __perceptualColor: Nullable<Color3>;
  47135. /**
  47136. * Experimental Internal Use Only.
  47137. *
  47138. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47139. * This acts as a helper to set the primary color to a more "human friendly" value.
  47140. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47141. * output color as close as possible from the chosen value.
  47142. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47143. * part of lighting setup.)
  47144. */
  47145. _perceptualColor: Nullable<Color3>;
  47146. protected _primaryColorShadowLevel: float;
  47147. /**
  47148. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47149. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47150. */
  47151. primaryColorShadowLevel: float;
  47152. protected _primaryColorHighlightLevel: float;
  47153. /**
  47154. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47155. * The primary color is used at the level chosen to define what the white area would look.
  47156. */
  47157. primaryColorHighlightLevel: float;
  47158. protected _reflectionTexture: Nullable<BaseTexture>;
  47159. /**
  47160. * Reflection Texture used in the material.
  47161. * Should be author in a specific way for the best result (refer to the documentation).
  47162. */
  47163. reflectionTexture: Nullable<BaseTexture>;
  47164. protected _reflectionBlur: float;
  47165. /**
  47166. * Reflection Texture level of blur.
  47167. *
  47168. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47169. * texture twice.
  47170. */
  47171. reflectionBlur: float;
  47172. protected _diffuseTexture: Nullable<BaseTexture>;
  47173. /**
  47174. * Diffuse Texture used in the material.
  47175. * Should be author in a specific way for the best result (refer to the documentation).
  47176. */
  47177. diffuseTexture: Nullable<BaseTexture>;
  47178. protected _shadowLights: Nullable<IShadowLight[]>;
  47179. /**
  47180. * Specify the list of lights casting shadow on the material.
  47181. * All scene shadow lights will be included if null.
  47182. */
  47183. shadowLights: Nullable<IShadowLight[]>;
  47184. protected _shadowLevel: float;
  47185. /**
  47186. * Helps adjusting the shadow to a softer level if required.
  47187. * 0 means black shadows and 1 means no shadows.
  47188. */
  47189. shadowLevel: float;
  47190. protected _sceneCenter: Vector3;
  47191. /**
  47192. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47193. * It is usually zero but might be interesting to modify according to your setup.
  47194. */
  47195. sceneCenter: Vector3;
  47196. protected _opacityFresnel: boolean;
  47197. /**
  47198. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47199. * This helps ensuring a nice transition when the camera goes under the ground.
  47200. */
  47201. opacityFresnel: boolean;
  47202. protected _reflectionFresnel: boolean;
  47203. /**
  47204. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47205. * This helps adding a mirror texture on the ground.
  47206. */
  47207. reflectionFresnel: boolean;
  47208. protected _reflectionFalloffDistance: number;
  47209. /**
  47210. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47211. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47212. */
  47213. reflectionFalloffDistance: number;
  47214. protected _reflectionAmount: number;
  47215. /**
  47216. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47217. */
  47218. reflectionAmount: number;
  47219. protected _reflectionReflectance0: number;
  47220. /**
  47221. * This specifies the weight of the reflection at grazing angle.
  47222. */
  47223. reflectionReflectance0: number;
  47224. protected _reflectionReflectance90: number;
  47225. /**
  47226. * This specifies the weight of the reflection at a perpendicular point of view.
  47227. */
  47228. reflectionReflectance90: number;
  47229. /**
  47230. * Sets the reflection reflectance fresnel values according to the default standard
  47231. * empirically know to work well :-)
  47232. */
  47233. reflectionStandardFresnelWeight: number;
  47234. protected _useRGBColor: boolean;
  47235. /**
  47236. * Helps to directly use the maps channels instead of their level.
  47237. */
  47238. useRGBColor: boolean;
  47239. protected _enableNoise: boolean;
  47240. /**
  47241. * This helps reducing the banding effect that could occur on the background.
  47242. */
  47243. enableNoise: boolean;
  47244. /**
  47245. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47246. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47247. * Recommended to be keep at 1.0 except for special cases.
  47248. */
  47249. fovMultiplier: number;
  47250. private _fovMultiplier;
  47251. /**
  47252. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47253. */
  47254. useEquirectangularFOV: boolean;
  47255. private _maxSimultaneousLights;
  47256. /**
  47257. * Number of Simultaneous lights allowed on the material.
  47258. */
  47259. maxSimultaneousLights: int;
  47260. /**
  47261. * Default configuration related to image processing available in the Background Material.
  47262. */
  47263. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47264. /**
  47265. * Keep track of the image processing observer to allow dispose and replace.
  47266. */
  47267. private _imageProcessingObserver;
  47268. /**
  47269. * Attaches a new image processing configuration to the PBR Material.
  47270. * @param configuration (if null the scene configuration will be use)
  47271. */
  47272. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47273. /**
  47274. * Gets the image processing configuration used either in this material.
  47275. */
  47276. /**
  47277. * Sets the Default image processing configuration used either in the this material.
  47278. *
  47279. * If sets to null, the scene one is in use.
  47280. */
  47281. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47282. /**
  47283. * Gets wether the color curves effect is enabled.
  47284. */
  47285. /**
  47286. * Sets wether the color curves effect is enabled.
  47287. */
  47288. cameraColorCurvesEnabled: boolean;
  47289. /**
  47290. * Gets wether the color grading effect is enabled.
  47291. */
  47292. /**
  47293. * Gets wether the color grading effect is enabled.
  47294. */
  47295. cameraColorGradingEnabled: boolean;
  47296. /**
  47297. * Gets wether tonemapping is enabled or not.
  47298. */
  47299. /**
  47300. * Sets wether tonemapping is enabled or not
  47301. */
  47302. cameraToneMappingEnabled: boolean;
  47303. /**
  47304. * The camera exposure used on this material.
  47305. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47306. * This corresponds to a photographic exposure.
  47307. */
  47308. /**
  47309. * The camera exposure used on this material.
  47310. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47311. * This corresponds to a photographic exposure.
  47312. */
  47313. cameraExposure: float;
  47314. /**
  47315. * Gets The camera contrast used on this material.
  47316. */
  47317. /**
  47318. * Sets The camera contrast used on this material.
  47319. */
  47320. cameraContrast: float;
  47321. /**
  47322. * Gets the Color Grading 2D Lookup Texture.
  47323. */
  47324. /**
  47325. * Sets the Color Grading 2D Lookup Texture.
  47326. */
  47327. cameraColorGradingTexture: Nullable<BaseTexture>;
  47328. /**
  47329. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47330. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47331. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  47332. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47333. */
  47334. /**
  47335. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47336. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47337. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  47338. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47339. */
  47340. cameraColorCurves: Nullable<ColorCurves>;
  47341. /**
  47342. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47343. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47344. */
  47345. switchToBGR: boolean;
  47346. private _renderTargets;
  47347. private _reflectionControls;
  47348. private _white;
  47349. private _primaryShadowColor;
  47350. private _primaryHighlightColor;
  47351. /**
  47352. * Instantiates a Background Material in the given scene
  47353. * @param name The friendly name of the material
  47354. * @param scene The scene to add the material to
  47355. */
  47356. constructor(name: string, scene: Scene);
  47357. /**
  47358. * Gets a boolean indicating that current material needs to register RTT
  47359. */
  47360. readonly hasRenderTargetTextures: boolean;
  47361. /**
  47362. * The entire material has been created in order to prevent overdraw.
  47363. * @returns false
  47364. */
  47365. needAlphaTesting(): boolean;
  47366. /**
  47367. * The entire material has been created in order to prevent overdraw.
  47368. * @returns true if blending is enable
  47369. */
  47370. needAlphaBlending(): boolean;
  47371. /**
  47372. * Checks wether the material is ready to be rendered for a given mesh.
  47373. * @param mesh The mesh to render
  47374. * @param subMesh The submesh to check against
  47375. * @param useInstances Specify wether or not the material is used with instances
  47376. * @returns true if all the dependencies are ready (Textures, Effects...)
  47377. */
  47378. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47379. /**
  47380. * Compute the primary color according to the chosen perceptual color.
  47381. */
  47382. private _computePrimaryColorFromPerceptualColor;
  47383. /**
  47384. * Compute the highlights and shadow colors according to their chosen levels.
  47385. */
  47386. private _computePrimaryColors;
  47387. /**
  47388. * Build the uniform buffer used in the material.
  47389. */
  47390. buildUniformLayout(): void;
  47391. /**
  47392. * Unbind the material.
  47393. */
  47394. unbind(): void;
  47395. /**
  47396. * Bind only the world matrix to the material.
  47397. * @param world The world matrix to bind.
  47398. */
  47399. bindOnlyWorldMatrix(world: Matrix): void;
  47400. /**
  47401. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47402. * @param world The world matrix to bind.
  47403. * @param subMesh The submesh to bind for.
  47404. */
  47405. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47406. /**
  47407. * Checks to see if a texture is used in the material.
  47408. * @param texture - Base texture to use.
  47409. * @returns - Boolean specifying if a texture is used in the material.
  47410. */
  47411. hasTexture(texture: BaseTexture): boolean;
  47412. /**
  47413. * Dispose the material.
  47414. * @param forceDisposeEffect Force disposal of the associated effect.
  47415. * @param forceDisposeTextures Force disposal of the associated textures.
  47416. */
  47417. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47418. /**
  47419. * Clones the material.
  47420. * @param name The cloned name.
  47421. * @returns The cloned material.
  47422. */
  47423. clone(name: string): BackgroundMaterial;
  47424. /**
  47425. * Serializes the current material to its JSON representation.
  47426. * @returns The JSON representation.
  47427. */
  47428. serialize(): any;
  47429. /**
  47430. * Gets the class name of the material
  47431. * @returns "BackgroundMaterial"
  47432. */
  47433. getClassName(): string;
  47434. /**
  47435. * Parse a JSON input to create back a background material.
  47436. * @param source The JSON data to parse
  47437. * @param scene The scene to create the parsed material in
  47438. * @param rootUrl The root url of the assets the material depends upon
  47439. * @returns the instantiated BackgroundMaterial.
  47440. */
  47441. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47442. }
  47443. }
  47444. declare module "babylonjs/Helpers/environmentHelper" {
  47445. import { Observable } from "babylonjs/Misc/observable";
  47446. import { Nullable } from "babylonjs/types";
  47447. import { Scene } from "babylonjs/scene";
  47448. import { Vector3 } from "babylonjs/Maths/math.vector";
  47449. import { Color3 } from "babylonjs/Maths/math.color";
  47450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47451. import { Mesh } from "babylonjs/Meshes/mesh";
  47452. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47453. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47454. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47455. import "babylonjs/Meshes/Builders/planeBuilder";
  47456. import "babylonjs/Meshes/Builders/boxBuilder";
  47457. /**
  47458. * Represents the different options available during the creation of
  47459. * a Environment helper.
  47460. *
  47461. * This can control the default ground, skybox and image processing setup of your scene.
  47462. */
  47463. export interface IEnvironmentHelperOptions {
  47464. /**
  47465. * Specifies wether or not to create a ground.
  47466. * True by default.
  47467. */
  47468. createGround: boolean;
  47469. /**
  47470. * Specifies the ground size.
  47471. * 15 by default.
  47472. */
  47473. groundSize: number;
  47474. /**
  47475. * The texture used on the ground for the main color.
  47476. * Comes from the BabylonJS CDN by default.
  47477. *
  47478. * Remarks: Can be either a texture or a url.
  47479. */
  47480. groundTexture: string | BaseTexture;
  47481. /**
  47482. * The color mixed in the ground texture by default.
  47483. * BabylonJS clearColor by default.
  47484. */
  47485. groundColor: Color3;
  47486. /**
  47487. * Specifies the ground opacity.
  47488. * 1 by default.
  47489. */
  47490. groundOpacity: number;
  47491. /**
  47492. * Enables the ground to receive shadows.
  47493. * True by default.
  47494. */
  47495. enableGroundShadow: boolean;
  47496. /**
  47497. * Helps preventing the shadow to be fully black on the ground.
  47498. * 0.5 by default.
  47499. */
  47500. groundShadowLevel: number;
  47501. /**
  47502. * Creates a mirror texture attach to the ground.
  47503. * false by default.
  47504. */
  47505. enableGroundMirror: boolean;
  47506. /**
  47507. * Specifies the ground mirror size ratio.
  47508. * 0.3 by default as the default kernel is 64.
  47509. */
  47510. groundMirrorSizeRatio: number;
  47511. /**
  47512. * Specifies the ground mirror blur kernel size.
  47513. * 64 by default.
  47514. */
  47515. groundMirrorBlurKernel: number;
  47516. /**
  47517. * Specifies the ground mirror visibility amount.
  47518. * 1 by default
  47519. */
  47520. groundMirrorAmount: number;
  47521. /**
  47522. * Specifies the ground mirror reflectance weight.
  47523. * This uses the standard weight of the background material to setup the fresnel effect
  47524. * of the mirror.
  47525. * 1 by default.
  47526. */
  47527. groundMirrorFresnelWeight: number;
  47528. /**
  47529. * Specifies the ground mirror Falloff distance.
  47530. * This can helps reducing the size of the reflection.
  47531. * 0 by Default.
  47532. */
  47533. groundMirrorFallOffDistance: number;
  47534. /**
  47535. * Specifies the ground mirror texture type.
  47536. * Unsigned Int by Default.
  47537. */
  47538. groundMirrorTextureType: number;
  47539. /**
  47540. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47541. * the shown objects.
  47542. */
  47543. groundYBias: number;
  47544. /**
  47545. * Specifies wether or not to create a skybox.
  47546. * True by default.
  47547. */
  47548. createSkybox: boolean;
  47549. /**
  47550. * Specifies the skybox size.
  47551. * 20 by default.
  47552. */
  47553. skyboxSize: number;
  47554. /**
  47555. * The texture used on the skybox for the main color.
  47556. * Comes from the BabylonJS CDN by default.
  47557. *
  47558. * Remarks: Can be either a texture or a url.
  47559. */
  47560. skyboxTexture: string | BaseTexture;
  47561. /**
  47562. * The color mixed in the skybox texture by default.
  47563. * BabylonJS clearColor by default.
  47564. */
  47565. skyboxColor: Color3;
  47566. /**
  47567. * The background rotation around the Y axis of the scene.
  47568. * This helps aligning the key lights of your scene with the background.
  47569. * 0 by default.
  47570. */
  47571. backgroundYRotation: number;
  47572. /**
  47573. * Compute automatically the size of the elements to best fit with the scene.
  47574. */
  47575. sizeAuto: boolean;
  47576. /**
  47577. * Default position of the rootMesh if autoSize is not true.
  47578. */
  47579. rootPosition: Vector3;
  47580. /**
  47581. * Sets up the image processing in the scene.
  47582. * true by default.
  47583. */
  47584. setupImageProcessing: boolean;
  47585. /**
  47586. * The texture used as your environment texture in the scene.
  47587. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47588. *
  47589. * Remarks: Can be either a texture or a url.
  47590. */
  47591. environmentTexture: string | BaseTexture;
  47592. /**
  47593. * The value of the exposure to apply to the scene.
  47594. * 0.6 by default if setupImageProcessing is true.
  47595. */
  47596. cameraExposure: number;
  47597. /**
  47598. * The value of the contrast to apply to the scene.
  47599. * 1.6 by default if setupImageProcessing is true.
  47600. */
  47601. cameraContrast: number;
  47602. /**
  47603. * Specifies wether or not tonemapping should be enabled in the scene.
  47604. * true by default if setupImageProcessing is true.
  47605. */
  47606. toneMappingEnabled: boolean;
  47607. }
  47608. /**
  47609. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47610. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47611. * It also helps with the default setup of your imageProcessing configuration.
  47612. */
  47613. export class EnvironmentHelper {
  47614. /**
  47615. * Default ground texture URL.
  47616. */
  47617. private static _groundTextureCDNUrl;
  47618. /**
  47619. * Default skybox texture URL.
  47620. */
  47621. private static _skyboxTextureCDNUrl;
  47622. /**
  47623. * Default environment texture URL.
  47624. */
  47625. private static _environmentTextureCDNUrl;
  47626. /**
  47627. * Creates the default options for the helper.
  47628. */
  47629. private static _getDefaultOptions;
  47630. private _rootMesh;
  47631. /**
  47632. * Gets the root mesh created by the helper.
  47633. */
  47634. readonly rootMesh: Mesh;
  47635. private _skybox;
  47636. /**
  47637. * Gets the skybox created by the helper.
  47638. */
  47639. readonly skybox: Nullable<Mesh>;
  47640. private _skyboxTexture;
  47641. /**
  47642. * Gets the skybox texture created by the helper.
  47643. */
  47644. readonly skyboxTexture: Nullable<BaseTexture>;
  47645. private _skyboxMaterial;
  47646. /**
  47647. * Gets the skybox material created by the helper.
  47648. */
  47649. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47650. private _ground;
  47651. /**
  47652. * Gets the ground mesh created by the helper.
  47653. */
  47654. readonly ground: Nullable<Mesh>;
  47655. private _groundTexture;
  47656. /**
  47657. * Gets the ground texture created by the helper.
  47658. */
  47659. readonly groundTexture: Nullable<BaseTexture>;
  47660. private _groundMirror;
  47661. /**
  47662. * Gets the ground mirror created by the helper.
  47663. */
  47664. readonly groundMirror: Nullable<MirrorTexture>;
  47665. /**
  47666. * Gets the ground mirror render list to helps pushing the meshes
  47667. * you wish in the ground reflection.
  47668. */
  47669. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47670. private _groundMaterial;
  47671. /**
  47672. * Gets the ground material created by the helper.
  47673. */
  47674. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47675. /**
  47676. * Stores the creation options.
  47677. */
  47678. private readonly _scene;
  47679. private _options;
  47680. /**
  47681. * This observable will be notified with any error during the creation of the environment,
  47682. * mainly texture creation errors.
  47683. */
  47684. onErrorObservable: Observable<{
  47685. message?: string;
  47686. exception?: any;
  47687. }>;
  47688. /**
  47689. * constructor
  47690. * @param options Defines the options we want to customize the helper
  47691. * @param scene The scene to add the material to
  47692. */
  47693. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47694. /**
  47695. * Updates the background according to the new options
  47696. * @param options
  47697. */
  47698. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47699. /**
  47700. * Sets the primary color of all the available elements.
  47701. * @param color the main color to affect to the ground and the background
  47702. */
  47703. setMainColor(color: Color3): void;
  47704. /**
  47705. * Setup the image processing according to the specified options.
  47706. */
  47707. private _setupImageProcessing;
  47708. /**
  47709. * Setup the environment texture according to the specified options.
  47710. */
  47711. private _setupEnvironmentTexture;
  47712. /**
  47713. * Setup the background according to the specified options.
  47714. */
  47715. private _setupBackground;
  47716. /**
  47717. * Get the scene sizes according to the setup.
  47718. */
  47719. private _getSceneSize;
  47720. /**
  47721. * Setup the ground according to the specified options.
  47722. */
  47723. private _setupGround;
  47724. /**
  47725. * Setup the ground material according to the specified options.
  47726. */
  47727. private _setupGroundMaterial;
  47728. /**
  47729. * Setup the ground diffuse texture according to the specified options.
  47730. */
  47731. private _setupGroundDiffuseTexture;
  47732. /**
  47733. * Setup the ground mirror texture according to the specified options.
  47734. */
  47735. private _setupGroundMirrorTexture;
  47736. /**
  47737. * Setup the ground to receive the mirror texture.
  47738. */
  47739. private _setupMirrorInGroundMaterial;
  47740. /**
  47741. * Setup the skybox according to the specified options.
  47742. */
  47743. private _setupSkybox;
  47744. /**
  47745. * Setup the skybox material according to the specified options.
  47746. */
  47747. private _setupSkyboxMaterial;
  47748. /**
  47749. * Setup the skybox reflection texture according to the specified options.
  47750. */
  47751. private _setupSkyboxReflectionTexture;
  47752. private _errorHandler;
  47753. /**
  47754. * Dispose all the elements created by the Helper.
  47755. */
  47756. dispose(): void;
  47757. }
  47758. }
  47759. declare module "babylonjs/Helpers/photoDome" {
  47760. import { Observable } from "babylonjs/Misc/observable";
  47761. import { Nullable } from "babylonjs/types";
  47762. import { Scene } from "babylonjs/scene";
  47763. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47764. import { Mesh } from "babylonjs/Meshes/mesh";
  47765. import { Texture } from "babylonjs/Materials/Textures/texture";
  47766. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47767. import "babylonjs/Meshes/Builders/sphereBuilder";
  47768. /**
  47769. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47770. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47771. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47772. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47773. */
  47774. export class PhotoDome extends TransformNode {
  47775. /**
  47776. * Define the image as a Monoscopic panoramic 360 image.
  47777. */
  47778. static readonly MODE_MONOSCOPIC: number;
  47779. /**
  47780. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47781. */
  47782. static readonly MODE_TOPBOTTOM: number;
  47783. /**
  47784. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47785. */
  47786. static readonly MODE_SIDEBYSIDE: number;
  47787. private _useDirectMapping;
  47788. /**
  47789. * The texture being displayed on the sphere
  47790. */
  47791. protected _photoTexture: Texture;
  47792. /**
  47793. * Gets or sets the texture being displayed on the sphere
  47794. */
  47795. photoTexture: Texture;
  47796. /**
  47797. * Observable raised when an error occured while loading the 360 image
  47798. */
  47799. onLoadErrorObservable: Observable<string>;
  47800. /**
  47801. * The skybox material
  47802. */
  47803. protected _material: BackgroundMaterial;
  47804. /**
  47805. * The surface used for the skybox
  47806. */
  47807. protected _mesh: Mesh;
  47808. /**
  47809. * Gets the mesh used for the skybox.
  47810. */
  47811. readonly mesh: Mesh;
  47812. /**
  47813. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47814. * Also see the options.resolution property.
  47815. */
  47816. fovMultiplier: number;
  47817. private _imageMode;
  47818. /**
  47819. * Gets or set the current video mode for the video. It can be:
  47820. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47821. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47822. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47823. */
  47824. imageMode: number;
  47825. /**
  47826. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47827. * @param name Element's name, child elements will append suffixes for their own names.
  47828. * @param urlsOfPhoto defines the url of the photo to display
  47829. * @param options defines an object containing optional or exposed sub element properties
  47830. * @param onError defines a callback called when an error occured while loading the texture
  47831. */
  47832. constructor(name: string, urlOfPhoto: string, options: {
  47833. resolution?: number;
  47834. size?: number;
  47835. useDirectMapping?: boolean;
  47836. faceForward?: boolean;
  47837. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47838. private _onBeforeCameraRenderObserver;
  47839. private _changeImageMode;
  47840. /**
  47841. * Releases resources associated with this node.
  47842. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47843. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47844. */
  47845. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47846. }
  47847. }
  47848. declare module "babylonjs/Misc/rgbdTextureTools" {
  47849. import "babylonjs/Shaders/rgbdDecode.fragment";
  47850. import { Texture } from "babylonjs/Materials/Textures/texture";
  47851. /**
  47852. * Class used to host RGBD texture specific utilities
  47853. */
  47854. export class RGBDTextureTools {
  47855. /**
  47856. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47857. * @param texture the texture to expand.
  47858. */
  47859. static ExpandRGBDTexture(texture: Texture): void;
  47860. }
  47861. }
  47862. declare module "babylonjs/Misc/brdfTextureTools" {
  47863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47864. import { Scene } from "babylonjs/scene";
  47865. /**
  47866. * Class used to host texture specific utilities
  47867. */
  47868. export class BRDFTextureTools {
  47869. /**
  47870. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47871. * @param scene defines the hosting scene
  47872. * @returns the environment BRDF texture
  47873. */
  47874. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47875. private static _environmentBRDFBase64Texture;
  47876. }
  47877. }
  47878. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47879. import { Nullable } from "babylonjs/types";
  47880. import { Color3 } from "babylonjs/Maths/math.color";
  47881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47882. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47883. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47884. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47885. import { Engine } from "babylonjs/Engines/engine";
  47886. import { Scene } from "babylonjs/scene";
  47887. /**
  47888. * @hidden
  47889. */
  47890. export interface IMaterialClearCoatDefines {
  47891. CLEARCOAT: boolean;
  47892. CLEARCOAT_DEFAULTIOR: boolean;
  47893. CLEARCOAT_TEXTURE: boolean;
  47894. CLEARCOAT_TEXTUREDIRECTUV: number;
  47895. CLEARCOAT_BUMP: boolean;
  47896. CLEARCOAT_BUMPDIRECTUV: number;
  47897. CLEARCOAT_TINT: boolean;
  47898. CLEARCOAT_TINT_TEXTURE: boolean;
  47899. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47900. /** @hidden */
  47901. _areTexturesDirty: boolean;
  47902. }
  47903. /**
  47904. * Define the code related to the clear coat parameters of the pbr material.
  47905. */
  47906. export class PBRClearCoatConfiguration {
  47907. /**
  47908. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47909. * The default fits with a polyurethane material.
  47910. */
  47911. private static readonly _DefaultIndexOfRefraction;
  47912. private _isEnabled;
  47913. /**
  47914. * Defines if the clear coat is enabled in the material.
  47915. */
  47916. isEnabled: boolean;
  47917. /**
  47918. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47919. */
  47920. intensity: number;
  47921. /**
  47922. * Defines the clear coat layer roughness.
  47923. */
  47924. roughness: number;
  47925. private _indexOfRefraction;
  47926. /**
  47927. * Defines the index of refraction of the clear coat.
  47928. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47929. * The default fits with a polyurethane material.
  47930. * Changing the default value is more performance intensive.
  47931. */
  47932. indexOfRefraction: number;
  47933. private _texture;
  47934. /**
  47935. * Stores the clear coat values in a texture.
  47936. */
  47937. texture: Nullable<BaseTexture>;
  47938. private _bumpTexture;
  47939. /**
  47940. * Define the clear coat specific bump texture.
  47941. */
  47942. bumpTexture: Nullable<BaseTexture>;
  47943. private _isTintEnabled;
  47944. /**
  47945. * Defines if the clear coat tint is enabled in the material.
  47946. */
  47947. isTintEnabled: boolean;
  47948. /**
  47949. * Defines the clear coat tint of the material.
  47950. * This is only use if tint is enabled
  47951. */
  47952. tintColor: Color3;
  47953. /**
  47954. * Defines the distance at which the tint color should be found in the
  47955. * clear coat media.
  47956. * This is only use if tint is enabled
  47957. */
  47958. tintColorAtDistance: number;
  47959. /**
  47960. * Defines the clear coat layer thickness.
  47961. * This is only use if tint is enabled
  47962. */
  47963. tintThickness: number;
  47964. private _tintTexture;
  47965. /**
  47966. * Stores the clear tint values in a texture.
  47967. * rgb is tint
  47968. * a is a thickness factor
  47969. */
  47970. tintTexture: Nullable<BaseTexture>;
  47971. /** @hidden */
  47972. private _internalMarkAllSubMeshesAsTexturesDirty;
  47973. /** @hidden */
  47974. _markAllSubMeshesAsTexturesDirty(): void;
  47975. /**
  47976. * Instantiate a new istance of clear coat configuration.
  47977. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47978. */
  47979. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47980. /**
  47981. * Gets wehter the submesh is ready to be used or not.
  47982. * @param defines the list of "defines" to update.
  47983. * @param scene defines the scene the material belongs to.
  47984. * @param engine defines the engine the material belongs to.
  47985. * @param disableBumpMap defines wether the material disables bump or not.
  47986. * @returns - boolean indicating that the submesh is ready or not.
  47987. */
  47988. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47989. /**
  47990. * Checks to see if a texture is used in the material.
  47991. * @param defines the list of "defines" to update.
  47992. * @param scene defines the scene to the material belongs to.
  47993. */
  47994. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47995. /**
  47996. * Binds the material data.
  47997. * @param uniformBuffer defines the Uniform buffer to fill in.
  47998. * @param scene defines the scene the material belongs to.
  47999. * @param engine defines the engine the material belongs to.
  48000. * @param disableBumpMap defines wether the material disables bump or not.
  48001. * @param isFrozen defines wether the material is frozen or not.
  48002. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48003. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48004. */
  48005. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48006. /**
  48007. * Checks to see if a texture is used in the material.
  48008. * @param texture - Base texture to use.
  48009. * @returns - Boolean specifying if a texture is used in the material.
  48010. */
  48011. hasTexture(texture: BaseTexture): boolean;
  48012. /**
  48013. * Returns an array of the actively used textures.
  48014. * @param activeTextures Array of BaseTextures
  48015. */
  48016. getActiveTextures(activeTextures: BaseTexture[]): void;
  48017. /**
  48018. * Returns the animatable textures.
  48019. * @param animatables Array of animatable textures.
  48020. */
  48021. getAnimatables(animatables: IAnimatable[]): void;
  48022. /**
  48023. * Disposes the resources of the material.
  48024. * @param forceDisposeTextures - Forces the disposal of all textures.
  48025. */
  48026. dispose(forceDisposeTextures?: boolean): void;
  48027. /**
  48028. * Get the current class name of the texture useful for serialization or dynamic coding.
  48029. * @returns "PBRClearCoatConfiguration"
  48030. */
  48031. getClassName(): string;
  48032. /**
  48033. * Add fallbacks to the effect fallbacks list.
  48034. * @param defines defines the Base texture to use.
  48035. * @param fallbacks defines the current fallback list.
  48036. * @param currentRank defines the current fallback rank.
  48037. * @returns the new fallback rank.
  48038. */
  48039. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48040. /**
  48041. * Add the required uniforms to the current list.
  48042. * @param uniforms defines the current uniform list.
  48043. */
  48044. static AddUniforms(uniforms: string[]): void;
  48045. /**
  48046. * Add the required samplers to the current list.
  48047. * @param samplers defines the current sampler list.
  48048. */
  48049. static AddSamplers(samplers: string[]): void;
  48050. /**
  48051. * Add the required uniforms to the current buffer.
  48052. * @param uniformBuffer defines the current uniform buffer.
  48053. */
  48054. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48055. /**
  48056. * Makes a duplicate of the current configuration into another one.
  48057. * @param clearCoatConfiguration define the config where to copy the info
  48058. */
  48059. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48060. /**
  48061. * Serializes this clear coat configuration.
  48062. * @returns - An object with the serialized config.
  48063. */
  48064. serialize(): any;
  48065. /**
  48066. * Parses a anisotropy Configuration from a serialized object.
  48067. * @param source - Serialized object.
  48068. * @param scene Defines the scene we are parsing for
  48069. * @param rootUrl Defines the rootUrl to load from
  48070. */
  48071. parse(source: any, scene: Scene, rootUrl: string): void;
  48072. }
  48073. }
  48074. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48075. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48076. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48078. import { Vector2 } from "babylonjs/Maths/math.vector";
  48079. import { Scene } from "babylonjs/scene";
  48080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48081. import { Nullable } from "babylonjs/types";
  48082. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48083. /**
  48084. * @hidden
  48085. */
  48086. export interface IMaterialAnisotropicDefines {
  48087. ANISOTROPIC: boolean;
  48088. ANISOTROPIC_TEXTURE: boolean;
  48089. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48090. MAINUV1: boolean;
  48091. _areTexturesDirty: boolean;
  48092. _needUVs: boolean;
  48093. }
  48094. /**
  48095. * Define the code related to the anisotropic parameters of the pbr material.
  48096. */
  48097. export class PBRAnisotropicConfiguration {
  48098. private _isEnabled;
  48099. /**
  48100. * Defines if the anisotropy is enabled in the material.
  48101. */
  48102. isEnabled: boolean;
  48103. /**
  48104. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48105. */
  48106. intensity: number;
  48107. /**
  48108. * Defines if the effect is along the tangents, bitangents or in between.
  48109. * By default, the effect is "strectching" the highlights along the tangents.
  48110. */
  48111. direction: Vector2;
  48112. private _texture;
  48113. /**
  48114. * Stores the anisotropy values in a texture.
  48115. * rg is direction (like normal from -1 to 1)
  48116. * b is a intensity
  48117. */
  48118. texture: Nullable<BaseTexture>;
  48119. /** @hidden */
  48120. private _internalMarkAllSubMeshesAsTexturesDirty;
  48121. /** @hidden */
  48122. _markAllSubMeshesAsTexturesDirty(): void;
  48123. /**
  48124. * Instantiate a new istance of anisotropy configuration.
  48125. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48126. */
  48127. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48128. /**
  48129. * Specifies that the submesh is ready to be used.
  48130. * @param defines the list of "defines" to update.
  48131. * @param scene defines the scene the material belongs to.
  48132. * @returns - boolean indicating that the submesh is ready or not.
  48133. */
  48134. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48135. /**
  48136. * Checks to see if a texture is used in the material.
  48137. * @param defines the list of "defines" to update.
  48138. * @param mesh the mesh we are preparing the defines for.
  48139. * @param scene defines the scene the material belongs to.
  48140. */
  48141. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48142. /**
  48143. * Binds the material data.
  48144. * @param uniformBuffer defines the Uniform buffer to fill in.
  48145. * @param scene defines the scene the material belongs to.
  48146. * @param isFrozen defines wether the material is frozen or not.
  48147. */
  48148. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48149. /**
  48150. * Checks to see if a texture is used in the material.
  48151. * @param texture - Base texture to use.
  48152. * @returns - Boolean specifying if a texture is used in the material.
  48153. */
  48154. hasTexture(texture: BaseTexture): boolean;
  48155. /**
  48156. * Returns an array of the actively used textures.
  48157. * @param activeTextures Array of BaseTextures
  48158. */
  48159. getActiveTextures(activeTextures: BaseTexture[]): void;
  48160. /**
  48161. * Returns the animatable textures.
  48162. * @param animatables Array of animatable textures.
  48163. */
  48164. getAnimatables(animatables: IAnimatable[]): void;
  48165. /**
  48166. * Disposes the resources of the material.
  48167. * @param forceDisposeTextures - Forces the disposal of all textures.
  48168. */
  48169. dispose(forceDisposeTextures?: boolean): void;
  48170. /**
  48171. * Get the current class name of the texture useful for serialization or dynamic coding.
  48172. * @returns "PBRAnisotropicConfiguration"
  48173. */
  48174. getClassName(): string;
  48175. /**
  48176. * Add fallbacks to the effect fallbacks list.
  48177. * @param defines defines the Base texture to use.
  48178. * @param fallbacks defines the current fallback list.
  48179. * @param currentRank defines the current fallback rank.
  48180. * @returns the new fallback rank.
  48181. */
  48182. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48183. /**
  48184. * Add the required uniforms to the current list.
  48185. * @param uniforms defines the current uniform list.
  48186. */
  48187. static AddUniforms(uniforms: string[]): void;
  48188. /**
  48189. * Add the required uniforms to the current buffer.
  48190. * @param uniformBuffer defines the current uniform buffer.
  48191. */
  48192. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48193. /**
  48194. * Add the required samplers to the current list.
  48195. * @param samplers defines the current sampler list.
  48196. */
  48197. static AddSamplers(samplers: string[]): void;
  48198. /**
  48199. * Makes a duplicate of the current configuration into another one.
  48200. * @param anisotropicConfiguration define the config where to copy the info
  48201. */
  48202. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48203. /**
  48204. * Serializes this anisotropy configuration.
  48205. * @returns - An object with the serialized config.
  48206. */
  48207. serialize(): any;
  48208. /**
  48209. * Parses a anisotropy Configuration from a serialized object.
  48210. * @param source - Serialized object.
  48211. * @param scene Defines the scene we are parsing for
  48212. * @param rootUrl Defines the rootUrl to load from
  48213. */
  48214. parse(source: any, scene: Scene, rootUrl: string): void;
  48215. }
  48216. }
  48217. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48218. import { Scene } from "babylonjs/scene";
  48219. /**
  48220. * @hidden
  48221. */
  48222. export interface IMaterialBRDFDefines {
  48223. BRDF_V_HEIGHT_CORRELATED: boolean;
  48224. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48225. SPHERICAL_HARMONICS: boolean;
  48226. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48227. /** @hidden */
  48228. _areMiscDirty: boolean;
  48229. }
  48230. /**
  48231. * Define the code related to the BRDF parameters of the pbr material.
  48232. */
  48233. export class PBRBRDFConfiguration {
  48234. /**
  48235. * Default value used for the energy conservation.
  48236. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48237. */
  48238. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48239. /**
  48240. * Default value used for the Smith Visibility Height Correlated mode.
  48241. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48242. */
  48243. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48244. /**
  48245. * Default value used for the IBL diffuse part.
  48246. * This can help switching back to the polynomials mode globally which is a tiny bit
  48247. * less GPU intensive at the drawback of a lower quality.
  48248. */
  48249. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48250. /**
  48251. * Default value used for activating energy conservation for the specular workflow.
  48252. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48253. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48254. */
  48255. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48256. private _useEnergyConservation;
  48257. /**
  48258. * Defines if the material uses energy conservation.
  48259. */
  48260. useEnergyConservation: boolean;
  48261. private _useSmithVisibilityHeightCorrelated;
  48262. /**
  48263. * LEGACY Mode set to false
  48264. * Defines if the material uses height smith correlated visibility term.
  48265. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48266. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48267. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48268. * Not relying on height correlated will also disable energy conservation.
  48269. */
  48270. useSmithVisibilityHeightCorrelated: boolean;
  48271. private _useSphericalHarmonics;
  48272. /**
  48273. * LEGACY Mode set to false
  48274. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48275. * diffuse part of the IBL.
  48276. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48277. * to the ground truth.
  48278. */
  48279. useSphericalHarmonics: boolean;
  48280. private _useSpecularGlossinessInputEnergyConservation;
  48281. /**
  48282. * Defines if the material uses energy conservation, when the specular workflow is active.
  48283. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48284. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48285. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48286. */
  48287. useSpecularGlossinessInputEnergyConservation: boolean;
  48288. /** @hidden */
  48289. private _internalMarkAllSubMeshesAsMiscDirty;
  48290. /** @hidden */
  48291. _markAllSubMeshesAsMiscDirty(): void;
  48292. /**
  48293. * Instantiate a new istance of clear coat configuration.
  48294. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48295. */
  48296. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48297. /**
  48298. * Checks to see if a texture is used in the material.
  48299. * @param defines the list of "defines" to update.
  48300. */
  48301. prepareDefines(defines: IMaterialBRDFDefines): void;
  48302. /**
  48303. * Get the current class name of the texture useful for serialization or dynamic coding.
  48304. * @returns "PBRClearCoatConfiguration"
  48305. */
  48306. getClassName(): string;
  48307. /**
  48308. * Makes a duplicate of the current configuration into another one.
  48309. * @param brdfConfiguration define the config where to copy the info
  48310. */
  48311. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48312. /**
  48313. * Serializes this BRDF configuration.
  48314. * @returns - An object with the serialized config.
  48315. */
  48316. serialize(): any;
  48317. /**
  48318. * Parses a anisotropy Configuration from a serialized object.
  48319. * @param source - Serialized object.
  48320. * @param scene Defines the scene we are parsing for
  48321. * @param rootUrl Defines the rootUrl to load from
  48322. */
  48323. parse(source: any, scene: Scene, rootUrl: string): void;
  48324. }
  48325. }
  48326. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48327. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48328. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48329. import { Color3 } from "babylonjs/Maths/math.color";
  48330. import { Scene } from "babylonjs/scene";
  48331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48332. import { Nullable } from "babylonjs/types";
  48333. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48334. /**
  48335. * @hidden
  48336. */
  48337. export interface IMaterialSheenDefines {
  48338. SHEEN: boolean;
  48339. SHEEN_TEXTURE: boolean;
  48340. SHEEN_TEXTUREDIRECTUV: number;
  48341. SHEEN_LINKWITHALBEDO: boolean;
  48342. /** @hidden */
  48343. _areTexturesDirty: boolean;
  48344. }
  48345. /**
  48346. * Define the code related to the Sheen parameters of the pbr material.
  48347. */
  48348. export class PBRSheenConfiguration {
  48349. private _isEnabled;
  48350. /**
  48351. * Defines if the material uses sheen.
  48352. */
  48353. isEnabled: boolean;
  48354. private _linkSheenWithAlbedo;
  48355. /**
  48356. * Defines if the sheen is linked to the sheen color.
  48357. */
  48358. linkSheenWithAlbedo: boolean;
  48359. /**
  48360. * Defines the sheen intensity.
  48361. */
  48362. intensity: number;
  48363. /**
  48364. * Defines the sheen color.
  48365. */
  48366. color: Color3;
  48367. private _texture;
  48368. /**
  48369. * Stores the sheen tint values in a texture.
  48370. * rgb is tint
  48371. * a is a intensity
  48372. */
  48373. texture: Nullable<BaseTexture>;
  48374. /** @hidden */
  48375. private _internalMarkAllSubMeshesAsTexturesDirty;
  48376. /** @hidden */
  48377. _markAllSubMeshesAsTexturesDirty(): void;
  48378. /**
  48379. * Instantiate a new istance of clear coat configuration.
  48380. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48381. */
  48382. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48383. /**
  48384. * Specifies that the submesh is ready to be used.
  48385. * @param defines the list of "defines" to update.
  48386. * @param scene defines the scene the material belongs to.
  48387. * @returns - boolean indicating that the submesh is ready or not.
  48388. */
  48389. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48390. /**
  48391. * Checks to see if a texture is used in the material.
  48392. * @param defines the list of "defines" to update.
  48393. * @param scene defines the scene the material belongs to.
  48394. */
  48395. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48396. /**
  48397. * Binds the material data.
  48398. * @param uniformBuffer defines the Uniform buffer to fill in.
  48399. * @param scene defines the scene the material belongs to.
  48400. * @param isFrozen defines wether the material is frozen or not.
  48401. */
  48402. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48403. /**
  48404. * Checks to see if a texture is used in the material.
  48405. * @param texture - Base texture to use.
  48406. * @returns - Boolean specifying if a texture is used in the material.
  48407. */
  48408. hasTexture(texture: BaseTexture): boolean;
  48409. /**
  48410. * Returns an array of the actively used textures.
  48411. * @param activeTextures Array of BaseTextures
  48412. */
  48413. getActiveTextures(activeTextures: BaseTexture[]): void;
  48414. /**
  48415. * Returns the animatable textures.
  48416. * @param animatables Array of animatable textures.
  48417. */
  48418. getAnimatables(animatables: IAnimatable[]): void;
  48419. /**
  48420. * Disposes the resources of the material.
  48421. * @param forceDisposeTextures - Forces the disposal of all textures.
  48422. */
  48423. dispose(forceDisposeTextures?: boolean): void;
  48424. /**
  48425. * Get the current class name of the texture useful for serialization or dynamic coding.
  48426. * @returns "PBRSheenConfiguration"
  48427. */
  48428. getClassName(): string;
  48429. /**
  48430. * Add fallbacks to the effect fallbacks list.
  48431. * @param defines defines the Base texture to use.
  48432. * @param fallbacks defines the current fallback list.
  48433. * @param currentRank defines the current fallback rank.
  48434. * @returns the new fallback rank.
  48435. */
  48436. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48437. /**
  48438. * Add the required uniforms to the current list.
  48439. * @param uniforms defines the current uniform list.
  48440. */
  48441. static AddUniforms(uniforms: string[]): void;
  48442. /**
  48443. * Add the required uniforms to the current buffer.
  48444. * @param uniformBuffer defines the current uniform buffer.
  48445. */
  48446. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48447. /**
  48448. * Add the required samplers to the current list.
  48449. * @param samplers defines the current sampler list.
  48450. */
  48451. static AddSamplers(samplers: string[]): void;
  48452. /**
  48453. * Makes a duplicate of the current configuration into another one.
  48454. * @param sheenConfiguration define the config where to copy the info
  48455. */
  48456. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48457. /**
  48458. * Serializes this BRDF configuration.
  48459. * @returns - An object with the serialized config.
  48460. */
  48461. serialize(): any;
  48462. /**
  48463. * Parses a anisotropy Configuration from a serialized object.
  48464. * @param source - Serialized object.
  48465. * @param scene Defines the scene we are parsing for
  48466. * @param rootUrl Defines the rootUrl to load from
  48467. */
  48468. parse(source: any, scene: Scene, rootUrl: string): void;
  48469. }
  48470. }
  48471. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48472. import { Nullable } from "babylonjs/types";
  48473. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48474. import { Color3 } from "babylonjs/Maths/math.color";
  48475. import { SmartArray } from "babylonjs/Misc/smartArray";
  48476. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48477. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48478. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  48479. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48480. import { Engine } from "babylonjs/Engines/engine";
  48481. import { Scene } from "babylonjs/scene";
  48482. /**
  48483. * @hidden
  48484. */
  48485. export interface IMaterialSubSurfaceDefines {
  48486. SUBSURFACE: boolean;
  48487. SS_REFRACTION: boolean;
  48488. SS_TRANSLUCENCY: boolean;
  48489. SS_SCATERRING: boolean;
  48490. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48491. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48492. SS_REFRACTIONMAP_3D: boolean;
  48493. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48494. SS_LODINREFRACTIONALPHA: boolean;
  48495. SS_GAMMAREFRACTION: boolean;
  48496. SS_RGBDREFRACTION: boolean;
  48497. SS_LINEARSPECULARREFRACTION: boolean;
  48498. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48499. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48500. /** @hidden */
  48501. _areTexturesDirty: boolean;
  48502. }
  48503. /**
  48504. * Define the code related to the sub surface parameters of the pbr material.
  48505. */
  48506. export class PBRSubSurfaceConfiguration {
  48507. private _isRefractionEnabled;
  48508. /**
  48509. * Defines if the refraction is enabled in the material.
  48510. */
  48511. isRefractionEnabled: boolean;
  48512. private _isTranslucencyEnabled;
  48513. /**
  48514. * Defines if the translucency is enabled in the material.
  48515. */
  48516. isTranslucencyEnabled: boolean;
  48517. private _isScatteringEnabled;
  48518. /**
  48519. * Defines the refraction intensity of the material.
  48520. * The refraction when enabled replaces the Diffuse part of the material.
  48521. * The intensity helps transitionning between diffuse and refraction.
  48522. */
  48523. refractionIntensity: number;
  48524. /**
  48525. * Defines the translucency intensity of the material.
  48526. * When translucency has been enabled, this defines how much of the "translucency"
  48527. * is addded to the diffuse part of the material.
  48528. */
  48529. translucencyIntensity: number;
  48530. /**
  48531. * Defines the scattering intensity of the material.
  48532. * When scattering has been enabled, this defines how much of the "scattered light"
  48533. * is addded to the diffuse part of the material.
  48534. */
  48535. scatteringIntensity: number;
  48536. private _thicknessTexture;
  48537. /**
  48538. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48539. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48540. * 0 would mean minimumThickness
  48541. * 1 would mean maximumThickness
  48542. * The other channels might be use as a mask to vary the different effects intensity.
  48543. */
  48544. thicknessTexture: Nullable<BaseTexture>;
  48545. private _refractionTexture;
  48546. /**
  48547. * Defines the texture to use for refraction.
  48548. */
  48549. refractionTexture: Nullable<BaseTexture>;
  48550. private _indexOfRefraction;
  48551. /**
  48552. * Defines the index of refraction used in the material.
  48553. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48554. */
  48555. indexOfRefraction: number;
  48556. private _invertRefractionY;
  48557. /**
  48558. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48559. */
  48560. invertRefractionY: boolean;
  48561. private _linkRefractionWithTransparency;
  48562. /**
  48563. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48564. * Materials half opaque for instance using refraction could benefit from this control.
  48565. */
  48566. linkRefractionWithTransparency: boolean;
  48567. /**
  48568. * Defines the minimum thickness stored in the thickness map.
  48569. * If no thickness map is defined, this value will be used to simulate thickness.
  48570. */
  48571. minimumThickness: number;
  48572. /**
  48573. * Defines the maximum thickness stored in the thickness map.
  48574. */
  48575. maximumThickness: number;
  48576. /**
  48577. * Defines the volume tint of the material.
  48578. * This is used for both translucency and scattering.
  48579. */
  48580. tintColor: Color3;
  48581. /**
  48582. * Defines the distance at which the tint color should be found in the media.
  48583. * This is used for refraction only.
  48584. */
  48585. tintColorAtDistance: number;
  48586. /**
  48587. * Defines how far each channel transmit through the media.
  48588. * It is defined as a color to simplify it selection.
  48589. */
  48590. diffusionDistance: Color3;
  48591. private _useMaskFromThicknessTexture;
  48592. /**
  48593. * Stores the intensity of the different subsurface effects in the thickness texture.
  48594. * * the green channel is the translucency intensity.
  48595. * * the blue channel is the scattering intensity.
  48596. * * the alpha channel is the refraction intensity.
  48597. */
  48598. useMaskFromThicknessTexture: boolean;
  48599. /** @hidden */
  48600. private _internalMarkAllSubMeshesAsTexturesDirty;
  48601. /** @hidden */
  48602. _markAllSubMeshesAsTexturesDirty(): void;
  48603. /**
  48604. * Instantiate a new istance of sub surface configuration.
  48605. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48606. */
  48607. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48608. /**
  48609. * Gets wehter the submesh is ready to be used or not.
  48610. * @param defines the list of "defines" to update.
  48611. * @param scene defines the scene the material belongs to.
  48612. * @returns - boolean indicating that the submesh is ready or not.
  48613. */
  48614. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48615. /**
  48616. * Checks to see if a texture is used in the material.
  48617. * @param defines the list of "defines" to update.
  48618. * @param scene defines the scene to the material belongs to.
  48619. */
  48620. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48621. /**
  48622. * Binds the material data.
  48623. * @param uniformBuffer defines the Uniform buffer to fill in.
  48624. * @param scene defines the scene the material belongs to.
  48625. * @param engine defines the engine the material belongs to.
  48626. * @param isFrozen defines wether the material is frozen or not.
  48627. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48628. */
  48629. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48630. /**
  48631. * Unbinds the material from the mesh.
  48632. * @param activeEffect defines the effect that should be unbound from.
  48633. * @returns true if unbound, otherwise false
  48634. */
  48635. unbind(activeEffect: Effect): boolean;
  48636. /**
  48637. * Returns the texture used for refraction or null if none is used.
  48638. * @param scene defines the scene the material belongs to.
  48639. * @returns - Refraction texture if present. If no refraction texture and refraction
  48640. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48641. */
  48642. private _getRefractionTexture;
  48643. /**
  48644. * Returns true if alpha blending should be disabled.
  48645. */
  48646. readonly disableAlphaBlending: boolean;
  48647. /**
  48648. * Fills the list of render target textures.
  48649. * @param renderTargets the list of render targets to update
  48650. */
  48651. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48652. /**
  48653. * Checks to see if a texture is used in the material.
  48654. * @param texture - Base texture to use.
  48655. * @returns - Boolean specifying if a texture is used in the material.
  48656. */
  48657. hasTexture(texture: BaseTexture): boolean;
  48658. /**
  48659. * Gets a boolean indicating that current material needs to register RTT
  48660. * @returns true if this uses a render target otherwise false.
  48661. */
  48662. hasRenderTargetTextures(): boolean;
  48663. /**
  48664. * Returns an array of the actively used textures.
  48665. * @param activeTextures Array of BaseTextures
  48666. */
  48667. getActiveTextures(activeTextures: BaseTexture[]): void;
  48668. /**
  48669. * Returns the animatable textures.
  48670. * @param animatables Array of animatable textures.
  48671. */
  48672. getAnimatables(animatables: IAnimatable[]): void;
  48673. /**
  48674. * Disposes the resources of the material.
  48675. * @param forceDisposeTextures - Forces the disposal of all textures.
  48676. */
  48677. dispose(forceDisposeTextures?: boolean): void;
  48678. /**
  48679. * Get the current class name of the texture useful for serialization or dynamic coding.
  48680. * @returns "PBRSubSurfaceConfiguration"
  48681. */
  48682. getClassName(): string;
  48683. /**
  48684. * Add fallbacks to the effect fallbacks list.
  48685. * @param defines defines the Base texture to use.
  48686. * @param fallbacks defines the current fallback list.
  48687. * @param currentRank defines the current fallback rank.
  48688. * @returns the new fallback rank.
  48689. */
  48690. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48691. /**
  48692. * Add the required uniforms to the current list.
  48693. * @param uniforms defines the current uniform list.
  48694. */
  48695. static AddUniforms(uniforms: string[]): void;
  48696. /**
  48697. * Add the required samplers to the current list.
  48698. * @param samplers defines the current sampler list.
  48699. */
  48700. static AddSamplers(samplers: string[]): void;
  48701. /**
  48702. * Add the required uniforms to the current buffer.
  48703. * @param uniformBuffer defines the current uniform buffer.
  48704. */
  48705. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48706. /**
  48707. * Makes a duplicate of the current configuration into another one.
  48708. * @param configuration define the config where to copy the info
  48709. */
  48710. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48711. /**
  48712. * Serializes this Sub Surface configuration.
  48713. * @returns - An object with the serialized config.
  48714. */
  48715. serialize(): any;
  48716. /**
  48717. * Parses a anisotropy Configuration from a serialized object.
  48718. * @param source - Serialized object.
  48719. * @param scene Defines the scene we are parsing for
  48720. * @param rootUrl Defines the rootUrl to load from
  48721. */
  48722. parse(source: any, scene: Scene, rootUrl: string): void;
  48723. }
  48724. }
  48725. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48726. /** @hidden */
  48727. export var pbrFragmentDeclaration: {
  48728. name: string;
  48729. shader: string;
  48730. };
  48731. }
  48732. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48733. /** @hidden */
  48734. export var pbrUboDeclaration: {
  48735. name: string;
  48736. shader: string;
  48737. };
  48738. }
  48739. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48740. /** @hidden */
  48741. export var pbrFragmentExtraDeclaration: {
  48742. name: string;
  48743. shader: string;
  48744. };
  48745. }
  48746. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48747. /** @hidden */
  48748. export var pbrFragmentSamplersDeclaration: {
  48749. name: string;
  48750. shader: string;
  48751. };
  48752. }
  48753. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48754. /** @hidden */
  48755. export var pbrHelperFunctions: {
  48756. name: string;
  48757. shader: string;
  48758. };
  48759. }
  48760. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48761. /** @hidden */
  48762. export var harmonicsFunctions: {
  48763. name: string;
  48764. shader: string;
  48765. };
  48766. }
  48767. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48768. /** @hidden */
  48769. export var pbrDirectLightingSetupFunctions: {
  48770. name: string;
  48771. shader: string;
  48772. };
  48773. }
  48774. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48775. /** @hidden */
  48776. export var pbrDirectLightingFalloffFunctions: {
  48777. name: string;
  48778. shader: string;
  48779. };
  48780. }
  48781. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48782. /** @hidden */
  48783. export var pbrBRDFFunctions: {
  48784. name: string;
  48785. shader: string;
  48786. };
  48787. }
  48788. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48789. /** @hidden */
  48790. export var pbrDirectLightingFunctions: {
  48791. name: string;
  48792. shader: string;
  48793. };
  48794. }
  48795. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48796. /** @hidden */
  48797. export var pbrIBLFunctions: {
  48798. name: string;
  48799. shader: string;
  48800. };
  48801. }
  48802. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48803. /** @hidden */
  48804. export var pbrDebug: {
  48805. name: string;
  48806. shader: string;
  48807. };
  48808. }
  48809. declare module "babylonjs/Shaders/pbr.fragment" {
  48810. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48811. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48812. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48813. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48814. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48815. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48816. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48817. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48818. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48819. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48820. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48821. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48822. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48823. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48824. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48825. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48826. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48827. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48828. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48829. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48830. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48831. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48832. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48833. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48834. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48835. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48836. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48837. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48838. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48839. /** @hidden */
  48840. export var pbrPixelShader: {
  48841. name: string;
  48842. shader: string;
  48843. };
  48844. }
  48845. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48846. /** @hidden */
  48847. export var pbrVertexDeclaration: {
  48848. name: string;
  48849. shader: string;
  48850. };
  48851. }
  48852. declare module "babylonjs/Shaders/pbr.vertex" {
  48853. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48854. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48855. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48856. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48857. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48858. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48859. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48860. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48861. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48862. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48863. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48864. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48865. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48866. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48867. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48868. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48869. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48870. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48871. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48872. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48873. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48874. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48875. /** @hidden */
  48876. export var pbrVertexShader: {
  48877. name: string;
  48878. shader: string;
  48879. };
  48880. }
  48881. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48882. import { Nullable } from "babylonjs/types";
  48883. import { Scene } from "babylonjs/scene";
  48884. import { Matrix } from "babylonjs/Maths/math.vector";
  48885. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48887. import { Mesh } from "babylonjs/Meshes/mesh";
  48888. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48889. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48890. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48891. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48892. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48893. import { Color3 } from "babylonjs/Maths/math.color";
  48894. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48895. import { Material } from "babylonjs/Materials/material";
  48896. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48897. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48898. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48899. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48900. import "babylonjs/Shaders/pbr.fragment";
  48901. import "babylonjs/Shaders/pbr.vertex";
  48902. /**
  48903. * Manages the defines for the PBR Material.
  48904. * @hidden
  48905. */
  48906. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48907. PBR: boolean;
  48908. MAINUV1: boolean;
  48909. MAINUV2: boolean;
  48910. UV1: boolean;
  48911. UV2: boolean;
  48912. ALBEDO: boolean;
  48913. ALBEDODIRECTUV: number;
  48914. VERTEXCOLOR: boolean;
  48915. AMBIENT: boolean;
  48916. AMBIENTDIRECTUV: number;
  48917. AMBIENTINGRAYSCALE: boolean;
  48918. OPACITY: boolean;
  48919. VERTEXALPHA: boolean;
  48920. OPACITYDIRECTUV: number;
  48921. OPACITYRGB: boolean;
  48922. ALPHATEST: boolean;
  48923. DEPTHPREPASS: boolean;
  48924. ALPHABLEND: boolean;
  48925. ALPHAFROMALBEDO: boolean;
  48926. ALPHATESTVALUE: string;
  48927. SPECULAROVERALPHA: boolean;
  48928. RADIANCEOVERALPHA: boolean;
  48929. ALPHAFRESNEL: boolean;
  48930. LINEARALPHAFRESNEL: boolean;
  48931. PREMULTIPLYALPHA: boolean;
  48932. EMISSIVE: boolean;
  48933. EMISSIVEDIRECTUV: number;
  48934. REFLECTIVITY: boolean;
  48935. REFLECTIVITYDIRECTUV: number;
  48936. SPECULARTERM: boolean;
  48937. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48938. MICROSURFACEAUTOMATIC: boolean;
  48939. LODBASEDMICROSFURACE: boolean;
  48940. MICROSURFACEMAP: boolean;
  48941. MICROSURFACEMAPDIRECTUV: number;
  48942. METALLICWORKFLOW: boolean;
  48943. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48944. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48945. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48946. AOSTOREINMETALMAPRED: boolean;
  48947. ENVIRONMENTBRDF: boolean;
  48948. ENVIRONMENTBRDF_RGBD: boolean;
  48949. NORMAL: boolean;
  48950. TANGENT: boolean;
  48951. BUMP: boolean;
  48952. BUMPDIRECTUV: number;
  48953. OBJECTSPACE_NORMALMAP: boolean;
  48954. PARALLAX: boolean;
  48955. PARALLAXOCCLUSION: boolean;
  48956. NORMALXYSCALE: boolean;
  48957. LIGHTMAP: boolean;
  48958. LIGHTMAPDIRECTUV: number;
  48959. USELIGHTMAPASSHADOWMAP: boolean;
  48960. GAMMALIGHTMAP: boolean;
  48961. RGBDLIGHTMAP: boolean;
  48962. REFLECTION: boolean;
  48963. REFLECTIONMAP_3D: boolean;
  48964. REFLECTIONMAP_SPHERICAL: boolean;
  48965. REFLECTIONMAP_PLANAR: boolean;
  48966. REFLECTIONMAP_CUBIC: boolean;
  48967. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48968. REFLECTIONMAP_PROJECTION: boolean;
  48969. REFLECTIONMAP_SKYBOX: boolean;
  48970. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48971. REFLECTIONMAP_EXPLICIT: boolean;
  48972. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48973. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48974. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48975. INVERTCUBICMAP: boolean;
  48976. USESPHERICALFROMREFLECTIONMAP: boolean;
  48977. USEIRRADIANCEMAP: boolean;
  48978. SPHERICAL_HARMONICS: boolean;
  48979. USESPHERICALINVERTEX: boolean;
  48980. REFLECTIONMAP_OPPOSITEZ: boolean;
  48981. LODINREFLECTIONALPHA: boolean;
  48982. GAMMAREFLECTION: boolean;
  48983. RGBDREFLECTION: boolean;
  48984. LINEARSPECULARREFLECTION: boolean;
  48985. RADIANCEOCCLUSION: boolean;
  48986. HORIZONOCCLUSION: boolean;
  48987. INSTANCES: boolean;
  48988. NUM_BONE_INFLUENCERS: number;
  48989. BonesPerMesh: number;
  48990. BONETEXTURE: boolean;
  48991. NONUNIFORMSCALING: boolean;
  48992. MORPHTARGETS: boolean;
  48993. MORPHTARGETS_NORMAL: boolean;
  48994. MORPHTARGETS_TANGENT: boolean;
  48995. MORPHTARGETS_UV: boolean;
  48996. NUM_MORPH_INFLUENCERS: number;
  48997. IMAGEPROCESSING: boolean;
  48998. VIGNETTE: boolean;
  48999. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49000. VIGNETTEBLENDMODEOPAQUE: boolean;
  49001. TONEMAPPING: boolean;
  49002. TONEMAPPING_ACES: boolean;
  49003. CONTRAST: boolean;
  49004. COLORCURVES: boolean;
  49005. COLORGRADING: boolean;
  49006. COLORGRADING3D: boolean;
  49007. SAMPLER3DGREENDEPTH: boolean;
  49008. SAMPLER3DBGRMAP: boolean;
  49009. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49010. EXPOSURE: boolean;
  49011. MULTIVIEW: boolean;
  49012. USEPHYSICALLIGHTFALLOFF: boolean;
  49013. USEGLTFLIGHTFALLOFF: boolean;
  49014. TWOSIDEDLIGHTING: boolean;
  49015. SHADOWFLOAT: boolean;
  49016. CLIPPLANE: boolean;
  49017. CLIPPLANE2: boolean;
  49018. CLIPPLANE3: boolean;
  49019. CLIPPLANE4: boolean;
  49020. POINTSIZE: boolean;
  49021. FOG: boolean;
  49022. LOGARITHMICDEPTH: boolean;
  49023. FORCENORMALFORWARD: boolean;
  49024. SPECULARAA: boolean;
  49025. CLEARCOAT: boolean;
  49026. CLEARCOAT_DEFAULTIOR: boolean;
  49027. CLEARCOAT_TEXTURE: boolean;
  49028. CLEARCOAT_TEXTUREDIRECTUV: number;
  49029. CLEARCOAT_BUMP: boolean;
  49030. CLEARCOAT_BUMPDIRECTUV: number;
  49031. CLEARCOAT_TINT: boolean;
  49032. CLEARCOAT_TINT_TEXTURE: boolean;
  49033. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49034. ANISOTROPIC: boolean;
  49035. ANISOTROPIC_TEXTURE: boolean;
  49036. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49037. BRDF_V_HEIGHT_CORRELATED: boolean;
  49038. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49039. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49040. SHEEN: boolean;
  49041. SHEEN_TEXTURE: boolean;
  49042. SHEEN_TEXTUREDIRECTUV: number;
  49043. SHEEN_LINKWITHALBEDO: boolean;
  49044. SUBSURFACE: boolean;
  49045. SS_REFRACTION: boolean;
  49046. SS_TRANSLUCENCY: boolean;
  49047. SS_SCATERRING: boolean;
  49048. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49049. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49050. SS_REFRACTIONMAP_3D: boolean;
  49051. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49052. SS_LODINREFRACTIONALPHA: boolean;
  49053. SS_GAMMAREFRACTION: boolean;
  49054. SS_RGBDREFRACTION: boolean;
  49055. SS_LINEARSPECULARREFRACTION: boolean;
  49056. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49057. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49058. UNLIT: boolean;
  49059. DEBUGMODE: number;
  49060. /**
  49061. * Initializes the PBR Material defines.
  49062. */
  49063. constructor();
  49064. /**
  49065. * Resets the PBR Material defines.
  49066. */
  49067. reset(): void;
  49068. }
  49069. /**
  49070. * The Physically based material base class of BJS.
  49071. *
  49072. * This offers the main features of a standard PBR material.
  49073. * For more information, please refer to the documentation :
  49074. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49075. */
  49076. export abstract class PBRBaseMaterial extends PushMaterial {
  49077. /**
  49078. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49079. */
  49080. static readonly PBRMATERIAL_OPAQUE: number;
  49081. /**
  49082. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49083. */
  49084. static readonly PBRMATERIAL_ALPHATEST: number;
  49085. /**
  49086. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49087. */
  49088. static readonly PBRMATERIAL_ALPHABLEND: number;
  49089. /**
  49090. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49091. * They are also discarded below the alpha cutoff threshold to improve performances.
  49092. */
  49093. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49094. /**
  49095. * Defines the default value of how much AO map is occluding the analytical lights
  49096. * (point spot...).
  49097. */
  49098. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49099. /**
  49100. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49101. */
  49102. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49103. /**
  49104. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49105. * to enhance interoperability with other engines.
  49106. */
  49107. static readonly LIGHTFALLOFF_GLTF: number;
  49108. /**
  49109. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49110. * to enhance interoperability with other materials.
  49111. */
  49112. static readonly LIGHTFALLOFF_STANDARD: number;
  49113. /**
  49114. * Intensity of the direct lights e.g. the four lights available in your scene.
  49115. * This impacts both the direct diffuse and specular highlights.
  49116. */
  49117. protected _directIntensity: number;
  49118. /**
  49119. * Intensity of the emissive part of the material.
  49120. * This helps controlling the emissive effect without modifying the emissive color.
  49121. */
  49122. protected _emissiveIntensity: number;
  49123. /**
  49124. * Intensity of the environment e.g. how much the environment will light the object
  49125. * either through harmonics for rough material or through the refelction for shiny ones.
  49126. */
  49127. protected _environmentIntensity: number;
  49128. /**
  49129. * This is a special control allowing the reduction of the specular highlights coming from the
  49130. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49131. */
  49132. protected _specularIntensity: number;
  49133. /**
  49134. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49135. */
  49136. private _lightingInfos;
  49137. /**
  49138. * Debug Control allowing disabling the bump map on this material.
  49139. */
  49140. protected _disableBumpMap: boolean;
  49141. /**
  49142. * AKA Diffuse Texture in standard nomenclature.
  49143. */
  49144. protected _albedoTexture: Nullable<BaseTexture>;
  49145. /**
  49146. * AKA Occlusion Texture in other nomenclature.
  49147. */
  49148. protected _ambientTexture: Nullable<BaseTexture>;
  49149. /**
  49150. * AKA Occlusion Texture Intensity in other nomenclature.
  49151. */
  49152. protected _ambientTextureStrength: number;
  49153. /**
  49154. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49155. * 1 means it completely occludes it
  49156. * 0 mean it has no impact
  49157. */
  49158. protected _ambientTextureImpactOnAnalyticalLights: number;
  49159. /**
  49160. * Stores the alpha values in a texture.
  49161. */
  49162. protected _opacityTexture: Nullable<BaseTexture>;
  49163. /**
  49164. * Stores the reflection values in a texture.
  49165. */
  49166. protected _reflectionTexture: Nullable<BaseTexture>;
  49167. /**
  49168. * Stores the emissive values in a texture.
  49169. */
  49170. protected _emissiveTexture: Nullable<BaseTexture>;
  49171. /**
  49172. * AKA Specular texture in other nomenclature.
  49173. */
  49174. protected _reflectivityTexture: Nullable<BaseTexture>;
  49175. /**
  49176. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49177. */
  49178. protected _metallicTexture: Nullable<BaseTexture>;
  49179. /**
  49180. * Specifies the metallic scalar of the metallic/roughness workflow.
  49181. * Can also be used to scale the metalness values of the metallic texture.
  49182. */
  49183. protected _metallic: Nullable<number>;
  49184. /**
  49185. * Specifies the roughness scalar of the metallic/roughness workflow.
  49186. * Can also be used to scale the roughness values of the metallic texture.
  49187. */
  49188. protected _roughness: Nullable<number>;
  49189. /**
  49190. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49191. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49192. */
  49193. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49194. /**
  49195. * Stores surface normal data used to displace a mesh in a texture.
  49196. */
  49197. protected _bumpTexture: Nullable<BaseTexture>;
  49198. /**
  49199. * Stores the pre-calculated light information of a mesh in a texture.
  49200. */
  49201. protected _lightmapTexture: Nullable<BaseTexture>;
  49202. /**
  49203. * The color of a material in ambient lighting.
  49204. */
  49205. protected _ambientColor: Color3;
  49206. /**
  49207. * AKA Diffuse Color in other nomenclature.
  49208. */
  49209. protected _albedoColor: Color3;
  49210. /**
  49211. * AKA Specular Color in other nomenclature.
  49212. */
  49213. protected _reflectivityColor: Color3;
  49214. /**
  49215. * The color applied when light is reflected from a material.
  49216. */
  49217. protected _reflectionColor: Color3;
  49218. /**
  49219. * The color applied when light is emitted from a material.
  49220. */
  49221. protected _emissiveColor: Color3;
  49222. /**
  49223. * AKA Glossiness in other nomenclature.
  49224. */
  49225. protected _microSurface: number;
  49226. /**
  49227. * Specifies that the material will use the light map as a show map.
  49228. */
  49229. protected _useLightmapAsShadowmap: boolean;
  49230. /**
  49231. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49232. * makes the reflect vector face the model (under horizon).
  49233. */
  49234. protected _useHorizonOcclusion: boolean;
  49235. /**
  49236. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49237. * too much the area relying on ambient texture to define their ambient occlusion.
  49238. */
  49239. protected _useRadianceOcclusion: boolean;
  49240. /**
  49241. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49242. */
  49243. protected _useAlphaFromAlbedoTexture: boolean;
  49244. /**
  49245. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49246. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49247. */
  49248. protected _useSpecularOverAlpha: boolean;
  49249. /**
  49250. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49251. */
  49252. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49253. /**
  49254. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49255. */
  49256. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49257. /**
  49258. * Specifies if the metallic texture contains the roughness information in its green channel.
  49259. */
  49260. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49261. /**
  49262. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49263. */
  49264. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49265. /**
  49266. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49267. */
  49268. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49269. /**
  49270. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49271. */
  49272. protected _useAmbientInGrayScale: boolean;
  49273. /**
  49274. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49275. * The material will try to infer what glossiness each pixel should be.
  49276. */
  49277. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49278. /**
  49279. * Defines the falloff type used in this material.
  49280. * It by default is Physical.
  49281. */
  49282. protected _lightFalloff: number;
  49283. /**
  49284. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49285. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49286. */
  49287. protected _useRadianceOverAlpha: boolean;
  49288. /**
  49289. * Allows using an object space normal map (instead of tangent space).
  49290. */
  49291. protected _useObjectSpaceNormalMap: boolean;
  49292. /**
  49293. * Allows using the bump map in parallax mode.
  49294. */
  49295. protected _useParallax: boolean;
  49296. /**
  49297. * Allows using the bump map in parallax occlusion mode.
  49298. */
  49299. protected _useParallaxOcclusion: boolean;
  49300. /**
  49301. * Controls the scale bias of the parallax mode.
  49302. */
  49303. protected _parallaxScaleBias: number;
  49304. /**
  49305. * If sets to true, disables all the lights affecting the material.
  49306. */
  49307. protected _disableLighting: boolean;
  49308. /**
  49309. * Number of Simultaneous lights allowed on the material.
  49310. */
  49311. protected _maxSimultaneousLights: number;
  49312. /**
  49313. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49314. */
  49315. protected _invertNormalMapX: boolean;
  49316. /**
  49317. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49318. */
  49319. protected _invertNormalMapY: boolean;
  49320. /**
  49321. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49322. */
  49323. protected _twoSidedLighting: boolean;
  49324. /**
  49325. * Defines the alpha limits in alpha test mode.
  49326. */
  49327. protected _alphaCutOff: number;
  49328. /**
  49329. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49330. */
  49331. protected _forceAlphaTest: boolean;
  49332. /**
  49333. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49334. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49335. */
  49336. protected _useAlphaFresnel: boolean;
  49337. /**
  49338. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49339. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49340. */
  49341. protected _useLinearAlphaFresnel: boolean;
  49342. /**
  49343. * The transparency mode of the material.
  49344. */
  49345. protected _transparencyMode: Nullable<number>;
  49346. /**
  49347. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49348. * from cos thetav and roughness:
  49349. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49350. */
  49351. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49352. /**
  49353. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49354. */
  49355. protected _forceIrradianceInFragment: boolean;
  49356. /**
  49357. * Force normal to face away from face.
  49358. */
  49359. protected _forceNormalForward: boolean;
  49360. /**
  49361. * Enables specular anti aliasing in the PBR shader.
  49362. * It will both interacts on the Geometry for analytical and IBL lighting.
  49363. * It also prefilter the roughness map based on the bump values.
  49364. */
  49365. protected _enableSpecularAntiAliasing: boolean;
  49366. /**
  49367. * Default configuration related to image processing available in the PBR Material.
  49368. */
  49369. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49370. /**
  49371. * Keep track of the image processing observer to allow dispose and replace.
  49372. */
  49373. private _imageProcessingObserver;
  49374. /**
  49375. * Attaches a new image processing configuration to the PBR Material.
  49376. * @param configuration
  49377. */
  49378. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49379. /**
  49380. * Stores the available render targets.
  49381. */
  49382. private _renderTargets;
  49383. /**
  49384. * Sets the global ambient color for the material used in lighting calculations.
  49385. */
  49386. private _globalAmbientColor;
  49387. /**
  49388. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49389. */
  49390. private _useLogarithmicDepth;
  49391. /**
  49392. * If set to true, no lighting calculations will be applied.
  49393. */
  49394. private _unlit;
  49395. private _debugMode;
  49396. /**
  49397. * @hidden
  49398. * This is reserved for the inspector.
  49399. * Defines the material debug mode.
  49400. * It helps seeing only some components of the material while troubleshooting.
  49401. */
  49402. debugMode: number;
  49403. /**
  49404. * @hidden
  49405. * This is reserved for the inspector.
  49406. * Specify from where on screen the debug mode should start.
  49407. * The value goes from -1 (full screen) to 1 (not visible)
  49408. * It helps with side by side comparison against the final render
  49409. * This defaults to -1
  49410. */
  49411. private debugLimit;
  49412. /**
  49413. * @hidden
  49414. * This is reserved for the inspector.
  49415. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49416. * You can use the factor to better multiply the final value.
  49417. */
  49418. private debugFactor;
  49419. /**
  49420. * Defines the clear coat layer parameters for the material.
  49421. */
  49422. readonly clearCoat: PBRClearCoatConfiguration;
  49423. /**
  49424. * Defines the anisotropic parameters for the material.
  49425. */
  49426. readonly anisotropy: PBRAnisotropicConfiguration;
  49427. /**
  49428. * Defines the BRDF parameters for the material.
  49429. */
  49430. readonly brdf: PBRBRDFConfiguration;
  49431. /**
  49432. * Defines the Sheen parameters for the material.
  49433. */
  49434. readonly sheen: PBRSheenConfiguration;
  49435. /**
  49436. * Defines the SubSurface parameters for the material.
  49437. */
  49438. readonly subSurface: PBRSubSurfaceConfiguration;
  49439. /**
  49440. * Custom callback helping to override the default shader used in the material.
  49441. */
  49442. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49443. protected _rebuildInParallel: boolean;
  49444. /**
  49445. * Instantiates a new PBRMaterial instance.
  49446. *
  49447. * @param name The material name
  49448. * @param scene The scene the material will be use in.
  49449. */
  49450. constructor(name: string, scene: Scene);
  49451. /**
  49452. * Gets a boolean indicating that current material needs to register RTT
  49453. */
  49454. readonly hasRenderTargetTextures: boolean;
  49455. /**
  49456. * Gets the name of the material class.
  49457. */
  49458. getClassName(): string;
  49459. /**
  49460. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49461. */
  49462. /**
  49463. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49464. */
  49465. useLogarithmicDepth: boolean;
  49466. /**
  49467. * Gets the current transparency mode.
  49468. */
  49469. /**
  49470. * Sets the transparency mode of the material.
  49471. *
  49472. * | Value | Type | Description |
  49473. * | ----- | ----------------------------------- | ----------- |
  49474. * | 0 | OPAQUE | |
  49475. * | 1 | ALPHATEST | |
  49476. * | 2 | ALPHABLEND | |
  49477. * | 3 | ALPHATESTANDBLEND | |
  49478. *
  49479. */
  49480. transparencyMode: Nullable<number>;
  49481. /**
  49482. * Returns true if alpha blending should be disabled.
  49483. */
  49484. private readonly _disableAlphaBlending;
  49485. /**
  49486. * Specifies whether or not this material should be rendered in alpha blend mode.
  49487. */
  49488. needAlphaBlending(): boolean;
  49489. /**
  49490. * Specifies if the mesh will require alpha blending.
  49491. * @param mesh - BJS mesh.
  49492. */
  49493. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49494. /**
  49495. * Specifies whether or not this material should be rendered in alpha test mode.
  49496. */
  49497. needAlphaTesting(): boolean;
  49498. /**
  49499. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49500. */
  49501. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49502. /**
  49503. * Gets the texture used for the alpha test.
  49504. */
  49505. getAlphaTestTexture(): Nullable<BaseTexture>;
  49506. /**
  49507. * Specifies that the submesh is ready to be used.
  49508. * @param mesh - BJS mesh.
  49509. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49510. * @param useInstances - Specifies that instances should be used.
  49511. * @returns - boolean indicating that the submesh is ready or not.
  49512. */
  49513. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49514. /**
  49515. * Specifies if the material uses metallic roughness workflow.
  49516. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49517. */
  49518. isMetallicWorkflow(): boolean;
  49519. private _prepareEffect;
  49520. private _prepareDefines;
  49521. /**
  49522. * Force shader compilation
  49523. */
  49524. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49525. clipPlane: boolean;
  49526. }>): void;
  49527. /**
  49528. * Initializes the uniform buffer layout for the shader.
  49529. */
  49530. buildUniformLayout(): void;
  49531. /**
  49532. * Unbinds the material from the mesh
  49533. */
  49534. unbind(): void;
  49535. /**
  49536. * Binds the submesh data.
  49537. * @param world - The world matrix.
  49538. * @param mesh - The BJS mesh.
  49539. * @param subMesh - A submesh of the BJS mesh.
  49540. */
  49541. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49542. /**
  49543. * Returns the animatable textures.
  49544. * @returns - Array of animatable textures.
  49545. */
  49546. getAnimatables(): IAnimatable[];
  49547. /**
  49548. * Returns the texture used for reflections.
  49549. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49550. */
  49551. private _getReflectionTexture;
  49552. /**
  49553. * Returns an array of the actively used textures.
  49554. * @returns - Array of BaseTextures
  49555. */
  49556. getActiveTextures(): BaseTexture[];
  49557. /**
  49558. * Checks to see if a texture is used in the material.
  49559. * @param texture - Base texture to use.
  49560. * @returns - Boolean specifying if a texture is used in the material.
  49561. */
  49562. hasTexture(texture: BaseTexture): boolean;
  49563. /**
  49564. * Disposes the resources of the material.
  49565. * @param forceDisposeEffect - Forces the disposal of effects.
  49566. * @param forceDisposeTextures - Forces the disposal of all textures.
  49567. */
  49568. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49569. }
  49570. }
  49571. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49572. import { Nullable } from "babylonjs/types";
  49573. import { Scene } from "babylonjs/scene";
  49574. import { Color3 } from "babylonjs/Maths/math.color";
  49575. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49576. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49577. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49578. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49579. /**
  49580. * The Physically based material of BJS.
  49581. *
  49582. * This offers the main features of a standard PBR material.
  49583. * For more information, please refer to the documentation :
  49584. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49585. */
  49586. export class PBRMaterial extends PBRBaseMaterial {
  49587. /**
  49588. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49589. */
  49590. static readonly PBRMATERIAL_OPAQUE: number;
  49591. /**
  49592. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49593. */
  49594. static readonly PBRMATERIAL_ALPHATEST: number;
  49595. /**
  49596. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49597. */
  49598. static readonly PBRMATERIAL_ALPHABLEND: number;
  49599. /**
  49600. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49601. * They are also discarded below the alpha cutoff threshold to improve performances.
  49602. */
  49603. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49604. /**
  49605. * Defines the default value of how much AO map is occluding the analytical lights
  49606. * (point spot...).
  49607. */
  49608. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49609. /**
  49610. * Intensity of the direct lights e.g. the four lights available in your scene.
  49611. * This impacts both the direct diffuse and specular highlights.
  49612. */
  49613. directIntensity: number;
  49614. /**
  49615. * Intensity of the emissive part of the material.
  49616. * This helps controlling the emissive effect without modifying the emissive color.
  49617. */
  49618. emissiveIntensity: number;
  49619. /**
  49620. * Intensity of the environment e.g. how much the environment will light the object
  49621. * either through harmonics for rough material or through the refelction for shiny ones.
  49622. */
  49623. environmentIntensity: number;
  49624. /**
  49625. * This is a special control allowing the reduction of the specular highlights coming from the
  49626. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49627. */
  49628. specularIntensity: number;
  49629. /**
  49630. * Debug Control allowing disabling the bump map on this material.
  49631. */
  49632. disableBumpMap: boolean;
  49633. /**
  49634. * AKA Diffuse Texture in standard nomenclature.
  49635. */
  49636. albedoTexture: BaseTexture;
  49637. /**
  49638. * AKA Occlusion Texture in other nomenclature.
  49639. */
  49640. ambientTexture: BaseTexture;
  49641. /**
  49642. * AKA Occlusion Texture Intensity in other nomenclature.
  49643. */
  49644. ambientTextureStrength: number;
  49645. /**
  49646. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49647. * 1 means it completely occludes it
  49648. * 0 mean it has no impact
  49649. */
  49650. ambientTextureImpactOnAnalyticalLights: number;
  49651. /**
  49652. * Stores the alpha values in a texture.
  49653. */
  49654. opacityTexture: BaseTexture;
  49655. /**
  49656. * Stores the reflection values in a texture.
  49657. */
  49658. reflectionTexture: Nullable<BaseTexture>;
  49659. /**
  49660. * Stores the emissive values in a texture.
  49661. */
  49662. emissiveTexture: BaseTexture;
  49663. /**
  49664. * AKA Specular texture in other nomenclature.
  49665. */
  49666. reflectivityTexture: BaseTexture;
  49667. /**
  49668. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49669. */
  49670. metallicTexture: BaseTexture;
  49671. /**
  49672. * Specifies the metallic scalar of the metallic/roughness workflow.
  49673. * Can also be used to scale the metalness values of the metallic texture.
  49674. */
  49675. metallic: Nullable<number>;
  49676. /**
  49677. * Specifies the roughness scalar of the metallic/roughness workflow.
  49678. * Can also be used to scale the roughness values of the metallic texture.
  49679. */
  49680. roughness: Nullable<number>;
  49681. /**
  49682. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49683. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49684. */
  49685. microSurfaceTexture: BaseTexture;
  49686. /**
  49687. * Stores surface normal data used to displace a mesh in a texture.
  49688. */
  49689. bumpTexture: BaseTexture;
  49690. /**
  49691. * Stores the pre-calculated light information of a mesh in a texture.
  49692. */
  49693. lightmapTexture: BaseTexture;
  49694. /**
  49695. * Stores the refracted light information in a texture.
  49696. */
  49697. refractionTexture: Nullable<BaseTexture>;
  49698. /**
  49699. * The color of a material in ambient lighting.
  49700. */
  49701. ambientColor: Color3;
  49702. /**
  49703. * AKA Diffuse Color in other nomenclature.
  49704. */
  49705. albedoColor: Color3;
  49706. /**
  49707. * AKA Specular Color in other nomenclature.
  49708. */
  49709. reflectivityColor: Color3;
  49710. /**
  49711. * The color reflected from the material.
  49712. */
  49713. reflectionColor: Color3;
  49714. /**
  49715. * The color emitted from the material.
  49716. */
  49717. emissiveColor: Color3;
  49718. /**
  49719. * AKA Glossiness in other nomenclature.
  49720. */
  49721. microSurface: number;
  49722. /**
  49723. * source material index of refraction (IOR)' / 'destination material IOR.
  49724. */
  49725. indexOfRefraction: number;
  49726. /**
  49727. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49728. */
  49729. invertRefractionY: boolean;
  49730. /**
  49731. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49732. * Materials half opaque for instance using refraction could benefit from this control.
  49733. */
  49734. linkRefractionWithTransparency: boolean;
  49735. /**
  49736. * If true, the light map contains occlusion information instead of lighting info.
  49737. */
  49738. useLightmapAsShadowmap: boolean;
  49739. /**
  49740. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49741. */
  49742. useAlphaFromAlbedoTexture: boolean;
  49743. /**
  49744. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49745. */
  49746. forceAlphaTest: boolean;
  49747. /**
  49748. * Defines the alpha limits in alpha test mode.
  49749. */
  49750. alphaCutOff: number;
  49751. /**
  49752. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49753. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49754. */
  49755. useSpecularOverAlpha: boolean;
  49756. /**
  49757. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49758. */
  49759. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49760. /**
  49761. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49762. */
  49763. useRoughnessFromMetallicTextureAlpha: boolean;
  49764. /**
  49765. * Specifies if the metallic texture contains the roughness information in its green channel.
  49766. */
  49767. useRoughnessFromMetallicTextureGreen: boolean;
  49768. /**
  49769. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49770. */
  49771. useMetallnessFromMetallicTextureBlue: boolean;
  49772. /**
  49773. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49774. */
  49775. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49776. /**
  49777. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49778. */
  49779. useAmbientInGrayScale: boolean;
  49780. /**
  49781. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49782. * The material will try to infer what glossiness each pixel should be.
  49783. */
  49784. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49785. /**
  49786. * BJS is using an harcoded light falloff based on a manually sets up range.
  49787. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49788. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49789. */
  49790. /**
  49791. * BJS is using an harcoded light falloff based on a manually sets up range.
  49792. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49793. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49794. */
  49795. usePhysicalLightFalloff: boolean;
  49796. /**
  49797. * In order to support the falloff compatibility with gltf, a special mode has been added
  49798. * to reproduce the gltf light falloff.
  49799. */
  49800. /**
  49801. * In order to support the falloff compatibility with gltf, a special mode has been added
  49802. * to reproduce the gltf light falloff.
  49803. */
  49804. useGLTFLightFalloff: boolean;
  49805. /**
  49806. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49807. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49808. */
  49809. useRadianceOverAlpha: boolean;
  49810. /**
  49811. * Allows using an object space normal map (instead of tangent space).
  49812. */
  49813. useObjectSpaceNormalMap: boolean;
  49814. /**
  49815. * Allows using the bump map in parallax mode.
  49816. */
  49817. useParallax: boolean;
  49818. /**
  49819. * Allows using the bump map in parallax occlusion mode.
  49820. */
  49821. useParallaxOcclusion: boolean;
  49822. /**
  49823. * Controls the scale bias of the parallax mode.
  49824. */
  49825. parallaxScaleBias: number;
  49826. /**
  49827. * If sets to true, disables all the lights affecting the material.
  49828. */
  49829. disableLighting: boolean;
  49830. /**
  49831. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49832. */
  49833. forceIrradianceInFragment: boolean;
  49834. /**
  49835. * Number of Simultaneous lights allowed on the material.
  49836. */
  49837. maxSimultaneousLights: number;
  49838. /**
  49839. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49840. */
  49841. invertNormalMapX: boolean;
  49842. /**
  49843. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49844. */
  49845. invertNormalMapY: boolean;
  49846. /**
  49847. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49848. */
  49849. twoSidedLighting: boolean;
  49850. /**
  49851. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49852. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49853. */
  49854. useAlphaFresnel: boolean;
  49855. /**
  49856. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49857. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49858. */
  49859. useLinearAlphaFresnel: boolean;
  49860. /**
  49861. * Let user defines the brdf lookup texture used for IBL.
  49862. * A default 8bit version is embedded but you could point at :
  49863. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49864. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49865. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49866. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49867. */
  49868. environmentBRDFTexture: Nullable<BaseTexture>;
  49869. /**
  49870. * Force normal to face away from face.
  49871. */
  49872. forceNormalForward: boolean;
  49873. /**
  49874. * Enables specular anti aliasing in the PBR shader.
  49875. * It will both interacts on the Geometry for analytical and IBL lighting.
  49876. * It also prefilter the roughness map based on the bump values.
  49877. */
  49878. enableSpecularAntiAliasing: boolean;
  49879. /**
  49880. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49881. * makes the reflect vector face the model (under horizon).
  49882. */
  49883. useHorizonOcclusion: boolean;
  49884. /**
  49885. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49886. * too much the area relying on ambient texture to define their ambient occlusion.
  49887. */
  49888. useRadianceOcclusion: boolean;
  49889. /**
  49890. * If set to true, no lighting calculations will be applied.
  49891. */
  49892. unlit: boolean;
  49893. /**
  49894. * Gets the image processing configuration used either in this material.
  49895. */
  49896. /**
  49897. * Sets the Default image processing configuration used either in the this material.
  49898. *
  49899. * If sets to null, the scene one is in use.
  49900. */
  49901. imageProcessingConfiguration: ImageProcessingConfiguration;
  49902. /**
  49903. * Gets wether the color curves effect is enabled.
  49904. */
  49905. /**
  49906. * Sets wether the color curves effect is enabled.
  49907. */
  49908. cameraColorCurvesEnabled: boolean;
  49909. /**
  49910. * Gets wether the color grading effect is enabled.
  49911. */
  49912. /**
  49913. * Gets wether the color grading effect is enabled.
  49914. */
  49915. cameraColorGradingEnabled: boolean;
  49916. /**
  49917. * Gets wether tonemapping is enabled or not.
  49918. */
  49919. /**
  49920. * Sets wether tonemapping is enabled or not
  49921. */
  49922. cameraToneMappingEnabled: boolean;
  49923. /**
  49924. * The camera exposure used on this material.
  49925. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49926. * This corresponds to a photographic exposure.
  49927. */
  49928. /**
  49929. * The camera exposure used on this material.
  49930. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49931. * This corresponds to a photographic exposure.
  49932. */
  49933. cameraExposure: number;
  49934. /**
  49935. * Gets The camera contrast used on this material.
  49936. */
  49937. /**
  49938. * Sets The camera contrast used on this material.
  49939. */
  49940. cameraContrast: number;
  49941. /**
  49942. * Gets the Color Grading 2D Lookup Texture.
  49943. */
  49944. /**
  49945. * Sets the Color Grading 2D Lookup Texture.
  49946. */
  49947. cameraColorGradingTexture: Nullable<BaseTexture>;
  49948. /**
  49949. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49950. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49951. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  49952. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49953. */
  49954. /**
  49955. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49956. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49957. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  49958. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49959. */
  49960. cameraColorCurves: Nullable<ColorCurves>;
  49961. /**
  49962. * Instantiates a new PBRMaterial instance.
  49963. *
  49964. * @param name The material name
  49965. * @param scene The scene the material will be use in.
  49966. */
  49967. constructor(name: string, scene: Scene);
  49968. /**
  49969. * Returns the name of this material class.
  49970. */
  49971. getClassName(): string;
  49972. /**
  49973. * Makes a duplicate of the current material.
  49974. * @param name - name to use for the new material.
  49975. */
  49976. clone(name: string): PBRMaterial;
  49977. /**
  49978. * Serializes this PBR Material.
  49979. * @returns - An object with the serialized material.
  49980. */
  49981. serialize(): any;
  49982. /**
  49983. * Parses a PBR Material from a serialized object.
  49984. * @param source - Serialized object.
  49985. * @param scene - BJS scene instance.
  49986. * @param rootUrl - url for the scene object
  49987. * @returns - PBRMaterial
  49988. */
  49989. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49990. }
  49991. }
  49992. declare module "babylonjs/Misc/dds" {
  49993. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49994. import { Engine } from "babylonjs/Engines/engine";
  49995. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49996. import { Nullable } from "babylonjs/types";
  49997. import { Scene } from "babylonjs/scene";
  49998. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49999. /**
  50000. * Direct draw surface info
  50001. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50002. */
  50003. export interface DDSInfo {
  50004. /**
  50005. * Width of the texture
  50006. */
  50007. width: number;
  50008. /**
  50009. * Width of the texture
  50010. */
  50011. height: number;
  50012. /**
  50013. * Number of Mipmaps for the texture
  50014. * @see https://en.wikipedia.org/wiki/Mipmap
  50015. */
  50016. mipmapCount: number;
  50017. /**
  50018. * If the textures format is a known fourCC format
  50019. * @see https://www.fourcc.org/
  50020. */
  50021. isFourCC: boolean;
  50022. /**
  50023. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50024. */
  50025. isRGB: boolean;
  50026. /**
  50027. * If the texture is a lumincance format
  50028. */
  50029. isLuminance: boolean;
  50030. /**
  50031. * If this is a cube texture
  50032. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50033. */
  50034. isCube: boolean;
  50035. /**
  50036. * If the texture is a compressed format eg. FOURCC_DXT1
  50037. */
  50038. isCompressed: boolean;
  50039. /**
  50040. * The dxgiFormat of the texture
  50041. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50042. */
  50043. dxgiFormat: number;
  50044. /**
  50045. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50046. */
  50047. textureType: number;
  50048. /**
  50049. * Sphericle polynomial created for the dds texture
  50050. */
  50051. sphericalPolynomial?: SphericalPolynomial;
  50052. }
  50053. /**
  50054. * Class used to provide DDS decompression tools
  50055. */
  50056. export class DDSTools {
  50057. /**
  50058. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50059. */
  50060. static StoreLODInAlphaChannel: boolean;
  50061. /**
  50062. * Gets DDS information from an array buffer
  50063. * @param arrayBuffer defines the array buffer to read data from
  50064. * @returns the DDS information
  50065. */
  50066. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50067. private static _FloatView;
  50068. private static _Int32View;
  50069. private static _ToHalfFloat;
  50070. private static _FromHalfFloat;
  50071. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50072. private static _GetHalfFloatRGBAArrayBuffer;
  50073. private static _GetFloatRGBAArrayBuffer;
  50074. private static _GetFloatAsUIntRGBAArrayBuffer;
  50075. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50076. private static _GetRGBAArrayBuffer;
  50077. private static _ExtractLongWordOrder;
  50078. private static _GetRGBArrayBuffer;
  50079. private static _GetLuminanceArrayBuffer;
  50080. /**
  50081. * Uploads DDS Levels to a Babylon Texture
  50082. * @hidden
  50083. */
  50084. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50085. }
  50086. module "babylonjs/Engines/engine" {
  50087. interface Engine {
  50088. /**
  50089. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50090. * @param rootUrl defines the url where the file to load is located
  50091. * @param scene defines the current scene
  50092. * @param lodScale defines scale to apply to the mip map selection
  50093. * @param lodOffset defines offset to apply to the mip map selection
  50094. * @param onLoad defines an optional callback raised when the texture is loaded
  50095. * @param onError defines an optional callback raised if there is an issue to load the texture
  50096. * @param format defines the format of the data
  50097. * @param forcedExtension defines the extension to use to pick the right loader
  50098. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50099. * @returns the cube texture as an InternalTexture
  50100. */
  50101. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  50102. }
  50103. }
  50104. }
  50105. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50106. import { Nullable } from "babylonjs/types";
  50107. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50108. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50109. /**
  50110. * Implementation of the DDS Texture Loader.
  50111. * @hidden
  50112. */
  50113. export class _DDSTextureLoader implements IInternalTextureLoader {
  50114. /**
  50115. * Defines wether the loader supports cascade loading the different faces.
  50116. */
  50117. readonly supportCascades: boolean;
  50118. /**
  50119. * This returns if the loader support the current file information.
  50120. * @param extension defines the file extension of the file being loaded
  50121. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50122. * @param fallback defines the fallback internal texture if any
  50123. * @param isBase64 defines whether the texture is encoded as a base64
  50124. * @param isBuffer defines whether the texture data are stored as a buffer
  50125. * @returns true if the loader can load the specified file
  50126. */
  50127. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50128. /**
  50129. * Transform the url before loading if required.
  50130. * @param rootUrl the url of the texture
  50131. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50132. * @returns the transformed texture
  50133. */
  50134. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50135. /**
  50136. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50137. * @param rootUrl the url of the texture
  50138. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50139. * @returns the fallback texture
  50140. */
  50141. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50142. /**
  50143. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50144. * @param data contains the texture data
  50145. * @param texture defines the BabylonJS internal texture
  50146. * @param createPolynomials will be true if polynomials have been requested
  50147. * @param onLoad defines the callback to trigger once the texture is ready
  50148. * @param onError defines the callback to trigger in case of error
  50149. */
  50150. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50151. /**
  50152. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50153. * @param data contains the texture data
  50154. * @param texture defines the BabylonJS internal texture
  50155. * @param callback defines the method to call once ready to upload
  50156. */
  50157. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50158. }
  50159. }
  50160. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50161. import { Nullable } from "babylonjs/types";
  50162. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50163. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50164. /**
  50165. * Implementation of the ENV Texture Loader.
  50166. * @hidden
  50167. */
  50168. export class _ENVTextureLoader implements IInternalTextureLoader {
  50169. /**
  50170. * Defines wether the loader supports cascade loading the different faces.
  50171. */
  50172. readonly supportCascades: boolean;
  50173. /**
  50174. * This returns if the loader support the current file information.
  50175. * @param extension defines the file extension of the file being loaded
  50176. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50177. * @param fallback defines the fallback internal texture if any
  50178. * @param isBase64 defines whether the texture is encoded as a base64
  50179. * @param isBuffer defines whether the texture data are stored as a buffer
  50180. * @returns true if the loader can load the specified file
  50181. */
  50182. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50183. /**
  50184. * Transform the url before loading if required.
  50185. * @param rootUrl the url of the texture
  50186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50187. * @returns the transformed texture
  50188. */
  50189. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50190. /**
  50191. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50192. * @param rootUrl the url of the texture
  50193. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50194. * @returns the fallback texture
  50195. */
  50196. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50197. /**
  50198. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50199. * @param data contains the texture data
  50200. * @param texture defines the BabylonJS internal texture
  50201. * @param createPolynomials will be true if polynomials have been requested
  50202. * @param onLoad defines the callback to trigger once the texture is ready
  50203. * @param onError defines the callback to trigger in case of error
  50204. */
  50205. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50206. /**
  50207. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50208. * @param data contains the texture data
  50209. * @param texture defines the BabylonJS internal texture
  50210. * @param callback defines the method to call once ready to upload
  50211. */
  50212. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50213. }
  50214. }
  50215. declare module "babylonjs/Misc/khronosTextureContainer" {
  50216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50217. /**
  50218. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50219. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50220. */
  50221. export class KhronosTextureContainer {
  50222. /** contents of the KTX container file */
  50223. arrayBuffer: any;
  50224. private static HEADER_LEN;
  50225. private static COMPRESSED_2D;
  50226. private static COMPRESSED_3D;
  50227. private static TEX_2D;
  50228. private static TEX_3D;
  50229. /**
  50230. * Gets the openGL type
  50231. */
  50232. glType: number;
  50233. /**
  50234. * Gets the openGL type size
  50235. */
  50236. glTypeSize: number;
  50237. /**
  50238. * Gets the openGL format
  50239. */
  50240. glFormat: number;
  50241. /**
  50242. * Gets the openGL internal format
  50243. */
  50244. glInternalFormat: number;
  50245. /**
  50246. * Gets the base internal format
  50247. */
  50248. glBaseInternalFormat: number;
  50249. /**
  50250. * Gets image width in pixel
  50251. */
  50252. pixelWidth: number;
  50253. /**
  50254. * Gets image height in pixel
  50255. */
  50256. pixelHeight: number;
  50257. /**
  50258. * Gets image depth in pixels
  50259. */
  50260. pixelDepth: number;
  50261. /**
  50262. * Gets the number of array elements
  50263. */
  50264. numberOfArrayElements: number;
  50265. /**
  50266. * Gets the number of faces
  50267. */
  50268. numberOfFaces: number;
  50269. /**
  50270. * Gets the number of mipmap levels
  50271. */
  50272. numberOfMipmapLevels: number;
  50273. /**
  50274. * Gets the bytes of key value data
  50275. */
  50276. bytesOfKeyValueData: number;
  50277. /**
  50278. * Gets the load type
  50279. */
  50280. loadType: number;
  50281. /**
  50282. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50283. */
  50284. isInvalid: boolean;
  50285. /**
  50286. * Creates a new KhronosTextureContainer
  50287. * @param arrayBuffer contents of the KTX container file
  50288. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50289. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50290. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50291. */
  50292. constructor(
  50293. /** contents of the KTX container file */
  50294. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50295. /**
  50296. * Uploads KTX content to a Babylon Texture.
  50297. * It is assumed that the texture has already been created & is currently bound
  50298. * @hidden
  50299. */
  50300. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50301. private _upload2DCompressedLevels;
  50302. }
  50303. }
  50304. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50305. import { Nullable } from "babylonjs/types";
  50306. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50307. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50308. /**
  50309. * Implementation of the KTX Texture Loader.
  50310. * @hidden
  50311. */
  50312. export class _KTXTextureLoader implements IInternalTextureLoader {
  50313. /**
  50314. * Defines wether the loader supports cascade loading the different faces.
  50315. */
  50316. readonly supportCascades: boolean;
  50317. /**
  50318. * This returns if the loader support the current file information.
  50319. * @param extension defines the file extension of the file being loaded
  50320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50321. * @param fallback defines the fallback internal texture if any
  50322. * @param isBase64 defines whether the texture is encoded as a base64
  50323. * @param isBuffer defines whether the texture data are stored as a buffer
  50324. * @returns true if the loader can load the specified file
  50325. */
  50326. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50327. /**
  50328. * Transform the url before loading if required.
  50329. * @param rootUrl the url of the texture
  50330. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50331. * @returns the transformed texture
  50332. */
  50333. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50334. /**
  50335. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50336. * @param rootUrl the url of the texture
  50337. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50338. * @returns the fallback texture
  50339. */
  50340. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50341. /**
  50342. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50343. * @param data contains the texture data
  50344. * @param texture defines the BabylonJS internal texture
  50345. * @param createPolynomials will be true if polynomials have been requested
  50346. * @param onLoad defines the callback to trigger once the texture is ready
  50347. * @param onError defines the callback to trigger in case of error
  50348. */
  50349. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50350. /**
  50351. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50352. * @param data contains the texture data
  50353. * @param texture defines the BabylonJS internal texture
  50354. * @param callback defines the method to call once ready to upload
  50355. */
  50356. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50357. }
  50358. }
  50359. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50360. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50361. import { Scene } from "babylonjs/scene";
  50362. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50363. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50364. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50365. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50366. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50367. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50369. /**
  50370. * Options for the default xr helper
  50371. */
  50372. export class WebXRDefaultExperienceOptions {
  50373. /**
  50374. * Floor meshes that should be used for teleporting
  50375. */
  50376. floorMeshes: Array<AbstractMesh>;
  50377. }
  50378. /**
  50379. * Default experience which provides a similar setup to the previous webVRExperience
  50380. */
  50381. export class WebXRDefaultExperience {
  50382. /**
  50383. * Base experience
  50384. */
  50385. baseExperience: WebXRExperienceHelper;
  50386. /**
  50387. * Input experience extension
  50388. */
  50389. input: WebXRInput;
  50390. /**
  50391. * Loads the controller models
  50392. */
  50393. controllerModelLoader: WebXRControllerModelLoader;
  50394. /**
  50395. * Enables laser pointer and selection
  50396. */
  50397. pointerSelection: WebXRControllerPointerSelection;
  50398. /**
  50399. * Enables teleportation
  50400. */
  50401. teleportation: WebXRControllerTeleportation;
  50402. /**
  50403. * Enables ui for enetering/exiting xr
  50404. */
  50405. enterExitUI: WebXREnterExitUI;
  50406. /**
  50407. * Default output canvas xr should render to
  50408. */
  50409. outputCanvas: WebXRManagedOutputCanvas;
  50410. /**
  50411. * Creates the default xr experience
  50412. * @param scene scene
  50413. * @param options options for basic configuration
  50414. * @returns resulting WebXRDefaultExperience
  50415. */
  50416. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50417. private constructor();
  50418. /**
  50419. * DIsposes of the experience helper
  50420. */
  50421. dispose(): void;
  50422. }
  50423. }
  50424. declare module "babylonjs/Helpers/sceneHelpers" {
  50425. import { Nullable } from "babylonjs/types";
  50426. import { Mesh } from "babylonjs/Meshes/mesh";
  50427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50428. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50429. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50430. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50431. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50432. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50433. import "babylonjs/Meshes/Builders/boxBuilder";
  50434. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50435. /** @hidden */
  50436. export var _forceSceneHelpersToBundle: boolean;
  50437. module "babylonjs/scene" {
  50438. interface Scene {
  50439. /**
  50440. * Creates a default light for the scene.
  50441. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50442. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50443. */
  50444. createDefaultLight(replace?: boolean): void;
  50445. /**
  50446. * Creates a default camera for the scene.
  50447. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50448. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50449. * @param replace has default false, when true replaces the active camera in the scene
  50450. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50451. */
  50452. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50453. /**
  50454. * Creates a default camera and a default light.
  50455. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50456. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50457. * @param replace has the default false, when true replaces the active camera/light in the scene
  50458. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50459. */
  50460. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50461. /**
  50462. * Creates a new sky box
  50463. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50464. * @param environmentTexture defines the texture to use as environment texture
  50465. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50466. * @param scale defines the overall scale of the skybox
  50467. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50468. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50469. * @returns a new mesh holding the sky box
  50470. */
  50471. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50472. /**
  50473. * Creates a new environment
  50474. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50475. * @param options defines the options you can use to configure the environment
  50476. * @returns the new EnvironmentHelper
  50477. */
  50478. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50479. /**
  50480. * Creates a new VREXperienceHelper
  50481. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50482. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50483. * @returns a new VREXperienceHelper
  50484. */
  50485. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50486. /**
  50487. * Creates a new WebXRDefaultExperience
  50488. * @see http://doc.babylonjs.com/how_to/webxr
  50489. * @param options experience options
  50490. * @returns a promise for a new WebXRDefaultExperience
  50491. */
  50492. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50493. }
  50494. }
  50495. }
  50496. declare module "babylonjs/Helpers/videoDome" {
  50497. import { Scene } from "babylonjs/scene";
  50498. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50499. import { Mesh } from "babylonjs/Meshes/mesh";
  50500. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50501. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50502. import "babylonjs/Meshes/Builders/sphereBuilder";
  50503. /**
  50504. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50505. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50506. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50507. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50508. */
  50509. export class VideoDome extends TransformNode {
  50510. /**
  50511. * Define the video source as a Monoscopic panoramic 360 video.
  50512. */
  50513. static readonly MODE_MONOSCOPIC: number;
  50514. /**
  50515. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50516. */
  50517. static readonly MODE_TOPBOTTOM: number;
  50518. /**
  50519. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50520. */
  50521. static readonly MODE_SIDEBYSIDE: number;
  50522. private _halfDome;
  50523. private _useDirectMapping;
  50524. /**
  50525. * The video texture being displayed on the sphere
  50526. */
  50527. protected _videoTexture: VideoTexture;
  50528. /**
  50529. * Gets the video texture being displayed on the sphere
  50530. */
  50531. readonly videoTexture: VideoTexture;
  50532. /**
  50533. * The skybox material
  50534. */
  50535. protected _material: BackgroundMaterial;
  50536. /**
  50537. * The surface used for the skybox
  50538. */
  50539. protected _mesh: Mesh;
  50540. /**
  50541. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50542. */
  50543. private _halfDomeMask;
  50544. /**
  50545. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50546. * Also see the options.resolution property.
  50547. */
  50548. fovMultiplier: number;
  50549. private _videoMode;
  50550. /**
  50551. * Gets or set the current video mode for the video. It can be:
  50552. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50553. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50554. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50555. */
  50556. videoMode: number;
  50557. /**
  50558. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50559. *
  50560. */
  50561. /**
  50562. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50563. */
  50564. halfDome: boolean;
  50565. /**
  50566. * Oberserver used in Stereoscopic VR Mode.
  50567. */
  50568. private _onBeforeCameraRenderObserver;
  50569. /**
  50570. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50571. * @param name Element's name, child elements will append suffixes for their own names.
  50572. * @param urlsOrVideo defines the url(s) or the video element to use
  50573. * @param options An object containing optional or exposed sub element properties
  50574. */
  50575. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50576. resolution?: number;
  50577. clickToPlay?: boolean;
  50578. autoPlay?: boolean;
  50579. loop?: boolean;
  50580. size?: number;
  50581. poster?: string;
  50582. faceForward?: boolean;
  50583. useDirectMapping?: boolean;
  50584. halfDomeMode?: boolean;
  50585. }, scene: Scene);
  50586. private _changeVideoMode;
  50587. /**
  50588. * Releases resources associated with this node.
  50589. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50590. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50591. */
  50592. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50593. }
  50594. }
  50595. declare module "babylonjs/Helpers/index" {
  50596. export * from "babylonjs/Helpers/environmentHelper";
  50597. export * from "babylonjs/Helpers/photoDome";
  50598. export * from "babylonjs/Helpers/sceneHelpers";
  50599. export * from "babylonjs/Helpers/videoDome";
  50600. }
  50601. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50602. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50603. import { IDisposable } from "babylonjs/scene";
  50604. import { Engine } from "babylonjs/Engines/engine";
  50605. /**
  50606. * This class can be used to get instrumentation data from a Babylon engine
  50607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50608. */
  50609. export class EngineInstrumentation implements IDisposable {
  50610. /**
  50611. * Define the instrumented engine.
  50612. */
  50613. engine: Engine;
  50614. private _captureGPUFrameTime;
  50615. private _gpuFrameTimeToken;
  50616. private _gpuFrameTime;
  50617. private _captureShaderCompilationTime;
  50618. private _shaderCompilationTime;
  50619. private _onBeginFrameObserver;
  50620. private _onEndFrameObserver;
  50621. private _onBeforeShaderCompilationObserver;
  50622. private _onAfterShaderCompilationObserver;
  50623. /**
  50624. * Gets the perf counter used for GPU frame time
  50625. */
  50626. readonly gpuFrameTimeCounter: PerfCounter;
  50627. /**
  50628. * Gets the GPU frame time capture status
  50629. */
  50630. /**
  50631. * Enable or disable the GPU frame time capture
  50632. */
  50633. captureGPUFrameTime: boolean;
  50634. /**
  50635. * Gets the perf counter used for shader compilation time
  50636. */
  50637. readonly shaderCompilationTimeCounter: PerfCounter;
  50638. /**
  50639. * Gets the shader compilation time capture status
  50640. */
  50641. /**
  50642. * Enable or disable the shader compilation time capture
  50643. */
  50644. captureShaderCompilationTime: boolean;
  50645. /**
  50646. * Instantiates a new engine instrumentation.
  50647. * This class can be used to get instrumentation data from a Babylon engine
  50648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50649. * @param engine Defines the engine to instrument
  50650. */
  50651. constructor(
  50652. /**
  50653. * Define the instrumented engine.
  50654. */
  50655. engine: Engine);
  50656. /**
  50657. * Dispose and release associated resources.
  50658. */
  50659. dispose(): void;
  50660. }
  50661. }
  50662. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50663. import { Scene, IDisposable } from "babylonjs/scene";
  50664. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50665. /**
  50666. * This class can be used to get instrumentation data from a Babylon engine
  50667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50668. */
  50669. export class SceneInstrumentation implements IDisposable {
  50670. /**
  50671. * Defines the scene to instrument
  50672. */
  50673. scene: Scene;
  50674. private _captureActiveMeshesEvaluationTime;
  50675. private _activeMeshesEvaluationTime;
  50676. private _captureRenderTargetsRenderTime;
  50677. private _renderTargetsRenderTime;
  50678. private _captureFrameTime;
  50679. private _frameTime;
  50680. private _captureRenderTime;
  50681. private _renderTime;
  50682. private _captureInterFrameTime;
  50683. private _interFrameTime;
  50684. private _captureParticlesRenderTime;
  50685. private _particlesRenderTime;
  50686. private _captureSpritesRenderTime;
  50687. private _spritesRenderTime;
  50688. private _capturePhysicsTime;
  50689. private _physicsTime;
  50690. private _captureAnimationsTime;
  50691. private _animationsTime;
  50692. private _captureCameraRenderTime;
  50693. private _cameraRenderTime;
  50694. private _onBeforeActiveMeshesEvaluationObserver;
  50695. private _onAfterActiveMeshesEvaluationObserver;
  50696. private _onBeforeRenderTargetsRenderObserver;
  50697. private _onAfterRenderTargetsRenderObserver;
  50698. private _onAfterRenderObserver;
  50699. private _onBeforeDrawPhaseObserver;
  50700. private _onAfterDrawPhaseObserver;
  50701. private _onBeforeAnimationsObserver;
  50702. private _onBeforeParticlesRenderingObserver;
  50703. private _onAfterParticlesRenderingObserver;
  50704. private _onBeforeSpritesRenderingObserver;
  50705. private _onAfterSpritesRenderingObserver;
  50706. private _onBeforePhysicsObserver;
  50707. private _onAfterPhysicsObserver;
  50708. private _onAfterAnimationsObserver;
  50709. private _onBeforeCameraRenderObserver;
  50710. private _onAfterCameraRenderObserver;
  50711. /**
  50712. * Gets the perf counter used for active meshes evaluation time
  50713. */
  50714. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50715. /**
  50716. * Gets the active meshes evaluation time capture status
  50717. */
  50718. /**
  50719. * Enable or disable the active meshes evaluation time capture
  50720. */
  50721. captureActiveMeshesEvaluationTime: boolean;
  50722. /**
  50723. * Gets the perf counter used for render targets render time
  50724. */
  50725. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50726. /**
  50727. * Gets the render targets render time capture status
  50728. */
  50729. /**
  50730. * Enable or disable the render targets render time capture
  50731. */
  50732. captureRenderTargetsRenderTime: boolean;
  50733. /**
  50734. * Gets the perf counter used for particles render time
  50735. */
  50736. readonly particlesRenderTimeCounter: PerfCounter;
  50737. /**
  50738. * Gets the particles render time capture status
  50739. */
  50740. /**
  50741. * Enable or disable the particles render time capture
  50742. */
  50743. captureParticlesRenderTime: boolean;
  50744. /**
  50745. * Gets the perf counter used for sprites render time
  50746. */
  50747. readonly spritesRenderTimeCounter: PerfCounter;
  50748. /**
  50749. * Gets the sprites render time capture status
  50750. */
  50751. /**
  50752. * Enable or disable the sprites render time capture
  50753. */
  50754. captureSpritesRenderTime: boolean;
  50755. /**
  50756. * Gets the perf counter used for physics time
  50757. */
  50758. readonly physicsTimeCounter: PerfCounter;
  50759. /**
  50760. * Gets the physics time capture status
  50761. */
  50762. /**
  50763. * Enable or disable the physics time capture
  50764. */
  50765. capturePhysicsTime: boolean;
  50766. /**
  50767. * Gets the perf counter used for animations time
  50768. */
  50769. readonly animationsTimeCounter: PerfCounter;
  50770. /**
  50771. * Gets the animations time capture status
  50772. */
  50773. /**
  50774. * Enable or disable the animations time capture
  50775. */
  50776. captureAnimationsTime: boolean;
  50777. /**
  50778. * Gets the perf counter used for frame time capture
  50779. */
  50780. readonly frameTimeCounter: PerfCounter;
  50781. /**
  50782. * Gets the frame time capture status
  50783. */
  50784. /**
  50785. * Enable or disable the frame time capture
  50786. */
  50787. captureFrameTime: boolean;
  50788. /**
  50789. * Gets the perf counter used for inter-frames time capture
  50790. */
  50791. readonly interFrameTimeCounter: PerfCounter;
  50792. /**
  50793. * Gets the inter-frames time capture status
  50794. */
  50795. /**
  50796. * Enable or disable the inter-frames time capture
  50797. */
  50798. captureInterFrameTime: boolean;
  50799. /**
  50800. * Gets the perf counter used for render time capture
  50801. */
  50802. readonly renderTimeCounter: PerfCounter;
  50803. /**
  50804. * Gets the render time capture status
  50805. */
  50806. /**
  50807. * Enable or disable the render time capture
  50808. */
  50809. captureRenderTime: boolean;
  50810. /**
  50811. * Gets the perf counter used for camera render time capture
  50812. */
  50813. readonly cameraRenderTimeCounter: PerfCounter;
  50814. /**
  50815. * Gets the camera render time capture status
  50816. */
  50817. /**
  50818. * Enable or disable the camera render time capture
  50819. */
  50820. captureCameraRenderTime: boolean;
  50821. /**
  50822. * Gets the perf counter used for draw calls
  50823. */
  50824. readonly drawCallsCounter: PerfCounter;
  50825. /**
  50826. * Instantiates a new scene instrumentation.
  50827. * This class can be used to get instrumentation data from a Babylon engine
  50828. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50829. * @param scene Defines the scene to instrument
  50830. */
  50831. constructor(
  50832. /**
  50833. * Defines the scene to instrument
  50834. */
  50835. scene: Scene);
  50836. /**
  50837. * Dispose and release associated resources.
  50838. */
  50839. dispose(): void;
  50840. }
  50841. }
  50842. declare module "babylonjs/Instrumentation/index" {
  50843. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50844. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50845. export * from "babylonjs/Instrumentation/timeToken";
  50846. }
  50847. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50848. /** @hidden */
  50849. export var glowMapGenerationPixelShader: {
  50850. name: string;
  50851. shader: string;
  50852. };
  50853. }
  50854. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50855. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50856. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50857. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50858. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50859. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50860. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50861. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50862. /** @hidden */
  50863. export var glowMapGenerationVertexShader: {
  50864. name: string;
  50865. shader: string;
  50866. };
  50867. }
  50868. declare module "babylonjs/Layers/effectLayer" {
  50869. import { Observable } from "babylonjs/Misc/observable";
  50870. import { Nullable } from "babylonjs/types";
  50871. import { Camera } from "babylonjs/Cameras/camera";
  50872. import { Scene } from "babylonjs/scene";
  50873. import { ISize } from "babylonjs/Maths/math.size";
  50874. import { Color4 } from "babylonjs/Maths/math.color";
  50875. import { Engine } from "babylonjs/Engines/engine";
  50876. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50878. import { Mesh } from "babylonjs/Meshes/mesh";
  50879. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50881. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50882. import { Effect } from "babylonjs/Materials/effect";
  50883. import { Material } from "babylonjs/Materials/material";
  50884. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50885. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50886. /**
  50887. * Effect layer options. This helps customizing the behaviour
  50888. * of the effect layer.
  50889. */
  50890. export interface IEffectLayerOptions {
  50891. /**
  50892. * Multiplication factor apply to the canvas size to compute the render target size
  50893. * used to generated the objects (the smaller the faster).
  50894. */
  50895. mainTextureRatio: number;
  50896. /**
  50897. * Enforces a fixed size texture to ensure effect stability across devices.
  50898. */
  50899. mainTextureFixedSize?: number;
  50900. /**
  50901. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50902. */
  50903. alphaBlendingMode: number;
  50904. /**
  50905. * The camera attached to the layer.
  50906. */
  50907. camera: Nullable<Camera>;
  50908. /**
  50909. * The rendering group to draw the layer in.
  50910. */
  50911. renderingGroupId: number;
  50912. }
  50913. /**
  50914. * The effect layer Helps adding post process effect blended with the main pass.
  50915. *
  50916. * This can be for instance use to generate glow or higlight effects on the scene.
  50917. *
  50918. * The effect layer class can not be used directly and is intented to inherited from to be
  50919. * customized per effects.
  50920. */
  50921. export abstract class EffectLayer {
  50922. private _vertexBuffers;
  50923. private _indexBuffer;
  50924. private _cachedDefines;
  50925. private _effectLayerMapGenerationEffect;
  50926. private _effectLayerOptions;
  50927. private _mergeEffect;
  50928. protected _scene: Scene;
  50929. protected _engine: Engine;
  50930. protected _maxSize: number;
  50931. protected _mainTextureDesiredSize: ISize;
  50932. protected _mainTexture: RenderTargetTexture;
  50933. protected _shouldRender: boolean;
  50934. protected _postProcesses: PostProcess[];
  50935. protected _textures: BaseTexture[];
  50936. protected _emissiveTextureAndColor: {
  50937. texture: Nullable<BaseTexture>;
  50938. color: Color4;
  50939. };
  50940. /**
  50941. * The name of the layer
  50942. */
  50943. name: string;
  50944. /**
  50945. * The clear color of the texture used to generate the glow map.
  50946. */
  50947. neutralColor: Color4;
  50948. /**
  50949. * Specifies wether the highlight layer is enabled or not.
  50950. */
  50951. isEnabled: boolean;
  50952. /**
  50953. * Gets the camera attached to the layer.
  50954. */
  50955. readonly camera: Nullable<Camera>;
  50956. /**
  50957. * Gets the rendering group id the layer should render in.
  50958. */
  50959. renderingGroupId: number;
  50960. /**
  50961. * An event triggered when the effect layer has been disposed.
  50962. */
  50963. onDisposeObservable: Observable<EffectLayer>;
  50964. /**
  50965. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50966. */
  50967. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50968. /**
  50969. * An event triggered when the generated texture is being merged in the scene.
  50970. */
  50971. onBeforeComposeObservable: Observable<EffectLayer>;
  50972. /**
  50973. * An event triggered when the generated texture has been merged in the scene.
  50974. */
  50975. onAfterComposeObservable: Observable<EffectLayer>;
  50976. /**
  50977. * An event triggered when the efffect layer changes its size.
  50978. */
  50979. onSizeChangedObservable: Observable<EffectLayer>;
  50980. /** @hidden */
  50981. static _SceneComponentInitialization: (scene: Scene) => void;
  50982. /**
  50983. * Instantiates a new effect Layer and references it in the scene.
  50984. * @param name The name of the layer
  50985. * @param scene The scene to use the layer in
  50986. */
  50987. constructor(
  50988. /** The Friendly of the effect in the scene */
  50989. name: string, scene: Scene);
  50990. /**
  50991. * Get the effect name of the layer.
  50992. * @return The effect name
  50993. */
  50994. abstract getEffectName(): string;
  50995. /**
  50996. * Checks for the readiness of the element composing the layer.
  50997. * @param subMesh the mesh to check for
  50998. * @param useInstances specify wether or not to use instances to render the mesh
  50999. * @return true if ready otherwise, false
  51000. */
  51001. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51002. /**
  51003. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51004. * @returns true if the effect requires stencil during the main canvas render pass.
  51005. */
  51006. abstract needStencil(): boolean;
  51007. /**
  51008. * Create the merge effect. This is the shader use to blit the information back
  51009. * to the main canvas at the end of the scene rendering.
  51010. * @returns The effect containing the shader used to merge the effect on the main canvas
  51011. */
  51012. protected abstract _createMergeEffect(): Effect;
  51013. /**
  51014. * Creates the render target textures and post processes used in the effect layer.
  51015. */
  51016. protected abstract _createTextureAndPostProcesses(): void;
  51017. /**
  51018. * Implementation specific of rendering the generating effect on the main canvas.
  51019. * @param effect The effect used to render through
  51020. */
  51021. protected abstract _internalRender(effect: Effect): void;
  51022. /**
  51023. * Sets the required values for both the emissive texture and and the main color.
  51024. */
  51025. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51026. /**
  51027. * Free any resources and references associated to a mesh.
  51028. * Internal use
  51029. * @param mesh The mesh to free.
  51030. */
  51031. abstract _disposeMesh(mesh: Mesh): void;
  51032. /**
  51033. * Serializes this layer (Glow or Highlight for example)
  51034. * @returns a serialized layer object
  51035. */
  51036. abstract serialize?(): any;
  51037. /**
  51038. * Initializes the effect layer with the required options.
  51039. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51040. */
  51041. protected _init(options: Partial<IEffectLayerOptions>): void;
  51042. /**
  51043. * Generates the index buffer of the full screen quad blending to the main canvas.
  51044. */
  51045. private _generateIndexBuffer;
  51046. /**
  51047. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51048. */
  51049. private _generateVertexBuffer;
  51050. /**
  51051. * Sets the main texture desired size which is the closest power of two
  51052. * of the engine canvas size.
  51053. */
  51054. private _setMainTextureSize;
  51055. /**
  51056. * Creates the main texture for the effect layer.
  51057. */
  51058. protected _createMainTexture(): void;
  51059. /**
  51060. * Adds specific effects defines.
  51061. * @param defines The defines to add specifics to.
  51062. */
  51063. protected _addCustomEffectDefines(defines: string[]): void;
  51064. /**
  51065. * Checks for the readiness of the element composing the layer.
  51066. * @param subMesh the mesh to check for
  51067. * @param useInstances specify wether or not to use instances to render the mesh
  51068. * @param emissiveTexture the associated emissive texture used to generate the glow
  51069. * @return true if ready otherwise, false
  51070. */
  51071. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51072. /**
  51073. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51074. */
  51075. render(): void;
  51076. /**
  51077. * Determine if a given mesh will be used in the current effect.
  51078. * @param mesh mesh to test
  51079. * @returns true if the mesh will be used
  51080. */
  51081. hasMesh(mesh: AbstractMesh): boolean;
  51082. /**
  51083. * Returns true if the layer contains information to display, otherwise false.
  51084. * @returns true if the glow layer should be rendered
  51085. */
  51086. shouldRender(): boolean;
  51087. /**
  51088. * Returns true if the mesh should render, otherwise false.
  51089. * @param mesh The mesh to render
  51090. * @returns true if it should render otherwise false
  51091. */
  51092. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51093. /**
  51094. * Returns true if the mesh can be rendered, otherwise false.
  51095. * @param mesh The mesh to render
  51096. * @param material The material used on the mesh
  51097. * @returns true if it can be rendered otherwise false
  51098. */
  51099. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51100. /**
  51101. * Returns true if the mesh should render, otherwise false.
  51102. * @param mesh The mesh to render
  51103. * @returns true if it should render otherwise false
  51104. */
  51105. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51106. /**
  51107. * Renders the submesh passed in parameter to the generation map.
  51108. */
  51109. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51110. /**
  51111. * Rebuild the required buffers.
  51112. * @hidden Internal use only.
  51113. */
  51114. _rebuild(): void;
  51115. /**
  51116. * Dispose only the render target textures and post process.
  51117. */
  51118. private _disposeTextureAndPostProcesses;
  51119. /**
  51120. * Dispose the highlight layer and free resources.
  51121. */
  51122. dispose(): void;
  51123. /**
  51124. * Gets the class name of the effect layer
  51125. * @returns the string with the class name of the effect layer
  51126. */
  51127. getClassName(): string;
  51128. /**
  51129. * Creates an effect layer from parsed effect layer data
  51130. * @param parsedEffectLayer defines effect layer data
  51131. * @param scene defines the current scene
  51132. * @param rootUrl defines the root URL containing the effect layer information
  51133. * @returns a parsed effect Layer
  51134. */
  51135. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51136. }
  51137. }
  51138. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51139. import { Scene } from "babylonjs/scene";
  51140. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51141. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51142. import { AbstractScene } from "babylonjs/abstractScene";
  51143. module "babylonjs/abstractScene" {
  51144. interface AbstractScene {
  51145. /**
  51146. * The list of effect layers (highlights/glow) added to the scene
  51147. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51148. * @see http://doc.babylonjs.com/how_to/glow_layer
  51149. */
  51150. effectLayers: Array<EffectLayer>;
  51151. /**
  51152. * Removes the given effect layer from this scene.
  51153. * @param toRemove defines the effect layer to remove
  51154. * @returns the index of the removed effect layer
  51155. */
  51156. removeEffectLayer(toRemove: EffectLayer): number;
  51157. /**
  51158. * Adds the given effect layer to this scene
  51159. * @param newEffectLayer defines the effect layer to add
  51160. */
  51161. addEffectLayer(newEffectLayer: EffectLayer): void;
  51162. }
  51163. }
  51164. /**
  51165. * Defines the layer scene component responsible to manage any effect layers
  51166. * in a given scene.
  51167. */
  51168. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51169. /**
  51170. * The component name helpfull to identify the component in the list of scene components.
  51171. */
  51172. readonly name: string;
  51173. /**
  51174. * The scene the component belongs to.
  51175. */
  51176. scene: Scene;
  51177. private _engine;
  51178. private _renderEffects;
  51179. private _needStencil;
  51180. private _previousStencilState;
  51181. /**
  51182. * Creates a new instance of the component for the given scene
  51183. * @param scene Defines the scene to register the component in
  51184. */
  51185. constructor(scene: Scene);
  51186. /**
  51187. * Registers the component in a given scene
  51188. */
  51189. register(): void;
  51190. /**
  51191. * Rebuilds the elements related to this component in case of
  51192. * context lost for instance.
  51193. */
  51194. rebuild(): void;
  51195. /**
  51196. * Serializes the component data to the specified json object
  51197. * @param serializationObject The object to serialize to
  51198. */
  51199. serialize(serializationObject: any): void;
  51200. /**
  51201. * Adds all the elements from the container to the scene
  51202. * @param container the container holding the elements
  51203. */
  51204. addFromContainer(container: AbstractScene): void;
  51205. /**
  51206. * Removes all the elements in the container from the scene
  51207. * @param container contains the elements to remove
  51208. * @param dispose if the removed element should be disposed (default: false)
  51209. */
  51210. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51211. /**
  51212. * Disposes the component and the associated ressources.
  51213. */
  51214. dispose(): void;
  51215. private _isReadyForMesh;
  51216. private _renderMainTexture;
  51217. private _setStencil;
  51218. private _setStencilBack;
  51219. private _draw;
  51220. private _drawCamera;
  51221. private _drawRenderingGroup;
  51222. }
  51223. }
  51224. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51225. /** @hidden */
  51226. export var glowMapMergePixelShader: {
  51227. name: string;
  51228. shader: string;
  51229. };
  51230. }
  51231. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51232. /** @hidden */
  51233. export var glowMapMergeVertexShader: {
  51234. name: string;
  51235. shader: string;
  51236. };
  51237. }
  51238. declare module "babylonjs/Layers/glowLayer" {
  51239. import { Nullable } from "babylonjs/types";
  51240. import { Camera } from "babylonjs/Cameras/camera";
  51241. import { Scene } from "babylonjs/scene";
  51242. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51244. import { Mesh } from "babylonjs/Meshes/mesh";
  51245. import { Texture } from "babylonjs/Materials/Textures/texture";
  51246. import { Effect } from "babylonjs/Materials/effect";
  51247. import { Material } from "babylonjs/Materials/material";
  51248. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51249. import { Color4 } from "babylonjs/Maths/math.color";
  51250. import "babylonjs/Shaders/glowMapMerge.fragment";
  51251. import "babylonjs/Shaders/glowMapMerge.vertex";
  51252. import "babylonjs/Layers/effectLayerSceneComponent";
  51253. module "babylonjs/abstractScene" {
  51254. interface AbstractScene {
  51255. /**
  51256. * Return a the first highlight layer of the scene with a given name.
  51257. * @param name The name of the highlight layer to look for.
  51258. * @return The highlight layer if found otherwise null.
  51259. */
  51260. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51261. }
  51262. }
  51263. /**
  51264. * Glow layer options. This helps customizing the behaviour
  51265. * of the glow layer.
  51266. */
  51267. export interface IGlowLayerOptions {
  51268. /**
  51269. * Multiplication factor apply to the canvas size to compute the render target size
  51270. * used to generated the glowing objects (the smaller the faster).
  51271. */
  51272. mainTextureRatio: number;
  51273. /**
  51274. * Enforces a fixed size texture to ensure resize independant blur.
  51275. */
  51276. mainTextureFixedSize?: number;
  51277. /**
  51278. * How big is the kernel of the blur texture.
  51279. */
  51280. blurKernelSize: number;
  51281. /**
  51282. * The camera attached to the layer.
  51283. */
  51284. camera: Nullable<Camera>;
  51285. /**
  51286. * Enable MSAA by chosing the number of samples.
  51287. */
  51288. mainTextureSamples?: number;
  51289. /**
  51290. * The rendering group to draw the layer in.
  51291. */
  51292. renderingGroupId: number;
  51293. }
  51294. /**
  51295. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51296. *
  51297. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51298. * glowy meshes to your scene.
  51299. *
  51300. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51301. */
  51302. export class GlowLayer extends EffectLayer {
  51303. /**
  51304. * Effect Name of the layer.
  51305. */
  51306. static readonly EffectName: string;
  51307. /**
  51308. * The default blur kernel size used for the glow.
  51309. */
  51310. static DefaultBlurKernelSize: number;
  51311. /**
  51312. * The default texture size ratio used for the glow.
  51313. */
  51314. static DefaultTextureRatio: number;
  51315. /**
  51316. * Sets the kernel size of the blur.
  51317. */
  51318. /**
  51319. * Gets the kernel size of the blur.
  51320. */
  51321. blurKernelSize: number;
  51322. /**
  51323. * Sets the glow intensity.
  51324. */
  51325. /**
  51326. * Gets the glow intensity.
  51327. */
  51328. intensity: number;
  51329. private _options;
  51330. private _intensity;
  51331. private _horizontalBlurPostprocess1;
  51332. private _verticalBlurPostprocess1;
  51333. private _horizontalBlurPostprocess2;
  51334. private _verticalBlurPostprocess2;
  51335. private _blurTexture1;
  51336. private _blurTexture2;
  51337. private _postProcesses1;
  51338. private _postProcesses2;
  51339. private _includedOnlyMeshes;
  51340. private _excludedMeshes;
  51341. /**
  51342. * Callback used to let the user override the color selection on a per mesh basis
  51343. */
  51344. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51345. /**
  51346. * Callback used to let the user override the texture selection on a per mesh basis
  51347. */
  51348. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51349. /**
  51350. * Instantiates a new glow Layer and references it to the scene.
  51351. * @param name The name of the layer
  51352. * @param scene The scene to use the layer in
  51353. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51354. */
  51355. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51356. /**
  51357. * Get the effect name of the layer.
  51358. * @return The effect name
  51359. */
  51360. getEffectName(): string;
  51361. /**
  51362. * Create the merge effect. This is the shader use to blit the information back
  51363. * to the main canvas at the end of the scene rendering.
  51364. */
  51365. protected _createMergeEffect(): Effect;
  51366. /**
  51367. * Creates the render target textures and post processes used in the glow layer.
  51368. */
  51369. protected _createTextureAndPostProcesses(): void;
  51370. /**
  51371. * Checks for the readiness of the element composing the layer.
  51372. * @param subMesh the mesh to check for
  51373. * @param useInstances specify wether or not to use instances to render the mesh
  51374. * @param emissiveTexture the associated emissive texture used to generate the glow
  51375. * @return true if ready otherwise, false
  51376. */
  51377. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51378. /**
  51379. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51380. */
  51381. needStencil(): boolean;
  51382. /**
  51383. * Returns true if the mesh can be rendered, otherwise false.
  51384. * @param mesh The mesh to render
  51385. * @param material The material used on the mesh
  51386. * @returns true if it can be rendered otherwise false
  51387. */
  51388. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51389. /**
  51390. * Implementation specific of rendering the generating effect on the main canvas.
  51391. * @param effect The effect used to render through
  51392. */
  51393. protected _internalRender(effect: Effect): void;
  51394. /**
  51395. * Sets the required values for both the emissive texture and and the main color.
  51396. */
  51397. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51398. /**
  51399. * Returns true if the mesh should render, otherwise false.
  51400. * @param mesh The mesh to render
  51401. * @returns true if it should render otherwise false
  51402. */
  51403. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51404. /**
  51405. * Adds specific effects defines.
  51406. * @param defines The defines to add specifics to.
  51407. */
  51408. protected _addCustomEffectDefines(defines: string[]): void;
  51409. /**
  51410. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51411. * @param mesh The mesh to exclude from the glow layer
  51412. */
  51413. addExcludedMesh(mesh: Mesh): void;
  51414. /**
  51415. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51416. * @param mesh The mesh to remove
  51417. */
  51418. removeExcludedMesh(mesh: Mesh): void;
  51419. /**
  51420. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51421. * @param mesh The mesh to include in the glow layer
  51422. */
  51423. addIncludedOnlyMesh(mesh: Mesh): void;
  51424. /**
  51425. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51426. * @param mesh The mesh to remove
  51427. */
  51428. removeIncludedOnlyMesh(mesh: Mesh): void;
  51429. /**
  51430. * Determine if a given mesh will be used in the glow layer
  51431. * @param mesh The mesh to test
  51432. * @returns true if the mesh will be highlighted by the current glow layer
  51433. */
  51434. hasMesh(mesh: AbstractMesh): boolean;
  51435. /**
  51436. * Free any resources and references associated to a mesh.
  51437. * Internal use
  51438. * @param mesh The mesh to free.
  51439. * @hidden
  51440. */
  51441. _disposeMesh(mesh: Mesh): void;
  51442. /**
  51443. * Gets the class name of the effect layer
  51444. * @returns the string with the class name of the effect layer
  51445. */
  51446. getClassName(): string;
  51447. /**
  51448. * Serializes this glow layer
  51449. * @returns a serialized glow layer object
  51450. */
  51451. serialize(): any;
  51452. /**
  51453. * Creates a Glow Layer from parsed glow layer data
  51454. * @param parsedGlowLayer defines glow layer data
  51455. * @param scene defines the current scene
  51456. * @param rootUrl defines the root URL containing the glow layer information
  51457. * @returns a parsed Glow Layer
  51458. */
  51459. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51460. }
  51461. }
  51462. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51463. /** @hidden */
  51464. export var glowBlurPostProcessPixelShader: {
  51465. name: string;
  51466. shader: string;
  51467. };
  51468. }
  51469. declare module "babylonjs/Layers/highlightLayer" {
  51470. import { Observable } from "babylonjs/Misc/observable";
  51471. import { Nullable } from "babylonjs/types";
  51472. import { Camera } from "babylonjs/Cameras/camera";
  51473. import { Scene } from "babylonjs/scene";
  51474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51476. import { Mesh } from "babylonjs/Meshes/mesh";
  51477. import { Effect } from "babylonjs/Materials/effect";
  51478. import { Material } from "babylonjs/Materials/material";
  51479. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51480. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51481. import "babylonjs/Shaders/glowMapMerge.fragment";
  51482. import "babylonjs/Shaders/glowMapMerge.vertex";
  51483. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51484. module "babylonjs/abstractScene" {
  51485. interface AbstractScene {
  51486. /**
  51487. * Return a the first highlight layer of the scene with a given name.
  51488. * @param name The name of the highlight layer to look for.
  51489. * @return The highlight layer if found otherwise null.
  51490. */
  51491. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51492. }
  51493. }
  51494. /**
  51495. * Highlight layer options. This helps customizing the behaviour
  51496. * of the highlight layer.
  51497. */
  51498. export interface IHighlightLayerOptions {
  51499. /**
  51500. * Multiplication factor apply to the canvas size to compute the render target size
  51501. * used to generated the glowing objects (the smaller the faster).
  51502. */
  51503. mainTextureRatio: number;
  51504. /**
  51505. * Enforces a fixed size texture to ensure resize independant blur.
  51506. */
  51507. mainTextureFixedSize?: number;
  51508. /**
  51509. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51510. * of the picture to blur (the smaller the faster).
  51511. */
  51512. blurTextureSizeRatio: number;
  51513. /**
  51514. * How big in texel of the blur texture is the vertical blur.
  51515. */
  51516. blurVerticalSize: number;
  51517. /**
  51518. * How big in texel of the blur texture is the horizontal blur.
  51519. */
  51520. blurHorizontalSize: number;
  51521. /**
  51522. * Alpha blending mode used to apply the blur. Default is combine.
  51523. */
  51524. alphaBlendingMode: number;
  51525. /**
  51526. * The camera attached to the layer.
  51527. */
  51528. camera: Nullable<Camera>;
  51529. /**
  51530. * Should we display highlight as a solid stroke?
  51531. */
  51532. isStroke?: boolean;
  51533. /**
  51534. * The rendering group to draw the layer in.
  51535. */
  51536. renderingGroupId: number;
  51537. }
  51538. /**
  51539. * The highlight layer Helps adding a glow effect around a mesh.
  51540. *
  51541. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51542. * glowy meshes to your scene.
  51543. *
  51544. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51545. */
  51546. export class HighlightLayer extends EffectLayer {
  51547. name: string;
  51548. /**
  51549. * Effect Name of the highlight layer.
  51550. */
  51551. static readonly EffectName: string;
  51552. /**
  51553. * The neutral color used during the preparation of the glow effect.
  51554. * This is black by default as the blend operation is a blend operation.
  51555. */
  51556. static NeutralColor: Color4;
  51557. /**
  51558. * Stencil value used for glowing meshes.
  51559. */
  51560. static GlowingMeshStencilReference: number;
  51561. /**
  51562. * Stencil value used for the other meshes in the scene.
  51563. */
  51564. static NormalMeshStencilReference: number;
  51565. /**
  51566. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51567. */
  51568. innerGlow: boolean;
  51569. /**
  51570. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51571. */
  51572. outerGlow: boolean;
  51573. /**
  51574. * Specifies the horizontal size of the blur.
  51575. */
  51576. /**
  51577. * Gets the horizontal size of the blur.
  51578. */
  51579. blurHorizontalSize: number;
  51580. /**
  51581. * Specifies the vertical size of the blur.
  51582. */
  51583. /**
  51584. * Gets the vertical size of the blur.
  51585. */
  51586. blurVerticalSize: number;
  51587. /**
  51588. * An event triggered when the highlight layer is being blurred.
  51589. */
  51590. onBeforeBlurObservable: Observable<HighlightLayer>;
  51591. /**
  51592. * An event triggered when the highlight layer has been blurred.
  51593. */
  51594. onAfterBlurObservable: Observable<HighlightLayer>;
  51595. private _instanceGlowingMeshStencilReference;
  51596. private _options;
  51597. private _downSamplePostprocess;
  51598. private _horizontalBlurPostprocess;
  51599. private _verticalBlurPostprocess;
  51600. private _blurTexture;
  51601. private _meshes;
  51602. private _excludedMeshes;
  51603. /**
  51604. * Instantiates a new highlight Layer and references it to the scene..
  51605. * @param name The name of the layer
  51606. * @param scene The scene to use the layer in
  51607. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51608. */
  51609. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51610. /**
  51611. * Get the effect name of the layer.
  51612. * @return The effect name
  51613. */
  51614. getEffectName(): string;
  51615. /**
  51616. * Create the merge effect. This is the shader use to blit the information back
  51617. * to the main canvas at the end of the scene rendering.
  51618. */
  51619. protected _createMergeEffect(): Effect;
  51620. /**
  51621. * Creates the render target textures and post processes used in the highlight layer.
  51622. */
  51623. protected _createTextureAndPostProcesses(): void;
  51624. /**
  51625. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51626. */
  51627. needStencil(): boolean;
  51628. /**
  51629. * Checks for the readiness of the element composing the layer.
  51630. * @param subMesh the mesh to check for
  51631. * @param useInstances specify wether or not to use instances to render the mesh
  51632. * @param emissiveTexture the associated emissive texture used to generate the glow
  51633. * @return true if ready otherwise, false
  51634. */
  51635. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51636. /**
  51637. * Implementation specific of rendering the generating effect on the main canvas.
  51638. * @param effect The effect used to render through
  51639. */
  51640. protected _internalRender(effect: Effect): void;
  51641. /**
  51642. * Returns true if the layer contains information to display, otherwise false.
  51643. */
  51644. shouldRender(): boolean;
  51645. /**
  51646. * Returns true if the mesh should render, otherwise false.
  51647. * @param mesh The mesh to render
  51648. * @returns true if it should render otherwise false
  51649. */
  51650. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51651. /**
  51652. * Sets the required values for both the emissive texture and and the main color.
  51653. */
  51654. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51655. /**
  51656. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51657. * @param mesh The mesh to exclude from the highlight layer
  51658. */
  51659. addExcludedMesh(mesh: Mesh): void;
  51660. /**
  51661. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51662. * @param mesh The mesh to highlight
  51663. */
  51664. removeExcludedMesh(mesh: Mesh): void;
  51665. /**
  51666. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51667. * @param mesh mesh to test
  51668. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51669. */
  51670. hasMesh(mesh: AbstractMesh): boolean;
  51671. /**
  51672. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51673. * @param mesh The mesh to highlight
  51674. * @param color The color of the highlight
  51675. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51676. */
  51677. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51678. /**
  51679. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51680. * @param mesh The mesh to highlight
  51681. */
  51682. removeMesh(mesh: Mesh): void;
  51683. /**
  51684. * Force the stencil to the normal expected value for none glowing parts
  51685. */
  51686. private _defaultStencilReference;
  51687. /**
  51688. * Free any resources and references associated to a mesh.
  51689. * Internal use
  51690. * @param mesh The mesh to free.
  51691. * @hidden
  51692. */
  51693. _disposeMesh(mesh: Mesh): void;
  51694. /**
  51695. * Dispose the highlight layer and free resources.
  51696. */
  51697. dispose(): void;
  51698. /**
  51699. * Gets the class name of the effect layer
  51700. * @returns the string with the class name of the effect layer
  51701. */
  51702. getClassName(): string;
  51703. /**
  51704. * Serializes this Highlight layer
  51705. * @returns a serialized Highlight layer object
  51706. */
  51707. serialize(): any;
  51708. /**
  51709. * Creates a Highlight layer from parsed Highlight layer data
  51710. * @param parsedHightlightLayer defines the Highlight layer data
  51711. * @param scene defines the current scene
  51712. * @param rootUrl defines the root URL containing the Highlight layer information
  51713. * @returns a parsed Highlight layer
  51714. */
  51715. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51716. }
  51717. }
  51718. declare module "babylonjs/Layers/layerSceneComponent" {
  51719. import { Scene } from "babylonjs/scene";
  51720. import { ISceneComponent } from "babylonjs/sceneComponent";
  51721. import { Layer } from "babylonjs/Layers/layer";
  51722. import { AbstractScene } from "babylonjs/abstractScene";
  51723. module "babylonjs/abstractScene" {
  51724. interface AbstractScene {
  51725. /**
  51726. * The list of layers (background and foreground) of the scene
  51727. */
  51728. layers: Array<Layer>;
  51729. }
  51730. }
  51731. /**
  51732. * Defines the layer scene component responsible to manage any layers
  51733. * in a given scene.
  51734. */
  51735. export class LayerSceneComponent implements ISceneComponent {
  51736. /**
  51737. * The component name helpfull to identify the component in the list of scene components.
  51738. */
  51739. readonly name: string;
  51740. /**
  51741. * The scene the component belongs to.
  51742. */
  51743. scene: Scene;
  51744. private _engine;
  51745. /**
  51746. * Creates a new instance of the component for the given scene
  51747. * @param scene Defines the scene to register the component in
  51748. */
  51749. constructor(scene: Scene);
  51750. /**
  51751. * Registers the component in a given scene
  51752. */
  51753. register(): void;
  51754. /**
  51755. * Rebuilds the elements related to this component in case of
  51756. * context lost for instance.
  51757. */
  51758. rebuild(): void;
  51759. /**
  51760. * Disposes the component and the associated ressources.
  51761. */
  51762. dispose(): void;
  51763. private _draw;
  51764. private _drawCameraPredicate;
  51765. private _drawCameraBackground;
  51766. private _drawCameraForeground;
  51767. private _drawRenderTargetPredicate;
  51768. private _drawRenderTargetBackground;
  51769. private _drawRenderTargetForeground;
  51770. /**
  51771. * Adds all the elements from the container to the scene
  51772. * @param container the container holding the elements
  51773. */
  51774. addFromContainer(container: AbstractScene): void;
  51775. /**
  51776. * Removes all the elements in the container from the scene
  51777. * @param container contains the elements to remove
  51778. * @param dispose if the removed element should be disposed (default: false)
  51779. */
  51780. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51781. }
  51782. }
  51783. declare module "babylonjs/Shaders/layer.fragment" {
  51784. /** @hidden */
  51785. export var layerPixelShader: {
  51786. name: string;
  51787. shader: string;
  51788. };
  51789. }
  51790. declare module "babylonjs/Shaders/layer.vertex" {
  51791. /** @hidden */
  51792. export var layerVertexShader: {
  51793. name: string;
  51794. shader: string;
  51795. };
  51796. }
  51797. declare module "babylonjs/Layers/layer" {
  51798. import { Observable } from "babylonjs/Misc/observable";
  51799. import { Nullable } from "babylonjs/types";
  51800. import { Scene } from "babylonjs/scene";
  51801. import { Vector2 } from "babylonjs/Maths/math.vector";
  51802. import { Color4 } from "babylonjs/Maths/math.color";
  51803. import { Texture } from "babylonjs/Materials/Textures/texture";
  51804. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51805. import "babylonjs/Shaders/layer.fragment";
  51806. import "babylonjs/Shaders/layer.vertex";
  51807. /**
  51808. * This represents a full screen 2d layer.
  51809. * This can be useful to display a picture in the background of your scene for instance.
  51810. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51811. */
  51812. export class Layer {
  51813. /**
  51814. * Define the name of the layer.
  51815. */
  51816. name: string;
  51817. /**
  51818. * Define the texture the layer should display.
  51819. */
  51820. texture: Nullable<Texture>;
  51821. /**
  51822. * Is the layer in background or foreground.
  51823. */
  51824. isBackground: boolean;
  51825. /**
  51826. * Define the color of the layer (instead of texture).
  51827. */
  51828. color: Color4;
  51829. /**
  51830. * Define the scale of the layer in order to zoom in out of the texture.
  51831. */
  51832. scale: Vector2;
  51833. /**
  51834. * Define an offset for the layer in order to shift the texture.
  51835. */
  51836. offset: Vector2;
  51837. /**
  51838. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51839. */
  51840. alphaBlendingMode: number;
  51841. /**
  51842. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51843. * Alpha test will not mix with the background color in case of transparency.
  51844. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51845. */
  51846. alphaTest: boolean;
  51847. /**
  51848. * Define a mask to restrict the layer to only some of the scene cameras.
  51849. */
  51850. layerMask: number;
  51851. /**
  51852. * Define the list of render target the layer is visible into.
  51853. */
  51854. renderTargetTextures: RenderTargetTexture[];
  51855. /**
  51856. * Define if the layer is only used in renderTarget or if it also
  51857. * renders in the main frame buffer of the canvas.
  51858. */
  51859. renderOnlyInRenderTargetTextures: boolean;
  51860. private _scene;
  51861. private _vertexBuffers;
  51862. private _indexBuffer;
  51863. private _effect;
  51864. private _alphaTestEffect;
  51865. /**
  51866. * An event triggered when the layer is disposed.
  51867. */
  51868. onDisposeObservable: Observable<Layer>;
  51869. private _onDisposeObserver;
  51870. /**
  51871. * Back compatibility with callback before the onDisposeObservable existed.
  51872. * The set callback will be triggered when the layer has been disposed.
  51873. */
  51874. onDispose: () => void;
  51875. /**
  51876. * An event triggered before rendering the scene
  51877. */
  51878. onBeforeRenderObservable: Observable<Layer>;
  51879. private _onBeforeRenderObserver;
  51880. /**
  51881. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51882. * The set callback will be triggered just before rendering the layer.
  51883. */
  51884. onBeforeRender: () => void;
  51885. /**
  51886. * An event triggered after rendering the scene
  51887. */
  51888. onAfterRenderObservable: Observable<Layer>;
  51889. private _onAfterRenderObserver;
  51890. /**
  51891. * Back compatibility with callback before the onAfterRenderObservable existed.
  51892. * The set callback will be triggered just after rendering the layer.
  51893. */
  51894. onAfterRender: () => void;
  51895. /**
  51896. * Instantiates a new layer.
  51897. * This represents a full screen 2d layer.
  51898. * This can be useful to display a picture in the background of your scene for instance.
  51899. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51900. * @param name Define the name of the layer in the scene
  51901. * @param imgUrl Define the url of the texture to display in the layer
  51902. * @param scene Define the scene the layer belongs to
  51903. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51904. * @param color Defines a color for the layer
  51905. */
  51906. constructor(
  51907. /**
  51908. * Define the name of the layer.
  51909. */
  51910. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51911. private _createIndexBuffer;
  51912. /** @hidden */
  51913. _rebuild(): void;
  51914. /**
  51915. * Renders the layer in the scene.
  51916. */
  51917. render(): void;
  51918. /**
  51919. * Disposes and releases the associated ressources.
  51920. */
  51921. dispose(): void;
  51922. }
  51923. }
  51924. declare module "babylonjs/Layers/index" {
  51925. export * from "babylonjs/Layers/effectLayer";
  51926. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51927. export * from "babylonjs/Layers/glowLayer";
  51928. export * from "babylonjs/Layers/highlightLayer";
  51929. export * from "babylonjs/Layers/layer";
  51930. export * from "babylonjs/Layers/layerSceneComponent";
  51931. }
  51932. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51933. /** @hidden */
  51934. export var lensFlarePixelShader: {
  51935. name: string;
  51936. shader: string;
  51937. };
  51938. }
  51939. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51940. /** @hidden */
  51941. export var lensFlareVertexShader: {
  51942. name: string;
  51943. shader: string;
  51944. };
  51945. }
  51946. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51947. import { Scene } from "babylonjs/scene";
  51948. import { Vector3 } from "babylonjs/Maths/math.vector";
  51949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51950. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51951. import "babylonjs/Shaders/lensFlare.fragment";
  51952. import "babylonjs/Shaders/lensFlare.vertex";
  51953. import { Viewport } from "babylonjs/Maths/math.viewport";
  51954. /**
  51955. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51956. * It is usually composed of several `lensFlare`.
  51957. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51958. */
  51959. export class LensFlareSystem {
  51960. /**
  51961. * Define the name of the lens flare system
  51962. */
  51963. name: string;
  51964. /**
  51965. * List of lens flares used in this system.
  51966. */
  51967. lensFlares: LensFlare[];
  51968. /**
  51969. * Define a limit from the border the lens flare can be visible.
  51970. */
  51971. borderLimit: number;
  51972. /**
  51973. * Define a viewport border we do not want to see the lens flare in.
  51974. */
  51975. viewportBorder: number;
  51976. /**
  51977. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51978. */
  51979. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51980. /**
  51981. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51982. */
  51983. layerMask: number;
  51984. /**
  51985. * Define the id of the lens flare system in the scene.
  51986. * (equal to name by default)
  51987. */
  51988. id: string;
  51989. private _scene;
  51990. private _emitter;
  51991. private _vertexBuffers;
  51992. private _indexBuffer;
  51993. private _effect;
  51994. private _positionX;
  51995. private _positionY;
  51996. private _isEnabled;
  51997. /** @hidden */
  51998. static _SceneComponentInitialization: (scene: Scene) => void;
  51999. /**
  52000. * Instantiates a lens flare system.
  52001. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52002. * It is usually composed of several `lensFlare`.
  52003. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52004. * @param name Define the name of the lens flare system in the scene
  52005. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52006. * @param scene Define the scene the lens flare system belongs to
  52007. */
  52008. constructor(
  52009. /**
  52010. * Define the name of the lens flare system
  52011. */
  52012. name: string, emitter: any, scene: Scene);
  52013. /**
  52014. * Define if the lens flare system is enabled.
  52015. */
  52016. isEnabled: boolean;
  52017. /**
  52018. * Get the scene the effects belongs to.
  52019. * @returns the scene holding the lens flare system
  52020. */
  52021. getScene(): Scene;
  52022. /**
  52023. * Get the emitter of the lens flare system.
  52024. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52025. * @returns the emitter of the lens flare system
  52026. */
  52027. getEmitter(): any;
  52028. /**
  52029. * Set the emitter of the lens flare system.
  52030. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52031. * @param newEmitter Define the new emitter of the system
  52032. */
  52033. setEmitter(newEmitter: any): void;
  52034. /**
  52035. * Get the lens flare system emitter position.
  52036. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52037. * @returns the position
  52038. */
  52039. getEmitterPosition(): Vector3;
  52040. /**
  52041. * @hidden
  52042. */
  52043. computeEffectivePosition(globalViewport: Viewport): boolean;
  52044. /** @hidden */
  52045. _isVisible(): boolean;
  52046. /**
  52047. * @hidden
  52048. */
  52049. render(): boolean;
  52050. /**
  52051. * Dispose and release the lens flare with its associated resources.
  52052. */
  52053. dispose(): void;
  52054. /**
  52055. * Parse a lens flare system from a JSON repressentation
  52056. * @param parsedLensFlareSystem Define the JSON to parse
  52057. * @param scene Define the scene the parsed system should be instantiated in
  52058. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52059. * @returns the parsed system
  52060. */
  52061. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52062. /**
  52063. * Serialize the current Lens Flare System into a JSON representation.
  52064. * @returns the serialized JSON
  52065. */
  52066. serialize(): any;
  52067. }
  52068. }
  52069. declare module "babylonjs/LensFlares/lensFlare" {
  52070. import { Nullable } from "babylonjs/types";
  52071. import { Color3 } from "babylonjs/Maths/math.color";
  52072. import { Texture } from "babylonjs/Materials/Textures/texture";
  52073. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52074. /**
  52075. * This represents one of the lens effect in a `lensFlareSystem`.
  52076. * It controls one of the indiviual texture used in the effect.
  52077. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52078. */
  52079. export class LensFlare {
  52080. /**
  52081. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52082. */
  52083. size: number;
  52084. /**
  52085. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  52086. */
  52087. position: number;
  52088. /**
  52089. * Define the lens color.
  52090. */
  52091. color: Color3;
  52092. /**
  52093. * Define the lens texture.
  52094. */
  52095. texture: Nullable<Texture>;
  52096. /**
  52097. * Define the alpha mode to render this particular lens.
  52098. */
  52099. alphaMode: number;
  52100. private _system;
  52101. /**
  52102. * Creates a new Lens Flare.
  52103. * This represents one of the lens effect in a `lensFlareSystem`.
  52104. * It controls one of the indiviual texture used in the effect.
  52105. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52106. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52107. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  52108. * @param color Define the lens color
  52109. * @param imgUrl Define the lens texture url
  52110. * @param system Define the `lensFlareSystem` this flare is part of
  52111. * @returns The newly created Lens Flare
  52112. */
  52113. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52114. /**
  52115. * Instantiates a new Lens Flare.
  52116. * This represents one of the lens effect in a `lensFlareSystem`.
  52117. * It controls one of the indiviual texture used in the effect.
  52118. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52119. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52120. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  52121. * @param color Define the lens color
  52122. * @param imgUrl Define the lens texture url
  52123. * @param system Define the `lensFlareSystem` this flare is part of
  52124. */
  52125. constructor(
  52126. /**
  52127. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52128. */
  52129. size: number,
  52130. /**
  52131. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  52132. */
  52133. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52134. /**
  52135. * Dispose and release the lens flare with its associated resources.
  52136. */
  52137. dispose(): void;
  52138. }
  52139. }
  52140. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52141. import { Nullable } from "babylonjs/types";
  52142. import { Scene } from "babylonjs/scene";
  52143. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52144. import { AbstractScene } from "babylonjs/abstractScene";
  52145. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52146. module "babylonjs/abstractScene" {
  52147. interface AbstractScene {
  52148. /**
  52149. * The list of lens flare system added to the scene
  52150. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52151. */
  52152. lensFlareSystems: Array<LensFlareSystem>;
  52153. /**
  52154. * Removes the given lens flare system from this scene.
  52155. * @param toRemove The lens flare system to remove
  52156. * @returns The index of the removed lens flare system
  52157. */
  52158. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52159. /**
  52160. * Adds the given lens flare system to this scene
  52161. * @param newLensFlareSystem The lens flare system to add
  52162. */
  52163. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52164. /**
  52165. * Gets a lens flare system using its name
  52166. * @param name defines the name to look for
  52167. * @returns the lens flare system or null if not found
  52168. */
  52169. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52170. /**
  52171. * Gets a lens flare system using its id
  52172. * @param id defines the id to look for
  52173. * @returns the lens flare system or null if not found
  52174. */
  52175. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52176. }
  52177. }
  52178. /**
  52179. * Defines the lens flare scene component responsible to manage any lens flares
  52180. * in a given scene.
  52181. */
  52182. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52183. /**
  52184. * The component name helpfull to identify the component in the list of scene components.
  52185. */
  52186. readonly name: string;
  52187. /**
  52188. * The scene the component belongs to.
  52189. */
  52190. scene: Scene;
  52191. /**
  52192. * Creates a new instance of the component for the given scene
  52193. * @param scene Defines the scene to register the component in
  52194. */
  52195. constructor(scene: Scene);
  52196. /**
  52197. * Registers the component in a given scene
  52198. */
  52199. register(): void;
  52200. /**
  52201. * Rebuilds the elements related to this component in case of
  52202. * context lost for instance.
  52203. */
  52204. rebuild(): void;
  52205. /**
  52206. * Adds all the elements from the container to the scene
  52207. * @param container the container holding the elements
  52208. */
  52209. addFromContainer(container: AbstractScene): void;
  52210. /**
  52211. * Removes all the elements in the container from the scene
  52212. * @param container contains the elements to remove
  52213. * @param dispose if the removed element should be disposed (default: false)
  52214. */
  52215. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52216. /**
  52217. * Serializes the component data to the specified json object
  52218. * @param serializationObject The object to serialize to
  52219. */
  52220. serialize(serializationObject: any): void;
  52221. /**
  52222. * Disposes the component and the associated ressources.
  52223. */
  52224. dispose(): void;
  52225. private _draw;
  52226. }
  52227. }
  52228. declare module "babylonjs/LensFlares/index" {
  52229. export * from "babylonjs/LensFlares/lensFlare";
  52230. export * from "babylonjs/LensFlares/lensFlareSystem";
  52231. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52232. }
  52233. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52234. import { Scene } from "babylonjs/scene";
  52235. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52236. import { AbstractScene } from "babylonjs/abstractScene";
  52237. /**
  52238. * Defines the shadow generator component responsible to manage any shadow generators
  52239. * in a given scene.
  52240. */
  52241. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52242. /**
  52243. * The component name helpfull to identify the component in the list of scene components.
  52244. */
  52245. readonly name: string;
  52246. /**
  52247. * The scene the component belongs to.
  52248. */
  52249. scene: Scene;
  52250. /**
  52251. * Creates a new instance of the component for the given scene
  52252. * @param scene Defines the scene to register the component in
  52253. */
  52254. constructor(scene: Scene);
  52255. /**
  52256. * Registers the component in a given scene
  52257. */
  52258. register(): void;
  52259. /**
  52260. * Rebuilds the elements related to this component in case of
  52261. * context lost for instance.
  52262. */
  52263. rebuild(): void;
  52264. /**
  52265. * Serializes the component data to the specified json object
  52266. * @param serializationObject The object to serialize to
  52267. */
  52268. serialize(serializationObject: any): void;
  52269. /**
  52270. * Adds all the elements from the container to the scene
  52271. * @param container the container holding the elements
  52272. */
  52273. addFromContainer(container: AbstractScene): void;
  52274. /**
  52275. * Removes all the elements in the container from the scene
  52276. * @param container contains the elements to remove
  52277. * @param dispose if the removed element should be disposed (default: false)
  52278. */
  52279. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52280. /**
  52281. * Rebuilds the elements related to this component in case of
  52282. * context lost for instance.
  52283. */
  52284. dispose(): void;
  52285. private _gatherRenderTargets;
  52286. }
  52287. }
  52288. declare module "babylonjs/Lights/Shadows/index" {
  52289. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52290. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52291. }
  52292. declare module "babylonjs/Lights/pointLight" {
  52293. import { Scene } from "babylonjs/scene";
  52294. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52296. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52297. import { Effect } from "babylonjs/Materials/effect";
  52298. /**
  52299. * A point light is a light defined by an unique point in world space.
  52300. * The light is emitted in every direction from this point.
  52301. * A good example of a point light is a standard light bulb.
  52302. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52303. */
  52304. export class PointLight extends ShadowLight {
  52305. private _shadowAngle;
  52306. /**
  52307. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52308. * This specifies what angle the shadow will use to be created.
  52309. *
  52310. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52311. */
  52312. /**
  52313. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52314. * This specifies what angle the shadow will use to be created.
  52315. *
  52316. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52317. */
  52318. shadowAngle: number;
  52319. /**
  52320. * Gets the direction if it has been set.
  52321. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52322. */
  52323. /**
  52324. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52325. */
  52326. direction: Vector3;
  52327. /**
  52328. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52329. * A PointLight emits the light in every direction.
  52330. * It can cast shadows.
  52331. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52332. * ```javascript
  52333. * var pointLight = new PointLight("pl", camera.position, scene);
  52334. * ```
  52335. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52336. * @param name The light friendly name
  52337. * @param position The position of the point light in the scene
  52338. * @param scene The scene the lights belongs to
  52339. */
  52340. constructor(name: string, position: Vector3, scene: Scene);
  52341. /**
  52342. * Returns the string "PointLight"
  52343. * @returns the class name
  52344. */
  52345. getClassName(): string;
  52346. /**
  52347. * Returns the integer 0.
  52348. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52349. */
  52350. getTypeID(): number;
  52351. /**
  52352. * Specifies wether or not the shadowmap should be a cube texture.
  52353. * @returns true if the shadowmap needs to be a cube texture.
  52354. */
  52355. needCube(): boolean;
  52356. /**
  52357. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52358. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52359. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52360. */
  52361. getShadowDirection(faceIndex?: number): Vector3;
  52362. /**
  52363. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52364. * - fov = PI / 2
  52365. * - aspect ratio : 1.0
  52366. * - z-near and far equal to the active camera minZ and maxZ.
  52367. * Returns the PointLight.
  52368. */
  52369. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52370. protected _buildUniformLayout(): void;
  52371. /**
  52372. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52373. * @param effect The effect to update
  52374. * @param lightIndex The index of the light in the effect to update
  52375. * @returns The point light
  52376. */
  52377. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52378. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52379. /**
  52380. * Prepares the list of defines specific to the light type.
  52381. * @param defines the list of defines
  52382. * @param lightIndex defines the index of the light for the effect
  52383. */
  52384. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52385. }
  52386. }
  52387. declare module "babylonjs/Lights/index" {
  52388. export * from "babylonjs/Lights/light";
  52389. export * from "babylonjs/Lights/shadowLight";
  52390. export * from "babylonjs/Lights/Shadows/index";
  52391. export * from "babylonjs/Lights/directionalLight";
  52392. export * from "babylonjs/Lights/hemisphericLight";
  52393. export * from "babylonjs/Lights/pointLight";
  52394. export * from "babylonjs/Lights/spotLight";
  52395. }
  52396. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52397. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52398. /**
  52399. * Header information of HDR texture files.
  52400. */
  52401. export interface HDRInfo {
  52402. /**
  52403. * The height of the texture in pixels.
  52404. */
  52405. height: number;
  52406. /**
  52407. * The width of the texture in pixels.
  52408. */
  52409. width: number;
  52410. /**
  52411. * The index of the beginning of the data in the binary file.
  52412. */
  52413. dataPosition: number;
  52414. }
  52415. /**
  52416. * This groups tools to convert HDR texture to native colors array.
  52417. */
  52418. export class HDRTools {
  52419. private static Ldexp;
  52420. private static Rgbe2float;
  52421. private static readStringLine;
  52422. /**
  52423. * Reads header information from an RGBE texture stored in a native array.
  52424. * More information on this format are available here:
  52425. * https://en.wikipedia.org/wiki/RGBE_image_format
  52426. *
  52427. * @param uint8array The binary file stored in native array.
  52428. * @return The header information.
  52429. */
  52430. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52431. /**
  52432. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52433. * This RGBE texture needs to store the information as a panorama.
  52434. *
  52435. * More information on this format are available here:
  52436. * https://en.wikipedia.org/wiki/RGBE_image_format
  52437. *
  52438. * @param buffer The binary file stored in an array buffer.
  52439. * @param size The expected size of the extracted cubemap.
  52440. * @return The Cube Map information.
  52441. */
  52442. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52443. /**
  52444. * Returns the pixels data extracted from an RGBE texture.
  52445. * This pixels will be stored left to right up to down in the R G B order in one array.
  52446. *
  52447. * More information on this format are available here:
  52448. * https://en.wikipedia.org/wiki/RGBE_image_format
  52449. *
  52450. * @param uint8array The binary file stored in an array buffer.
  52451. * @param hdrInfo The header information of the file.
  52452. * @return The pixels data in RGB right to left up to down order.
  52453. */
  52454. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52455. private static RGBE_ReadPixels_RLE;
  52456. }
  52457. }
  52458. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52459. import { Nullable } from "babylonjs/types";
  52460. import { Scene } from "babylonjs/scene";
  52461. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52462. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52463. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52464. /**
  52465. * This represents a texture coming from an HDR input.
  52466. *
  52467. * The only supported format is currently panorama picture stored in RGBE format.
  52468. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52469. */
  52470. export class HDRCubeTexture extends BaseTexture {
  52471. private static _facesMapping;
  52472. private _generateHarmonics;
  52473. private _noMipmap;
  52474. private _textureMatrix;
  52475. private _size;
  52476. private _onLoad;
  52477. private _onError;
  52478. /**
  52479. * The texture URL.
  52480. */
  52481. url: string;
  52482. /**
  52483. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52484. */
  52485. coordinatesMode: number;
  52486. protected _isBlocking: boolean;
  52487. /**
  52488. * Sets wether or not the texture is blocking during loading.
  52489. */
  52490. /**
  52491. * Gets wether or not the texture is blocking during loading.
  52492. */
  52493. isBlocking: boolean;
  52494. protected _rotationY: number;
  52495. /**
  52496. * Sets texture matrix rotation angle around Y axis in radians.
  52497. */
  52498. /**
  52499. * Gets texture matrix rotation angle around Y axis radians.
  52500. */
  52501. rotationY: number;
  52502. /**
  52503. * Gets or sets the center of the bounding box associated with the cube texture
  52504. * It must define where the camera used to render the texture was set
  52505. */
  52506. boundingBoxPosition: Vector3;
  52507. private _boundingBoxSize;
  52508. /**
  52509. * Gets or sets the size of the bounding box associated with the cube texture
  52510. * When defined, the cubemap will switch to local mode
  52511. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52512. * @example https://www.babylonjs-playground.com/#RNASML
  52513. */
  52514. boundingBoxSize: Vector3;
  52515. /**
  52516. * Instantiates an HDRTexture from the following parameters.
  52517. *
  52518. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52519. * @param scene The scene the texture will be used in
  52520. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52521. * @param noMipmap Forces to not generate the mipmap if true
  52522. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52523. * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  52524. * @param reserved Reserved flag for internal use.
  52525. */
  52526. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52527. /**
  52528. * Get the current class name of the texture useful for serialization or dynamic coding.
  52529. * @returns "HDRCubeTexture"
  52530. */
  52531. getClassName(): string;
  52532. /**
  52533. * Occurs when the file is raw .hdr file.
  52534. */
  52535. private loadTexture;
  52536. clone(): HDRCubeTexture;
  52537. delayLoad(): void;
  52538. /**
  52539. * Get the texture reflection matrix used to rotate/transform the reflection.
  52540. * @returns the reflection matrix
  52541. */
  52542. getReflectionTextureMatrix(): Matrix;
  52543. /**
  52544. * Set the texture reflection matrix used to rotate/transform the reflection.
  52545. * @param value Define the reflection matrix to set
  52546. */
  52547. setReflectionTextureMatrix(value: Matrix): void;
  52548. /**
  52549. * Parses a JSON representation of an HDR Texture in order to create the texture
  52550. * @param parsedTexture Define the JSON representation
  52551. * @param scene Define the scene the texture should be created in
  52552. * @param rootUrl Define the root url in case we need to load relative dependencies
  52553. * @returns the newly created texture after parsing
  52554. */
  52555. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52556. serialize(): any;
  52557. }
  52558. }
  52559. declare module "babylonjs/Physics/physicsEngine" {
  52560. import { Nullable } from "babylonjs/types";
  52561. import { Vector3 } from "babylonjs/Maths/math.vector";
  52562. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52563. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52564. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52565. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52566. /**
  52567. * Class used to control physics engine
  52568. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52569. */
  52570. export class PhysicsEngine implements IPhysicsEngine {
  52571. private _physicsPlugin;
  52572. /**
  52573. * Global value used to control the smallest number supported by the simulation
  52574. */
  52575. static Epsilon: number;
  52576. private _impostors;
  52577. private _joints;
  52578. /**
  52579. * Gets the gravity vector used by the simulation
  52580. */
  52581. gravity: Vector3;
  52582. /**
  52583. * Factory used to create the default physics plugin.
  52584. * @returns The default physics plugin
  52585. */
  52586. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52587. /**
  52588. * Creates a new Physics Engine
  52589. * @param gravity defines the gravity vector used by the simulation
  52590. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52591. */
  52592. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52593. /**
  52594. * Sets the gravity vector used by the simulation
  52595. * @param gravity defines the gravity vector to use
  52596. */
  52597. setGravity(gravity: Vector3): void;
  52598. /**
  52599. * Set the time step of the physics engine.
  52600. * Default is 1/60.
  52601. * To slow it down, enter 1/600 for example.
  52602. * To speed it up, 1/30
  52603. * @param newTimeStep defines the new timestep to apply to this world.
  52604. */
  52605. setTimeStep(newTimeStep?: number): void;
  52606. /**
  52607. * Get the time step of the physics engine.
  52608. * @returns the current time step
  52609. */
  52610. getTimeStep(): number;
  52611. /**
  52612. * Release all resources
  52613. */
  52614. dispose(): void;
  52615. /**
  52616. * Gets the name of the current physics plugin
  52617. * @returns the name of the plugin
  52618. */
  52619. getPhysicsPluginName(): string;
  52620. /**
  52621. * Adding a new impostor for the impostor tracking.
  52622. * This will be done by the impostor itself.
  52623. * @param impostor the impostor to add
  52624. */
  52625. addImpostor(impostor: PhysicsImpostor): void;
  52626. /**
  52627. * Remove an impostor from the engine.
  52628. * This impostor and its mesh will not longer be updated by the physics engine.
  52629. * @param impostor the impostor to remove
  52630. */
  52631. removeImpostor(impostor: PhysicsImpostor): void;
  52632. /**
  52633. * Add a joint to the physics engine
  52634. * @param mainImpostor defines the main impostor to which the joint is added.
  52635. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52636. * @param joint defines the joint that will connect both impostors.
  52637. */
  52638. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52639. /**
  52640. * Removes a joint from the simulation
  52641. * @param mainImpostor defines the impostor used with the joint
  52642. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52643. * @param joint defines the joint to remove
  52644. */
  52645. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52646. /**
  52647. * Called by the scene. No need to call it.
  52648. * @param delta defines the timespam between frames
  52649. */
  52650. _step(delta: number): void;
  52651. /**
  52652. * Gets the current plugin used to run the simulation
  52653. * @returns current plugin
  52654. */
  52655. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52656. /**
  52657. * Gets the list of physic impostors
  52658. * @returns an array of PhysicsImpostor
  52659. */
  52660. getImpostors(): Array<PhysicsImpostor>;
  52661. /**
  52662. * Gets the impostor for a physics enabled object
  52663. * @param object defines the object impersonated by the impostor
  52664. * @returns the PhysicsImpostor or null if not found
  52665. */
  52666. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52667. /**
  52668. * Gets the impostor for a physics body object
  52669. * @param body defines physics body used by the impostor
  52670. * @returns the PhysicsImpostor or null if not found
  52671. */
  52672. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52673. /**
  52674. * Does a raycast in the physics world
  52675. * @param from when should the ray start?
  52676. * @param to when should the ray end?
  52677. * @returns PhysicsRaycastResult
  52678. */
  52679. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52680. }
  52681. }
  52682. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52683. import { Nullable } from "babylonjs/types";
  52684. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52686. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52687. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52688. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52689. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52690. /** @hidden */
  52691. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52692. private _useDeltaForWorldStep;
  52693. world: any;
  52694. name: string;
  52695. private _physicsMaterials;
  52696. private _fixedTimeStep;
  52697. private _cannonRaycastResult;
  52698. private _raycastResult;
  52699. private _physicsBodysToRemoveAfterStep;
  52700. BJSCANNON: any;
  52701. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52702. setGravity(gravity: Vector3): void;
  52703. setTimeStep(timeStep: number): void;
  52704. getTimeStep(): number;
  52705. executeStep(delta: number): void;
  52706. private _removeMarkedPhysicsBodiesFromWorld;
  52707. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52708. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52709. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52710. private _processChildMeshes;
  52711. removePhysicsBody(impostor: PhysicsImpostor): void;
  52712. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52713. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52714. private _addMaterial;
  52715. private _checkWithEpsilon;
  52716. private _createShape;
  52717. private _createHeightmap;
  52718. private _minus90X;
  52719. private _plus90X;
  52720. private _tmpPosition;
  52721. private _tmpDeltaPosition;
  52722. private _tmpUnityRotation;
  52723. private _updatePhysicsBodyTransformation;
  52724. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52725. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52726. isSupported(): boolean;
  52727. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52728. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52729. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52730. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52731. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52732. getBodyMass(impostor: PhysicsImpostor): number;
  52733. getBodyFriction(impostor: PhysicsImpostor): number;
  52734. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52735. getBodyRestitution(impostor: PhysicsImpostor): number;
  52736. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52737. sleepBody(impostor: PhysicsImpostor): void;
  52738. wakeUpBody(impostor: PhysicsImpostor): void;
  52739. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52740. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52741. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52742. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52743. getRadius(impostor: PhysicsImpostor): number;
  52744. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52745. dispose(): void;
  52746. private _extendNamespace;
  52747. /**
  52748. * Does a raycast in the physics world
  52749. * @param from when should the ray start?
  52750. * @param to when should the ray end?
  52751. * @returns PhysicsRaycastResult
  52752. */
  52753. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52754. }
  52755. }
  52756. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52757. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52758. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52759. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52761. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52762. import { Nullable } from "babylonjs/types";
  52763. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52764. /** @hidden */
  52765. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52766. world: any;
  52767. name: string;
  52768. BJSOIMO: any;
  52769. private _raycastResult;
  52770. constructor(iterations?: number, oimoInjection?: any);
  52771. setGravity(gravity: Vector3): void;
  52772. setTimeStep(timeStep: number): void;
  52773. getTimeStep(): number;
  52774. private _tmpImpostorsArray;
  52775. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52776. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52777. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52778. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52779. private _tmpPositionVector;
  52780. removePhysicsBody(impostor: PhysicsImpostor): void;
  52781. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52782. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52783. isSupported(): boolean;
  52784. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52785. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52786. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52787. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52788. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52789. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52790. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52791. getBodyMass(impostor: PhysicsImpostor): number;
  52792. getBodyFriction(impostor: PhysicsImpostor): number;
  52793. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52794. getBodyRestitution(impostor: PhysicsImpostor): number;
  52795. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52796. sleepBody(impostor: PhysicsImpostor): void;
  52797. wakeUpBody(impostor: PhysicsImpostor): void;
  52798. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52799. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52800. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52801. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52802. getRadius(impostor: PhysicsImpostor): number;
  52803. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52804. dispose(): void;
  52805. /**
  52806. * Does a raycast in the physics world
  52807. * @param from when should the ray start?
  52808. * @param to when should the ray end?
  52809. * @returns PhysicsRaycastResult
  52810. */
  52811. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52812. }
  52813. }
  52814. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52815. import { Nullable } from "babylonjs/types";
  52816. import { Scene } from "babylonjs/scene";
  52817. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52818. import { Color4 } from "babylonjs/Maths/math.color";
  52819. import { Mesh } from "babylonjs/Meshes/mesh";
  52820. /**
  52821. * Class containing static functions to help procedurally build meshes
  52822. */
  52823. export class RibbonBuilder {
  52824. /**
  52825. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52826. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52827. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52828. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52829. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  52830. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  52831. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  52832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52834. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52835. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  52836. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52837. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  52838. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52840. * @param name defines the name of the mesh
  52841. * @param options defines the options used to create the mesh
  52842. * @param scene defines the hosting scene
  52843. * @returns the ribbon mesh
  52844. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52845. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52846. */
  52847. static CreateRibbon(name: string, options: {
  52848. pathArray: Vector3[][];
  52849. closeArray?: boolean;
  52850. closePath?: boolean;
  52851. offset?: number;
  52852. updatable?: boolean;
  52853. sideOrientation?: number;
  52854. frontUVs?: Vector4;
  52855. backUVs?: Vector4;
  52856. instance?: Mesh;
  52857. invertUV?: boolean;
  52858. uvs?: Vector2[];
  52859. colors?: Color4[];
  52860. }, scene?: Nullable<Scene>): Mesh;
  52861. }
  52862. }
  52863. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52864. import { Nullable } from "babylonjs/types";
  52865. import { Scene } from "babylonjs/scene";
  52866. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52867. import { Mesh } from "babylonjs/Meshes/mesh";
  52868. /**
  52869. * Class containing static functions to help procedurally build meshes
  52870. */
  52871. export class ShapeBuilder {
  52872. /**
  52873. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52874. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  52875. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52876. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  52877. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52878. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  52879. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  52880. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52883. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52885. * @param name defines the name of the mesh
  52886. * @param options defines the options used to create the mesh
  52887. * @param scene defines the hosting scene
  52888. * @returns the extruded shape mesh
  52889. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52890. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52891. */
  52892. static ExtrudeShape(name: string, options: {
  52893. shape: Vector3[];
  52894. path: Vector3[];
  52895. scale?: number;
  52896. rotation?: number;
  52897. cap?: number;
  52898. updatable?: boolean;
  52899. sideOrientation?: number;
  52900. frontUVs?: Vector4;
  52901. backUVs?: Vector4;
  52902. instance?: Mesh;
  52903. invertUV?: boolean;
  52904. }, scene?: Nullable<Scene>): Mesh;
  52905. /**
  52906. * Creates an custom extruded shape mesh.
  52907. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52908. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  52909. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52910. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  52911. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52912. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  52913. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52914. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52915. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52916. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  52917. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  52918. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52921. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52923. * @param name defines the name of the mesh
  52924. * @param options defines the options used to create the mesh
  52925. * @param scene defines the hosting scene
  52926. * @returns the custom extruded shape mesh
  52927. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52928. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52930. */
  52931. static ExtrudeShapeCustom(name: string, options: {
  52932. shape: Vector3[];
  52933. path: Vector3[];
  52934. scaleFunction?: any;
  52935. rotationFunction?: any;
  52936. ribbonCloseArray?: boolean;
  52937. ribbonClosePath?: boolean;
  52938. cap?: number;
  52939. updatable?: boolean;
  52940. sideOrientation?: number;
  52941. frontUVs?: Vector4;
  52942. backUVs?: Vector4;
  52943. instance?: Mesh;
  52944. invertUV?: boolean;
  52945. }, scene?: Nullable<Scene>): Mesh;
  52946. private static _ExtrudeShapeGeneric;
  52947. }
  52948. }
  52949. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52950. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52951. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52952. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52953. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52954. import { Nullable } from "babylonjs/types";
  52955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52956. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52957. /**
  52958. * AmmoJS Physics plugin
  52959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52960. * @see https://github.com/kripken/ammo.js/
  52961. */
  52962. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52963. private _useDeltaForWorldStep;
  52964. /**
  52965. * Reference to the Ammo library
  52966. */
  52967. bjsAMMO: any;
  52968. /**
  52969. * Created ammoJS world which physics bodies are added to
  52970. */
  52971. world: any;
  52972. /**
  52973. * Name of the plugin
  52974. */
  52975. name: string;
  52976. private _timeStep;
  52977. private _fixedTimeStep;
  52978. private _maxSteps;
  52979. private _tmpQuaternion;
  52980. private _tmpAmmoTransform;
  52981. private _tmpAmmoQuaternion;
  52982. private _tmpAmmoConcreteContactResultCallback;
  52983. private _collisionConfiguration;
  52984. private _dispatcher;
  52985. private _overlappingPairCache;
  52986. private _solver;
  52987. private _softBodySolver;
  52988. private _tmpAmmoVectorA;
  52989. private _tmpAmmoVectorB;
  52990. private _tmpAmmoVectorC;
  52991. private _tmpAmmoVectorD;
  52992. private _tmpContactCallbackResult;
  52993. private _tmpAmmoVectorRCA;
  52994. private _tmpAmmoVectorRCB;
  52995. private _raycastResult;
  52996. private static readonly DISABLE_COLLISION_FLAG;
  52997. private static readonly KINEMATIC_FLAG;
  52998. private static readonly DISABLE_DEACTIVATION_FLAG;
  52999. /**
  53000. * Initializes the ammoJS plugin
  53001. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53002. * @param ammoInjection can be used to inject your own ammo reference
  53003. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53004. */
  53005. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53006. /**
  53007. * Sets the gravity of the physics world (m/(s^2))
  53008. * @param gravity Gravity to set
  53009. */
  53010. setGravity(gravity: Vector3): void;
  53011. /**
  53012. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53013. * @param timeStep timestep to use in seconds
  53014. */
  53015. setTimeStep(timeStep: number): void;
  53016. /**
  53017. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  53018. * @param fixedTimeStep fixedTimeStep to use in seconds
  53019. */
  53020. setFixedTimeStep(fixedTimeStep: number): void;
  53021. /**
  53022. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53023. * @param maxSteps the maximum number of steps by the physics engine per frame
  53024. */
  53025. setMaxSteps(maxSteps: number): void;
  53026. /**
  53027. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53028. * @returns the current timestep in seconds
  53029. */
  53030. getTimeStep(): number;
  53031. private _isImpostorInContact;
  53032. private _isImpostorPairInContact;
  53033. private _stepSimulation;
  53034. /**
  53035. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53036. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53037. * After the step the babylon meshes are set to the position of the physics imposters
  53038. * @param delta amount of time to step forward
  53039. * @param impostors array of imposters to update before/after the step
  53040. */
  53041. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53042. /**
  53043. * Update babylon mesh to match physics world object
  53044. * @param impostor imposter to match
  53045. */
  53046. private _afterSoftStep;
  53047. /**
  53048. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53049. * @param impostor imposter to match
  53050. */
  53051. private _ropeStep;
  53052. /**
  53053. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53054. * @param impostor imposter to match
  53055. */
  53056. private _softbodyOrClothStep;
  53057. private _tmpVector;
  53058. private _tmpMatrix;
  53059. /**
  53060. * Applies an impulse on the imposter
  53061. * @param impostor imposter to apply impulse to
  53062. * @param force amount of force to be applied to the imposter
  53063. * @param contactPoint the location to apply the impulse on the imposter
  53064. */
  53065. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53066. /**
  53067. * Applies a force on the imposter
  53068. * @param impostor imposter to apply force
  53069. * @param force amount of force to be applied to the imposter
  53070. * @param contactPoint the location to apply the force on the imposter
  53071. */
  53072. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53073. /**
  53074. * Creates a physics body using the plugin
  53075. * @param impostor the imposter to create the physics body on
  53076. */
  53077. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53078. /**
  53079. * Removes the physics body from the imposter and disposes of the body's memory
  53080. * @param impostor imposter to remove the physics body from
  53081. */
  53082. removePhysicsBody(impostor: PhysicsImpostor): void;
  53083. /**
  53084. * Generates a joint
  53085. * @param impostorJoint the imposter joint to create the joint with
  53086. */
  53087. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53088. /**
  53089. * Removes a joint
  53090. * @param impostorJoint the imposter joint to remove the joint from
  53091. */
  53092. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53093. private _addMeshVerts;
  53094. /**
  53095. * Initialise the soft body vertices to match its object's (mesh) vertices
  53096. * Softbody vertices (nodes) are in world space and to match this
  53097. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53098. * @param impostor to create the softbody for
  53099. */
  53100. private _softVertexData;
  53101. /**
  53102. * Create an impostor's soft body
  53103. * @param impostor to create the softbody for
  53104. */
  53105. private _createSoftbody;
  53106. /**
  53107. * Create cloth for an impostor
  53108. * @param impostor to create the softbody for
  53109. */
  53110. private _createCloth;
  53111. /**
  53112. * Create rope for an impostor
  53113. * @param impostor to create the softbody for
  53114. */
  53115. private _createRope;
  53116. private _addHullVerts;
  53117. private _createShape;
  53118. /**
  53119. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53120. * @param impostor imposter containing the physics body and babylon object
  53121. */
  53122. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53123. /**
  53124. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53125. * @param impostor imposter containing the physics body and babylon object
  53126. * @param newPosition new position
  53127. * @param newRotation new rotation
  53128. */
  53129. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53130. /**
  53131. * If this plugin is supported
  53132. * @returns true if its supported
  53133. */
  53134. isSupported(): boolean;
  53135. /**
  53136. * Sets the linear velocity of the physics body
  53137. * @param impostor imposter to set the velocity on
  53138. * @param velocity velocity to set
  53139. */
  53140. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53141. /**
  53142. * Sets the angular velocity of the physics body
  53143. * @param impostor imposter to set the velocity on
  53144. * @param velocity velocity to set
  53145. */
  53146. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53147. /**
  53148. * gets the linear velocity
  53149. * @param impostor imposter to get linear velocity from
  53150. * @returns linear velocity
  53151. */
  53152. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53153. /**
  53154. * gets the angular velocity
  53155. * @param impostor imposter to get angular velocity from
  53156. * @returns angular velocity
  53157. */
  53158. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53159. /**
  53160. * Sets the mass of physics body
  53161. * @param impostor imposter to set the mass on
  53162. * @param mass mass to set
  53163. */
  53164. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53165. /**
  53166. * Gets the mass of the physics body
  53167. * @param impostor imposter to get the mass from
  53168. * @returns mass
  53169. */
  53170. getBodyMass(impostor: PhysicsImpostor): number;
  53171. /**
  53172. * Gets friction of the impostor
  53173. * @param impostor impostor to get friction from
  53174. * @returns friction value
  53175. */
  53176. getBodyFriction(impostor: PhysicsImpostor): number;
  53177. /**
  53178. * Sets friction of the impostor
  53179. * @param impostor impostor to set friction on
  53180. * @param friction friction value
  53181. */
  53182. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53183. /**
  53184. * Gets restitution of the impostor
  53185. * @param impostor impostor to get restitution from
  53186. * @returns restitution value
  53187. */
  53188. getBodyRestitution(impostor: PhysicsImpostor): number;
  53189. /**
  53190. * Sets resitution of the impostor
  53191. * @param impostor impostor to set resitution on
  53192. * @param restitution resitution value
  53193. */
  53194. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53195. /**
  53196. * Gets pressure inside the impostor
  53197. * @param impostor impostor to get pressure from
  53198. * @returns pressure value
  53199. */
  53200. getBodyPressure(impostor: PhysicsImpostor): number;
  53201. /**
  53202. * Sets pressure inside a soft body impostor
  53203. * Cloth and rope must remain 0 pressure
  53204. * @param impostor impostor to set pressure on
  53205. * @param pressure pressure value
  53206. */
  53207. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53208. /**
  53209. * Gets stiffness of the impostor
  53210. * @param impostor impostor to get stiffness from
  53211. * @returns pressure value
  53212. */
  53213. getBodyStiffness(impostor: PhysicsImpostor): number;
  53214. /**
  53215. * Sets stiffness of the impostor
  53216. * @param impostor impostor to set stiffness on
  53217. * @param stiffness stiffness value from 0 to 1
  53218. */
  53219. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53220. /**
  53221. * Gets velocityIterations of the impostor
  53222. * @param impostor impostor to get velocity iterations from
  53223. * @returns velocityIterations value
  53224. */
  53225. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53226. /**
  53227. * Sets velocityIterations of the impostor
  53228. * @param impostor impostor to set velocity iterations on
  53229. * @param velocityIterations velocityIterations value
  53230. */
  53231. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53232. /**
  53233. * Gets positionIterations of the impostor
  53234. * @param impostor impostor to get position iterations from
  53235. * @returns positionIterations value
  53236. */
  53237. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53238. /**
  53239. * Sets positionIterations of the impostor
  53240. * @param impostor impostor to set position on
  53241. * @param positionIterations positionIterations value
  53242. */
  53243. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53244. /**
  53245. * Append an anchor to a cloth object
  53246. * @param impostor is the cloth impostor to add anchor to
  53247. * @param otherImpostor is the rigid impostor to anchor to
  53248. * @param width ratio across width from 0 to 1
  53249. * @param height ratio up height from 0 to 1
  53250. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53251. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53252. */
  53253. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53254. /**
  53255. * Append an hook to a rope object
  53256. * @param impostor is the rope impostor to add hook to
  53257. * @param otherImpostor is the rigid impostor to hook to
  53258. * @param length ratio along the rope from 0 to 1
  53259. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53260. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53261. */
  53262. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53263. /**
  53264. * Sleeps the physics body and stops it from being active
  53265. * @param impostor impostor to sleep
  53266. */
  53267. sleepBody(impostor: PhysicsImpostor): void;
  53268. /**
  53269. * Activates the physics body
  53270. * @param impostor impostor to activate
  53271. */
  53272. wakeUpBody(impostor: PhysicsImpostor): void;
  53273. /**
  53274. * Updates the distance parameters of the joint
  53275. * @param joint joint to update
  53276. * @param maxDistance maximum distance of the joint
  53277. * @param minDistance minimum distance of the joint
  53278. */
  53279. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53280. /**
  53281. * Sets a motor on the joint
  53282. * @param joint joint to set motor on
  53283. * @param speed speed of the motor
  53284. * @param maxForce maximum force of the motor
  53285. * @param motorIndex index of the motor
  53286. */
  53287. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53288. /**
  53289. * Sets the motors limit
  53290. * @param joint joint to set limit on
  53291. * @param upperLimit upper limit
  53292. * @param lowerLimit lower limit
  53293. */
  53294. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53295. /**
  53296. * Syncs the position and rotation of a mesh with the impostor
  53297. * @param mesh mesh to sync
  53298. * @param impostor impostor to update the mesh with
  53299. */
  53300. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53301. /**
  53302. * Gets the radius of the impostor
  53303. * @param impostor impostor to get radius from
  53304. * @returns the radius
  53305. */
  53306. getRadius(impostor: PhysicsImpostor): number;
  53307. /**
  53308. * Gets the box size of the impostor
  53309. * @param impostor impostor to get box size from
  53310. * @param result the resulting box size
  53311. */
  53312. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53313. /**
  53314. * Disposes of the impostor
  53315. */
  53316. dispose(): void;
  53317. /**
  53318. * Does a raycast in the physics world
  53319. * @param from when should the ray start?
  53320. * @param to when should the ray end?
  53321. * @returns PhysicsRaycastResult
  53322. */
  53323. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53324. }
  53325. }
  53326. declare module "babylonjs/Probes/reflectionProbe" {
  53327. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53328. import { Vector3 } from "babylonjs/Maths/math.vector";
  53329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53330. import { Nullable } from "babylonjs/types";
  53331. import { Scene } from "babylonjs/scene";
  53332. module "babylonjs/abstractScene" {
  53333. interface AbstractScene {
  53334. /**
  53335. * The list of reflection probes added to the scene
  53336. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53337. */
  53338. reflectionProbes: Array<ReflectionProbe>;
  53339. /**
  53340. * Removes the given reflection probe from this scene.
  53341. * @param toRemove The reflection probe to remove
  53342. * @returns The index of the removed reflection probe
  53343. */
  53344. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53345. /**
  53346. * Adds the given reflection probe to this scene.
  53347. * @param newReflectionProbe The reflection probe to add
  53348. */
  53349. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53350. }
  53351. }
  53352. /**
  53353. * Class used to generate realtime reflection / refraction cube textures
  53354. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53355. */
  53356. export class ReflectionProbe {
  53357. /** defines the name of the probe */
  53358. name: string;
  53359. private _scene;
  53360. private _renderTargetTexture;
  53361. private _projectionMatrix;
  53362. private _viewMatrix;
  53363. private _target;
  53364. private _add;
  53365. private _attachedMesh;
  53366. private _invertYAxis;
  53367. /** Gets or sets probe position (center of the cube map) */
  53368. position: Vector3;
  53369. /**
  53370. * Creates a new reflection probe
  53371. * @param name defines the name of the probe
  53372. * @param size defines the texture resolution (for each face)
  53373. * @param scene defines the hosting scene
  53374. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53375. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53376. */
  53377. constructor(
  53378. /** defines the name of the probe */
  53379. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53380. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53381. samples: number;
  53382. /** Gets or sets the refresh rate to use (on every frame by default) */
  53383. refreshRate: number;
  53384. /**
  53385. * Gets the hosting scene
  53386. * @returns a Scene
  53387. */
  53388. getScene(): Scene;
  53389. /** Gets the internal CubeTexture used to render to */
  53390. readonly cubeTexture: RenderTargetTexture;
  53391. /** Gets the list of meshes to render */
  53392. readonly renderList: Nullable<AbstractMesh[]>;
  53393. /**
  53394. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53395. * @param mesh defines the mesh to attach to
  53396. */
  53397. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53398. /**
  53399. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53400. * @param renderingGroupId The rendering group id corresponding to its index
  53401. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53402. */
  53403. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53404. /**
  53405. * Clean all associated resources
  53406. */
  53407. dispose(): void;
  53408. /**
  53409. * Converts the reflection probe information to a readable string for debug purpose.
  53410. * @param fullDetails Supports for multiple levels of logging within scene loading
  53411. * @returns the human readable reflection probe info
  53412. */
  53413. toString(fullDetails?: boolean): string;
  53414. /**
  53415. * Get the class name of the relfection probe.
  53416. * @returns "ReflectionProbe"
  53417. */
  53418. getClassName(): string;
  53419. /**
  53420. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53421. * @returns The JSON representation of the texture
  53422. */
  53423. serialize(): any;
  53424. /**
  53425. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53426. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53427. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53428. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53429. * @returns The parsed reflection probe if successful
  53430. */
  53431. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53432. }
  53433. }
  53434. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53435. /** @hidden */
  53436. export var _BabylonLoaderRegistered: boolean;
  53437. }
  53438. declare module "babylonjs/Loading/Plugins/index" {
  53439. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53440. }
  53441. declare module "babylonjs/Loading/index" {
  53442. export * from "babylonjs/Loading/loadingScreen";
  53443. export * from "babylonjs/Loading/Plugins/index";
  53444. export * from "babylonjs/Loading/sceneLoader";
  53445. export * from "babylonjs/Loading/sceneLoaderFlags";
  53446. }
  53447. declare module "babylonjs/Materials/Background/index" {
  53448. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53449. }
  53450. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53451. import { Scene } from "babylonjs/scene";
  53452. import { Color3 } from "babylonjs/Maths/math.color";
  53453. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53454. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53455. /**
  53456. * The Physically based simple base material of BJS.
  53457. *
  53458. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53459. * It is used as the base class for both the specGloss and metalRough conventions.
  53460. */
  53461. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53462. /**
  53463. * Number of Simultaneous lights allowed on the material.
  53464. */
  53465. maxSimultaneousLights: number;
  53466. /**
  53467. * If sets to true, disables all the lights affecting the material.
  53468. */
  53469. disableLighting: boolean;
  53470. /**
  53471. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53472. */
  53473. environmentTexture: BaseTexture;
  53474. /**
  53475. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53476. */
  53477. invertNormalMapX: boolean;
  53478. /**
  53479. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53480. */
  53481. invertNormalMapY: boolean;
  53482. /**
  53483. * Normal map used in the model.
  53484. */
  53485. normalTexture: BaseTexture;
  53486. /**
  53487. * Emissivie color used to self-illuminate the model.
  53488. */
  53489. emissiveColor: Color3;
  53490. /**
  53491. * Emissivie texture used to self-illuminate the model.
  53492. */
  53493. emissiveTexture: BaseTexture;
  53494. /**
  53495. * Occlusion Channel Strenght.
  53496. */
  53497. occlusionStrength: number;
  53498. /**
  53499. * Occlusion Texture of the material (adding extra occlusion effects).
  53500. */
  53501. occlusionTexture: BaseTexture;
  53502. /**
  53503. * Defines the alpha limits in alpha test mode.
  53504. */
  53505. alphaCutOff: number;
  53506. /**
  53507. * Gets the current double sided mode.
  53508. */
  53509. /**
  53510. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53511. */
  53512. doubleSided: boolean;
  53513. /**
  53514. * Stores the pre-calculated light information of a mesh in a texture.
  53515. */
  53516. lightmapTexture: BaseTexture;
  53517. /**
  53518. * If true, the light map contains occlusion information instead of lighting info.
  53519. */
  53520. useLightmapAsShadowmap: boolean;
  53521. /**
  53522. * Instantiates a new PBRMaterial instance.
  53523. *
  53524. * @param name The material name
  53525. * @param scene The scene the material will be use in.
  53526. */
  53527. constructor(name: string, scene: Scene);
  53528. getClassName(): string;
  53529. }
  53530. }
  53531. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53532. import { Scene } from "babylonjs/scene";
  53533. import { Color3 } from "babylonjs/Maths/math.color";
  53534. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53535. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53536. /**
  53537. * The PBR material of BJS following the metal roughness convention.
  53538. *
  53539. * This fits to the PBR convention in the GLTF definition:
  53540. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53541. */
  53542. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53543. /**
  53544. * The base color has two different interpretations depending on the value of metalness.
  53545. * When the material is a metal, the base color is the specific measured reflectance value
  53546. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53547. * of the material.
  53548. */
  53549. baseColor: Color3;
  53550. /**
  53551. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53552. * well as opacity information in the alpha channel.
  53553. */
  53554. baseTexture: BaseTexture;
  53555. /**
  53556. * Specifies the metallic scalar value of the material.
  53557. * Can also be used to scale the metalness values of the metallic texture.
  53558. */
  53559. metallic: number;
  53560. /**
  53561. * Specifies the roughness scalar value of the material.
  53562. * Can also be used to scale the roughness values of the metallic texture.
  53563. */
  53564. roughness: number;
  53565. /**
  53566. * Texture containing both the metallic value in the B channel and the
  53567. * roughness value in the G channel to keep better precision.
  53568. */
  53569. metallicRoughnessTexture: BaseTexture;
  53570. /**
  53571. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53572. *
  53573. * @param name The material name
  53574. * @param scene The scene the material will be use in.
  53575. */
  53576. constructor(name: string, scene: Scene);
  53577. /**
  53578. * Return the currrent class name of the material.
  53579. */
  53580. getClassName(): string;
  53581. /**
  53582. * Makes a duplicate of the current material.
  53583. * @param name - name to use for the new material.
  53584. */
  53585. clone(name: string): PBRMetallicRoughnessMaterial;
  53586. /**
  53587. * Serialize the material to a parsable JSON object.
  53588. */
  53589. serialize(): any;
  53590. /**
  53591. * Parses a JSON object correponding to the serialize function.
  53592. */
  53593. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53594. }
  53595. }
  53596. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53597. import { Scene } from "babylonjs/scene";
  53598. import { Color3 } from "babylonjs/Maths/math.color";
  53599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53600. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53601. /**
  53602. * The PBR material of BJS following the specular glossiness convention.
  53603. *
  53604. * This fits to the PBR convention in the GLTF definition:
  53605. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53606. */
  53607. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53608. /**
  53609. * Specifies the diffuse color of the material.
  53610. */
  53611. diffuseColor: Color3;
  53612. /**
  53613. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53614. * channel.
  53615. */
  53616. diffuseTexture: BaseTexture;
  53617. /**
  53618. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53619. */
  53620. specularColor: Color3;
  53621. /**
  53622. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53623. */
  53624. glossiness: number;
  53625. /**
  53626. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53627. */
  53628. specularGlossinessTexture: BaseTexture;
  53629. /**
  53630. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53631. *
  53632. * @param name The material name
  53633. * @param scene The scene the material will be use in.
  53634. */
  53635. constructor(name: string, scene: Scene);
  53636. /**
  53637. * Return the currrent class name of the material.
  53638. */
  53639. getClassName(): string;
  53640. /**
  53641. * Makes a duplicate of the current material.
  53642. * @param name - name to use for the new material.
  53643. */
  53644. clone(name: string): PBRSpecularGlossinessMaterial;
  53645. /**
  53646. * Serialize the material to a parsable JSON object.
  53647. */
  53648. serialize(): any;
  53649. /**
  53650. * Parses a JSON object correponding to the serialize function.
  53651. */
  53652. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53653. }
  53654. }
  53655. declare module "babylonjs/Materials/PBR/index" {
  53656. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53657. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53658. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53659. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53660. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53661. }
  53662. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53663. import { Nullable } from "babylonjs/types";
  53664. import { Scene } from "babylonjs/scene";
  53665. import { Matrix } from "babylonjs/Maths/math.vector";
  53666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53667. /**
  53668. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53669. * It can help converting any input color in a desired output one. This can then be used to create effects
  53670. * from sepia, black and white to sixties or futuristic rendering...
  53671. *
  53672. * The only supported format is currently 3dl.
  53673. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53674. */
  53675. export class ColorGradingTexture extends BaseTexture {
  53676. /**
  53677. * The current texture matrix. (will always be identity in color grading texture)
  53678. */
  53679. private _textureMatrix;
  53680. /**
  53681. * The texture URL.
  53682. */
  53683. url: string;
  53684. /**
  53685. * Empty line regex stored for GC.
  53686. */
  53687. private static _noneEmptyLineRegex;
  53688. private _engine;
  53689. /**
  53690. * Instantiates a ColorGradingTexture from the following parameters.
  53691. *
  53692. * @param url The location of the color gradind data (currently only supporting 3dl)
  53693. * @param scene The scene the texture will be used in
  53694. */
  53695. constructor(url: string, scene: Scene);
  53696. /**
  53697. * Returns the texture matrix used in most of the material.
  53698. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53699. */
  53700. getTextureMatrix(): Matrix;
  53701. /**
  53702. * Occurs when the file being loaded is a .3dl LUT file.
  53703. */
  53704. private load3dlTexture;
  53705. /**
  53706. * Starts the loading process of the texture.
  53707. */
  53708. private loadTexture;
  53709. /**
  53710. * Clones the color gradind texture.
  53711. */
  53712. clone(): ColorGradingTexture;
  53713. /**
  53714. * Called during delayed load for textures.
  53715. */
  53716. delayLoad(): void;
  53717. /**
  53718. * Parses a color grading texture serialized by Babylon.
  53719. * @param parsedTexture The texture information being parsedTexture
  53720. * @param scene The scene to load the texture in
  53721. * @param rootUrl The root url of the data assets to load
  53722. * @return A color gradind texture
  53723. */
  53724. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53725. /**
  53726. * Serializes the LUT texture to json format.
  53727. */
  53728. serialize(): any;
  53729. }
  53730. }
  53731. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53732. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53733. import { Scene } from "babylonjs/scene";
  53734. import { Nullable } from "babylonjs/types";
  53735. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53736. /**
  53737. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53738. */
  53739. export class EquiRectangularCubeTexture extends BaseTexture {
  53740. /** The six faces of the cube. */
  53741. private static _FacesMapping;
  53742. private _noMipmap;
  53743. private _onLoad;
  53744. private _onError;
  53745. /** The size of the cubemap. */
  53746. private _size;
  53747. /** The buffer of the image. */
  53748. private _buffer;
  53749. /** The width of the input image. */
  53750. private _width;
  53751. /** The height of the input image. */
  53752. private _height;
  53753. /** The URL to the image. */
  53754. url: string;
  53755. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53756. coordinatesMode: number;
  53757. /**
  53758. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53759. * @param url The location of the image
  53760. * @param scene The scene the texture will be used in
  53761. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53762. * @param noMipmap Forces to not generate the mipmap if true
  53763. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53764. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53765. * @param onLoad — defines a callback called when texture is loaded
  53766. * @param onError — defines a callback called if there is an error
  53767. */
  53768. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53769. /**
  53770. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53771. */
  53772. private loadImage;
  53773. /**
  53774. * Convert the image buffer into a cubemap and create a CubeTexture.
  53775. */
  53776. private loadTexture;
  53777. /**
  53778. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53779. * @param buffer The ArrayBuffer that should be converted.
  53780. * @returns The buffer as Float32Array.
  53781. */
  53782. private getFloat32ArrayFromArrayBuffer;
  53783. /**
  53784. * Get the current class name of the texture useful for serialization or dynamic coding.
  53785. * @returns "EquiRectangularCubeTexture"
  53786. */
  53787. getClassName(): string;
  53788. /**
  53789. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53790. * @returns A clone of the current EquiRectangularCubeTexture.
  53791. */
  53792. clone(): EquiRectangularCubeTexture;
  53793. }
  53794. }
  53795. declare module "babylonjs/Misc/tga" {
  53796. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53797. /**
  53798. * Based on jsTGALoader - Javascript loader for TGA file
  53799. * By Vincent Thibault
  53800. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53801. */
  53802. export class TGATools {
  53803. private static _TYPE_INDEXED;
  53804. private static _TYPE_RGB;
  53805. private static _TYPE_GREY;
  53806. private static _TYPE_RLE_INDEXED;
  53807. private static _TYPE_RLE_RGB;
  53808. private static _TYPE_RLE_GREY;
  53809. private static _ORIGIN_MASK;
  53810. private static _ORIGIN_SHIFT;
  53811. private static _ORIGIN_BL;
  53812. private static _ORIGIN_BR;
  53813. private static _ORIGIN_UL;
  53814. private static _ORIGIN_UR;
  53815. /**
  53816. * Gets the header of a TGA file
  53817. * @param data defines the TGA data
  53818. * @returns the header
  53819. */
  53820. static GetTGAHeader(data: Uint8Array): any;
  53821. /**
  53822. * Uploads TGA content to a Babylon Texture
  53823. * @hidden
  53824. */
  53825. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53826. /** @hidden */
  53827. static _getImageData8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53828. /** @hidden */
  53829. static _getImageData16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53830. /** @hidden */
  53831. static _getImageData24bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53832. /** @hidden */
  53833. static _getImageData32bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53834. /** @hidden */
  53835. static _getImageDataGrey8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53836. /** @hidden */
  53837. static _getImageDataGrey16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53838. }
  53839. }
  53840. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53841. import { Nullable } from "babylonjs/types";
  53842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53843. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53844. /**
  53845. * Implementation of the TGA Texture Loader.
  53846. * @hidden
  53847. */
  53848. export class _TGATextureLoader implements IInternalTextureLoader {
  53849. /**
  53850. * Defines wether the loader supports cascade loading the different faces.
  53851. */
  53852. readonly supportCascades: boolean;
  53853. /**
  53854. * This returns if the loader support the current file information.
  53855. * @param extension defines the file extension of the file being loaded
  53856. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53857. * @param fallback defines the fallback internal texture if any
  53858. * @param isBase64 defines whether the texture is encoded as a base64
  53859. * @param isBuffer defines whether the texture data are stored as a buffer
  53860. * @returns true if the loader can load the specified file
  53861. */
  53862. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53863. /**
  53864. * Transform the url before loading if required.
  53865. * @param rootUrl the url of the texture
  53866. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53867. * @returns the transformed texture
  53868. */
  53869. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53870. /**
  53871. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53872. * @param rootUrl the url of the texture
  53873. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53874. * @returns the fallback texture
  53875. */
  53876. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53877. /**
  53878. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53879. * @param data contains the texture data
  53880. * @param texture defines the BabylonJS internal texture
  53881. * @param createPolynomials will be true if polynomials have been requested
  53882. * @param onLoad defines the callback to trigger once the texture is ready
  53883. * @param onError defines the callback to trigger in case of error
  53884. */
  53885. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53886. /**
  53887. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53888. * @param data contains the texture data
  53889. * @param texture defines the BabylonJS internal texture
  53890. * @param callback defines the method to call once ready to upload
  53891. */
  53892. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53893. }
  53894. }
  53895. declare module "babylonjs/Misc/basis" {
  53896. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53897. /**
  53898. * Info about the .basis files
  53899. */
  53900. class BasisFileInfo {
  53901. /**
  53902. * If the file has alpha
  53903. */
  53904. hasAlpha: boolean;
  53905. /**
  53906. * Info about each image of the basis file
  53907. */
  53908. images: Array<{
  53909. levels: Array<{
  53910. width: number;
  53911. height: number;
  53912. transcodedPixels: ArrayBufferView;
  53913. }>;
  53914. }>;
  53915. }
  53916. /**
  53917. * Result of transcoding a basis file
  53918. */
  53919. class TranscodeResult {
  53920. /**
  53921. * Info about the .basis file
  53922. */
  53923. fileInfo: BasisFileInfo;
  53924. /**
  53925. * Format to use when loading the file
  53926. */
  53927. format: number;
  53928. }
  53929. /**
  53930. * Configuration options for the Basis transcoder
  53931. */
  53932. export class BasisTranscodeConfiguration {
  53933. /**
  53934. * Supported compression formats used to determine the supported output format of the transcoder
  53935. */
  53936. supportedCompressionFormats?: {
  53937. /**
  53938. * etc1 compression format
  53939. */
  53940. etc1?: boolean;
  53941. /**
  53942. * s3tc compression format
  53943. */
  53944. s3tc?: boolean;
  53945. /**
  53946. * pvrtc compression format
  53947. */
  53948. pvrtc?: boolean;
  53949. /**
  53950. * etc2 compression format
  53951. */
  53952. etc2?: boolean;
  53953. };
  53954. /**
  53955. * If mipmap levels should be loaded for transcoded images (Default: true)
  53956. */
  53957. loadMipmapLevels?: boolean;
  53958. /**
  53959. * Index of a single image to load (Default: all images)
  53960. */
  53961. loadSingleImage?: number;
  53962. }
  53963. /**
  53964. * Used to load .Basis files
  53965. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53966. */
  53967. export class BasisTools {
  53968. private static _IgnoreSupportedFormats;
  53969. /**
  53970. * URL to use when loading the basis transcoder
  53971. */
  53972. static JSModuleURL: string;
  53973. /**
  53974. * URL to use when loading the wasm module for the transcoder
  53975. */
  53976. static WasmModuleURL: string;
  53977. /**
  53978. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53979. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53980. * @returns internal format corresponding to the Basis format
  53981. */
  53982. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53983. private static _WorkerPromise;
  53984. private static _Worker;
  53985. private static _actionId;
  53986. private static _CreateWorkerAsync;
  53987. /**
  53988. * Transcodes a loaded image file to compressed pixel data
  53989. * @param imageData image data to transcode
  53990. * @param config configuration options for the transcoding
  53991. * @returns a promise resulting in the transcoded image
  53992. */
  53993. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53994. /**
  53995. * Loads a texture from the transcode result
  53996. * @param texture texture load to
  53997. * @param transcodeResult the result of transcoding the basis file to load from
  53998. */
  53999. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54000. }
  54001. }
  54002. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54003. import { Nullable } from "babylonjs/types";
  54004. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54005. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54006. /**
  54007. * Loader for .basis file format
  54008. */
  54009. export class _BasisTextureLoader implements IInternalTextureLoader {
  54010. /**
  54011. * Defines whether the loader supports cascade loading the different faces.
  54012. */
  54013. readonly supportCascades: boolean;
  54014. /**
  54015. * This returns if the loader support the current file information.
  54016. * @param extension defines the file extension of the file being loaded
  54017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54018. * @param fallback defines the fallback internal texture if any
  54019. * @param isBase64 defines whether the texture is encoded as a base64
  54020. * @param isBuffer defines whether the texture data are stored as a buffer
  54021. * @returns true if the loader can load the specified file
  54022. */
  54023. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54024. /**
  54025. * Transform the url before loading if required.
  54026. * @param rootUrl the url of the texture
  54027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54028. * @returns the transformed texture
  54029. */
  54030. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54031. /**
  54032. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54033. * @param rootUrl the url of the texture
  54034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54035. * @returns the fallback texture
  54036. */
  54037. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54038. /**
  54039. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54040. * @param data contains the texture data
  54041. * @param texture defines the BabylonJS internal texture
  54042. * @param createPolynomials will be true if polynomials have been requested
  54043. * @param onLoad defines the callback to trigger once the texture is ready
  54044. * @param onError defines the callback to trigger in case of error
  54045. */
  54046. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54047. /**
  54048. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54049. * @param data contains the texture data
  54050. * @param texture defines the BabylonJS internal texture
  54051. * @param callback defines the method to call once ready to upload
  54052. */
  54053. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54054. }
  54055. }
  54056. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54057. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54058. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54059. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54060. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54061. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54062. }
  54063. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54064. import { Scene } from "babylonjs/scene";
  54065. import { Texture } from "babylonjs/Materials/Textures/texture";
  54066. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54067. /**
  54068. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  54069. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54070. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54071. */
  54072. export class CustomProceduralTexture extends ProceduralTexture {
  54073. private _animate;
  54074. private _time;
  54075. private _config;
  54076. private _texturePath;
  54077. /**
  54078. * Instantiates a new Custom Procedural Texture.
  54079. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  54080. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54081. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54082. * @param name Define the name of the texture
  54083. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54084. * @param size Define the size of the texture to create
  54085. * @param scene Define the scene the texture belongs to
  54086. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54087. * @param generateMipMaps Define if the texture should creates mip maps or not
  54088. */
  54089. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54090. private _loadJson;
  54091. /**
  54092. * Is the texture ready to be used ? (rendered at least once)
  54093. * @returns true if ready, otherwise, false.
  54094. */
  54095. isReady(): boolean;
  54096. /**
  54097. * Render the texture to its associated render target.
  54098. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54099. */
  54100. render(useCameraPostProcess?: boolean): void;
  54101. /**
  54102. * Update the list of dependant textures samplers in the shader.
  54103. */
  54104. updateTextures(): void;
  54105. /**
  54106. * Update the uniform values of the procedural texture in the shader.
  54107. */
  54108. updateShaderUniforms(): void;
  54109. /**
  54110. * Define if the texture animates or not.
  54111. */
  54112. animate: boolean;
  54113. }
  54114. }
  54115. declare module "babylonjs/Shaders/noise.fragment" {
  54116. /** @hidden */
  54117. export var noisePixelShader: {
  54118. name: string;
  54119. shader: string;
  54120. };
  54121. }
  54122. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54123. import { Nullable } from "babylonjs/types";
  54124. import { Scene } from "babylonjs/scene";
  54125. import { Texture } from "babylonjs/Materials/Textures/texture";
  54126. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54127. import "babylonjs/Shaders/noise.fragment";
  54128. /**
  54129. * Class used to generate noise procedural textures
  54130. */
  54131. export class NoiseProceduralTexture extends ProceduralTexture {
  54132. private _time;
  54133. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54134. brightness: number;
  54135. /** Defines the number of octaves to process */
  54136. octaves: number;
  54137. /** Defines the level of persistence (0.8 by default) */
  54138. persistence: number;
  54139. /** Gets or sets animation speed factor (default is 1) */
  54140. animationSpeedFactor: number;
  54141. /**
  54142. * Creates a new NoiseProceduralTexture
  54143. * @param name defines the name fo the texture
  54144. * @param size defines the size of the texture (default is 256)
  54145. * @param scene defines the hosting scene
  54146. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54147. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54148. */
  54149. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54150. private _updateShaderUniforms;
  54151. protected _getDefines(): string;
  54152. /** Generate the current state of the procedural texture */
  54153. render(useCameraPostProcess?: boolean): void;
  54154. /**
  54155. * Serializes this noise procedural texture
  54156. * @returns a serialized noise procedural texture object
  54157. */
  54158. serialize(): any;
  54159. /**
  54160. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54161. * @param parsedTexture defines parsed texture data
  54162. * @param scene defines the current scene
  54163. * @param rootUrl defines the root URL containing noise procedural texture information
  54164. * @returns a parsed NoiseProceduralTexture
  54165. */
  54166. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54167. }
  54168. }
  54169. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54170. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54171. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54172. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54173. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54174. }
  54175. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54176. import { Nullable } from "babylonjs/types";
  54177. import { Scene } from "babylonjs/scene";
  54178. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54179. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54180. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54181. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54182. /**
  54183. * Raw cube texture where the raw buffers are passed in
  54184. */
  54185. export class RawCubeTexture extends CubeTexture {
  54186. /**
  54187. * Creates a cube texture where the raw buffers are passed in.
  54188. * @param scene defines the scene the texture is attached to
  54189. * @param data defines the array of data to use to create each face
  54190. * @param size defines the size of the textures
  54191. * @param format defines the format of the data
  54192. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54193. * @param generateMipMaps defines if the engine should generate the mip levels
  54194. * @param invertY defines if data must be stored with Y axis inverted
  54195. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54196. * @param compression defines the compression used (null by default)
  54197. */
  54198. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54199. /**
  54200. * Updates the raw cube texture.
  54201. * @param data defines the data to store
  54202. * @param format defines the data format
  54203. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54204. * @param invertY defines if data must be stored with Y axis inverted
  54205. * @param compression defines the compression used (null by default)
  54206. * @param level defines which level of the texture to update
  54207. */
  54208. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54209. /**
  54210. * Updates a raw cube texture with RGBD encoded data.
  54211. * @param data defines the array of data [mipmap][face] to use to create each face
  54212. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54213. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54214. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54215. * @returns a promsie that resolves when the operation is complete
  54216. */
  54217. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54218. /**
  54219. * Clones the raw cube texture.
  54220. * @return a new cube texture
  54221. */
  54222. clone(): CubeTexture;
  54223. /** @hidden */
  54224. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54225. }
  54226. }
  54227. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54228. import { Scene } from "babylonjs/scene";
  54229. import { Texture } from "babylonjs/Materials/Textures/texture";
  54230. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54231. /**
  54232. * Class used to store 3D textures containing user data
  54233. */
  54234. export class RawTexture3D extends Texture {
  54235. /** Gets or sets the texture format to use */
  54236. format: number;
  54237. private _engine;
  54238. /**
  54239. * Create a new RawTexture3D
  54240. * @param data defines the data of the texture
  54241. * @param width defines the width of the texture
  54242. * @param height defines the height of the texture
  54243. * @param depth defines the depth of the texture
  54244. * @param format defines the texture format to use
  54245. * @param scene defines the hosting scene
  54246. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54247. * @param invertY defines if texture must be stored with Y axis inverted
  54248. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54249. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54250. */
  54251. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54252. /** Gets or sets the texture format to use */
  54253. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54254. /**
  54255. * Update the texture with new data
  54256. * @param data defines the data to store in the texture
  54257. */
  54258. update(data: ArrayBufferView): void;
  54259. }
  54260. }
  54261. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54262. import { Scene } from "babylonjs/scene";
  54263. import { Plane } from "babylonjs/Maths/math.plane";
  54264. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54265. /**
  54266. * Creates a refraction texture used by refraction channel of the standard material.
  54267. * It is like a mirror but to see through a material.
  54268. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54269. */
  54270. export class RefractionTexture extends RenderTargetTexture {
  54271. /**
  54272. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54273. * It is possible to directly set the refractionPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  54274. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54275. */
  54276. refractionPlane: Plane;
  54277. /**
  54278. * Define how deep under the surface we should see.
  54279. */
  54280. depth: number;
  54281. /**
  54282. * Creates a refraction texture used by refraction channel of the standard material.
  54283. * It is like a mirror but to see through a material.
  54284. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54285. * @param name Define the texture name
  54286. * @param size Define the size of the underlying texture
  54287. * @param scene Define the scene the refraction belongs to
  54288. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54289. */
  54290. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54291. /**
  54292. * Clone the refraction texture.
  54293. * @returns the cloned texture
  54294. */
  54295. clone(): RefractionTexture;
  54296. /**
  54297. * Serialize the texture to a JSON representation you could use in Parse later on
  54298. * @returns the serialized JSON representation
  54299. */
  54300. serialize(): any;
  54301. }
  54302. }
  54303. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54304. import { Nullable } from "babylonjs/types";
  54305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54306. import { Matrix } from "babylonjs/Maths/math.vector";
  54307. import { Engine } from "babylonjs/Engines/engine";
  54308. import { Scene } from "babylonjs/scene";
  54309. /**
  54310. * Defines the options related to the creation of an HtmlElementTexture
  54311. */
  54312. export interface IHtmlElementTextureOptions {
  54313. /**
  54314. * Defines wether mip maps should be created or not.
  54315. */
  54316. generateMipMaps?: boolean;
  54317. /**
  54318. * Defines the sampling mode of the texture.
  54319. */
  54320. samplingMode?: number;
  54321. /**
  54322. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54323. */
  54324. engine: Nullable<Engine>;
  54325. /**
  54326. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54327. */
  54328. scene: Nullable<Scene>;
  54329. }
  54330. /**
  54331. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54332. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54333. * is automatically managed.
  54334. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54335. * in your application.
  54336. *
  54337. * As the update is not automatic, you need to call them manually.
  54338. */
  54339. export class HtmlElementTexture extends BaseTexture {
  54340. /**
  54341. * The texture URL.
  54342. */
  54343. element: HTMLVideoElement | HTMLCanvasElement;
  54344. private static readonly DefaultOptions;
  54345. private _textureMatrix;
  54346. private _engine;
  54347. private _isVideo;
  54348. private _generateMipMaps;
  54349. private _samplingMode;
  54350. /**
  54351. * Instantiates a HtmlElementTexture from the following parameters.
  54352. *
  54353. * @param name Defines the name of the texture
  54354. * @param element Defines the video or canvas the texture is filled with
  54355. * @param options Defines the other none mandatory texture creation options
  54356. */
  54357. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54358. private _createInternalTexture;
  54359. /**
  54360. * Returns the texture matrix used in most of the material.
  54361. */
  54362. getTextureMatrix(): Matrix;
  54363. /**
  54364. * Updates the content of the texture.
  54365. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54366. */
  54367. update(invertY?: Nullable<boolean>): void;
  54368. }
  54369. }
  54370. declare module "babylonjs/Materials/Textures/index" {
  54371. export * from "babylonjs/Materials/Textures/baseTexture";
  54372. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54373. export * from "babylonjs/Materials/Textures/cubeTexture";
  54374. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54375. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54376. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54377. export * from "babylonjs/Materials/Textures/internalTexture";
  54378. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54379. export * from "babylonjs/Materials/Textures/Loaders/index";
  54380. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54381. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54382. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54383. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54384. export * from "babylonjs/Materials/Textures/rawTexture";
  54385. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54386. export * from "babylonjs/Materials/Textures/refractionTexture";
  54387. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54388. export * from "babylonjs/Materials/Textures/texture";
  54389. export * from "babylonjs/Materials/Textures/videoTexture";
  54390. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54391. }
  54392. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  54393. /**
  54394. * Enum used to define the target of a block
  54395. */
  54396. export enum NodeMaterialBlockTargets {
  54397. /** Vertex shader */
  54398. Vertex = 1,
  54399. /** Fragment shader */
  54400. Fragment = 2,
  54401. /** Neutral */
  54402. Neutral = 4,
  54403. /** Vertex and Fragment */
  54404. VertexAndFragment = 3
  54405. }
  54406. }
  54407. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  54408. /**
  54409. * Defines the kind of connection point for node based material
  54410. */
  54411. export enum NodeMaterialBlockConnectionPointTypes {
  54412. /** Float */
  54413. Float = 1,
  54414. /** Int */
  54415. Int = 2,
  54416. /** Vector2 */
  54417. Vector2 = 4,
  54418. /** Vector3 */
  54419. Vector3 = 8,
  54420. /** Vector4 */
  54421. Vector4 = 16,
  54422. /** Color3 */
  54423. Color3 = 32,
  54424. /** Color4 */
  54425. Color4 = 64,
  54426. /** Matrix */
  54427. Matrix = 128,
  54428. /** Detect type based on connection */
  54429. AutoDetect = 1024,
  54430. /** Output type that will be defined by input type */
  54431. BasedOnInput = 2048
  54432. }
  54433. }
  54434. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54435. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54436. /**
  54437. * Root class for all node material optimizers
  54438. */
  54439. export class NodeMaterialOptimizer {
  54440. /**
  54441. * Function used to optimize a NodeMaterial graph
  54442. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54443. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54444. */
  54445. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54446. }
  54447. }
  54448. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54452. import { Scene } from "babylonjs/scene";
  54453. /**
  54454. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54455. */
  54456. export class TransformBlock extends NodeMaterialBlock {
  54457. /**
  54458. * Defines the value to use to complement W value to transform it to a Vector4
  54459. */
  54460. complementW: number;
  54461. /**
  54462. * Defines the value to use to complement z value to transform it to a Vector4
  54463. */
  54464. complementZ: number;
  54465. /**
  54466. * Creates a new TransformBlock
  54467. * @param name defines the block name
  54468. */
  54469. constructor(name: string);
  54470. /**
  54471. * Gets the current class name
  54472. * @returns the class name
  54473. */
  54474. getClassName(): string;
  54475. /**
  54476. * Gets the vector input
  54477. */
  54478. readonly vector: NodeMaterialConnectionPoint;
  54479. /**
  54480. * Gets the output component
  54481. */
  54482. readonly output: NodeMaterialConnectionPoint;
  54483. /**
  54484. * Gets the matrix transform input
  54485. */
  54486. readonly transform: NodeMaterialConnectionPoint;
  54487. protected _buildBlock(state: NodeMaterialBuildState): this;
  54488. serialize(): any;
  54489. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54490. protected _dumpPropertiesCode(): string;
  54491. }
  54492. }
  54493. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54495. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54496. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54497. /**
  54498. * Block used to output the vertex position
  54499. */
  54500. export class VertexOutputBlock extends NodeMaterialBlock {
  54501. /**
  54502. * Creates a new VertexOutputBlock
  54503. * @param name defines the block name
  54504. */
  54505. constructor(name: string);
  54506. /**
  54507. * Gets the current class name
  54508. * @returns the class name
  54509. */
  54510. getClassName(): string;
  54511. /**
  54512. * Gets the vector input component
  54513. */
  54514. readonly vector: NodeMaterialConnectionPoint;
  54515. protected _buildBlock(state: NodeMaterialBuildState): this;
  54516. }
  54517. }
  54518. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54519. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54520. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54521. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54522. /**
  54523. * Block used to output the final color
  54524. */
  54525. export class FragmentOutputBlock extends NodeMaterialBlock {
  54526. /**
  54527. * Create a new FragmentOutputBlock
  54528. * @param name defines the block name
  54529. */
  54530. constructor(name: string);
  54531. /**
  54532. * Gets the current class name
  54533. * @returns the class name
  54534. */
  54535. getClassName(): string;
  54536. /**
  54537. * Gets the rgba input component
  54538. */
  54539. readonly rgba: NodeMaterialConnectionPoint;
  54540. /**
  54541. * Gets the rgb input component
  54542. */
  54543. readonly rgb: NodeMaterialConnectionPoint;
  54544. /**
  54545. * Gets the a input component
  54546. */
  54547. readonly a: NodeMaterialConnectionPoint;
  54548. protected _buildBlock(state: NodeMaterialBuildState): this;
  54549. }
  54550. }
  54551. declare module "babylonjs/Materials/Node/nodeMaterialSystemValues" {
  54552. /**
  54553. * Enum used to define system values e.g. values automatically provided by the system
  54554. */
  54555. export enum NodeMaterialSystemValues {
  54556. /** World */
  54557. World = 1,
  54558. /** View */
  54559. View = 2,
  54560. /** Projection */
  54561. Projection = 3,
  54562. /** ViewProjection */
  54563. ViewProjection = 4,
  54564. /** WorldView */
  54565. WorldView = 5,
  54566. /** WorldViewProjection */
  54567. WorldViewProjection = 6,
  54568. /** CameraPosition */
  54569. CameraPosition = 7,
  54570. /** Fog Color */
  54571. FogColor = 8
  54572. }
  54573. }
  54574. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54575. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54576. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54577. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54578. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54580. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54581. import { Effect } from "babylonjs/Materials/effect";
  54582. import { Mesh } from "babylonjs/Meshes/mesh";
  54583. import { Nullable } from "babylonjs/types";
  54584. import { Scene } from "babylonjs/scene";
  54585. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54586. /**
  54587. * Block used to read a reflection texture from a sampler
  54588. */
  54589. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54590. private _define3DName;
  54591. private _defineCubicName;
  54592. private _defineExplicitName;
  54593. private _defineProjectionName;
  54594. private _defineLocalCubicName;
  54595. private _defineSphericalName;
  54596. private _definePlanarName;
  54597. private _defineEquirectangularName;
  54598. private _defineMirroredEquirectangularFixedName;
  54599. private _defineEquirectangularFixedName;
  54600. private _defineSkyboxName;
  54601. private _cubeSamplerName;
  54602. private _2DSamplerName;
  54603. private _positionUVWName;
  54604. private _directionWName;
  54605. private _reflectionCoordsName;
  54606. private _reflection2DCoordsName;
  54607. private _reflectionColorName;
  54608. private _reflectionMatrixName;
  54609. /**
  54610. * Gets or sets the texture associated with the node
  54611. */
  54612. texture: Nullable<BaseTexture>;
  54613. /**
  54614. * Create a new TextureBlock
  54615. * @param name defines the block name
  54616. */
  54617. constructor(name: string);
  54618. /**
  54619. * Gets the current class name
  54620. * @returns the class name
  54621. */
  54622. getClassName(): string;
  54623. /**
  54624. * Gets the world position input component
  54625. */
  54626. readonly position: NodeMaterialConnectionPoint;
  54627. /**
  54628. * Gets the world position input component
  54629. */
  54630. readonly worldPosition: NodeMaterialConnectionPoint;
  54631. /**
  54632. * Gets the world normal input component
  54633. */
  54634. readonly worldNormal: NodeMaterialConnectionPoint;
  54635. /**
  54636. * Gets the world input component
  54637. */
  54638. readonly world: NodeMaterialConnectionPoint;
  54639. /**
  54640. * Gets the camera (or eye) position component
  54641. */
  54642. readonly cameraPosition: NodeMaterialConnectionPoint;
  54643. /**
  54644. * Gets the view input component
  54645. */
  54646. readonly view: NodeMaterialConnectionPoint;
  54647. /**
  54648. * Gets the rgb output component
  54649. */
  54650. readonly rgb: NodeMaterialConnectionPoint;
  54651. /**
  54652. * Gets the r output component
  54653. */
  54654. readonly r: NodeMaterialConnectionPoint;
  54655. /**
  54656. * Gets the g output component
  54657. */
  54658. readonly g: NodeMaterialConnectionPoint;
  54659. /**
  54660. * Gets the b output component
  54661. */
  54662. readonly b: NodeMaterialConnectionPoint;
  54663. autoConfigure(material: NodeMaterial): void;
  54664. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54665. isReady(): boolean;
  54666. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54667. private _injectVertexCode;
  54668. private _writeOutput;
  54669. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54670. serialize(): any;
  54671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54672. }
  54673. }
  54674. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54675. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54676. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54677. import { Scene } from "babylonjs/scene";
  54678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54679. import { Matrix } from "babylonjs/Maths/math.vector";
  54680. import { Mesh } from "babylonjs/Meshes/mesh";
  54681. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54682. import { Observable } from "babylonjs/Misc/observable";
  54683. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54684. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54685. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54686. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54687. import { Nullable } from "babylonjs/types";
  54688. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54689. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54690. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54691. /**
  54692. * Interface used to configure the node material editor
  54693. */
  54694. export interface INodeMaterialEditorOptions {
  54695. /** Define the URl to load node editor script */
  54696. editorURL?: string;
  54697. }
  54698. /** @hidden */
  54699. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54700. /** BONES */
  54701. NUM_BONE_INFLUENCERS: number;
  54702. BonesPerMesh: number;
  54703. BONETEXTURE: boolean;
  54704. /** MORPH TARGETS */
  54705. MORPHTARGETS: boolean;
  54706. MORPHTARGETS_NORMAL: boolean;
  54707. MORPHTARGETS_TANGENT: boolean;
  54708. MORPHTARGETS_UV: boolean;
  54709. NUM_MORPH_INFLUENCERS: number;
  54710. /** IMAGE PROCESSING */
  54711. IMAGEPROCESSING: boolean;
  54712. VIGNETTE: boolean;
  54713. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54714. VIGNETTEBLENDMODEOPAQUE: boolean;
  54715. TONEMAPPING: boolean;
  54716. TONEMAPPING_ACES: boolean;
  54717. CONTRAST: boolean;
  54718. EXPOSURE: boolean;
  54719. COLORCURVES: boolean;
  54720. COLORGRADING: boolean;
  54721. COLORGRADING3D: boolean;
  54722. SAMPLER3DGREENDEPTH: boolean;
  54723. SAMPLER3DBGRMAP: boolean;
  54724. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54725. /** MISC. */
  54726. BUMPDIRECTUV: number;
  54727. constructor();
  54728. setValue(name: string, value: boolean): void;
  54729. }
  54730. /**
  54731. * Class used to configure NodeMaterial
  54732. */
  54733. export interface INodeMaterialOptions {
  54734. /**
  54735. * Defines if blocks should emit comments
  54736. */
  54737. emitComments: boolean;
  54738. }
  54739. /**
  54740. * Class used to create a node based material built by assembling shader blocks
  54741. */
  54742. export class NodeMaterial extends PushMaterial {
  54743. private static _BuildIdGenerator;
  54744. private _options;
  54745. private _vertexCompilationState;
  54746. private _fragmentCompilationState;
  54747. private _sharedData;
  54748. private _buildId;
  54749. private _buildWasSuccessful;
  54750. private _cachedWorldViewMatrix;
  54751. private _cachedWorldViewProjectionMatrix;
  54752. private _optimizers;
  54753. private _animationFrame;
  54754. /** Define the URl to load node editor script */
  54755. static EditorURL: string;
  54756. private BJSNODEMATERIALEDITOR;
  54757. /** Get the inspector from bundle or global */
  54758. private _getGlobalNodeMaterialEditor;
  54759. /**
  54760. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  54761. */
  54762. ignoreAlpha: boolean;
  54763. /**
  54764. * Defines the maximum number of lights that can be used in the material
  54765. */
  54766. maxSimultaneousLights: number;
  54767. /**
  54768. * Observable raised when the material is built
  54769. */
  54770. onBuildObservable: Observable<NodeMaterial>;
  54771. /**
  54772. * Gets or sets the root nodes of the material vertex shader
  54773. */
  54774. _vertexOutputNodes: NodeMaterialBlock[];
  54775. /**
  54776. * Gets or sets the root nodes of the material fragment (pixel) shader
  54777. */
  54778. _fragmentOutputNodes: NodeMaterialBlock[];
  54779. /** Gets or sets options to control the node material overall behavior */
  54780. options: INodeMaterialOptions;
  54781. /**
  54782. * Default configuration related to image processing available in the standard Material.
  54783. */
  54784. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54785. /**
  54786. * Gets the image processing configuration used either in this material.
  54787. */
  54788. /**
  54789. * Sets the Default image processing configuration used either in the this material.
  54790. *
  54791. * If sets to null, the scene one is in use.
  54792. */
  54793. imageProcessingConfiguration: ImageProcessingConfiguration;
  54794. /**
  54795. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54796. */
  54797. attachedBlocks: NodeMaterialBlock[];
  54798. /**
  54799. * Create a new node based material
  54800. * @param name defines the material name
  54801. * @param scene defines the hosting scene
  54802. * @param options defines creation option
  54803. */
  54804. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54805. /**
  54806. * Gets the current class name of the material e.g. "NodeMaterial"
  54807. * @returns the class name
  54808. */
  54809. getClassName(): string;
  54810. /**
  54811. * Keep track of the image processing observer to allow dispose and replace.
  54812. */
  54813. private _imageProcessingObserver;
  54814. /**
  54815. * Attaches a new image processing configuration to the Standard Material.
  54816. * @param configuration
  54817. */
  54818. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54819. /**
  54820. * Get a block by its name
  54821. * @param name defines the name of the block to retrieve
  54822. * @returns the required block or null if not found
  54823. */
  54824. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54825. /**
  54826. * Get a block by its name
  54827. * @param predicate defines the predicate used to find the good candidate
  54828. * @returns the required block or null if not found
  54829. */
  54830. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54831. /**
  54832. * Get an input block by its name
  54833. * @param predicate defines the predicate used to find the good candidate
  54834. * @returns the required input block or null if not found
  54835. */
  54836. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54837. /**
  54838. * Gets the list of input blocks attached to this material
  54839. * @returns an array of InputBlocks
  54840. */
  54841. getInputBlocks(): InputBlock[];
  54842. /**
  54843. * Adds a new optimizer to the list of optimizers
  54844. * @param optimizer defines the optimizers to add
  54845. * @returns the current material
  54846. */
  54847. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54848. /**
  54849. * Remove an optimizer from the list of optimizers
  54850. * @param optimizer defines the optimizers to remove
  54851. * @returns the current material
  54852. */
  54853. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54854. /**
  54855. * Add a new block to the list of output nodes
  54856. * @param node defines the node to add
  54857. * @returns the current material
  54858. */
  54859. addOutputNode(node: NodeMaterialBlock): this;
  54860. /**
  54861. * Remove a block from the list of root nodes
  54862. * @param node defines the node to remove
  54863. * @returns the current material
  54864. */
  54865. removeOutputNode(node: NodeMaterialBlock): this;
  54866. private _addVertexOutputNode;
  54867. private _removeVertexOutputNode;
  54868. private _addFragmentOutputNode;
  54869. private _removeFragmentOutputNode;
  54870. /**
  54871. * Specifies if the material will require alpha blending
  54872. * @returns a boolean specifying if alpha blending is needed
  54873. */
  54874. needAlphaBlending(): boolean;
  54875. /**
  54876. * Specifies if this material should be rendered in alpha test mode
  54877. * @returns a boolean specifying if an alpha test is needed.
  54878. */
  54879. needAlphaTesting(): boolean;
  54880. private _initializeBlock;
  54881. private _resetDualBlocks;
  54882. /**
  54883. * Build the material and generates the inner effect
  54884. * @param verbose defines if the build should log activity
  54885. */
  54886. build(verbose?: boolean): void;
  54887. /**
  54888. * Runs an otpimization phase to try to improve the shader code
  54889. */
  54890. optimize(): void;
  54891. private _prepareDefinesForAttributes;
  54892. /**
  54893. * Get if the submesh is ready to be used and all its information available.
  54894. * Child classes can use it to update shaders
  54895. * @param mesh defines the mesh to check
  54896. * @param subMesh defines which submesh to check
  54897. * @param useInstances specifies that instances should be used
  54898. * @returns a boolean indicating that the submesh is ready or not
  54899. */
  54900. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54901. /**
  54902. * Get a string representing the shaders built by the current node graph
  54903. */
  54904. readonly compiledShaders: string;
  54905. /**
  54906. * Binds the world matrix to the material
  54907. * @param world defines the world transformation matrix
  54908. */
  54909. bindOnlyWorldMatrix(world: Matrix): void;
  54910. /**
  54911. * Binds the submesh to this material by preparing the effect and shader to draw
  54912. * @param world defines the world transformation matrix
  54913. * @param mesh defines the mesh containing the submesh
  54914. * @param subMesh defines the submesh to bind the material to
  54915. */
  54916. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54917. /**
  54918. * Gets the active textures from the material
  54919. * @returns an array of textures
  54920. */
  54921. getActiveTextures(): BaseTexture[];
  54922. /**
  54923. * Gets the list of texture blocks
  54924. * @returns an array of texture blocks
  54925. */
  54926. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54927. /**
  54928. * Specifies if the material uses a texture
  54929. * @param texture defines the texture to check against the material
  54930. * @returns a boolean specifying if the material uses the texture
  54931. */
  54932. hasTexture(texture: BaseTexture): boolean;
  54933. /**
  54934. * Disposes the material
  54935. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54936. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54937. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54938. */
  54939. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54940. /** Creates the node editor window. */
  54941. private _createNodeEditor;
  54942. /**
  54943. * Launch the node material editor
  54944. * @param config Define the configuration of the editor
  54945. * @return a promise fulfilled when the node editor is visible
  54946. */
  54947. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54948. /**
  54949. * Clear the current material
  54950. */
  54951. clear(): void;
  54952. /**
  54953. * Clear the current material and set it to a default state
  54954. */
  54955. setToDefault(): void;
  54956. /**
  54957. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54958. * @param url defines the url to load from
  54959. * @returns a promise that will fullfil when the material is fully loaded
  54960. */
  54961. loadAsync(url: string): Promise<unknown>;
  54962. private _gatherBlocks;
  54963. /**
  54964. * Generate a string containing the code declaration required to create an equivalent of this material
  54965. * @returns a string
  54966. */
  54967. generateCode(): string;
  54968. /**
  54969. * Serializes this material in a JSON representation
  54970. * @returns the serialized material object
  54971. */
  54972. serialize(): any;
  54973. private _restoreConnections;
  54974. /**
  54975. * Clear the current graph and load a new one from a serialization object
  54976. * @param source defines the JSON representation of the material
  54977. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54978. */
  54979. loadFromSerialization(source: any, rootUrl?: string): void;
  54980. /**
  54981. * Creates a node material from parsed material data
  54982. * @param source defines the JSON representation of the material
  54983. * @param scene defines the hosting scene
  54984. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54985. * @returns a new node material
  54986. */
  54987. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54988. /**
  54989. * Creates a new node material set to default basic configuration
  54990. * @param name defines the name of the material
  54991. * @param scene defines the hosting scene
  54992. * @returns a new NodeMaterial
  54993. */
  54994. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54995. }
  54996. }
  54997. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55000. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55001. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55003. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55004. import { Effect } from "babylonjs/Materials/effect";
  55005. import { Mesh } from "babylonjs/Meshes/mesh";
  55006. import { Nullable } from "babylonjs/types";
  55007. import { Texture } from "babylonjs/Materials/Textures/texture";
  55008. import { Scene } from "babylonjs/scene";
  55009. /**
  55010. * Block used to read a texture from a sampler
  55011. */
  55012. export class TextureBlock extends NodeMaterialBlock {
  55013. private _defineName;
  55014. private _samplerName;
  55015. private _transformedUVName;
  55016. private _textureTransformName;
  55017. private _textureInfoName;
  55018. private _mainUVName;
  55019. private _mainUVDefineName;
  55020. /**
  55021. * Gets or sets the texture associated with the node
  55022. */
  55023. texture: Nullable<Texture>;
  55024. /**
  55025. * Create a new TextureBlock
  55026. * @param name defines the block name
  55027. */
  55028. constructor(name: string);
  55029. /**
  55030. * Gets the current class name
  55031. * @returns the class name
  55032. */
  55033. getClassName(): string;
  55034. /**
  55035. * Gets the uv input component
  55036. */
  55037. readonly uv: NodeMaterialConnectionPoint;
  55038. /**
  55039. * Gets the rgba output component
  55040. */
  55041. readonly rgba: NodeMaterialConnectionPoint;
  55042. /**
  55043. * Gets the rgb output component
  55044. */
  55045. readonly rgb: NodeMaterialConnectionPoint;
  55046. /**
  55047. * Gets the r output component
  55048. */
  55049. readonly r: NodeMaterialConnectionPoint;
  55050. /**
  55051. * Gets the g output component
  55052. */
  55053. readonly g: NodeMaterialConnectionPoint;
  55054. /**
  55055. * Gets the b output component
  55056. */
  55057. readonly b: NodeMaterialConnectionPoint;
  55058. /**
  55059. * Gets the a output component
  55060. */
  55061. readonly a: NodeMaterialConnectionPoint;
  55062. readonly target: NodeMaterialBlockTargets;
  55063. autoConfigure(material: NodeMaterial): void;
  55064. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55065. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55066. isReady(): boolean;
  55067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55068. private readonly _isMixed;
  55069. private _injectVertexCode;
  55070. private _writeOutput;
  55071. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55072. protected _dumpPropertiesCode(): string;
  55073. serialize(): any;
  55074. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55075. }
  55076. }
  55077. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55079. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55080. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55081. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55082. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55083. import { Scene } from "babylonjs/scene";
  55084. /**
  55085. * Class used to store shared data between 2 NodeMaterialBuildState
  55086. */
  55087. export class NodeMaterialBuildStateSharedData {
  55088. /**
  55089. * Gets the list of emitted varyings
  55090. */
  55091. temps: string[];
  55092. /**
  55093. * Gets the list of emitted varyings
  55094. */
  55095. varyings: string[];
  55096. /**
  55097. * Gets the varying declaration string
  55098. */
  55099. varyingDeclaration: string;
  55100. /**
  55101. * Input blocks
  55102. */
  55103. inputBlocks: InputBlock[];
  55104. /**
  55105. * Input blocks
  55106. */
  55107. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55108. /**
  55109. * Bindable blocks (Blocks that need to set data to the effect)
  55110. */
  55111. bindableBlocks: NodeMaterialBlock[];
  55112. /**
  55113. * List of blocks that can provide a compilation fallback
  55114. */
  55115. blocksWithFallbacks: NodeMaterialBlock[];
  55116. /**
  55117. * List of blocks that can provide a define update
  55118. */
  55119. blocksWithDefines: NodeMaterialBlock[];
  55120. /**
  55121. * List of blocks that can provide a repeatable content
  55122. */
  55123. repeatableContentBlocks: NodeMaterialBlock[];
  55124. /**
  55125. * List of blocks that can provide a dynamic list of uniforms
  55126. */
  55127. dynamicUniformBlocks: NodeMaterialBlock[];
  55128. /**
  55129. * List of blocks that can block the isReady function for the material
  55130. */
  55131. blockingBlocks: NodeMaterialBlock[];
  55132. /**
  55133. * Gets the list of animated inputs
  55134. */
  55135. animatedInputs: InputBlock[];
  55136. /**
  55137. * Build Id used to avoid multiple recompilations
  55138. */
  55139. buildId: number;
  55140. /** List of emitted variables */
  55141. variableNames: {
  55142. [key: string]: number;
  55143. };
  55144. /** List of emitted defines */
  55145. defineNames: {
  55146. [key: string]: number;
  55147. };
  55148. /** Should emit comments? */
  55149. emitComments: boolean;
  55150. /** Emit build activity */
  55151. verbose: boolean;
  55152. /** Gets or sets the hosting scene */
  55153. scene: Scene;
  55154. /**
  55155. * Gets the compilation hints emitted at compilation time
  55156. */
  55157. hints: {
  55158. needWorldViewMatrix: boolean;
  55159. needWorldViewProjectionMatrix: boolean;
  55160. needAlphaBlending: boolean;
  55161. needAlphaTesting: boolean;
  55162. };
  55163. /**
  55164. * List of compilation checks
  55165. */
  55166. checks: {
  55167. emitVertex: boolean;
  55168. emitFragment: boolean;
  55169. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55170. };
  55171. /** Creates a new shared data */
  55172. constructor();
  55173. /**
  55174. * Emits console errors and exceptions if there is a failing check
  55175. */
  55176. emitErrors(): void;
  55177. }
  55178. }
  55179. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55180. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55181. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55182. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55183. /**
  55184. * Class used to store node based material build state
  55185. */
  55186. export class NodeMaterialBuildState {
  55187. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55188. supportUniformBuffers: boolean;
  55189. /**
  55190. * Gets the list of emitted attributes
  55191. */
  55192. attributes: string[];
  55193. /**
  55194. * Gets the list of emitted uniforms
  55195. */
  55196. uniforms: string[];
  55197. /**
  55198. * Gets the list of emitted uniform buffers
  55199. */
  55200. uniformBuffers: string[];
  55201. /**
  55202. * Gets the list of emitted samplers
  55203. */
  55204. samplers: string[];
  55205. /**
  55206. * Gets the list of emitted functions
  55207. */
  55208. functions: {
  55209. [key: string]: string;
  55210. };
  55211. /**
  55212. * Gets the list of emitted extensions
  55213. */
  55214. extensions: {
  55215. [key: string]: string;
  55216. };
  55217. /**
  55218. * Gets the target of the compilation state
  55219. */
  55220. target: NodeMaterialBlockTargets;
  55221. /**
  55222. * Gets the list of emitted counters
  55223. */
  55224. counters: {
  55225. [key: string]: number;
  55226. };
  55227. /**
  55228. * Shared data between multiple NodeMaterialBuildState instances
  55229. */
  55230. sharedData: NodeMaterialBuildStateSharedData;
  55231. /** @hidden */
  55232. _vertexState: NodeMaterialBuildState;
  55233. /** @hidden */
  55234. _attributeDeclaration: string;
  55235. /** @hidden */
  55236. _uniformDeclaration: string;
  55237. /** @hidden */
  55238. _samplerDeclaration: string;
  55239. /** @hidden */
  55240. _varyingTransfer: string;
  55241. private _repeatableContentAnchorIndex;
  55242. /** @hidden */
  55243. _builtCompilationString: string;
  55244. /**
  55245. * Gets the emitted compilation strings
  55246. */
  55247. compilationString: string;
  55248. /**
  55249. * Finalize the compilation strings
  55250. * @param state defines the current compilation state
  55251. */
  55252. finalize(state: NodeMaterialBuildState): void;
  55253. /** @hidden */
  55254. readonly _repeatableContentAnchor: string;
  55255. /** @hidden */
  55256. _getFreeVariableName(prefix: string): string;
  55257. /** @hidden */
  55258. _getFreeDefineName(prefix: string): string;
  55259. /** @hidden */
  55260. _excludeVariableName(name: string): void;
  55261. /** @hidden */
  55262. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55263. /** @hidden */
  55264. _emitExtension(name: string, extension: string): void;
  55265. /** @hidden */
  55266. _emitFunction(name: string, code: string, comments: string): void;
  55267. /** @hidden */
  55268. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55269. replaceStrings?: {
  55270. search: RegExp;
  55271. replace: string;
  55272. }[];
  55273. repeatKey?: string;
  55274. }): string;
  55275. /** @hidden */
  55276. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55277. repeatKey?: string;
  55278. removeAttributes?: boolean;
  55279. removeUniforms?: boolean;
  55280. removeVaryings?: boolean;
  55281. removeIfDef?: boolean;
  55282. replaceStrings?: {
  55283. search: RegExp;
  55284. replace: string;
  55285. }[];
  55286. }, storeKey?: string): void;
  55287. /** @hidden */
  55288. _registerTempVariable(name: string): boolean;
  55289. /** @hidden */
  55290. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55291. /** @hidden */
  55292. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55293. }
  55294. }
  55295. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55296. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55297. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55298. import { Nullable } from "babylonjs/types";
  55299. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55300. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55301. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55303. import { Mesh } from "babylonjs/Meshes/mesh";
  55304. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55305. import { Scene } from "babylonjs/scene";
  55306. /**
  55307. * Defines a block that can be used inside a node based material
  55308. */
  55309. export class NodeMaterialBlock {
  55310. private _buildId;
  55311. private _buildTarget;
  55312. private _target;
  55313. private _isFinalMerger;
  55314. private _isInput;
  55315. /** @hidden */
  55316. _codeVariableName: string;
  55317. /** @hidden */
  55318. _inputs: NodeMaterialConnectionPoint[];
  55319. /** @hidden */
  55320. _outputs: NodeMaterialConnectionPoint[];
  55321. /** @hidden */
  55322. _preparationId: number;
  55323. /**
  55324. * Gets or sets the name of the block
  55325. */
  55326. name: string;
  55327. /**
  55328. * Gets or sets the unique id of the node
  55329. */
  55330. uniqueId: number;
  55331. /**
  55332. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55333. */
  55334. readonly isFinalMerger: boolean;
  55335. /**
  55336. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55337. */
  55338. readonly isInput: boolean;
  55339. /**
  55340. * Gets or sets the build Id
  55341. */
  55342. buildId: number;
  55343. /**
  55344. * Gets or sets the target of the block
  55345. */
  55346. target: NodeMaterialBlockTargets;
  55347. /**
  55348. * Gets the list of input points
  55349. */
  55350. readonly inputs: NodeMaterialConnectionPoint[];
  55351. /** Gets the list of output points */
  55352. readonly outputs: NodeMaterialConnectionPoint[];
  55353. /**
  55354. * Find an input by its name
  55355. * @param name defines the name of the input to look for
  55356. * @returns the input or null if not found
  55357. */
  55358. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55359. /**
  55360. * Find an output by its name
  55361. * @param name defines the name of the outputto look for
  55362. * @returns the output or null if not found
  55363. */
  55364. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55365. /**
  55366. * Creates a new NodeMaterialBlock
  55367. * @param name defines the block name
  55368. * @param target defines the target of that block (Vertex by default)
  55369. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55370. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55371. */
  55372. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55373. /**
  55374. * Initialize the block and prepare the context for build
  55375. * @param state defines the state that will be used for the build
  55376. */
  55377. initialize(state: NodeMaterialBuildState): void;
  55378. /**
  55379. * Bind data to effect. Will only be called for blocks with isBindable === true
  55380. * @param effect defines the effect to bind data to
  55381. * @param nodeMaterial defines the hosting NodeMaterial
  55382. * @param mesh defines the mesh that will be rendered
  55383. */
  55384. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55385. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55386. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55387. protected _writeFloat(value: number): string;
  55388. /**
  55389. * Gets the current class name e.g. "NodeMaterialBlock"
  55390. * @returns the class name
  55391. */
  55392. getClassName(): string;
  55393. /**
  55394. * Register a new input. Must be called inside a block constructor
  55395. * @param name defines the connection point name
  55396. * @param type defines the connection point type
  55397. * @param isOptional defines a boolean indicating that this input can be omitted
  55398. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55399. * @returns the current block
  55400. */
  55401. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55402. /**
  55403. * Register a new output. Must be called inside a block constructor
  55404. * @param name defines the connection point name
  55405. * @param type defines the connection point type
  55406. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55407. * @returns the current block
  55408. */
  55409. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55410. /**
  55411. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55412. * @param forOutput defines an optional connection point to check compatibility with
  55413. * @returns the first available input or null
  55414. */
  55415. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55416. /**
  55417. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55418. * @param forBlock defines an optional block to check compatibility with
  55419. * @returns the first available input or null
  55420. */
  55421. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55422. /**
  55423. * Gets the sibling of the given output
  55424. * @param current defines the current output
  55425. * @returns the next output in the list or null
  55426. */
  55427. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55428. /**
  55429. * Connect current block with another block
  55430. * @param other defines the block to connect with
  55431. * @param options define the various options to help pick the right connections
  55432. * @returns the current block
  55433. */
  55434. connectTo(other: NodeMaterialBlock, options?: {
  55435. input?: string;
  55436. output?: string;
  55437. outputSwizzle?: string;
  55438. }): this | undefined;
  55439. protected _buildBlock(state: NodeMaterialBuildState): void;
  55440. /**
  55441. * Add uniforms, samplers and uniform buffers at compilation time
  55442. * @param state defines the state to update
  55443. * @param nodeMaterial defines the node material requesting the update
  55444. * @param defines defines the material defines to update
  55445. */
  55446. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55447. /**
  55448. * Add potential fallbacks if shader compilation fails
  55449. * @param mesh defines the mesh to be rendered
  55450. * @param fallbacks defines the current prioritized list of fallbacks
  55451. */
  55452. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55453. /**
  55454. * Initialize defines for shader compilation
  55455. * @param mesh defines the mesh to be rendered
  55456. * @param nodeMaterial defines the node material requesting the update
  55457. * @param defines defines the material defines to update
  55458. * @param useInstances specifies that instances should be used
  55459. */
  55460. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55461. /**
  55462. * Update defines for shader compilation
  55463. * @param mesh defines the mesh to be rendered
  55464. * @param nodeMaterial defines the node material requesting the update
  55465. * @param defines defines the material defines to update
  55466. * @param useInstances specifies that instances should be used
  55467. */
  55468. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55469. /**
  55470. * Lets the block try to connect some inputs automatically
  55471. * @param material defines the hosting NodeMaterial
  55472. */
  55473. autoConfigure(material: NodeMaterial): void;
  55474. /**
  55475. * Function called when a block is declared as repeatable content generator
  55476. * @param vertexShaderState defines the current compilation state for the vertex shader
  55477. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55478. * @param mesh defines the mesh to be rendered
  55479. * @param defines defines the material defines to update
  55480. */
  55481. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55482. /**
  55483. * Checks if the block is ready
  55484. * @param mesh defines the mesh to be rendered
  55485. * @param nodeMaterial defines the node material requesting the update
  55486. * @param defines defines the material defines to update
  55487. * @param useInstances specifies that instances should be used
  55488. * @returns true if the block is ready
  55489. */
  55490. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55491. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55492. private _processBuild;
  55493. /**
  55494. * Compile the current node and generate the shader code
  55495. * @param state defines the current compilation state (uniforms, samplers, current string)
  55496. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55497. * @returns true if already built
  55498. */
  55499. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55500. protected _inputRename(name: string): string;
  55501. protected _outputRename(name: string): string;
  55502. protected _dumpPropertiesCode(): string;
  55503. /** @hidden */
  55504. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55505. /**
  55506. * Clone the current block to a new identical block
  55507. * @param scene defines the hosting scene
  55508. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55509. * @returns a copy of the current block
  55510. */
  55511. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55512. /**
  55513. * Serializes this block in a JSON representation
  55514. * @returns the serialized block object
  55515. */
  55516. serialize(): any;
  55517. /** @hidden */
  55518. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55519. }
  55520. }
  55521. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  55522. /**
  55523. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55524. */
  55525. export enum NodeMaterialBlockConnectionPointMode {
  55526. /** Value is an uniform */
  55527. Uniform = 0,
  55528. /** Value is a mesh attribute */
  55529. Attribute = 1,
  55530. /** Value is a varying between vertex and fragment shaders */
  55531. Varying = 2,
  55532. /** Mode is undefined */
  55533. Undefined = 3
  55534. }
  55535. }
  55536. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55537. /**
  55538. * Enum defining the type of animations supported by InputBlock
  55539. */
  55540. export enum AnimatedInputBlockTypes {
  55541. /** No animation */
  55542. None = 0,
  55543. /** Time based animation. Will only work for floats */
  55544. Time = 1
  55545. }
  55546. }
  55547. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55549. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55550. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/nodeMaterialSystemValues";
  55551. import { Nullable } from "babylonjs/types";
  55552. import { Effect } from "babylonjs/Materials/effect";
  55553. import { Matrix } from "babylonjs/Maths/math.vector";
  55554. import { Scene } from "babylonjs/scene";
  55555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55556. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55557. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55558. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55559. /**
  55560. * Block used to expose an input value
  55561. */
  55562. export class InputBlock extends NodeMaterialBlock {
  55563. private _mode;
  55564. private _associatedVariableName;
  55565. private _storedValue;
  55566. private _valueCallback;
  55567. private _type;
  55568. private _animationType;
  55569. /** Gets or set a value used to limit the range of float values */
  55570. min: number;
  55571. /** Gets or set a value used to limit the range of float values */
  55572. max: number;
  55573. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  55574. matrixMode: number;
  55575. /** @hidden */
  55576. _systemValue: Nullable<NodeMaterialSystemValues>;
  55577. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55578. visibleInInspector: boolean;
  55579. /**
  55580. * Gets or sets the connection point type (default is float)
  55581. */
  55582. readonly type: NodeMaterialBlockConnectionPointTypes;
  55583. /**
  55584. * Creates a new InputBlock
  55585. * @param name defines the block name
  55586. * @param target defines the target of that block (Vertex by default)
  55587. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55588. */
  55589. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55590. /**
  55591. * Gets the output component
  55592. */
  55593. readonly output: NodeMaterialConnectionPoint;
  55594. /**
  55595. * Set the source of this connection point to a vertex attribute
  55596. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55597. * @returns the current connection point
  55598. */
  55599. setAsAttribute(attributeName?: string): InputBlock;
  55600. /**
  55601. * Set the source of this connection point to a system value
  55602. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55603. * @returns the current connection point
  55604. */
  55605. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55606. /**
  55607. * Gets or sets the value of that point.
  55608. * Please note that this value will be ignored if valueCallback is defined
  55609. */
  55610. value: any;
  55611. /**
  55612. * Gets or sets a callback used to get the value of that point.
  55613. * Please note that setting this value will force the connection point to ignore the value property
  55614. */
  55615. valueCallback: () => any;
  55616. /**
  55617. * Gets or sets the associated variable name in the shader
  55618. */
  55619. associatedVariableName: string;
  55620. /** Gets or sets the type of animation applied to the input */
  55621. animationType: AnimatedInputBlockTypes;
  55622. /**
  55623. * Gets a boolean indicating that this connection point not defined yet
  55624. */
  55625. readonly isUndefined: boolean;
  55626. /**
  55627. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55628. * In this case the connection point name must be the name of the uniform to use.
  55629. * Can only be set on inputs
  55630. */
  55631. isUniform: boolean;
  55632. /**
  55633. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55634. * In this case the connection point name must be the name of the attribute to use
  55635. * Can only be set on inputs
  55636. */
  55637. isAttribute: boolean;
  55638. /**
  55639. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55640. * Can only be set on exit points
  55641. */
  55642. isVarying: boolean;
  55643. /**
  55644. * Gets a boolean indicating that the current connection point is a system value
  55645. */
  55646. readonly isSystemValue: boolean;
  55647. /**
  55648. * Gets or sets the current well known value or null if not defined as a system value
  55649. */
  55650. systemValue: Nullable<NodeMaterialSystemValues>;
  55651. /**
  55652. * Gets the current class name
  55653. * @returns the class name
  55654. */
  55655. getClassName(): string;
  55656. /**
  55657. * Animate the input if animationType !== None
  55658. * @param scene defines the rendering scene
  55659. */
  55660. animate(scene: Scene): void;
  55661. private _emitDefine;
  55662. initialize(state: NodeMaterialBuildState): void;
  55663. /**
  55664. * Set the input block to its default value (based on its type)
  55665. */
  55666. setDefaultValue(): void;
  55667. protected _dumpPropertiesCode(): string;
  55668. private _emit;
  55669. /** @hidden */
  55670. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55671. /** @hidden */
  55672. _transmit(effect: Effect, scene: Scene): void;
  55673. protected _buildBlock(state: NodeMaterialBuildState): void;
  55674. serialize(): any;
  55675. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55676. }
  55677. }
  55678. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55679. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55680. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55681. import { Nullable } from "babylonjs/types";
  55682. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55683. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55684. /**
  55685. * Defines a connection point for a block
  55686. */
  55687. export class NodeMaterialConnectionPoint {
  55688. /** @hidden */
  55689. _ownerBlock: NodeMaterialBlock;
  55690. /** @hidden */
  55691. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55692. private _endpoints;
  55693. private _associatedVariableName;
  55694. /** @hidden */
  55695. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55696. /** @hidden */
  55697. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55698. private _type;
  55699. /** @hidden */
  55700. _enforceAssociatedVariableName: boolean;
  55701. /**
  55702. * Gets or sets the additional types supported byt this connection point
  55703. */
  55704. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55705. /**
  55706. * Gets or sets the associated variable name in the shader
  55707. */
  55708. associatedVariableName: string;
  55709. /**
  55710. * Gets or sets the connection point type (default is float)
  55711. */
  55712. type: NodeMaterialBlockConnectionPointTypes;
  55713. /**
  55714. * Gets or sets the connection point name
  55715. */
  55716. name: string;
  55717. /**
  55718. * Gets or sets a boolean indicating that this connection point can be omitted
  55719. */
  55720. isOptional: boolean;
  55721. /**
  55722. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55723. */
  55724. define: string;
  55725. /** Gets or sets the target of that connection point */
  55726. target: NodeMaterialBlockTargets;
  55727. /**
  55728. * Gets a boolean indicating that the current point is connected
  55729. */
  55730. readonly isConnected: boolean;
  55731. /**
  55732. * Gets a boolean indicating that the current point is connected to an input block
  55733. */
  55734. readonly isConnectedToInputBlock: boolean;
  55735. /**
  55736. * Gets a the connected input block (if any)
  55737. */
  55738. readonly connectInputBlock: Nullable<InputBlock>;
  55739. /** Get the other side of the connection (if any) */
  55740. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55741. /** Get the block that owns this connection point */
  55742. readonly ownerBlock: NodeMaterialBlock;
  55743. /** Get the block connected on the other side of this connection (if any) */
  55744. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55745. /** Get the block connected on the endpoints of this connection (if any) */
  55746. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55747. /** Gets the list of connected endpoints */
  55748. readonly endpoints: NodeMaterialConnectionPoint[];
  55749. /** Gets a boolean indicating if that output point is connected to at least one input */
  55750. readonly hasEndpoints: boolean;
  55751. /**
  55752. * Creates a new connection point
  55753. * @param name defines the connection point name
  55754. * @param ownerBlock defines the block hosting this connection point
  55755. */
  55756. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55757. /**
  55758. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55759. * @returns the class name
  55760. */
  55761. getClassName(): string;
  55762. /**
  55763. * Gets an boolean indicating if the current point can be connected to another point
  55764. * @param connectionPoint defines the other connection point
  55765. * @returns true if the connection is possible
  55766. */
  55767. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55768. /**
  55769. * Connect this point to another connection point
  55770. * @param connectionPoint defines the other connection point
  55771. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55772. * @returns the current connection point
  55773. */
  55774. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55775. /**
  55776. * Disconnect this point from one of his endpoint
  55777. * @param endpoint defines the other connection point
  55778. * @returns the current connection point
  55779. */
  55780. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55781. /**
  55782. * Serializes this point in a JSON representation
  55783. * @returns the serialized point object
  55784. */
  55785. serialize(): any;
  55786. }
  55787. }
  55788. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55789. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55790. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55792. import { Mesh } from "babylonjs/Meshes/mesh";
  55793. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55794. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55795. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55796. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55797. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55798. /**
  55799. * Block used to add support for vertex skinning (bones)
  55800. */
  55801. export class BonesBlock extends NodeMaterialBlock {
  55802. /**
  55803. * Creates a new BonesBlock
  55804. * @param name defines the block name
  55805. */
  55806. constructor(name: string);
  55807. /**
  55808. * Initialize the block and prepare the context for build
  55809. * @param state defines the state that will be used for the build
  55810. */
  55811. initialize(state: NodeMaterialBuildState): void;
  55812. /**
  55813. * Gets the current class name
  55814. * @returns the class name
  55815. */
  55816. getClassName(): string;
  55817. /**
  55818. * Gets the matrix indices input component
  55819. */
  55820. readonly matricesIndices: NodeMaterialConnectionPoint;
  55821. /**
  55822. * Gets the matrix weights input component
  55823. */
  55824. readonly matricesWeights: NodeMaterialConnectionPoint;
  55825. /**
  55826. * Gets the extra matrix indices input component
  55827. */
  55828. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55829. /**
  55830. * Gets the extra matrix weights input component
  55831. */
  55832. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55833. /**
  55834. * Gets the world input component
  55835. */
  55836. readonly world: NodeMaterialConnectionPoint;
  55837. /**
  55838. * Gets the output component
  55839. */
  55840. readonly output: NodeMaterialConnectionPoint;
  55841. autoConfigure(material: NodeMaterial): void;
  55842. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55843. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55844. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55845. protected _buildBlock(state: NodeMaterialBuildState): this;
  55846. }
  55847. }
  55848. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55850. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55853. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55854. /**
  55855. * Block used to add support for instances
  55856. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55857. */
  55858. export class InstancesBlock extends NodeMaterialBlock {
  55859. /**
  55860. * Creates a new InstancesBlock
  55861. * @param name defines the block name
  55862. */
  55863. constructor(name: string);
  55864. /**
  55865. * Gets the current class name
  55866. * @returns the class name
  55867. */
  55868. getClassName(): string;
  55869. /**
  55870. * Gets the first world row input component
  55871. */
  55872. readonly world0: NodeMaterialConnectionPoint;
  55873. /**
  55874. * Gets the second world row input component
  55875. */
  55876. readonly world1: NodeMaterialConnectionPoint;
  55877. /**
  55878. * Gets the third world row input component
  55879. */
  55880. readonly world2: NodeMaterialConnectionPoint;
  55881. /**
  55882. * Gets the forth world row input component
  55883. */
  55884. readonly world3: NodeMaterialConnectionPoint;
  55885. /**
  55886. * Gets the world input component
  55887. */
  55888. readonly world: NodeMaterialConnectionPoint;
  55889. /**
  55890. * Gets the output component
  55891. */
  55892. readonly output: NodeMaterialConnectionPoint;
  55893. autoConfigure(material: NodeMaterial): void;
  55894. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55895. protected _buildBlock(state: NodeMaterialBuildState): this;
  55896. }
  55897. }
  55898. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55899. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55900. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55901. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55903. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55904. import { Effect } from "babylonjs/Materials/effect";
  55905. import { Mesh } from "babylonjs/Meshes/mesh";
  55906. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55907. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55908. /**
  55909. * Block used to add morph targets support to vertex shader
  55910. */
  55911. export class MorphTargetsBlock extends NodeMaterialBlock {
  55912. private _repeatableContentAnchor;
  55913. private _repeatebleContentGenerated;
  55914. /**
  55915. * Create a new MorphTargetsBlock
  55916. * @param name defines the block name
  55917. */
  55918. constructor(name: string);
  55919. /**
  55920. * Gets the current class name
  55921. * @returns the class name
  55922. */
  55923. getClassName(): string;
  55924. /**
  55925. * Gets the position input component
  55926. */
  55927. readonly position: NodeMaterialConnectionPoint;
  55928. /**
  55929. * Gets the normal input component
  55930. */
  55931. readonly normal: NodeMaterialConnectionPoint;
  55932. /**
  55933. * Gets the tangent input component
  55934. */
  55935. readonly tangent: NodeMaterialConnectionPoint;
  55936. /**
  55937. * Gets the tangent input component
  55938. */
  55939. readonly uv: NodeMaterialConnectionPoint;
  55940. /**
  55941. * Gets the position output component
  55942. */
  55943. readonly positionOutput: NodeMaterialConnectionPoint;
  55944. /**
  55945. * Gets the normal output component
  55946. */
  55947. readonly normalOutput: NodeMaterialConnectionPoint;
  55948. /**
  55949. * Gets the tangent output component
  55950. */
  55951. readonly tangentOutput: NodeMaterialConnectionPoint;
  55952. /**
  55953. * Gets the tangent output component
  55954. */
  55955. readonly uvOutput: NodeMaterialConnectionPoint;
  55956. initialize(state: NodeMaterialBuildState): void;
  55957. autoConfigure(material: NodeMaterial): void;
  55958. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55959. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55960. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55961. protected _buildBlock(state: NodeMaterialBuildState): this;
  55962. }
  55963. }
  55964. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  55965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55968. import { Nullable } from "babylonjs/types";
  55969. import { Scene } from "babylonjs/scene";
  55970. import { Effect } from "babylonjs/Materials/effect";
  55971. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  55972. import { Mesh } from "babylonjs/Meshes/mesh";
  55973. import { Light } from "babylonjs/Lights/light";
  55974. /**
  55975. * Block used to get data information from a light
  55976. */
  55977. export class LightInformationBlock extends NodeMaterialBlock {
  55978. private _lightDataUniformName;
  55979. private _lightColorUniformName;
  55980. /**
  55981. * Gets or sets the light associated with this block
  55982. */
  55983. light: Nullable<Light>;
  55984. /**
  55985. * Creates a new LightInformationBlock
  55986. * @param name defines the block name
  55987. */
  55988. constructor(name: string);
  55989. /**
  55990. * Gets the current class name
  55991. * @returns the class name
  55992. */
  55993. getClassName(): string;
  55994. /**
  55995. * Gets the world position input component
  55996. */
  55997. readonly worldPosition: NodeMaterialConnectionPoint;
  55998. /**
  55999. * Gets the direction output component
  56000. */
  56001. readonly direction: NodeMaterialConnectionPoint;
  56002. /**
  56003. * Gets the direction output component
  56004. */
  56005. readonly color: NodeMaterialConnectionPoint;
  56006. /**
  56007. * Gets the direction output component
  56008. */
  56009. readonly intensity: NodeMaterialConnectionPoint;
  56010. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56011. protected _buildBlock(state: NodeMaterialBuildState): this;
  56012. serialize(): any;
  56013. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56014. }
  56015. }
  56016. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56017. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56018. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56019. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56020. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56021. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56022. }
  56023. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  56024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56027. import { Scene } from "babylonjs/scene";
  56028. /**
  56029. * Block used to add an alpha test in the fragment shader
  56030. */
  56031. export class AlphaTestBlock extends NodeMaterialBlock {
  56032. /**
  56033. * Gets or sets the alpha value where alpha testing happens
  56034. */
  56035. alphaCutOff: number;
  56036. /**
  56037. * Create a new AlphaTestBlock
  56038. * @param name defines the block name
  56039. */
  56040. constructor(name: string);
  56041. /**
  56042. * Gets the current class name
  56043. * @returns the class name
  56044. */
  56045. getClassName(): string;
  56046. /**
  56047. * Gets the color input component
  56048. */
  56049. readonly color: NodeMaterialConnectionPoint;
  56050. /**
  56051. * Gets the alpha input component
  56052. */
  56053. readonly alpha: NodeMaterialConnectionPoint;
  56054. protected _buildBlock(state: NodeMaterialBuildState): this;
  56055. protected _dumpPropertiesCode(): string;
  56056. serialize(): any;
  56057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56058. }
  56059. }
  56060. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56065. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56066. import { Effect } from "babylonjs/Materials/effect";
  56067. import { Mesh } from "babylonjs/Meshes/mesh";
  56068. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56069. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56070. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56071. /**
  56072. * Block used to add image processing support to fragment shader
  56073. */
  56074. export class ImageProcessingBlock extends NodeMaterialBlock {
  56075. /**
  56076. * Create a new ImageProcessingBlock
  56077. * @param name defines the block name
  56078. */
  56079. constructor(name: string);
  56080. /**
  56081. * Gets the current class name
  56082. * @returns the class name
  56083. */
  56084. getClassName(): string;
  56085. /**
  56086. * Gets the color input component
  56087. */
  56088. readonly color: NodeMaterialConnectionPoint;
  56089. /**
  56090. * Gets the output component
  56091. */
  56092. readonly output: NodeMaterialConnectionPoint;
  56093. /**
  56094. * Initialize the block and prepare the context for build
  56095. * @param state defines the state that will be used for the build
  56096. */
  56097. initialize(state: NodeMaterialBuildState): void;
  56098. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56099. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56100. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56101. protected _buildBlock(state: NodeMaterialBuildState): this;
  56102. }
  56103. }
  56104. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56105. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56106. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56107. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56108. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56110. import { Effect } from "babylonjs/Materials/effect";
  56111. import { Mesh } from "babylonjs/Meshes/mesh";
  56112. import { Scene } from "babylonjs/scene";
  56113. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56114. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56115. /**
  56116. * Block used to pertub normals based on a normal map
  56117. */
  56118. export class PerturbNormalBlock extends NodeMaterialBlock {
  56119. private _tangentSpaceParameterName;
  56120. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56121. invertX: boolean;
  56122. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56123. invertY: boolean;
  56124. /**
  56125. * Create a new PerturbNormalBlock
  56126. * @param name defines the block name
  56127. */
  56128. constructor(name: string);
  56129. /**
  56130. * Gets the current class name
  56131. * @returns the class name
  56132. */
  56133. getClassName(): string;
  56134. /**
  56135. * Gets the world position input component
  56136. */
  56137. readonly worldPosition: NodeMaterialConnectionPoint;
  56138. /**
  56139. * Gets the world normal input component
  56140. */
  56141. readonly worldNormal: NodeMaterialConnectionPoint;
  56142. /**
  56143. * Gets the uv input component
  56144. */
  56145. readonly uv: NodeMaterialConnectionPoint;
  56146. /**
  56147. * Gets the normal map color input component
  56148. */
  56149. readonly normalMapColor: NodeMaterialConnectionPoint;
  56150. /**
  56151. * Gets the strength input component
  56152. */
  56153. readonly strength: NodeMaterialConnectionPoint;
  56154. /**
  56155. * Gets the output component
  56156. */
  56157. readonly output: NodeMaterialConnectionPoint;
  56158. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56159. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56160. autoConfigure(material: NodeMaterial): void;
  56161. protected _buildBlock(state: NodeMaterialBuildState): this;
  56162. protected _dumpPropertiesCode(): string;
  56163. serialize(): any;
  56164. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56165. }
  56166. }
  56167. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56168. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56169. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  56170. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56171. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56172. }
  56173. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56174. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56175. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56176. import { Mesh } from "babylonjs/Meshes/mesh";
  56177. import { Effect } from "babylonjs/Materials/effect";
  56178. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56180. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56181. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56182. /**
  56183. * Block used to add support for scene fog
  56184. */
  56185. export class FogBlock extends NodeMaterialBlock {
  56186. private _fogDistanceName;
  56187. private _fogParameters;
  56188. /**
  56189. * Create a new FogBlock
  56190. * @param name defines the block name
  56191. */
  56192. constructor(name: string);
  56193. /**
  56194. * Gets the current class name
  56195. * @returns the class name
  56196. */
  56197. getClassName(): string;
  56198. /**
  56199. * Gets the world position input component
  56200. */
  56201. readonly worldPosition: NodeMaterialConnectionPoint;
  56202. /**
  56203. * Gets the view input component
  56204. */
  56205. readonly view: NodeMaterialConnectionPoint;
  56206. /**
  56207. * Gets the color input component
  56208. */
  56209. readonly input: NodeMaterialConnectionPoint;
  56210. /**
  56211. * Gets the fog color input component
  56212. */
  56213. readonly fogColor: NodeMaterialConnectionPoint;
  56214. /**
  56215. * Gets the output component
  56216. */
  56217. readonly output: NodeMaterialConnectionPoint;
  56218. autoConfigure(material: NodeMaterial): void;
  56219. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56220. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56221. protected _buildBlock(state: NodeMaterialBuildState): this;
  56222. }
  56223. }
  56224. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56225. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56226. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56227. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56229. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56230. import { Effect } from "babylonjs/Materials/effect";
  56231. import { Mesh } from "babylonjs/Meshes/mesh";
  56232. import { Light } from "babylonjs/Lights/light";
  56233. import { Nullable } from "babylonjs/types";
  56234. import { Scene } from "babylonjs/scene";
  56235. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56236. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56237. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56238. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56239. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56240. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56241. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56242. /**
  56243. * Block used to add light in the fragment shader
  56244. */
  56245. export class LightBlock extends NodeMaterialBlock {
  56246. private _lightId;
  56247. /**
  56248. * Gets or sets the light associated with this block
  56249. */
  56250. light: Nullable<Light>;
  56251. /**
  56252. * Create a new LightBlock
  56253. * @param name defines the block name
  56254. */
  56255. constructor(name: string);
  56256. /**
  56257. * Gets the current class name
  56258. * @returns the class name
  56259. */
  56260. getClassName(): string;
  56261. /**
  56262. * Gets the world position input component
  56263. */
  56264. readonly worldPosition: NodeMaterialConnectionPoint;
  56265. /**
  56266. * Gets the world normal input component
  56267. */
  56268. readonly worldNormal: NodeMaterialConnectionPoint;
  56269. /**
  56270. * Gets the camera (or eye) position component
  56271. */
  56272. readonly cameraPosition: NodeMaterialConnectionPoint;
  56273. /**
  56274. * Gets the diffuse output component
  56275. */
  56276. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56277. /**
  56278. * Gets the specular output component
  56279. */
  56280. readonly specularOutput: NodeMaterialConnectionPoint;
  56281. autoConfigure(material: NodeMaterial): void;
  56282. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56283. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56284. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56285. private _injectVertexCode;
  56286. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56287. serialize(): any;
  56288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56289. }
  56290. }
  56291. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56292. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56293. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56294. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56295. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56296. }
  56297. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56298. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56299. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56300. }
  56301. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56302. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56303. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56304. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56305. /**
  56306. * Block used to multiply 2 values
  56307. */
  56308. export class MultiplyBlock extends NodeMaterialBlock {
  56309. /**
  56310. * Creates a new MultiplyBlock
  56311. * @param name defines the block name
  56312. */
  56313. constructor(name: string);
  56314. /**
  56315. * Gets the current class name
  56316. * @returns the class name
  56317. */
  56318. getClassName(): string;
  56319. /**
  56320. * Gets the left operand input component
  56321. */
  56322. readonly left: NodeMaterialConnectionPoint;
  56323. /**
  56324. * Gets the right operand input component
  56325. */
  56326. readonly right: NodeMaterialConnectionPoint;
  56327. /**
  56328. * Gets the output component
  56329. */
  56330. readonly output: NodeMaterialConnectionPoint;
  56331. protected _buildBlock(state: NodeMaterialBuildState): this;
  56332. }
  56333. }
  56334. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56338. /**
  56339. * Block used to add 2 vectors
  56340. */
  56341. export class AddBlock extends NodeMaterialBlock {
  56342. /**
  56343. * Creates a new AddBlock
  56344. * @param name defines the block name
  56345. */
  56346. constructor(name: string);
  56347. /**
  56348. * Gets the current class name
  56349. * @returns the class name
  56350. */
  56351. getClassName(): string;
  56352. /**
  56353. * Gets the left operand input component
  56354. */
  56355. readonly left: NodeMaterialConnectionPoint;
  56356. /**
  56357. * Gets the right operand input component
  56358. */
  56359. readonly right: NodeMaterialConnectionPoint;
  56360. /**
  56361. * Gets the output component
  56362. */
  56363. readonly output: NodeMaterialConnectionPoint;
  56364. protected _buildBlock(state: NodeMaterialBuildState): this;
  56365. }
  56366. }
  56367. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56368. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56369. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56370. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56371. /**
  56372. * Block used to scale a vector by a float
  56373. */
  56374. export class ScaleBlock extends NodeMaterialBlock {
  56375. /**
  56376. * Creates a new ScaleBlock
  56377. * @param name defines the block name
  56378. */
  56379. constructor(name: string);
  56380. /**
  56381. * Gets the current class name
  56382. * @returns the class name
  56383. */
  56384. getClassName(): string;
  56385. /**
  56386. * Gets the input component
  56387. */
  56388. readonly input: NodeMaterialConnectionPoint;
  56389. /**
  56390. * Gets the factor input component
  56391. */
  56392. readonly factor: NodeMaterialConnectionPoint;
  56393. /**
  56394. * Gets the output component
  56395. */
  56396. readonly output: NodeMaterialConnectionPoint;
  56397. protected _buildBlock(state: NodeMaterialBuildState): this;
  56398. }
  56399. }
  56400. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56404. import { Scene } from "babylonjs/scene";
  56405. /**
  56406. * Block used to clamp a float
  56407. */
  56408. export class ClampBlock extends NodeMaterialBlock {
  56409. /** Gets or sets the minimum range */
  56410. minimum: number;
  56411. /** Gets or sets the maximum range */
  56412. maximum: number;
  56413. /**
  56414. * Creates a new ClampBlock
  56415. * @param name defines the block name
  56416. */
  56417. constructor(name: string);
  56418. /**
  56419. * Gets the current class name
  56420. * @returns the class name
  56421. */
  56422. getClassName(): string;
  56423. /**
  56424. * Gets the value input component
  56425. */
  56426. readonly value: NodeMaterialConnectionPoint;
  56427. /**
  56428. * Gets the output component
  56429. */
  56430. readonly output: NodeMaterialConnectionPoint;
  56431. protected _buildBlock(state: NodeMaterialBuildState): this;
  56432. protected _dumpPropertiesCode(): string;
  56433. serialize(): any;
  56434. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56435. }
  56436. }
  56437. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56441. /**
  56442. * Block used to apply a cross product between 2 vectors
  56443. */
  56444. export class CrossBlock extends NodeMaterialBlock {
  56445. /**
  56446. * Creates a new CrossBlock
  56447. * @param name defines the block name
  56448. */
  56449. constructor(name: string);
  56450. /**
  56451. * Gets the current class name
  56452. * @returns the class name
  56453. */
  56454. getClassName(): string;
  56455. /**
  56456. * Gets the left operand input component
  56457. */
  56458. readonly left: NodeMaterialConnectionPoint;
  56459. /**
  56460. * Gets the right operand input component
  56461. */
  56462. readonly right: NodeMaterialConnectionPoint;
  56463. /**
  56464. * Gets the output component
  56465. */
  56466. readonly output: NodeMaterialConnectionPoint;
  56467. protected _buildBlock(state: NodeMaterialBuildState): this;
  56468. }
  56469. }
  56470. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  56471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56472. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56473. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56474. /**
  56475. * Block used to apply a dot product between 2 vectors
  56476. */
  56477. export class DotBlock extends NodeMaterialBlock {
  56478. /**
  56479. * Creates a new DotBlock
  56480. * @param name defines the block name
  56481. */
  56482. constructor(name: string);
  56483. /**
  56484. * Gets the current class name
  56485. * @returns the class name
  56486. */
  56487. getClassName(): string;
  56488. /**
  56489. * Gets the left operand input component
  56490. */
  56491. readonly left: NodeMaterialConnectionPoint;
  56492. /**
  56493. * Gets the right operand input component
  56494. */
  56495. readonly right: NodeMaterialConnectionPoint;
  56496. /**
  56497. * Gets the output component
  56498. */
  56499. readonly output: NodeMaterialConnectionPoint;
  56500. protected _buildBlock(state: NodeMaterialBuildState): this;
  56501. }
  56502. }
  56503. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56507. import { Vector2 } from "babylonjs/Maths/math.vector";
  56508. import { Scene } from "babylonjs/scene";
  56509. /**
  56510. * Block used to remap a float from a range to a new one
  56511. */
  56512. export class RemapBlock extends NodeMaterialBlock {
  56513. /**
  56514. * Gets or sets the source range
  56515. */
  56516. sourceRange: Vector2;
  56517. /**
  56518. * Gets or sets the target range
  56519. */
  56520. targetRange: Vector2;
  56521. /**
  56522. * Creates a new RemapBlock
  56523. * @param name defines the block name
  56524. */
  56525. constructor(name: string);
  56526. /**
  56527. * Gets the current class name
  56528. * @returns the class name
  56529. */
  56530. getClassName(): string;
  56531. /**
  56532. * Gets the input component
  56533. */
  56534. readonly input: NodeMaterialConnectionPoint;
  56535. /**
  56536. * Gets the source min input component
  56537. */
  56538. readonly sourceMin: NodeMaterialConnectionPoint;
  56539. /**
  56540. * Gets the source max input component
  56541. */
  56542. readonly sourceMax: NodeMaterialConnectionPoint;
  56543. /**
  56544. * Gets the target min input component
  56545. */
  56546. readonly targetMin: NodeMaterialConnectionPoint;
  56547. /**
  56548. * Gets the target max input component
  56549. */
  56550. readonly targetMax: NodeMaterialConnectionPoint;
  56551. /**
  56552. * Gets the output component
  56553. */
  56554. readonly output: NodeMaterialConnectionPoint;
  56555. protected _buildBlock(state: NodeMaterialBuildState): this;
  56556. protected _dumpPropertiesCode(): string;
  56557. serialize(): any;
  56558. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56559. }
  56560. }
  56561. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56562. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56563. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56564. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56565. /**
  56566. * Block used to normalize a vector
  56567. */
  56568. export class NormalizeBlock extends NodeMaterialBlock {
  56569. /**
  56570. * Creates a new NormalizeBlock
  56571. * @param name defines the block name
  56572. */
  56573. constructor(name: string);
  56574. /**
  56575. * Gets the current class name
  56576. * @returns the class name
  56577. */
  56578. getClassName(): string;
  56579. /**
  56580. * Gets the input component
  56581. */
  56582. readonly input: NodeMaterialConnectionPoint;
  56583. /**
  56584. * Gets the output component
  56585. */
  56586. readonly output: NodeMaterialConnectionPoint;
  56587. protected _buildBlock(state: NodeMaterialBuildState): this;
  56588. }
  56589. }
  56590. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56594. import { Scene } from "babylonjs/scene";
  56595. /**
  56596. * Operations supported by the Trigonometry block
  56597. */
  56598. export enum TrigonometryBlockOperations {
  56599. /** Cos */
  56600. Cos = 0,
  56601. /** Sin */
  56602. Sin = 1,
  56603. /** Abs */
  56604. Abs = 2,
  56605. /** Exp */
  56606. Exp = 3,
  56607. /** Exp2 */
  56608. Exp2 = 4,
  56609. /** Round */
  56610. Round = 5,
  56611. /** Floor */
  56612. Floor = 6,
  56613. /** Ceiling */
  56614. Ceiling = 7,
  56615. /** Square root */
  56616. Sqrt = 8
  56617. }
  56618. /**
  56619. * Block used to apply trigonometry operation to floats
  56620. */
  56621. export class TrigonometryBlock extends NodeMaterialBlock {
  56622. /**
  56623. * Gets or sets the operation applied by the block
  56624. */
  56625. operation: TrigonometryBlockOperations;
  56626. /**
  56627. * Creates a new TrigonometryBlock
  56628. * @param name defines the block name
  56629. */
  56630. constructor(name: string);
  56631. /**
  56632. * Gets the current class name
  56633. * @returns the class name
  56634. */
  56635. getClassName(): string;
  56636. /**
  56637. * Gets the input component
  56638. */
  56639. readonly input: NodeMaterialConnectionPoint;
  56640. /**
  56641. * Gets the output component
  56642. */
  56643. readonly output: NodeMaterialConnectionPoint;
  56644. protected _buildBlock(state: NodeMaterialBuildState): this;
  56645. serialize(): any;
  56646. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56647. }
  56648. }
  56649. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56651. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56653. /**
  56654. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56655. */
  56656. export class ColorMergerBlock extends NodeMaterialBlock {
  56657. /**
  56658. * Create a new ColorMergerBlock
  56659. * @param name defines the block name
  56660. */
  56661. constructor(name: string);
  56662. /**
  56663. * Gets the current class name
  56664. * @returns the class name
  56665. */
  56666. getClassName(): string;
  56667. /**
  56668. * Gets the r component (input)
  56669. */
  56670. readonly r: NodeMaterialConnectionPoint;
  56671. /**
  56672. * Gets the g component (input)
  56673. */
  56674. readonly g: NodeMaterialConnectionPoint;
  56675. /**
  56676. * Gets the b component (input)
  56677. */
  56678. readonly b: NodeMaterialConnectionPoint;
  56679. /**
  56680. * Gets the a component (input)
  56681. */
  56682. readonly a: NodeMaterialConnectionPoint;
  56683. /**
  56684. * Gets the rgba component (output)
  56685. */
  56686. readonly rgba: NodeMaterialConnectionPoint;
  56687. /**
  56688. * Gets the rgb component (output)
  56689. */
  56690. readonly rgb: NodeMaterialConnectionPoint;
  56691. protected _buildBlock(state: NodeMaterialBuildState): this;
  56692. }
  56693. }
  56694. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56695. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56696. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56698. /**
  56699. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56700. */
  56701. export class VectorMergerBlock extends NodeMaterialBlock {
  56702. /**
  56703. * Create a new VectorMergerBlock
  56704. * @param name defines the block name
  56705. */
  56706. constructor(name: string);
  56707. /**
  56708. * Gets the current class name
  56709. * @returns the class name
  56710. */
  56711. getClassName(): string;
  56712. /**
  56713. * Gets the x component (input)
  56714. */
  56715. readonly x: NodeMaterialConnectionPoint;
  56716. /**
  56717. * Gets the y component (input)
  56718. */
  56719. readonly y: NodeMaterialConnectionPoint;
  56720. /**
  56721. * Gets the z component (input)
  56722. */
  56723. readonly z: NodeMaterialConnectionPoint;
  56724. /**
  56725. * Gets the w component (input)
  56726. */
  56727. readonly w: NodeMaterialConnectionPoint;
  56728. /**
  56729. * Gets the xyzw component (output)
  56730. */
  56731. readonly xyzw: NodeMaterialConnectionPoint;
  56732. /**
  56733. * Gets the xyz component (output)
  56734. */
  56735. readonly xyz: NodeMaterialConnectionPoint;
  56736. /**
  56737. * Gets the xy component (output)
  56738. */
  56739. readonly xy: NodeMaterialConnectionPoint;
  56740. protected _buildBlock(state: NodeMaterialBuildState): this;
  56741. }
  56742. }
  56743. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56744. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56745. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56746. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56747. /**
  56748. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56749. */
  56750. export class ColorSplitterBlock extends NodeMaterialBlock {
  56751. /**
  56752. * Create a new ColorSplitterBlock
  56753. * @param name defines the block name
  56754. */
  56755. constructor(name: string);
  56756. /**
  56757. * Gets the current class name
  56758. * @returns the class name
  56759. */
  56760. getClassName(): string;
  56761. /**
  56762. * Gets the rgba component (input)
  56763. */
  56764. readonly rgba: NodeMaterialConnectionPoint;
  56765. /**
  56766. * Gets the rgb component (input)
  56767. */
  56768. readonly rgbIn: NodeMaterialConnectionPoint;
  56769. /**
  56770. * Gets the rgb component (output)
  56771. */
  56772. readonly rgbOut: NodeMaterialConnectionPoint;
  56773. /**
  56774. * Gets the r component (output)
  56775. */
  56776. readonly r: NodeMaterialConnectionPoint;
  56777. /**
  56778. * Gets the g component (output)
  56779. */
  56780. readonly g: NodeMaterialConnectionPoint;
  56781. /**
  56782. * Gets the b component (output)
  56783. */
  56784. readonly b: NodeMaterialConnectionPoint;
  56785. /**
  56786. * Gets the a component (output)
  56787. */
  56788. readonly a: NodeMaterialConnectionPoint;
  56789. protected _inputRename(name: string): string;
  56790. protected _outputRename(name: string): string;
  56791. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56792. }
  56793. }
  56794. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56795. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56796. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56797. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56798. /**
  56799. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56800. */
  56801. export class VectorSplitterBlock extends NodeMaterialBlock {
  56802. /**
  56803. * Create a new VectorSplitterBlock
  56804. * @param name defines the block name
  56805. */
  56806. constructor(name: string);
  56807. /**
  56808. * Gets the current class name
  56809. * @returns the class name
  56810. */
  56811. getClassName(): string;
  56812. /**
  56813. * Gets the xyzw component (input)
  56814. */
  56815. readonly xyzw: NodeMaterialConnectionPoint;
  56816. /**
  56817. * Gets the xyz component (input)
  56818. */
  56819. readonly xyzIn: NodeMaterialConnectionPoint;
  56820. /**
  56821. * Gets the xy component (input)
  56822. */
  56823. readonly xyIn: NodeMaterialConnectionPoint;
  56824. /**
  56825. * Gets the xyz component (output)
  56826. */
  56827. readonly xyzOut: NodeMaterialConnectionPoint;
  56828. /**
  56829. * Gets the xy component (output)
  56830. */
  56831. readonly xyOut: NodeMaterialConnectionPoint;
  56832. /**
  56833. * Gets the x component (output)
  56834. */
  56835. readonly x: NodeMaterialConnectionPoint;
  56836. /**
  56837. * Gets the y component (output)
  56838. */
  56839. readonly y: NodeMaterialConnectionPoint;
  56840. /**
  56841. * Gets the z component (output)
  56842. */
  56843. readonly z: NodeMaterialConnectionPoint;
  56844. /**
  56845. * Gets the w component (output)
  56846. */
  56847. readonly w: NodeMaterialConnectionPoint;
  56848. protected _inputRename(name: string): string;
  56849. protected _outputRename(name: string): string;
  56850. protected _buildBlock(state: NodeMaterialBuildState): this;
  56851. }
  56852. }
  56853. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56854. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56855. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56856. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56857. /**
  56858. * Block used to lerp 2 values
  56859. */
  56860. export class LerpBlock extends NodeMaterialBlock {
  56861. /**
  56862. * Creates a new LerpBlock
  56863. * @param name defines the block name
  56864. */
  56865. constructor(name: string);
  56866. /**
  56867. * Gets the current class name
  56868. * @returns the class name
  56869. */
  56870. getClassName(): string;
  56871. /**
  56872. * Gets the left operand input component
  56873. */
  56874. readonly left: NodeMaterialConnectionPoint;
  56875. /**
  56876. * Gets the right operand input component
  56877. */
  56878. readonly right: NodeMaterialConnectionPoint;
  56879. /**
  56880. * Gets the gradient operand input component
  56881. */
  56882. readonly gradient: NodeMaterialConnectionPoint;
  56883. /**
  56884. * Gets the output component
  56885. */
  56886. readonly output: NodeMaterialConnectionPoint;
  56887. protected _buildBlock(state: NodeMaterialBuildState): this;
  56888. }
  56889. }
  56890. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56891. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56892. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56893. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56894. /**
  56895. * Block used to divide 2 vectors
  56896. */
  56897. export class DivideBlock extends NodeMaterialBlock {
  56898. /**
  56899. * Creates a new DivideBlock
  56900. * @param name defines the block name
  56901. */
  56902. constructor(name: string);
  56903. /**
  56904. * Gets the current class name
  56905. * @returns the class name
  56906. */
  56907. getClassName(): string;
  56908. /**
  56909. * Gets the left operand input component
  56910. */
  56911. readonly left: NodeMaterialConnectionPoint;
  56912. /**
  56913. * Gets the right operand input component
  56914. */
  56915. readonly right: NodeMaterialConnectionPoint;
  56916. /**
  56917. * Gets the output component
  56918. */
  56919. readonly output: NodeMaterialConnectionPoint;
  56920. protected _buildBlock(state: NodeMaterialBuildState): this;
  56921. }
  56922. }
  56923. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56924. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56925. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56926. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56927. /**
  56928. * Block used to subtract 2 vectors
  56929. */
  56930. export class SubtractBlock extends NodeMaterialBlock {
  56931. /**
  56932. * Creates a new SubtractBlock
  56933. * @param name defines the block name
  56934. */
  56935. constructor(name: string);
  56936. /**
  56937. * Gets the current class name
  56938. * @returns the class name
  56939. */
  56940. getClassName(): string;
  56941. /**
  56942. * Gets the left operand input component
  56943. */
  56944. readonly left: NodeMaterialConnectionPoint;
  56945. /**
  56946. * Gets the right operand input component
  56947. */
  56948. readonly right: NodeMaterialConnectionPoint;
  56949. /**
  56950. * Gets the output component
  56951. */
  56952. readonly output: NodeMaterialConnectionPoint;
  56953. protected _buildBlock(state: NodeMaterialBuildState): this;
  56954. }
  56955. }
  56956. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  56957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56960. /**
  56961. * Block used to step a value
  56962. */
  56963. export class StepBlock extends NodeMaterialBlock {
  56964. /**
  56965. * Creates a new AddBlock
  56966. * @param name defines the block name
  56967. */
  56968. constructor(name: string);
  56969. /**
  56970. * Gets the current class name
  56971. * @returns the class name
  56972. */
  56973. getClassName(): string;
  56974. /**
  56975. * Gets the value operand input component
  56976. */
  56977. readonly value: NodeMaterialConnectionPoint;
  56978. /**
  56979. * Gets the edge operand input component
  56980. */
  56981. readonly edge: NodeMaterialConnectionPoint;
  56982. /**
  56983. * Gets the output component
  56984. */
  56985. readonly output: NodeMaterialConnectionPoint;
  56986. protected _buildBlock(state: NodeMaterialBuildState): this;
  56987. }
  56988. }
  56989. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  56990. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56991. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56992. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56993. /**
  56994. * Block used to get the opposite (1 - x) of a value
  56995. */
  56996. export class OneMinusBlock extends NodeMaterialBlock {
  56997. /**
  56998. * Creates a new OneMinusBlock
  56999. * @param name defines the block name
  57000. */
  57001. constructor(name: string);
  57002. /**
  57003. * Gets the current class name
  57004. * @returns the class name
  57005. */
  57006. getClassName(): string;
  57007. /**
  57008. * Gets the input component
  57009. */
  57010. readonly input: NodeMaterialConnectionPoint;
  57011. /**
  57012. * Gets the output component
  57013. */
  57014. readonly output: NodeMaterialConnectionPoint;
  57015. protected _buildBlock(state: NodeMaterialBuildState): this;
  57016. }
  57017. }
  57018. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  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. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57023. /**
  57024. * Block used to get the view direction
  57025. */
  57026. export class ViewDirectionBlock extends NodeMaterialBlock {
  57027. /**
  57028. * Creates a new ViewDirectionBlock
  57029. * @param name defines the block name
  57030. */
  57031. constructor(name: string);
  57032. /**
  57033. * Gets the current class name
  57034. * @returns the class name
  57035. */
  57036. getClassName(): string;
  57037. /**
  57038. * Gets the world position component
  57039. */
  57040. readonly worldPosition: NodeMaterialConnectionPoint;
  57041. /**
  57042. * Gets the camera position component
  57043. */
  57044. readonly cameraPosition: NodeMaterialConnectionPoint;
  57045. /**
  57046. * Gets the output component
  57047. */
  57048. readonly output: NodeMaterialConnectionPoint;
  57049. autoConfigure(material: NodeMaterial): void;
  57050. protected _buildBlock(state: NodeMaterialBuildState): this;
  57051. }
  57052. }
  57053. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57054. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57055. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57056. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57057. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57058. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57059. /**
  57060. * Block used to compute fresnel value
  57061. */
  57062. export class FresnelBlock extends NodeMaterialBlock {
  57063. /**
  57064. * Create a new FresnelBlock
  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 world normal input component
  57075. */
  57076. readonly worldNormal: NodeMaterialConnectionPoint;
  57077. /**
  57078. * Gets the view direction input component
  57079. */
  57080. readonly viewDirection: NodeMaterialConnectionPoint;
  57081. /**
  57082. * Gets the bias input component
  57083. */
  57084. readonly bias: NodeMaterialConnectionPoint;
  57085. /**
  57086. * Gets the camera (or eye) position component
  57087. */
  57088. readonly power: NodeMaterialConnectionPoint;
  57089. /**
  57090. * Gets the fresnel output component
  57091. */
  57092. readonly fresnel: NodeMaterialConnectionPoint;
  57093. autoConfigure(material: NodeMaterial): void;
  57094. protected _buildBlock(state: NodeMaterialBuildState): this;
  57095. }
  57096. }
  57097. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57098. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57099. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57100. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57101. /**
  57102. * Block used to get the max of 2 values
  57103. */
  57104. export class MaxBlock extends NodeMaterialBlock {
  57105. /**
  57106. * Creates a new MaxBlock
  57107. * @param name defines the block name
  57108. */
  57109. constructor(name: string);
  57110. /**
  57111. * Gets the current class name
  57112. * @returns the class name
  57113. */
  57114. getClassName(): string;
  57115. /**
  57116. * Gets the left operand input component
  57117. */
  57118. readonly left: NodeMaterialConnectionPoint;
  57119. /**
  57120. * Gets the right operand input component
  57121. */
  57122. readonly right: NodeMaterialConnectionPoint;
  57123. /**
  57124. * Gets the output component
  57125. */
  57126. readonly output: NodeMaterialConnectionPoint;
  57127. protected _buildBlock(state: NodeMaterialBuildState): this;
  57128. }
  57129. }
  57130. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57132. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57134. /**
  57135. * Block used to get the min of 2 values
  57136. */
  57137. export class MinBlock extends NodeMaterialBlock {
  57138. /**
  57139. * Creates a new MinBlock
  57140. * @param name defines the block name
  57141. */
  57142. constructor(name: string);
  57143. /**
  57144. * Gets the current class name
  57145. * @returns the class name
  57146. */
  57147. getClassName(): string;
  57148. /**
  57149. * Gets the left operand input component
  57150. */
  57151. readonly left: NodeMaterialConnectionPoint;
  57152. /**
  57153. * Gets the right operand input component
  57154. */
  57155. readonly right: NodeMaterialConnectionPoint;
  57156. /**
  57157. * Gets the output component
  57158. */
  57159. readonly output: NodeMaterialConnectionPoint;
  57160. protected _buildBlock(state: NodeMaterialBuildState): this;
  57161. }
  57162. }
  57163. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57164. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57165. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57166. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57167. /**
  57168. * Block used to get the distance between 2 values
  57169. */
  57170. export class DistanceBlock extends NodeMaterialBlock {
  57171. /**
  57172. * Creates a new DistanceBlock
  57173. * @param name defines the block name
  57174. */
  57175. constructor(name: string);
  57176. /**
  57177. * Gets the current class name
  57178. * @returns the class name
  57179. */
  57180. getClassName(): string;
  57181. /**
  57182. * Gets the left operand input component
  57183. */
  57184. readonly left: NodeMaterialConnectionPoint;
  57185. /**
  57186. * Gets the right operand input component
  57187. */
  57188. readonly right: NodeMaterialConnectionPoint;
  57189. /**
  57190. * Gets the output component
  57191. */
  57192. readonly output: NodeMaterialConnectionPoint;
  57193. protected _buildBlock(state: NodeMaterialBuildState): this;
  57194. }
  57195. }
  57196. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57197. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57198. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57199. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57200. /**
  57201. * Block used to get the length of a vector
  57202. */
  57203. export class LengthBlock extends NodeMaterialBlock {
  57204. /**
  57205. * Creates a new LengthBlock
  57206. * @param name defines the block name
  57207. */
  57208. constructor(name: string);
  57209. /**
  57210. * Gets the current class name
  57211. * @returns the class name
  57212. */
  57213. getClassName(): string;
  57214. /**
  57215. * Gets the value input component
  57216. */
  57217. readonly value: NodeMaterialConnectionPoint;
  57218. /**
  57219. * Gets the output component
  57220. */
  57221. readonly output: NodeMaterialConnectionPoint;
  57222. protected _buildBlock(state: NodeMaterialBuildState): this;
  57223. }
  57224. }
  57225. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57226. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57227. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57228. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57229. /**
  57230. * Block used to get negative version of a value (i.e. x * -1)
  57231. */
  57232. export class NegateBlock extends NodeMaterialBlock {
  57233. /**
  57234. * Creates a new NegateBlock
  57235. * @param name defines the block name
  57236. */
  57237. constructor(name: string);
  57238. /**
  57239. * Gets the current class name
  57240. * @returns the class name
  57241. */
  57242. getClassName(): string;
  57243. /**
  57244. * Gets the value input component
  57245. */
  57246. readonly value: NodeMaterialConnectionPoint;
  57247. /**
  57248. * Gets the output component
  57249. */
  57250. readonly output: NodeMaterialConnectionPoint;
  57251. protected _buildBlock(state: NodeMaterialBuildState): this;
  57252. }
  57253. }
  57254. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57258. /**
  57259. * Block used to get the value of the first parameter raised to the power of the second
  57260. */
  57261. export class PowBlock extends NodeMaterialBlock {
  57262. /**
  57263. * Creates a new PowBlock
  57264. * @param name defines the block name
  57265. */
  57266. constructor(name: string);
  57267. /**
  57268. * Gets the current class name
  57269. * @returns the class name
  57270. */
  57271. getClassName(): string;
  57272. /**
  57273. * Gets the value operand input component
  57274. */
  57275. readonly value: NodeMaterialConnectionPoint;
  57276. /**
  57277. * Gets the power operand input component
  57278. */
  57279. readonly power: NodeMaterialConnectionPoint;
  57280. /**
  57281. * Gets the output component
  57282. */
  57283. readonly output: NodeMaterialConnectionPoint;
  57284. protected _buildBlock(state: NodeMaterialBuildState): this;
  57285. }
  57286. }
  57287. declare module "babylonjs/Materials/Node/Blocks/index" {
  57288. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  57289. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  57290. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  57291. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  57292. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  57293. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  57294. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  57295. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  57296. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  57297. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  57298. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  57299. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  57300. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57301. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57302. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57303. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57304. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57305. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57306. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57307. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57308. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57309. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57310. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  57311. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57312. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57313. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57314. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57315. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  57316. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  57317. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  57318. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  57319. }
  57320. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57321. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57322. }
  57323. declare module "babylonjs/Materials/Node/index" {
  57324. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  57325. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  57326. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57327. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57328. export * from "babylonjs/Materials/Node/nodeMaterial";
  57329. export * from "babylonjs/Materials/Node/nodeMaterialSystemValues";
  57330. export * from "babylonjs/Materials/Node/Blocks/index";
  57331. export * from "babylonjs/Materials/Node/Optimizers/index";
  57332. }
  57333. declare module "babylonjs/Materials/effectRenderer" {
  57334. import { Nullable } from "babylonjs/types";
  57335. import { Texture } from "babylonjs/Materials/Textures/texture";
  57336. import { Engine } from "babylonjs/Engines/engine";
  57337. import { Viewport } from "babylonjs/Maths/math.viewport";
  57338. import { Observable } from "babylonjs/Misc/observable";
  57339. import { Effect } from "babylonjs/Materials/effect";
  57340. import "babylonjs/Shaders/postprocess.vertex";
  57341. /**
  57342. * Effect Render Options
  57343. */
  57344. export interface IEffectRendererOptions {
  57345. /**
  57346. * Defines the vertices positions.
  57347. */
  57348. positions?: number[];
  57349. /**
  57350. * Defines the indices.
  57351. */
  57352. indices?: number[];
  57353. }
  57354. /**
  57355. * Helper class to render one or more effects
  57356. */
  57357. export class EffectRenderer {
  57358. private engine;
  57359. private static _DefaultOptions;
  57360. private _vertexBuffers;
  57361. private _indexBuffer;
  57362. private _ringBufferIndex;
  57363. private _ringScreenBuffer;
  57364. private _fullscreenViewport;
  57365. private _getNextFrameBuffer;
  57366. /**
  57367. * Creates an effect renderer
  57368. * @param engine the engine to use for rendering
  57369. * @param options defines the options of the effect renderer
  57370. */
  57371. constructor(engine: Engine, options?: IEffectRendererOptions);
  57372. /**
  57373. * Sets the current viewport in normalized coordinates 0-1
  57374. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57375. */
  57376. setViewport(viewport?: Viewport): void;
  57377. /**
  57378. * Binds the embedded attributes buffer to the effect.
  57379. * @param effect Defines the effect to bind the attributes for
  57380. */
  57381. bindBuffers(effect: Effect): void;
  57382. /**
  57383. * Sets the current effect wrapper to use during draw.
  57384. * The effect needs to be ready before calling this api.
  57385. * This also sets the default full screen position attribute.
  57386. * @param effectWrapper Defines the effect to draw with
  57387. */
  57388. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57389. /**
  57390. * Draws a full screen quad.
  57391. */
  57392. draw(): void;
  57393. /**
  57394. * renders one or more effects to a specified texture
  57395. * @param effectWrappers list of effects to renderer
  57396. * @param outputTexture texture to draw to, if null it will render to the screen
  57397. */
  57398. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57399. /**
  57400. * Disposes of the effect renderer
  57401. */
  57402. dispose(): void;
  57403. }
  57404. /**
  57405. * Options to create an EffectWrapper
  57406. */
  57407. interface EffectWrapperCreationOptions {
  57408. /**
  57409. * Engine to use to create the effect
  57410. */
  57411. engine: Engine;
  57412. /**
  57413. * Fragment shader for the effect
  57414. */
  57415. fragmentShader: string;
  57416. /**
  57417. * Vertex shader for the effect
  57418. */
  57419. vertexShader?: string;
  57420. /**
  57421. * Attributes to use in the shader
  57422. */
  57423. attributeNames?: Array<string>;
  57424. /**
  57425. * Uniforms to use in the shader
  57426. */
  57427. uniformNames?: Array<string>;
  57428. /**
  57429. * Texture sampler names to use in the shader
  57430. */
  57431. samplerNames?: Array<string>;
  57432. /**
  57433. * The friendly name of the effect displayed in Spector.
  57434. */
  57435. name?: string;
  57436. }
  57437. /**
  57438. * Wraps an effect to be used for rendering
  57439. */
  57440. export class EffectWrapper {
  57441. /**
  57442. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57443. */
  57444. onApplyObservable: Observable<{}>;
  57445. /**
  57446. * The underlying effect
  57447. */
  57448. effect: Effect;
  57449. /**
  57450. * Creates an effect to be renderer
  57451. * @param creationOptions options to create the effect
  57452. */
  57453. constructor(creationOptions: EffectWrapperCreationOptions);
  57454. /**
  57455. * Disposes of the effect wrapper
  57456. */
  57457. dispose(): void;
  57458. }
  57459. }
  57460. declare module "babylonjs/Materials/index" {
  57461. export * from "babylonjs/Materials/Background/index";
  57462. export * from "babylonjs/Materials/colorCurves";
  57463. export * from "babylonjs/Materials/effect";
  57464. export * from "babylonjs/Materials/fresnelParameters";
  57465. export * from "babylonjs/Materials/imageProcessingConfiguration";
  57466. export * from "babylonjs/Materials/material";
  57467. export * from "babylonjs/Materials/materialDefines";
  57468. export * from "babylonjs/Materials/materialHelper";
  57469. export * from "babylonjs/Materials/multiMaterial";
  57470. export * from "babylonjs/Materials/PBR/index";
  57471. export * from "babylonjs/Materials/pushMaterial";
  57472. export * from "babylonjs/Materials/shaderMaterial";
  57473. export * from "babylonjs/Materials/standardMaterial";
  57474. export * from "babylonjs/Materials/Textures/index";
  57475. export * from "babylonjs/Materials/uniformBuffer";
  57476. export * from "babylonjs/Materials/materialFlags";
  57477. export * from "babylonjs/Materials/Node/index";
  57478. export * from "babylonjs/Materials/effectRenderer";
  57479. }
  57480. declare module "babylonjs/Maths/index" {
  57481. export * from "babylonjs/Maths/math.scalar";
  57482. export * from "babylonjs/Maths/math";
  57483. export * from "babylonjs/Maths/sphericalPolynomial";
  57484. }
  57485. declare module "babylonjs/Misc/workerPool" {
  57486. import { IDisposable } from "babylonjs/scene";
  57487. /**
  57488. * Helper class to push actions to a pool of workers.
  57489. */
  57490. export class WorkerPool implements IDisposable {
  57491. private _workerInfos;
  57492. private _pendingActions;
  57493. /**
  57494. * Constructor
  57495. * @param workers Array of workers to use for actions
  57496. */
  57497. constructor(workers: Array<Worker>);
  57498. /**
  57499. * Terminates all workers and clears any pending actions.
  57500. */
  57501. dispose(): void;
  57502. /**
  57503. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57504. * pended until a worker has completed its action.
  57505. * @param action The action to perform. Call onComplete when the action is complete.
  57506. */
  57507. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57508. private _execute;
  57509. }
  57510. }
  57511. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  57512. import { IDisposable } from "babylonjs/scene";
  57513. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57514. /**
  57515. * Configuration for Draco compression
  57516. */
  57517. export interface IDracoCompressionConfiguration {
  57518. /**
  57519. * Configuration for the decoder.
  57520. */
  57521. decoder: {
  57522. /**
  57523. * The url to the WebAssembly module.
  57524. */
  57525. wasmUrl?: string;
  57526. /**
  57527. * The url to the WebAssembly binary.
  57528. */
  57529. wasmBinaryUrl?: string;
  57530. /**
  57531. * The url to the fallback JavaScript module.
  57532. */
  57533. fallbackUrl?: string;
  57534. };
  57535. }
  57536. /**
  57537. * Draco compression (https://google.github.io/draco/)
  57538. *
  57539. * This class wraps the Draco module.
  57540. *
  57541. * **Encoder**
  57542. *
  57543. * The encoder is not currently implemented.
  57544. *
  57545. * **Decoder**
  57546. *
  57547. * 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.
  57548. *
  57549. * To update the configuration, use the following code:
  57550. * ```javascript
  57551. * DracoCompression.Configuration = {
  57552. * decoder: {
  57553. * wasmUrl: "<url to the WebAssembly library>",
  57554. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57555. * fallbackUrl: "<url to the fallback JavaScript library>",
  57556. * }
  57557. * };
  57558. * ```
  57559. *
  57560. * 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.
  57561. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57562. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57563. *
  57564. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57565. * ```javascript
  57566. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57567. * ```
  57568. *
  57569. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57570. */
  57571. export class DracoCompression implements IDisposable {
  57572. private _workerPoolPromise?;
  57573. private _decoderModulePromise?;
  57574. /**
  57575. * The configuration. Defaults to the following urls:
  57576. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57577. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57578. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57579. */
  57580. static Configuration: IDracoCompressionConfiguration;
  57581. /**
  57582. * Returns true if the decoder configuration is available.
  57583. */
  57584. static readonly DecoderAvailable: boolean;
  57585. /**
  57586. * Default number of workers to create when creating the draco compression object.
  57587. */
  57588. static DefaultNumWorkers: number;
  57589. private static GetDefaultNumWorkers;
  57590. private static _Default;
  57591. /**
  57592. * Default instance for the draco compression object.
  57593. */
  57594. static readonly Default: DracoCompression;
  57595. /**
  57596. * Constructor
  57597. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57598. */
  57599. constructor(numWorkers?: number);
  57600. /**
  57601. * Stop all async operations and release resources.
  57602. */
  57603. dispose(): void;
  57604. /**
  57605. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57606. * @returns a promise that resolves when ready
  57607. */
  57608. whenReadyAsync(): Promise<void>;
  57609. /**
  57610. * Decode Draco compressed mesh data to vertex data.
  57611. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57612. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57613. * @returns A promise that resolves with the decoded vertex data
  57614. */
  57615. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57616. [kind: string]: number;
  57617. }): Promise<VertexData>;
  57618. }
  57619. }
  57620. declare module "babylonjs/Meshes/Compression/index" {
  57621. export * from "babylonjs/Meshes/Compression/dracoCompression";
  57622. }
  57623. declare module "babylonjs/Meshes/csg" {
  57624. import { Nullable } from "babylonjs/types";
  57625. import { Scene } from "babylonjs/scene";
  57626. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57627. import { Mesh } from "babylonjs/Meshes/mesh";
  57628. import { Material } from "babylonjs/Materials/material";
  57629. /**
  57630. * Class for building Constructive Solid Geometry
  57631. */
  57632. export class CSG {
  57633. private polygons;
  57634. /**
  57635. * The world matrix
  57636. */
  57637. matrix: Matrix;
  57638. /**
  57639. * Stores the position
  57640. */
  57641. position: Vector3;
  57642. /**
  57643. * Stores the rotation
  57644. */
  57645. rotation: Vector3;
  57646. /**
  57647. * Stores the rotation quaternion
  57648. */
  57649. rotationQuaternion: Nullable<Quaternion>;
  57650. /**
  57651. * Stores the scaling vector
  57652. */
  57653. scaling: Vector3;
  57654. /**
  57655. * Convert the Mesh to CSG
  57656. * @param mesh The Mesh to convert to CSG
  57657. * @returns A new CSG from the Mesh
  57658. */
  57659. static FromMesh(mesh: Mesh): CSG;
  57660. /**
  57661. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57662. * @param polygons Polygons used to construct a CSG solid
  57663. */
  57664. private static FromPolygons;
  57665. /**
  57666. * Clones, or makes a deep copy, of the CSG
  57667. * @returns A new CSG
  57668. */
  57669. clone(): CSG;
  57670. /**
  57671. * Unions this CSG with another CSG
  57672. * @param csg The CSG to union against this CSG
  57673. * @returns The unioned CSG
  57674. */
  57675. union(csg: CSG): CSG;
  57676. /**
  57677. * Unions this CSG with another CSG in place
  57678. * @param csg The CSG to union against this CSG
  57679. */
  57680. unionInPlace(csg: CSG): void;
  57681. /**
  57682. * Subtracts this CSG with another CSG
  57683. * @param csg The CSG to subtract against this CSG
  57684. * @returns A new CSG
  57685. */
  57686. subtract(csg: CSG): CSG;
  57687. /**
  57688. * Subtracts this CSG with another CSG in place
  57689. * @param csg The CSG to subtact against this CSG
  57690. */
  57691. subtractInPlace(csg: CSG): void;
  57692. /**
  57693. * Intersect this CSG with another CSG
  57694. * @param csg The CSG to intersect against this CSG
  57695. * @returns A new CSG
  57696. */
  57697. intersect(csg: CSG): CSG;
  57698. /**
  57699. * Intersects this CSG with another CSG in place
  57700. * @param csg The CSG to intersect against this CSG
  57701. */
  57702. intersectInPlace(csg: CSG): void;
  57703. /**
  57704. * Return a new CSG solid with solid and empty space switched. This solid is
  57705. * not modified.
  57706. * @returns A new CSG solid with solid and empty space switched
  57707. */
  57708. inverse(): CSG;
  57709. /**
  57710. * Inverses the CSG in place
  57711. */
  57712. inverseInPlace(): void;
  57713. /**
  57714. * This is used to keep meshes transformations so they can be restored
  57715. * when we build back a Babylon Mesh
  57716. * NB : All CSG operations are performed in world coordinates
  57717. * @param csg The CSG to copy the transform attributes from
  57718. * @returns This CSG
  57719. */
  57720. copyTransformAttributes(csg: CSG): CSG;
  57721. /**
  57722. * Build Raw mesh from CSG
  57723. * Coordinates here are in world space
  57724. * @param name The name of the mesh geometry
  57725. * @param scene The Scene
  57726. * @param keepSubMeshes Specifies if the submeshes should be kept
  57727. * @returns A new Mesh
  57728. */
  57729. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57730. /**
  57731. * Build Mesh from CSG taking material and transforms into account
  57732. * @param name The name of the Mesh
  57733. * @param material The material of the Mesh
  57734. * @param scene The Scene
  57735. * @param keepSubMeshes Specifies if submeshes should be kept
  57736. * @returns The new Mesh
  57737. */
  57738. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57739. }
  57740. }
  57741. declare module "babylonjs/Meshes/trailMesh" {
  57742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57743. import { Mesh } from "babylonjs/Meshes/mesh";
  57744. import { Scene } from "babylonjs/scene";
  57745. /**
  57746. * Class used to create a trail following a mesh
  57747. */
  57748. export class TrailMesh extends Mesh {
  57749. private _generator;
  57750. private _autoStart;
  57751. private _running;
  57752. private _diameter;
  57753. private _length;
  57754. private _sectionPolygonPointsCount;
  57755. private _sectionVectors;
  57756. private _sectionNormalVectors;
  57757. private _beforeRenderObserver;
  57758. /**
  57759. * @constructor
  57760. * @param name The value used by scene.getMeshByName() to do a lookup.
  57761. * @param generator The mesh to generate a trail.
  57762. * @param scene The scene to add this mesh to.
  57763. * @param diameter Diameter of trailing mesh. Default is 1.
  57764. * @param length Length of trailing mesh. Default is 60.
  57765. * @param autoStart Automatically start trailing mesh. Default true.
  57766. */
  57767. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57768. /**
  57769. * "TrailMesh"
  57770. * @returns "TrailMesh"
  57771. */
  57772. getClassName(): string;
  57773. private _createMesh;
  57774. /**
  57775. * Start trailing mesh.
  57776. */
  57777. start(): void;
  57778. /**
  57779. * Stop trailing mesh.
  57780. */
  57781. stop(): void;
  57782. /**
  57783. * Update trailing mesh geometry.
  57784. */
  57785. update(): void;
  57786. /**
  57787. * Returns a new TrailMesh object.
  57788. * @param name is a string, the name given to the new mesh
  57789. * @param newGenerator use new generator object for cloned trail mesh
  57790. * @returns a new mesh
  57791. */
  57792. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57793. /**
  57794. * Serializes this trail mesh
  57795. * @param serializationObject object to write serialization to
  57796. */
  57797. serialize(serializationObject: any): void;
  57798. /**
  57799. * Parses a serialized trail mesh
  57800. * @param parsedMesh the serialized mesh
  57801. * @param scene the scene to create the trail mesh in
  57802. * @returns the created trail mesh
  57803. */
  57804. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57805. }
  57806. }
  57807. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  57808. import { Nullable } from "babylonjs/types";
  57809. import { Scene } from "babylonjs/scene";
  57810. import { Vector4 } from "babylonjs/Maths/math.vector";
  57811. import { Color4 } from "babylonjs/Maths/math.color";
  57812. import { Mesh } from "babylonjs/Meshes/mesh";
  57813. /**
  57814. * Class containing static functions to help procedurally build meshes
  57815. */
  57816. export class TiledBoxBuilder {
  57817. /**
  57818. * Creates a box mesh
  57819. * 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)
  57820. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57824. * @param name defines the name of the mesh
  57825. * @param options defines the options used to create the mesh
  57826. * @param scene defines the hosting scene
  57827. * @returns the box mesh
  57828. */
  57829. static CreateTiledBox(name: string, options: {
  57830. pattern?: number;
  57831. width?: number;
  57832. height?: number;
  57833. depth?: number;
  57834. tileSize?: number;
  57835. tileWidth?: number;
  57836. tileHeight?: number;
  57837. alignHorizontal?: number;
  57838. alignVertical?: number;
  57839. faceUV?: Vector4[];
  57840. faceColors?: Color4[];
  57841. sideOrientation?: number;
  57842. updatable?: boolean;
  57843. }, scene?: Nullable<Scene>): Mesh;
  57844. }
  57845. }
  57846. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57847. import { Vector4 } from "babylonjs/Maths/math.vector";
  57848. import { Mesh } from "babylonjs/Meshes/mesh";
  57849. /**
  57850. * Class containing static functions to help procedurally build meshes
  57851. */
  57852. export class TorusKnotBuilder {
  57853. /**
  57854. * Creates a torus knot mesh
  57855. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57856. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57857. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57858. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57862. * @param name defines the name of the mesh
  57863. * @param options defines the options used to create the mesh
  57864. * @param scene defines the hosting scene
  57865. * @returns the torus knot mesh
  57866. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57867. */
  57868. static CreateTorusKnot(name: string, options: {
  57869. radius?: number;
  57870. tube?: number;
  57871. radialSegments?: number;
  57872. tubularSegments?: number;
  57873. p?: number;
  57874. q?: number;
  57875. updatable?: boolean;
  57876. sideOrientation?: number;
  57877. frontUVs?: Vector4;
  57878. backUVs?: Vector4;
  57879. }, scene: any): Mesh;
  57880. }
  57881. }
  57882. declare module "babylonjs/Meshes/polygonMesh" {
  57883. import { Scene } from "babylonjs/scene";
  57884. import { Vector2 } from "babylonjs/Maths/math.vector";
  57885. import { Mesh } from "babylonjs/Meshes/mesh";
  57886. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57887. import { Path2 } from "babylonjs/Maths/math.path";
  57888. /**
  57889. * Polygon
  57890. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57891. */
  57892. export class Polygon {
  57893. /**
  57894. * Creates a rectangle
  57895. * @param xmin bottom X coord
  57896. * @param ymin bottom Y coord
  57897. * @param xmax top X coord
  57898. * @param ymax top Y coord
  57899. * @returns points that make the resulting rectation
  57900. */
  57901. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57902. /**
  57903. * Creates a circle
  57904. * @param radius radius of circle
  57905. * @param cx scale in x
  57906. * @param cy scale in y
  57907. * @param numberOfSides number of sides that make up the circle
  57908. * @returns points that make the resulting circle
  57909. */
  57910. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57911. /**
  57912. * Creates a polygon from input string
  57913. * @param input Input polygon data
  57914. * @returns the parsed points
  57915. */
  57916. static Parse(input: string): Vector2[];
  57917. /**
  57918. * Starts building a polygon from x and y coordinates
  57919. * @param x x coordinate
  57920. * @param y y coordinate
  57921. * @returns the started path2
  57922. */
  57923. static StartingAt(x: number, y: number): Path2;
  57924. }
  57925. /**
  57926. * Builds a polygon
  57927. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57928. */
  57929. export class PolygonMeshBuilder {
  57930. private _points;
  57931. private _outlinepoints;
  57932. private _holes;
  57933. private _name;
  57934. private _scene;
  57935. private _epoints;
  57936. private _eholes;
  57937. private _addToepoint;
  57938. /**
  57939. * Babylon reference to the earcut plugin.
  57940. */
  57941. bjsEarcut: any;
  57942. /**
  57943. * Creates a PolygonMeshBuilder
  57944. * @param name name of the builder
  57945. * @param contours Path of the polygon
  57946. * @param scene scene to add to when creating the mesh
  57947. * @param earcutInjection can be used to inject your own earcut reference
  57948. */
  57949. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57950. /**
  57951. * Adds a whole within the polygon
  57952. * @param hole Array of points defining the hole
  57953. * @returns this
  57954. */
  57955. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57956. /**
  57957. * Creates the polygon
  57958. * @param updatable If the mesh should be updatable
  57959. * @param depth The depth of the mesh created
  57960. * @returns the created mesh
  57961. */
  57962. build(updatable?: boolean, depth?: number): Mesh;
  57963. /**
  57964. * Creates the polygon
  57965. * @param depth The depth of the mesh created
  57966. * @returns the created VertexData
  57967. */
  57968. buildVertexData(depth?: number): VertexData;
  57969. /**
  57970. * Adds a side to the polygon
  57971. * @param positions points that make the polygon
  57972. * @param normals normals of the polygon
  57973. * @param uvs uvs of the polygon
  57974. * @param indices indices of the polygon
  57975. * @param bounds bounds of the polygon
  57976. * @param points points of the polygon
  57977. * @param depth depth of the polygon
  57978. * @param flip flip of the polygon
  57979. */
  57980. private addSide;
  57981. }
  57982. }
  57983. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  57984. import { Scene } from "babylonjs/scene";
  57985. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57986. import { Color4 } from "babylonjs/Maths/math.color";
  57987. import { Mesh } from "babylonjs/Meshes/mesh";
  57988. import { Nullable } from "babylonjs/types";
  57989. /**
  57990. * Class containing static functions to help procedurally build meshes
  57991. */
  57992. export class PolygonBuilder {
  57993. /**
  57994. * Creates a polygon mesh
  57995. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57996. * * 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
  57997. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58000. * * Remember you can only change the shape positions, not their number when updating a polygon
  58001. * @param name defines the name of the mesh
  58002. * @param options defines the options used to create the mesh
  58003. * @param scene defines the hosting scene
  58004. * @param earcutInjection can be used to inject your own earcut reference
  58005. * @returns the polygon mesh
  58006. */
  58007. static CreatePolygon(name: string, options: {
  58008. shape: Vector3[];
  58009. holes?: Vector3[][];
  58010. depth?: number;
  58011. faceUV?: Vector4[];
  58012. faceColors?: Color4[];
  58013. updatable?: boolean;
  58014. sideOrientation?: number;
  58015. frontUVs?: Vector4;
  58016. backUVs?: Vector4;
  58017. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58018. /**
  58019. * Creates an extruded polygon mesh, with depth in the Y direction.
  58020. * * 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)
  58021. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58022. * @param name defines the name of the mesh
  58023. * @param options defines the options used to create the mesh
  58024. * @param scene defines the hosting scene
  58025. * @param earcutInjection can be used to inject your own earcut reference
  58026. * @returns the polygon mesh
  58027. */
  58028. static ExtrudePolygon(name: string, options: {
  58029. shape: Vector3[];
  58030. holes?: Vector3[][];
  58031. depth?: number;
  58032. faceUV?: Vector4[];
  58033. faceColors?: Color4[];
  58034. updatable?: boolean;
  58035. sideOrientation?: number;
  58036. frontUVs?: Vector4;
  58037. backUVs?: Vector4;
  58038. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58039. }
  58040. }
  58041. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58042. import { Scene } from "babylonjs/scene";
  58043. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58044. import { Mesh } from "babylonjs/Meshes/mesh";
  58045. import { Nullable } from "babylonjs/types";
  58046. /**
  58047. * Class containing static functions to help procedurally build meshes
  58048. */
  58049. export class LatheBuilder {
  58050. /**
  58051. * Creates lathe mesh.
  58052. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58053. * * 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
  58054. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58055. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58056. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58057. * * 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
  58058. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58059. * * 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
  58060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58062. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58064. * @param name defines the name of the mesh
  58065. * @param options defines the options used to create the mesh
  58066. * @param scene defines the hosting scene
  58067. * @returns the lathe mesh
  58068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58069. */
  58070. static CreateLathe(name: string, options: {
  58071. shape: Vector3[];
  58072. radius?: number;
  58073. tessellation?: number;
  58074. clip?: number;
  58075. arc?: number;
  58076. closed?: boolean;
  58077. updatable?: boolean;
  58078. sideOrientation?: number;
  58079. frontUVs?: Vector4;
  58080. backUVs?: Vector4;
  58081. cap?: number;
  58082. invertUV?: boolean;
  58083. }, scene?: Nullable<Scene>): Mesh;
  58084. }
  58085. }
  58086. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58087. import { Nullable } from "babylonjs/types";
  58088. import { Scene } from "babylonjs/scene";
  58089. import { Vector4 } from "babylonjs/Maths/math.vector";
  58090. import { Mesh } from "babylonjs/Meshes/mesh";
  58091. /**
  58092. * Class containing static functions to help procedurally build meshes
  58093. */
  58094. export class TiledPlaneBuilder {
  58095. /**
  58096. * Creates a tiled plane mesh
  58097. * * The parameter `pattern` will, depending on value, do nothing or
  58098. * * * flip (reflect about central vertical) alternate tiles across and up
  58099. * * * flip every tile on alternate rows
  58100. * * * rotate (180 degs) alternate tiles across and up
  58101. * * * rotate every tile on alternate rows
  58102. * * * flip and rotate alternate tiles across and up
  58103. * * * flip and rotate every tile on alternate rows
  58104. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58105. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58108. * * 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)
  58109. * * 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)
  58110. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58111. * @param name defines the name of the mesh
  58112. * @param options defines the options used to create the mesh
  58113. * @param scene defines the hosting scene
  58114. * @returns the box mesh
  58115. */
  58116. static CreateTiledPlane(name: string, options: {
  58117. pattern?: number;
  58118. tileSize?: number;
  58119. tileWidth?: number;
  58120. tileHeight?: number;
  58121. size?: number;
  58122. width?: number;
  58123. height?: number;
  58124. alignHorizontal?: number;
  58125. alignVertical?: number;
  58126. sideOrientation?: number;
  58127. frontUVs?: Vector4;
  58128. backUVs?: Vector4;
  58129. updatable?: boolean;
  58130. }, scene?: Nullable<Scene>): Mesh;
  58131. }
  58132. }
  58133. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  58134. import { Nullable } from "babylonjs/types";
  58135. import { Scene } from "babylonjs/scene";
  58136. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58137. import { Mesh } from "babylonjs/Meshes/mesh";
  58138. /**
  58139. * Class containing static functions to help procedurally build meshes
  58140. */
  58141. export class TubeBuilder {
  58142. /**
  58143. * Creates a tube mesh.
  58144. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58145. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58146. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58147. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58148. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58149. * * 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)
  58150. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58151. * * 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
  58152. * * 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
  58153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58155. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58157. * @param name defines the name of the mesh
  58158. * @param options defines the options used to create the mesh
  58159. * @param scene defines the hosting scene
  58160. * @returns the tube mesh
  58161. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58162. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58163. */
  58164. static CreateTube(name: string, options: {
  58165. path: Vector3[];
  58166. radius?: number;
  58167. tessellation?: number;
  58168. radiusFunction?: {
  58169. (i: number, distance: number): number;
  58170. };
  58171. cap?: number;
  58172. arc?: number;
  58173. updatable?: boolean;
  58174. sideOrientation?: number;
  58175. frontUVs?: Vector4;
  58176. backUVs?: Vector4;
  58177. instance?: Mesh;
  58178. invertUV?: boolean;
  58179. }, scene?: Nullable<Scene>): Mesh;
  58180. }
  58181. }
  58182. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  58183. import { Scene } from "babylonjs/scene";
  58184. import { Vector4 } from "babylonjs/Maths/math.vector";
  58185. import { Mesh } from "babylonjs/Meshes/mesh";
  58186. import { Nullable } from "babylonjs/types";
  58187. /**
  58188. * Class containing static functions to help procedurally build meshes
  58189. */
  58190. export class IcoSphereBuilder {
  58191. /**
  58192. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58193. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58194. * * 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`)
  58195. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58196. * * 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
  58197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58200. * @param name defines the name of the mesh
  58201. * @param options defines the options used to create the mesh
  58202. * @param scene defines the hosting scene
  58203. * @returns the icosahedron mesh
  58204. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58205. */
  58206. static CreateIcoSphere(name: string, options: {
  58207. radius?: number;
  58208. radiusX?: number;
  58209. radiusY?: number;
  58210. radiusZ?: number;
  58211. flat?: boolean;
  58212. subdivisions?: number;
  58213. sideOrientation?: number;
  58214. frontUVs?: Vector4;
  58215. backUVs?: Vector4;
  58216. updatable?: boolean;
  58217. }, scene?: Nullable<Scene>): Mesh;
  58218. }
  58219. }
  58220. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  58221. import { Vector3 } from "babylonjs/Maths/math.vector";
  58222. import { Mesh } from "babylonjs/Meshes/mesh";
  58223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58224. /**
  58225. * Class containing static functions to help procedurally build meshes
  58226. */
  58227. export class DecalBuilder {
  58228. /**
  58229. * Creates a decal mesh.
  58230. * 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
  58231. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58232. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58233. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58234. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58235. * @param name defines the name of the mesh
  58236. * @param sourceMesh defines the mesh where the decal must be applied
  58237. * @param options defines the options used to create the mesh
  58238. * @param scene defines the hosting scene
  58239. * @returns the decal mesh
  58240. * @see https://doc.babylonjs.com/how_to/decals
  58241. */
  58242. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58243. position?: Vector3;
  58244. normal?: Vector3;
  58245. size?: Vector3;
  58246. angle?: number;
  58247. }): Mesh;
  58248. }
  58249. }
  58250. declare module "babylonjs/Meshes/meshBuilder" {
  58251. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  58252. import { Nullable } from "babylonjs/types";
  58253. import { Scene } from "babylonjs/scene";
  58254. import { Mesh } from "babylonjs/Meshes/mesh";
  58255. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58256. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  58257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58258. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58259. import { Plane } from "babylonjs/Maths/math.plane";
  58260. /**
  58261. * Class containing static functions to help procedurally build meshes
  58262. */
  58263. export class MeshBuilder {
  58264. /**
  58265. * Creates a box mesh
  58266. * * The parameter `size` sets the size (float) of each box side (default 1)
  58267. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58268. * * 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)
  58269. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58273. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58274. * @param name defines the name of the mesh
  58275. * @param options defines the options used to create the mesh
  58276. * @param scene defines the hosting scene
  58277. * @returns the box mesh
  58278. */
  58279. static CreateBox(name: string, options: {
  58280. size?: number;
  58281. width?: number;
  58282. height?: number;
  58283. depth?: number;
  58284. faceUV?: Vector4[];
  58285. faceColors?: Color4[];
  58286. sideOrientation?: number;
  58287. frontUVs?: Vector4;
  58288. backUVs?: Vector4;
  58289. updatable?: boolean;
  58290. }, scene?: Nullable<Scene>): Mesh;
  58291. /**
  58292. * Creates a tiled box mesh
  58293. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58295. * @param name defines the name of the mesh
  58296. * @param options defines the options used to create the mesh
  58297. * @param scene defines the hosting scene
  58298. * @returns the tiled box mesh
  58299. */
  58300. static CreateTiledBox(name: string, options: {
  58301. pattern?: number;
  58302. size?: number;
  58303. width?: number;
  58304. height?: number;
  58305. depth: number;
  58306. tileSize?: number;
  58307. tileWidth?: number;
  58308. tileHeight?: number;
  58309. faceUV?: Vector4[];
  58310. faceColors?: Color4[];
  58311. alignHorizontal?: number;
  58312. alignVertical?: number;
  58313. sideOrientation?: number;
  58314. updatable?: boolean;
  58315. }, scene?: Nullable<Scene>): Mesh;
  58316. /**
  58317. * Creates a sphere mesh
  58318. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58319. * * 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`)
  58320. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58321. * * 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
  58322. * * 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)
  58323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58326. * @param name defines the name of the mesh
  58327. * @param options defines the options used to create the mesh
  58328. * @param scene defines the hosting scene
  58329. * @returns the sphere mesh
  58330. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58331. */
  58332. static CreateSphere(name: string, options: {
  58333. segments?: number;
  58334. diameter?: number;
  58335. diameterX?: number;
  58336. diameterY?: number;
  58337. diameterZ?: number;
  58338. arc?: number;
  58339. slice?: number;
  58340. sideOrientation?: number;
  58341. frontUVs?: Vector4;
  58342. backUVs?: Vector4;
  58343. updatable?: boolean;
  58344. }, scene?: Nullable<Scene>): Mesh;
  58345. /**
  58346. * Creates a plane polygonal mesh. By default, this is a disc
  58347. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58348. * * 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
  58349. * * 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
  58350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58353. * @param name defines the name of the mesh
  58354. * @param options defines the options used to create the mesh
  58355. * @param scene defines the hosting scene
  58356. * @returns the plane polygonal mesh
  58357. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58358. */
  58359. static CreateDisc(name: string, options: {
  58360. radius?: number;
  58361. tessellation?: number;
  58362. arc?: number;
  58363. updatable?: boolean;
  58364. sideOrientation?: number;
  58365. frontUVs?: Vector4;
  58366. backUVs?: Vector4;
  58367. }, scene?: Nullable<Scene>): Mesh;
  58368. /**
  58369. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58370. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58371. * * 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`)
  58372. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58373. * * 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
  58374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58377. * @param name defines the name of the mesh
  58378. * @param options defines the options used to create the mesh
  58379. * @param scene defines the hosting scene
  58380. * @returns the icosahedron mesh
  58381. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58382. */
  58383. static CreateIcoSphere(name: string, options: {
  58384. radius?: number;
  58385. radiusX?: number;
  58386. radiusY?: number;
  58387. radiusZ?: number;
  58388. flat?: boolean;
  58389. subdivisions?: number;
  58390. sideOrientation?: number;
  58391. frontUVs?: Vector4;
  58392. backUVs?: Vector4;
  58393. updatable?: boolean;
  58394. }, scene?: Nullable<Scene>): Mesh;
  58395. /**
  58396. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58397. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58398. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58399. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58400. * * 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
  58401. * * 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
  58402. * * 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
  58403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58405. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58406. * * 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
  58407. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58408. * * 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
  58409. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58411. * @param name defines the name of the mesh
  58412. * @param options defines the options used to create the mesh
  58413. * @param scene defines the hosting scene
  58414. * @returns the ribbon mesh
  58415. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58416. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58417. */
  58418. static CreateRibbon(name: string, options: {
  58419. pathArray: Vector3[][];
  58420. closeArray?: boolean;
  58421. closePath?: boolean;
  58422. offset?: number;
  58423. updatable?: boolean;
  58424. sideOrientation?: number;
  58425. frontUVs?: Vector4;
  58426. backUVs?: Vector4;
  58427. instance?: Mesh;
  58428. invertUV?: boolean;
  58429. uvs?: Vector2[];
  58430. colors?: Color4[];
  58431. }, scene?: Nullable<Scene>): Mesh;
  58432. /**
  58433. * Creates a cylinder or a cone mesh
  58434. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58435. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58436. * * 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.
  58437. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58438. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58439. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58440. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58441. * * 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).
  58442. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58443. * * 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).
  58444. * * 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
  58445. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58446. * * 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
  58447. * * 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.
  58448. * * If `enclose` is false, a ring surface is one element.
  58449. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58450. * * 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
  58451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58454. * @param name defines the name of the mesh
  58455. * @param options defines the options used to create the mesh
  58456. * @param scene defines the hosting scene
  58457. * @returns the cylinder mesh
  58458. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58459. */
  58460. static CreateCylinder(name: string, options: {
  58461. height?: number;
  58462. diameterTop?: number;
  58463. diameterBottom?: number;
  58464. diameter?: number;
  58465. tessellation?: number;
  58466. subdivisions?: number;
  58467. arc?: number;
  58468. faceColors?: Color4[];
  58469. faceUV?: Vector4[];
  58470. updatable?: boolean;
  58471. hasRings?: boolean;
  58472. enclose?: boolean;
  58473. cap?: number;
  58474. sideOrientation?: number;
  58475. frontUVs?: Vector4;
  58476. backUVs?: Vector4;
  58477. }, scene?: Nullable<Scene>): Mesh;
  58478. /**
  58479. * Creates a torus mesh
  58480. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58481. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58482. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58486. * @param name defines the name of the mesh
  58487. * @param options defines the options used to create the mesh
  58488. * @param scene defines the hosting scene
  58489. * @returns the torus mesh
  58490. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58491. */
  58492. static CreateTorus(name: string, options: {
  58493. diameter?: number;
  58494. thickness?: number;
  58495. tessellation?: number;
  58496. updatable?: boolean;
  58497. sideOrientation?: number;
  58498. frontUVs?: Vector4;
  58499. backUVs?: Vector4;
  58500. }, scene?: Nullable<Scene>): Mesh;
  58501. /**
  58502. * Creates a torus knot mesh
  58503. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58504. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58505. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58506. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58510. * @param name defines the name of the mesh
  58511. * @param options defines the options used to create the mesh
  58512. * @param scene defines the hosting scene
  58513. * @returns the torus knot mesh
  58514. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58515. */
  58516. static CreateTorusKnot(name: string, options: {
  58517. radius?: number;
  58518. tube?: number;
  58519. radialSegments?: number;
  58520. tubularSegments?: number;
  58521. p?: number;
  58522. q?: number;
  58523. updatable?: boolean;
  58524. sideOrientation?: number;
  58525. frontUVs?: Vector4;
  58526. backUVs?: Vector4;
  58527. }, scene?: Nullable<Scene>): Mesh;
  58528. /**
  58529. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58530. * * 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
  58531. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58532. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58533. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58534. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58535. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58536. * * 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
  58537. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58540. * @param name defines the name of the new line system
  58541. * @param options defines the options used to create the line system
  58542. * @param scene defines the hosting scene
  58543. * @returns a new line system mesh
  58544. */
  58545. static CreateLineSystem(name: string, options: {
  58546. lines: Vector3[][];
  58547. updatable?: boolean;
  58548. instance?: Nullable<LinesMesh>;
  58549. colors?: Nullable<Color4[][]>;
  58550. useVertexAlpha?: boolean;
  58551. }, scene: Nullable<Scene>): LinesMesh;
  58552. /**
  58553. * Creates a line mesh
  58554. * 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
  58555. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58556. * * The parameter `points` is an array successive Vector3
  58557. * * 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
  58558. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58559. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58560. * * When updating an instance, remember that only point positions can change, not the number of points
  58561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58563. * @param name defines the name of the new line system
  58564. * @param options defines the options used to create the line system
  58565. * @param scene defines the hosting scene
  58566. * @returns a new line mesh
  58567. */
  58568. static CreateLines(name: string, options: {
  58569. points: Vector3[];
  58570. updatable?: boolean;
  58571. instance?: Nullable<LinesMesh>;
  58572. colors?: Color4[];
  58573. useVertexAlpha?: boolean;
  58574. }, scene?: Nullable<Scene>): LinesMesh;
  58575. /**
  58576. * Creates a dashed line mesh
  58577. * * 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
  58578. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58579. * * The parameter `points` is an array successive Vector3
  58580. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58581. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58582. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58583. * * 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
  58584. * * When updating an instance, remember that only point positions can change, not the number of points
  58585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58586. * @param name defines the name of the mesh
  58587. * @param options defines the options used to create the mesh
  58588. * @param scene defines the hosting scene
  58589. * @returns the dashed line mesh
  58590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58591. */
  58592. static CreateDashedLines(name: string, options: {
  58593. points: Vector3[];
  58594. dashSize?: number;
  58595. gapSize?: number;
  58596. dashNb?: number;
  58597. updatable?: boolean;
  58598. instance?: LinesMesh;
  58599. }, scene?: Nullable<Scene>): LinesMesh;
  58600. /**
  58601. * 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.
  58602. * * 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.
  58603. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58604. * * 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.
  58605. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58606. * * 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
  58607. * * 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
  58608. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58611. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58613. * @param name defines the name of the mesh
  58614. * @param options defines the options used to create the mesh
  58615. * @param scene defines the hosting scene
  58616. * @returns the extruded shape mesh
  58617. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58618. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58619. */
  58620. static ExtrudeShape(name: string, options: {
  58621. shape: Vector3[];
  58622. path: Vector3[];
  58623. scale?: number;
  58624. rotation?: number;
  58625. cap?: number;
  58626. updatable?: boolean;
  58627. sideOrientation?: number;
  58628. frontUVs?: Vector4;
  58629. backUVs?: Vector4;
  58630. instance?: Mesh;
  58631. invertUV?: boolean;
  58632. }, scene?: Nullable<Scene>): Mesh;
  58633. /**
  58634. * Creates an custom extruded shape mesh.
  58635. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58636. * * 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.
  58637. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58638. * * 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
  58639. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58640. * * 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
  58641. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58642. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58643. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58644. * * 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
  58645. * * 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
  58646. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58648. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58649. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58651. * @param name defines the name of the mesh
  58652. * @param options defines the options used to create the mesh
  58653. * @param scene defines the hosting scene
  58654. * @returns the custom extruded shape mesh
  58655. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58656. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58657. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58658. */
  58659. static ExtrudeShapeCustom(name: string, options: {
  58660. shape: Vector3[];
  58661. path: Vector3[];
  58662. scaleFunction?: any;
  58663. rotationFunction?: any;
  58664. ribbonCloseArray?: boolean;
  58665. ribbonClosePath?: boolean;
  58666. cap?: number;
  58667. updatable?: boolean;
  58668. sideOrientation?: number;
  58669. frontUVs?: Vector4;
  58670. backUVs?: Vector4;
  58671. instance?: Mesh;
  58672. invertUV?: boolean;
  58673. }, scene?: Nullable<Scene>): Mesh;
  58674. /**
  58675. * Creates lathe mesh.
  58676. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58677. * * 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
  58678. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58679. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58680. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58681. * * 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
  58682. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58683. * * 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
  58684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58686. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58688. * @param name defines the name of the mesh
  58689. * @param options defines the options used to create the mesh
  58690. * @param scene defines the hosting scene
  58691. * @returns the lathe mesh
  58692. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58693. */
  58694. static CreateLathe(name: string, options: {
  58695. shape: Vector3[];
  58696. radius?: number;
  58697. tessellation?: number;
  58698. clip?: number;
  58699. arc?: number;
  58700. closed?: boolean;
  58701. updatable?: boolean;
  58702. sideOrientation?: number;
  58703. frontUVs?: Vector4;
  58704. backUVs?: Vector4;
  58705. cap?: number;
  58706. invertUV?: boolean;
  58707. }, scene?: Nullable<Scene>): Mesh;
  58708. /**
  58709. * Creates a tiled plane mesh
  58710. * * You can set a limited pattern arrangement with the tiles
  58711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58714. * @param name defines the name of the mesh
  58715. * @param options defines the options used to create the mesh
  58716. * @param scene defines the hosting scene
  58717. * @returns the plane mesh
  58718. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58719. */
  58720. static CreateTiledPlane(name: string, options: {
  58721. pattern?: number;
  58722. tileSize?: number;
  58723. tileWidth?: number;
  58724. tileHeight?: number;
  58725. size?: number;
  58726. width?: number;
  58727. height?: number;
  58728. alignHorizontal?: number;
  58729. alignVertical?: number;
  58730. sideOrientation?: number;
  58731. frontUVs?: Vector4;
  58732. backUVs?: Vector4;
  58733. updatable?: boolean;
  58734. }, scene?: Nullable<Scene>): Mesh;
  58735. /**
  58736. * Creates a plane mesh
  58737. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58738. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58739. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58743. * @param name defines the name of the mesh
  58744. * @param options defines the options used to create the mesh
  58745. * @param scene defines the hosting scene
  58746. * @returns the plane mesh
  58747. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58748. */
  58749. static CreatePlane(name: string, options: {
  58750. size?: number;
  58751. width?: number;
  58752. height?: number;
  58753. sideOrientation?: number;
  58754. frontUVs?: Vector4;
  58755. backUVs?: Vector4;
  58756. updatable?: boolean;
  58757. sourcePlane?: Plane;
  58758. }, scene?: Nullable<Scene>): Mesh;
  58759. /**
  58760. * Creates a ground mesh
  58761. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58762. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58764. * @param name defines the name of the mesh
  58765. * @param options defines the options used to create the mesh
  58766. * @param scene defines the hosting scene
  58767. * @returns the ground mesh
  58768. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58769. */
  58770. static CreateGround(name: string, options: {
  58771. width?: number;
  58772. height?: number;
  58773. subdivisions?: number;
  58774. subdivisionsX?: number;
  58775. subdivisionsY?: number;
  58776. updatable?: boolean;
  58777. }, scene?: Nullable<Scene>): Mesh;
  58778. /**
  58779. * Creates a tiled ground mesh
  58780. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58781. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58782. * * 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
  58783. * * 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
  58784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58785. * @param name defines the name of the mesh
  58786. * @param options defines the options used to create the mesh
  58787. * @param scene defines the hosting scene
  58788. * @returns the tiled ground mesh
  58789. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58790. */
  58791. static CreateTiledGround(name: string, options: {
  58792. xmin: number;
  58793. zmin: number;
  58794. xmax: number;
  58795. zmax: number;
  58796. subdivisions?: {
  58797. w: number;
  58798. h: number;
  58799. };
  58800. precision?: {
  58801. w: number;
  58802. h: number;
  58803. };
  58804. updatable?: boolean;
  58805. }, scene?: Nullable<Scene>): Mesh;
  58806. /**
  58807. * Creates a ground mesh from a height map
  58808. * * The parameter `url` sets the URL of the height map image resource.
  58809. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58810. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58811. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58812. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58813. * * 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.
  58814. * * 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).
  58815. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58817. * @param name defines the name of the mesh
  58818. * @param url defines the url to the height map
  58819. * @param options defines the options used to create the mesh
  58820. * @param scene defines the hosting scene
  58821. * @returns the ground mesh
  58822. * @see https://doc.babylonjs.com/babylon101/height_map
  58823. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58824. */
  58825. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58826. width?: number;
  58827. height?: number;
  58828. subdivisions?: number;
  58829. minHeight?: number;
  58830. maxHeight?: number;
  58831. colorFilter?: Color3;
  58832. alphaFilter?: number;
  58833. updatable?: boolean;
  58834. onReady?: (mesh: GroundMesh) => void;
  58835. }, scene?: Nullable<Scene>): GroundMesh;
  58836. /**
  58837. * Creates a polygon mesh
  58838. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58839. * * 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
  58840. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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)
  58843. * * Remember you can only change the shape positions, not their number when updating a polygon
  58844. * @param name defines the name of the mesh
  58845. * @param options defines the options used to create the mesh
  58846. * @param scene defines the hosting scene
  58847. * @param earcutInjection can be used to inject your own earcut reference
  58848. * @returns the polygon mesh
  58849. */
  58850. static CreatePolygon(name: string, options: {
  58851. shape: Vector3[];
  58852. holes?: Vector3[][];
  58853. depth?: number;
  58854. faceUV?: Vector4[];
  58855. faceColors?: Color4[];
  58856. updatable?: boolean;
  58857. sideOrientation?: number;
  58858. frontUVs?: Vector4;
  58859. backUVs?: Vector4;
  58860. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58861. /**
  58862. * Creates an extruded polygon mesh, with depth in the Y direction.
  58863. * * 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)
  58864. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58865. * @param name defines the name of the mesh
  58866. * @param options defines the options used to create the mesh
  58867. * @param scene defines the hosting scene
  58868. * @param earcutInjection can be used to inject your own earcut reference
  58869. * @returns the polygon mesh
  58870. */
  58871. static ExtrudePolygon(name: string, options: {
  58872. shape: Vector3[];
  58873. holes?: Vector3[][];
  58874. depth?: number;
  58875. faceUV?: Vector4[];
  58876. faceColors?: Color4[];
  58877. updatable?: boolean;
  58878. sideOrientation?: number;
  58879. frontUVs?: Vector4;
  58880. backUVs?: Vector4;
  58881. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58882. /**
  58883. * Creates a tube mesh.
  58884. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58885. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58886. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58887. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58888. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58889. * * 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)
  58890. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58891. * * 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
  58892. * * 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
  58893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58894. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58895. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58897. * @param name defines the name of the mesh
  58898. * @param options defines the options used to create the mesh
  58899. * @param scene defines the hosting scene
  58900. * @returns the tube mesh
  58901. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58902. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58903. */
  58904. static CreateTube(name: string, options: {
  58905. path: Vector3[];
  58906. radius?: number;
  58907. tessellation?: number;
  58908. radiusFunction?: {
  58909. (i: number, distance: number): number;
  58910. };
  58911. cap?: number;
  58912. arc?: number;
  58913. updatable?: boolean;
  58914. sideOrientation?: number;
  58915. frontUVs?: Vector4;
  58916. backUVs?: Vector4;
  58917. instance?: Mesh;
  58918. invertUV?: boolean;
  58919. }, scene?: Nullable<Scene>): Mesh;
  58920. /**
  58921. * Creates a polyhedron mesh
  58922. * * 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
  58923. * * The parameter `size` (positive float, default 1) sets the polygon size
  58924. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58925. * * 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`
  58926. * * 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
  58927. * * 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)`)
  58928. * * 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
  58929. * * 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
  58930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58931. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58933. * @param name defines the name of the mesh
  58934. * @param options defines the options used to create the mesh
  58935. * @param scene defines the hosting scene
  58936. * @returns the polyhedron mesh
  58937. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58938. */
  58939. static CreatePolyhedron(name: string, options: {
  58940. type?: number;
  58941. size?: number;
  58942. sizeX?: number;
  58943. sizeY?: number;
  58944. sizeZ?: number;
  58945. custom?: any;
  58946. faceUV?: Vector4[];
  58947. faceColors?: Color4[];
  58948. flat?: boolean;
  58949. updatable?: boolean;
  58950. sideOrientation?: number;
  58951. frontUVs?: Vector4;
  58952. backUVs?: Vector4;
  58953. }, scene?: Nullable<Scene>): Mesh;
  58954. /**
  58955. * Creates a decal mesh.
  58956. * 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
  58957. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58958. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58959. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58960. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58961. * @param name defines the name of the mesh
  58962. * @param sourceMesh defines the mesh where the decal must be applied
  58963. * @param options defines the options used to create the mesh
  58964. * @param scene defines the hosting scene
  58965. * @returns the decal mesh
  58966. * @see https://doc.babylonjs.com/how_to/decals
  58967. */
  58968. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58969. position?: Vector3;
  58970. normal?: Vector3;
  58971. size?: Vector3;
  58972. angle?: number;
  58973. }): Mesh;
  58974. }
  58975. }
  58976. declare module "babylonjs/Meshes/meshSimplification" {
  58977. import { Mesh } from "babylonjs/Meshes/mesh";
  58978. /**
  58979. * A simplifier interface for future simplification implementations
  58980. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58981. */
  58982. export interface ISimplifier {
  58983. /**
  58984. * Simplification of a given mesh according to the given settings.
  58985. * Since this requires computation, it is assumed that the function runs async.
  58986. * @param settings The settings of the simplification, including quality and distance
  58987. * @param successCallback A callback that will be called after the mesh was simplified.
  58988. * @param errorCallback in case of an error, this callback will be called. optional.
  58989. */
  58990. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58991. }
  58992. /**
  58993. * Expected simplification settings.
  58994. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  58995. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58996. */
  58997. export interface ISimplificationSettings {
  58998. /**
  58999. * Gets or sets the expected quality
  59000. */
  59001. quality: number;
  59002. /**
  59003. * Gets or sets the distance when this optimized version should be used
  59004. */
  59005. distance: number;
  59006. /**
  59007. * Gets an already optimized mesh
  59008. */
  59009. optimizeMesh?: boolean;
  59010. }
  59011. /**
  59012. * Class used to specify simplification options
  59013. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59014. */
  59015. export class SimplificationSettings implements ISimplificationSettings {
  59016. /** expected quality */
  59017. quality: number;
  59018. /** distance when this optimized version should be used */
  59019. distance: number;
  59020. /** already optimized mesh */
  59021. optimizeMesh?: boolean | undefined;
  59022. /**
  59023. * Creates a SimplificationSettings
  59024. * @param quality expected quality
  59025. * @param distance distance when this optimized version should be used
  59026. * @param optimizeMesh already optimized mesh
  59027. */
  59028. constructor(
  59029. /** expected quality */
  59030. quality: number,
  59031. /** distance when this optimized version should be used */
  59032. distance: number,
  59033. /** already optimized mesh */
  59034. optimizeMesh?: boolean | undefined);
  59035. }
  59036. /**
  59037. * Interface used to define a simplification task
  59038. */
  59039. export interface ISimplificationTask {
  59040. /**
  59041. * Array of settings
  59042. */
  59043. settings: Array<ISimplificationSettings>;
  59044. /**
  59045. * Simplification type
  59046. */
  59047. simplificationType: SimplificationType;
  59048. /**
  59049. * Mesh to simplify
  59050. */
  59051. mesh: Mesh;
  59052. /**
  59053. * Callback called on success
  59054. */
  59055. successCallback?: () => void;
  59056. /**
  59057. * Defines if parallel processing can be used
  59058. */
  59059. parallelProcessing: boolean;
  59060. }
  59061. /**
  59062. * Queue used to order the simplification tasks
  59063. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59064. */
  59065. export class SimplificationQueue {
  59066. private _simplificationArray;
  59067. /**
  59068. * Gets a boolean indicating that the process is still running
  59069. */
  59070. running: boolean;
  59071. /**
  59072. * Creates a new queue
  59073. */
  59074. constructor();
  59075. /**
  59076. * Adds a new simplification task
  59077. * @param task defines a task to add
  59078. */
  59079. addTask(task: ISimplificationTask): void;
  59080. /**
  59081. * Execute next task
  59082. */
  59083. executeNext(): void;
  59084. /**
  59085. * Execute a simplification task
  59086. * @param task defines the task to run
  59087. */
  59088. runSimplification(task: ISimplificationTask): void;
  59089. private getSimplifier;
  59090. }
  59091. /**
  59092. * The implemented types of simplification
  59093. * At the moment only Quadratic Error Decimation is implemented
  59094. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59095. */
  59096. export enum SimplificationType {
  59097. /** Quadratic error decimation */
  59098. QUADRATIC = 0
  59099. }
  59100. }
  59101. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  59102. import { Scene } from "babylonjs/scene";
  59103. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  59104. import { ISceneComponent } from "babylonjs/sceneComponent";
  59105. module "babylonjs/scene" {
  59106. interface Scene {
  59107. /** @hidden (Backing field) */
  59108. _simplificationQueue: SimplificationQueue;
  59109. /**
  59110. * Gets or sets the simplification queue attached to the scene
  59111. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59112. */
  59113. simplificationQueue: SimplificationQueue;
  59114. }
  59115. }
  59116. module "babylonjs/Meshes/mesh" {
  59117. interface Mesh {
  59118. /**
  59119. * Simplify the mesh according to the given array of settings.
  59120. * Function will return immediately and will simplify async
  59121. * @param settings a collection of simplification settings
  59122. * @param parallelProcessing should all levels calculate parallel or one after the other
  59123. * @param simplificationType the type of simplification to run
  59124. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59125. * @returns the current mesh
  59126. */
  59127. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59128. }
  59129. }
  59130. /**
  59131. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59132. * created in a scene
  59133. */
  59134. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59135. /**
  59136. * The component name helpfull to identify the component in the list of scene components.
  59137. */
  59138. readonly name: string;
  59139. /**
  59140. * The scene the component belongs to.
  59141. */
  59142. scene: Scene;
  59143. /**
  59144. * Creates a new instance of the component for the given scene
  59145. * @param scene Defines the scene to register the component in
  59146. */
  59147. constructor(scene: Scene);
  59148. /**
  59149. * Registers the component in a given scene
  59150. */
  59151. register(): void;
  59152. /**
  59153. * Rebuilds the elements related to this component in case of
  59154. * context lost for instance.
  59155. */
  59156. rebuild(): void;
  59157. /**
  59158. * Disposes the component and the associated ressources
  59159. */
  59160. dispose(): void;
  59161. private _beforeCameraUpdate;
  59162. }
  59163. }
  59164. declare module "babylonjs/Meshes/Builders/index" {
  59165. export * from "babylonjs/Meshes/Builders/boxBuilder";
  59166. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  59167. export * from "babylonjs/Meshes/Builders/discBuilder";
  59168. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  59169. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  59170. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  59171. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  59172. export * from "babylonjs/Meshes/Builders/torusBuilder";
  59173. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  59174. export * from "babylonjs/Meshes/Builders/linesBuilder";
  59175. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  59176. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  59177. export * from "babylonjs/Meshes/Builders/latheBuilder";
  59178. export * from "babylonjs/Meshes/Builders/planeBuilder";
  59179. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  59180. export * from "babylonjs/Meshes/Builders/groundBuilder";
  59181. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  59182. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  59183. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  59184. export * from "babylonjs/Meshes/Builders/decalBuilder";
  59185. }
  59186. declare module "babylonjs/Meshes/index" {
  59187. export * from "babylonjs/Meshes/abstractMesh";
  59188. export * from "babylonjs/Meshes/buffer";
  59189. export * from "babylonjs/Meshes/Compression/index";
  59190. export * from "babylonjs/Meshes/csg";
  59191. export * from "babylonjs/Meshes/geometry";
  59192. export * from "babylonjs/Meshes/groundMesh";
  59193. export * from "babylonjs/Meshes/trailMesh";
  59194. export * from "babylonjs/Meshes/instancedMesh";
  59195. export * from "babylonjs/Meshes/linesMesh";
  59196. export * from "babylonjs/Meshes/mesh";
  59197. export * from "babylonjs/Meshes/mesh.vertexData";
  59198. export * from "babylonjs/Meshes/meshBuilder";
  59199. export * from "babylonjs/Meshes/meshSimplification";
  59200. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  59201. export * from "babylonjs/Meshes/polygonMesh";
  59202. export * from "babylonjs/Meshes/subMesh";
  59203. export * from "babylonjs/Meshes/meshLODLevel";
  59204. export * from "babylonjs/Meshes/transformNode";
  59205. export * from "babylonjs/Meshes/Builders/index";
  59206. export * from "babylonjs/Meshes/dataBuffer";
  59207. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  59208. }
  59209. declare module "babylonjs/Morph/index" {
  59210. export * from "babylonjs/Morph/morphTarget";
  59211. export * from "babylonjs/Morph/morphTargetManager";
  59212. }
  59213. declare module "babylonjs/Navigation/INavigationEngine" {
  59214. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59215. import { Vector3 } from "babylonjs/Maths/math";
  59216. import { Mesh } from "babylonjs/Meshes/mesh";
  59217. import { Scene } from "babylonjs/scene";
  59218. /**
  59219. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59220. */
  59221. export interface INavigationEnginePlugin {
  59222. /**
  59223. * plugin name
  59224. */
  59225. name: string;
  59226. /**
  59227. * Creates a navigation mesh
  59228. * @param meshes array of all the geometry used to compute the navigatio mesh
  59229. * @param parameters bunch of parameters used to filter geometry
  59230. */
  59231. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59232. /**
  59233. * Create a navigation mesh debug mesh
  59234. * @param scene is where the mesh will be added
  59235. * @returns debug display mesh
  59236. */
  59237. createDebugNavMesh(scene: Scene): Mesh;
  59238. /**
  59239. * Get a navigation mesh constrained position, closest to the parameter position
  59240. * @param position world position
  59241. * @returns the closest point to position constrained by the navigation mesh
  59242. */
  59243. getClosestPoint(position: Vector3): Vector3;
  59244. /**
  59245. * Get a navigation mesh constrained position, within a particular radius
  59246. * @param position world position
  59247. * @param maxRadius the maximum distance to the constrained world position
  59248. * @returns the closest point to position constrained by the navigation mesh
  59249. */
  59250. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59251. /**
  59252. * Compute the final position from a segment made of destination-position
  59253. * @param position world position
  59254. * @param destination world position
  59255. * @returns the resulting point along the navmesh
  59256. */
  59257. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59258. /**
  59259. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59260. * @param start world position
  59261. * @param end world position
  59262. * @returns array containing world position composing the path
  59263. */
  59264. computePath(start: Vector3, end: Vector3): Vector3[];
  59265. /**
  59266. * If this plugin is supported
  59267. * @returns true if plugin is supported
  59268. */
  59269. isSupported(): boolean;
  59270. /**
  59271. * Create a new Crowd so you can add agents
  59272. * @param maxAgents the maximum agent count in the crowd
  59273. * @param maxAgentRadius the maximum radius an agent can have
  59274. * @param scene to attach the crowd to
  59275. * @returns the crowd you can add agents to
  59276. */
  59277. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59278. /**
  59279. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59280. * The queries will try to find a solution within those bounds
  59281. * default is (1,1,1)
  59282. * @param extent x,y,z value that define the extent around the queries point of reference
  59283. */
  59284. setDefaultQueryExtent(extent: Vector3): void;
  59285. /**
  59286. * Get the Bounding box extent specified by setDefaultQueryExtent
  59287. * @returns the box extent values
  59288. */
  59289. getDefaultQueryExtent(): Vector3;
  59290. /**
  59291. * Release all resources
  59292. */
  59293. dispose(): void;
  59294. }
  59295. /**
  59296. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59297. */
  59298. export interface ICrowd {
  59299. /**
  59300. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59301. * You can attach anything to that node. The node position is updated in the scene update tick.
  59302. * @param pos world position that will be constrained by the navigation mesh
  59303. * @param parameters agent parameters
  59304. * @param transform hooked to the agent that will be update by the scene
  59305. * @returns agent index
  59306. */
  59307. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59308. /**
  59309. * Returns the agent position in world space
  59310. * @param index agent index returned by addAgent
  59311. * @returns world space position
  59312. */
  59313. getAgentPosition(index: number): Vector3;
  59314. /**
  59315. * Gets the agent velocity in world space
  59316. * @param index agent index returned by addAgent
  59317. * @returns world space velocity
  59318. */
  59319. getAgentVelocity(index: number): Vector3;
  59320. /**
  59321. * remove a particular agent previously created
  59322. * @param index agent index returned by addAgent
  59323. */
  59324. removeAgent(index: number): void;
  59325. /**
  59326. * get the list of all agents attached to this crowd
  59327. * @returns list of agent indices
  59328. */
  59329. getAgents(): number[];
  59330. /**
  59331. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59332. * @param deltaTime in seconds
  59333. */
  59334. update(deltaTime: number): void;
  59335. /**
  59336. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59337. * @param index agent index returned by addAgent
  59338. * @param destination targeted world position
  59339. */
  59340. agentGoto(index: number, destination: Vector3): void;
  59341. /**
  59342. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59343. * The queries will try to find a solution within those bounds
  59344. * default is (1,1,1)
  59345. * @param extent x,y,z value that define the extent around the queries point of reference
  59346. */
  59347. setDefaultQueryExtent(extent: Vector3): void;
  59348. /**
  59349. * Get the Bounding box extent specified by setDefaultQueryExtent
  59350. * @returns the box extent values
  59351. */
  59352. getDefaultQueryExtent(): Vector3;
  59353. /**
  59354. * Release all resources
  59355. */
  59356. dispose(): void;
  59357. }
  59358. /**
  59359. * Configures an agent
  59360. */
  59361. export interface IAgentParameters {
  59362. /**
  59363. * Agent radius. [Limit: >= 0]
  59364. */
  59365. radius: number;
  59366. /**
  59367. * Agent height. [Limit: > 0]
  59368. */
  59369. height: number;
  59370. /**
  59371. * Maximum allowed acceleration. [Limit: >= 0]
  59372. */
  59373. maxAcceleration: number;
  59374. /**
  59375. * Maximum allowed speed. [Limit: >= 0]
  59376. */
  59377. maxSpeed: number;
  59378. /**
  59379. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59380. */
  59381. collisionQueryRange: number;
  59382. /**
  59383. * The path visibility optimization range. [Limit: > 0]
  59384. */
  59385. pathOptimizationRange: number;
  59386. /**
  59387. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59388. */
  59389. separationWeight: number;
  59390. }
  59391. /**
  59392. * Configures the navigation mesh creation
  59393. */
  59394. export interface INavMeshParameters {
  59395. /**
  59396. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59397. */
  59398. cs: number;
  59399. /**
  59400. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59401. */
  59402. ch: number;
  59403. /**
  59404. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59405. */
  59406. walkableSlopeAngle: number;
  59407. /**
  59408. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59409. * be considered walkable. [Limit: >= 3] [Units: vx]
  59410. */
  59411. walkableHeight: number;
  59412. /**
  59413. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59414. */
  59415. walkableClimb: number;
  59416. /**
  59417. * The distance to erode/shrink the walkable area of the heightfield away from
  59418. * obstructions. [Limit: >=0] [Units: vx]
  59419. */
  59420. walkableRadius: number;
  59421. /**
  59422. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59423. */
  59424. maxEdgeLen: number;
  59425. /**
  59426. * The maximum distance a simplfied contour's border edges should deviate
  59427. * the original raw contour. [Limit: >=0] [Units: vx]
  59428. */
  59429. maxSimplificationError: number;
  59430. /**
  59431. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59432. */
  59433. minRegionArea: number;
  59434. /**
  59435. * Any regions with a span count smaller than this value will, if possible,
  59436. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59437. */
  59438. mergeRegionArea: number;
  59439. /**
  59440. * The maximum number of vertices allowed for polygons generated during the
  59441. * contour to polygon conversion process. [Limit: >= 3]
  59442. */
  59443. maxVertsPerPoly: number;
  59444. /**
  59445. * Sets the sampling distance to use when generating the detail mesh.
  59446. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59447. */
  59448. detailSampleDist: number;
  59449. /**
  59450. * The maximum distance the detail mesh surface should deviate from heightfield
  59451. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59452. */
  59453. detailSampleMaxError: number;
  59454. }
  59455. }
  59456. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  59457. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  59458. import { Mesh } from "babylonjs/Meshes/mesh";
  59459. import { Scene } from "babylonjs/scene";
  59460. import { Vector3 } from "babylonjs/Maths/math";
  59461. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59462. /**
  59463. * RecastJS navigation plugin
  59464. */
  59465. export class RecastJSPlugin implements INavigationEnginePlugin {
  59466. /**
  59467. * Reference to the Recast library
  59468. */
  59469. bjsRECAST: any;
  59470. /**
  59471. * plugin name
  59472. */
  59473. name: string;
  59474. /**
  59475. * the first navmesh created. We might extend this to support multiple navmeshes
  59476. */
  59477. navMesh: any;
  59478. /**
  59479. * Initializes the recastJS plugin
  59480. * @param recastInjection can be used to inject your own recast reference
  59481. */
  59482. constructor(recastInjection?: any);
  59483. /**
  59484. * Creates a navigation mesh
  59485. * @param meshes array of all the geometry used to compute the navigatio mesh
  59486. * @param parameters bunch of parameters used to filter geometry
  59487. */
  59488. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59489. /**
  59490. * Create a navigation mesh debug mesh
  59491. * @param scene is where the mesh will be added
  59492. * @returns debug display mesh
  59493. */
  59494. createDebugNavMesh(scene: Scene): Mesh;
  59495. /**
  59496. * Get a navigation mesh constrained position, closest to the parameter position
  59497. * @param position world position
  59498. * @returns the closest point to position constrained by the navigation mesh
  59499. */
  59500. getClosestPoint(position: Vector3): Vector3;
  59501. /**
  59502. * Get a navigation mesh constrained position, within a particular radius
  59503. * @param position world position
  59504. * @param maxRadius the maximum distance to the constrained world position
  59505. * @returns the closest point to position constrained by the navigation mesh
  59506. */
  59507. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59508. /**
  59509. * Compute the final position from a segment made of destination-position
  59510. * @param position world position
  59511. * @param destination world position
  59512. * @returns the resulting point along the navmesh
  59513. */
  59514. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59515. /**
  59516. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59517. * @param start world position
  59518. * @param end world position
  59519. * @returns array containing world position composing the path
  59520. */
  59521. computePath(start: Vector3, end: Vector3): Vector3[];
  59522. /**
  59523. * Create a new Crowd so you can add agents
  59524. * @param maxAgents the maximum agent count in the crowd
  59525. * @param maxAgentRadius the maximum radius an agent can have
  59526. * @param scene to attach the crowd to
  59527. * @returns the crowd you can add agents to
  59528. */
  59529. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59530. /**
  59531. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59532. * The queries will try to find a solution within those bounds
  59533. * default is (1,1,1)
  59534. * @param extent x,y,z value that define the extent around the queries point of reference
  59535. */
  59536. setDefaultQueryExtent(extent: Vector3): void;
  59537. /**
  59538. * Get the Bounding box extent specified by setDefaultQueryExtent
  59539. * @returns the box extent values
  59540. */
  59541. getDefaultQueryExtent(): Vector3;
  59542. /**
  59543. * Disposes
  59544. */
  59545. dispose(): void;
  59546. /**
  59547. * If this plugin is supported
  59548. * @returns true if plugin is supported
  59549. */
  59550. isSupported(): boolean;
  59551. }
  59552. /**
  59553. * Recast detour crowd implementation
  59554. */
  59555. export class RecastJSCrowd implements ICrowd {
  59556. /**
  59557. * Recast/detour plugin
  59558. */
  59559. bjsRECASTPlugin: RecastJSPlugin;
  59560. /**
  59561. * Link to the detour crowd
  59562. */
  59563. recastCrowd: any;
  59564. /**
  59565. * One transform per agent
  59566. */
  59567. transforms: TransformNode[];
  59568. /**
  59569. * All agents created
  59570. */
  59571. agents: number[];
  59572. /**
  59573. * Link to the scene is kept to unregister the crowd from the scene
  59574. */
  59575. private _scene;
  59576. /**
  59577. * Observer for crowd updates
  59578. */
  59579. private _onBeforeAnimationsObserver;
  59580. /**
  59581. * Constructor
  59582. * @param plugin recastJS plugin
  59583. * @param maxAgents the maximum agent count in the crowd
  59584. * @param maxAgentRadius the maximum radius an agent can have
  59585. * @param scene to attach the crowd to
  59586. * @returns the crowd you can add agents to
  59587. */
  59588. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59589. /**
  59590. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59591. * You can attach anything to that node. The node position is updated in the scene update tick.
  59592. * @param pos world position that will be constrained by the navigation mesh
  59593. * @param parameters agent parameters
  59594. * @param transform hooked to the agent that will be update by the scene
  59595. * @returns agent index
  59596. */
  59597. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59598. /**
  59599. * Returns the agent position in world space
  59600. * @param index agent index returned by addAgent
  59601. * @returns world space position
  59602. */
  59603. getAgentPosition(index: number): Vector3;
  59604. /**
  59605. * Returns the agent velocity in world space
  59606. * @param index agent index returned by addAgent
  59607. * @returns world space velocity
  59608. */
  59609. getAgentVelocity(index: number): Vector3;
  59610. /**
  59611. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59612. * @param index agent index returned by addAgent
  59613. * @param destination targeted world position
  59614. */
  59615. agentGoto(index: number, destination: Vector3): void;
  59616. /**
  59617. * remove a particular agent previously created
  59618. * @param index agent index returned by addAgent
  59619. */
  59620. removeAgent(index: number): void;
  59621. /**
  59622. * get the list of all agents attached to this crowd
  59623. * @returns list of agent indices
  59624. */
  59625. getAgents(): number[];
  59626. /**
  59627. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59628. * @param deltaTime in seconds
  59629. */
  59630. update(deltaTime: number): void;
  59631. /**
  59632. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59633. * The queries will try to find a solution within those bounds
  59634. * default is (1,1,1)
  59635. * @param extent x,y,z value that define the extent around the queries point of reference
  59636. */
  59637. setDefaultQueryExtent(extent: Vector3): void;
  59638. /**
  59639. * Get the Bounding box extent specified by setDefaultQueryExtent
  59640. * @returns the box extent values
  59641. */
  59642. getDefaultQueryExtent(): Vector3;
  59643. /**
  59644. * Release all resources
  59645. */
  59646. dispose(): void;
  59647. }
  59648. }
  59649. declare module "babylonjs/Navigation/Plugins/index" {
  59650. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  59651. }
  59652. declare module "babylonjs/Navigation/index" {
  59653. export * from "babylonjs/Navigation/INavigationEngine";
  59654. export * from "babylonjs/Navigation/Plugins/index";
  59655. }
  59656. declare module "babylonjs/Offline/database" {
  59657. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  59658. /**
  59659. * Class used to enable access to IndexedDB
  59660. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59661. */
  59662. export class Database implements IOfflineProvider {
  59663. private _callbackManifestChecked;
  59664. private _currentSceneUrl;
  59665. private _db;
  59666. private _enableSceneOffline;
  59667. private _enableTexturesOffline;
  59668. private _manifestVersionFound;
  59669. private _mustUpdateRessources;
  59670. private _hasReachedQuota;
  59671. private _isSupported;
  59672. private _idbFactory;
  59673. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59674. private static IsUASupportingBlobStorage;
  59675. /**
  59676. * Gets a boolean indicating if Database storate is enabled (off by default)
  59677. */
  59678. static IDBStorageEnabled: boolean;
  59679. /**
  59680. * Gets a boolean indicating if scene must be saved in the database
  59681. */
  59682. readonly enableSceneOffline: boolean;
  59683. /**
  59684. * Gets a boolean indicating if textures must be saved in the database
  59685. */
  59686. readonly enableTexturesOffline: boolean;
  59687. /**
  59688. * Creates a new Database
  59689. * @param urlToScene defines the url to load the scene
  59690. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59691. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59692. */
  59693. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59694. private static _ParseURL;
  59695. private static _ReturnFullUrlLocation;
  59696. private _checkManifestFile;
  59697. /**
  59698. * Open the database and make it available
  59699. * @param successCallback defines the callback to call on success
  59700. * @param errorCallback defines the callback to call on error
  59701. */
  59702. open(successCallback: () => void, errorCallback: () => void): void;
  59703. /**
  59704. * Loads an image from the database
  59705. * @param url defines the url to load from
  59706. * @param image defines the target DOM image
  59707. */
  59708. loadImage(url: string, image: HTMLImageElement): void;
  59709. private _loadImageFromDBAsync;
  59710. private _saveImageIntoDBAsync;
  59711. private _checkVersionFromDB;
  59712. private _loadVersionFromDBAsync;
  59713. private _saveVersionIntoDBAsync;
  59714. /**
  59715. * Loads a file from database
  59716. * @param url defines the URL to load from
  59717. * @param sceneLoaded defines a callback to call on success
  59718. * @param progressCallBack defines a callback to call when progress changed
  59719. * @param errorCallback defines a callback to call on error
  59720. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59721. */
  59722. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59723. private _loadFileAsync;
  59724. private _saveFileAsync;
  59725. /**
  59726. * Validates if xhr data is correct
  59727. * @param xhr defines the request to validate
  59728. * @param dataType defines the expected data type
  59729. * @returns true if data is correct
  59730. */
  59731. private static _ValidateXHRData;
  59732. }
  59733. }
  59734. declare module "babylonjs/Offline/index" {
  59735. export * from "babylonjs/Offline/database";
  59736. export * from "babylonjs/Offline/IOfflineProvider";
  59737. }
  59738. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  59739. /** @hidden */
  59740. export var gpuUpdateParticlesPixelShader: {
  59741. name: string;
  59742. shader: string;
  59743. };
  59744. }
  59745. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  59746. /** @hidden */
  59747. export var gpuUpdateParticlesVertexShader: {
  59748. name: string;
  59749. shader: string;
  59750. };
  59751. }
  59752. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  59753. /** @hidden */
  59754. export var clipPlaneFragmentDeclaration2: {
  59755. name: string;
  59756. shader: string;
  59757. };
  59758. }
  59759. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  59760. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  59761. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59762. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59763. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59764. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59765. /** @hidden */
  59766. export var gpuRenderParticlesPixelShader: {
  59767. name: string;
  59768. shader: string;
  59769. };
  59770. }
  59771. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  59772. /** @hidden */
  59773. export var clipPlaneVertexDeclaration2: {
  59774. name: string;
  59775. shader: string;
  59776. };
  59777. }
  59778. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  59779. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  59780. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59781. /** @hidden */
  59782. export var gpuRenderParticlesVertexShader: {
  59783. name: string;
  59784. shader: string;
  59785. };
  59786. }
  59787. declare module "babylonjs/Particles/gpuParticleSystem" {
  59788. import { Nullable } from "babylonjs/types";
  59789. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  59790. import { Observable } from "babylonjs/Misc/observable";
  59791. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59792. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59793. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59794. import { Scene, IDisposable } from "babylonjs/scene";
  59795. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59796. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59797. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59798. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59799. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59800. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59801. /**
  59802. * This represents a GPU particle system in Babylon
  59803. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59804. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59805. */
  59806. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59807. /**
  59808. * The layer mask we are rendering the particles through.
  59809. */
  59810. layerMask: number;
  59811. private _capacity;
  59812. private _activeCount;
  59813. private _currentActiveCount;
  59814. private _accumulatedCount;
  59815. private _renderEffect;
  59816. private _updateEffect;
  59817. private _buffer0;
  59818. private _buffer1;
  59819. private _spriteBuffer;
  59820. private _updateVAO;
  59821. private _renderVAO;
  59822. private _targetIndex;
  59823. private _sourceBuffer;
  59824. private _targetBuffer;
  59825. private _engine;
  59826. private _currentRenderId;
  59827. private _started;
  59828. private _stopped;
  59829. private _timeDelta;
  59830. private _randomTexture;
  59831. private _randomTexture2;
  59832. private _attributesStrideSize;
  59833. private _updateEffectOptions;
  59834. private _randomTextureSize;
  59835. private _actualFrame;
  59836. private readonly _rawTextureWidth;
  59837. /**
  59838. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59839. */
  59840. static readonly IsSupported: boolean;
  59841. /**
  59842. * An event triggered when the system is disposed.
  59843. */
  59844. onDisposeObservable: Observable<GPUParticleSystem>;
  59845. /**
  59846. * Gets the maximum number of particles active at the same time.
  59847. * @returns The max number of active particles.
  59848. */
  59849. getCapacity(): number;
  59850. /**
  59851. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59852. * to override the particles.
  59853. */
  59854. forceDepthWrite: boolean;
  59855. /**
  59856. * Gets or set the number of active particles
  59857. */
  59858. activeParticleCount: number;
  59859. private _preWarmDone;
  59860. /**
  59861. * Is this system ready to be used/rendered
  59862. * @return true if the system is ready
  59863. */
  59864. isReady(): boolean;
  59865. /**
  59866. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59867. * @returns True if it has been started, otherwise false.
  59868. */
  59869. isStarted(): boolean;
  59870. /**
  59871. * Starts the particle system and begins to emit
  59872. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59873. */
  59874. start(delay?: number): void;
  59875. /**
  59876. * Stops the particle system.
  59877. */
  59878. stop(): void;
  59879. /**
  59880. * Remove all active particles
  59881. */
  59882. reset(): void;
  59883. /**
  59884. * Returns the string "GPUParticleSystem"
  59885. * @returns a string containing the class name
  59886. */
  59887. getClassName(): string;
  59888. private _colorGradientsTexture;
  59889. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59890. /**
  59891. * Adds a new color gradient
  59892. * @param gradient defines the gradient to use (between 0 and 1)
  59893. * @param color1 defines the color to affect to the specified gradient
  59894. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59895. * @returns the current particle system
  59896. */
  59897. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59898. /**
  59899. * Remove a specific color gradient
  59900. * @param gradient defines the gradient to remove
  59901. * @returns the current particle system
  59902. */
  59903. removeColorGradient(gradient: number): GPUParticleSystem;
  59904. private _angularSpeedGradientsTexture;
  59905. private _sizeGradientsTexture;
  59906. private _velocityGradientsTexture;
  59907. private _limitVelocityGradientsTexture;
  59908. private _dragGradientsTexture;
  59909. private _addFactorGradient;
  59910. /**
  59911. * Adds a new size gradient
  59912. * @param gradient defines the gradient to use (between 0 and 1)
  59913. * @param factor defines the size factor to affect to the specified gradient
  59914. * @returns the current particle system
  59915. */
  59916. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59917. /**
  59918. * Remove a specific size gradient
  59919. * @param gradient defines the gradient to remove
  59920. * @returns the current particle system
  59921. */
  59922. removeSizeGradient(gradient: number): GPUParticleSystem;
  59923. /**
  59924. * Adds a new angular speed gradient
  59925. * @param gradient defines the gradient to use (between 0 and 1)
  59926. * @param factor defines the angular speed to affect to the specified gradient
  59927. * @returns the current particle system
  59928. */
  59929. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59930. /**
  59931. * Remove a specific angular speed gradient
  59932. * @param gradient defines the gradient to remove
  59933. * @returns the current particle system
  59934. */
  59935. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59936. /**
  59937. * Adds a new velocity gradient
  59938. * @param gradient defines the gradient to use (between 0 and 1)
  59939. * @param factor defines the velocity to affect to the specified gradient
  59940. * @returns the current particle system
  59941. */
  59942. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59943. /**
  59944. * Remove a specific velocity gradient
  59945. * @param gradient defines the gradient to remove
  59946. * @returns the current particle system
  59947. */
  59948. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59949. /**
  59950. * Adds a new limit velocity gradient
  59951. * @param gradient defines the gradient to use (between 0 and 1)
  59952. * @param factor defines the limit velocity value to affect to the specified gradient
  59953. * @returns the current particle system
  59954. */
  59955. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59956. /**
  59957. * Remove a specific limit velocity gradient
  59958. * @param gradient defines the gradient to remove
  59959. * @returns the current particle system
  59960. */
  59961. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59962. /**
  59963. * Adds a new drag gradient
  59964. * @param gradient defines the gradient to use (between 0 and 1)
  59965. * @param factor defines the drag value to affect to the specified gradient
  59966. * @returns the current particle system
  59967. */
  59968. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59969. /**
  59970. * Remove a specific drag gradient
  59971. * @param gradient defines the gradient to remove
  59972. * @returns the current particle system
  59973. */
  59974. removeDragGradient(gradient: number): GPUParticleSystem;
  59975. /**
  59976. * Not supported by GPUParticleSystem
  59977. * @param gradient defines the gradient to use (between 0 and 1)
  59978. * @param factor defines the emit rate value to affect to the specified gradient
  59979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59980. * @returns the current particle system
  59981. */
  59982. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59983. /**
  59984. * Not supported by GPUParticleSystem
  59985. * @param gradient defines the gradient to remove
  59986. * @returns the current particle system
  59987. */
  59988. removeEmitRateGradient(gradient: number): IParticleSystem;
  59989. /**
  59990. * Not supported by GPUParticleSystem
  59991. * @param gradient defines the gradient to use (between 0 and 1)
  59992. * @param factor defines the start size value to affect to the specified gradient
  59993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59994. * @returns the current particle system
  59995. */
  59996. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59997. /**
  59998. * Not supported by GPUParticleSystem
  59999. * @param gradient defines the gradient to remove
  60000. * @returns the current particle system
  60001. */
  60002. removeStartSizeGradient(gradient: number): IParticleSystem;
  60003. /**
  60004. * Not supported by GPUParticleSystem
  60005. * @param gradient defines the gradient to use (between 0 and 1)
  60006. * @param min defines the color remap minimal range
  60007. * @param max defines the color remap maximal range
  60008. * @returns the current particle system
  60009. */
  60010. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60011. /**
  60012. * Not supported by GPUParticleSystem
  60013. * @param gradient defines the gradient to remove
  60014. * @returns the current particle system
  60015. */
  60016. removeColorRemapGradient(): IParticleSystem;
  60017. /**
  60018. * Not supported by GPUParticleSystem
  60019. * @param gradient defines the gradient to use (between 0 and 1)
  60020. * @param min defines the alpha remap minimal range
  60021. * @param max defines the alpha remap maximal range
  60022. * @returns the current particle system
  60023. */
  60024. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60025. /**
  60026. * Not supported by GPUParticleSystem
  60027. * @param gradient defines the gradient to remove
  60028. * @returns the current particle system
  60029. */
  60030. removeAlphaRemapGradient(): IParticleSystem;
  60031. /**
  60032. * Not supported by GPUParticleSystem
  60033. * @param gradient defines the gradient to use (between 0 and 1)
  60034. * @param color defines the color to affect to the specified gradient
  60035. * @returns the current particle system
  60036. */
  60037. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60038. /**
  60039. * Not supported by GPUParticleSystem
  60040. * @param gradient defines the gradient to remove
  60041. * @returns the current particle system
  60042. */
  60043. removeRampGradient(): IParticleSystem;
  60044. /**
  60045. * Not supported by GPUParticleSystem
  60046. * @returns the list of ramp gradients
  60047. */
  60048. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60049. /**
  60050. * Not supported by GPUParticleSystem
  60051. * Gets or sets a boolean indicating that ramp gradients must be used
  60052. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60053. */
  60054. useRampGradients: boolean;
  60055. /**
  60056. * Not supported by GPUParticleSystem
  60057. * @param gradient defines the gradient to use (between 0 and 1)
  60058. * @param factor defines the life time factor to affect to the specified gradient
  60059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60060. * @returns the current particle system
  60061. */
  60062. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60063. /**
  60064. * Not supported by GPUParticleSystem
  60065. * @param gradient defines the gradient to remove
  60066. * @returns the current particle system
  60067. */
  60068. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60069. /**
  60070. * Instantiates a GPU particle system.
  60071. * 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.
  60072. * @param name The name of the particle system
  60073. * @param options The options used to create the system
  60074. * @param scene The scene the particle system belongs to
  60075. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60076. */
  60077. constructor(name: string, options: Partial<{
  60078. capacity: number;
  60079. randomTextureSize: number;
  60080. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60081. protected _reset(): void;
  60082. private _createUpdateVAO;
  60083. private _createRenderVAO;
  60084. private _initialize;
  60085. /** @hidden */
  60086. _recreateUpdateEffect(): void;
  60087. /** @hidden */
  60088. _recreateRenderEffect(): void;
  60089. /**
  60090. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60091. * @param preWarm defines if we are in the pre-warmimg phase
  60092. */
  60093. animate(preWarm?: boolean): void;
  60094. private _createFactorGradientTexture;
  60095. private _createSizeGradientTexture;
  60096. private _createAngularSpeedGradientTexture;
  60097. private _createVelocityGradientTexture;
  60098. private _createLimitVelocityGradientTexture;
  60099. private _createDragGradientTexture;
  60100. private _createColorGradientTexture;
  60101. /**
  60102. * Renders the particle system in its current state
  60103. * @param preWarm defines if the system should only update the particles but not render them
  60104. * @returns the current number of particles
  60105. */
  60106. render(preWarm?: boolean): number;
  60107. /**
  60108. * Rebuilds the particle system
  60109. */
  60110. rebuild(): void;
  60111. private _releaseBuffers;
  60112. private _releaseVAOs;
  60113. /**
  60114. * Disposes the particle system and free the associated resources
  60115. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60116. */
  60117. dispose(disposeTexture?: boolean): void;
  60118. /**
  60119. * Clones the particle system.
  60120. * @param name The name of the cloned object
  60121. * @param newEmitter The new emitter to use
  60122. * @returns the cloned particle system
  60123. */
  60124. clone(name: string, newEmitter: any): GPUParticleSystem;
  60125. /**
  60126. * Serializes the particle system to a JSON object.
  60127. * @returns the JSON object
  60128. */
  60129. serialize(): any;
  60130. /**
  60131. * Parses a JSON object to create a GPU particle system.
  60132. * @param parsedParticleSystem The JSON object to parse
  60133. * @param scene The scene to create the particle system in
  60134. * @param rootUrl The root url to use to load external dependencies like texture
  60135. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60136. * @returns the parsed GPU particle system
  60137. */
  60138. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60139. }
  60140. }
  60141. declare module "babylonjs/Particles/particleSystemSet" {
  60142. import { Nullable } from "babylonjs/types";
  60143. import { Color3 } from "babylonjs/Maths/math.color";
  60144. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60146. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60147. import { Scene, IDisposable } from "babylonjs/scene";
  60148. /**
  60149. * Represents a set of particle systems working together to create a specific effect
  60150. */
  60151. export class ParticleSystemSet implements IDisposable {
  60152. private _emitterCreationOptions;
  60153. private _emitterNode;
  60154. /**
  60155. * Gets the particle system list
  60156. */
  60157. systems: IParticleSystem[];
  60158. /**
  60159. * Gets the emitter node used with this set
  60160. */
  60161. readonly emitterNode: Nullable<TransformNode>;
  60162. /**
  60163. * Creates a new emitter mesh as a sphere
  60164. * @param options defines the options used to create the sphere
  60165. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60166. * @param scene defines the hosting scene
  60167. */
  60168. setEmitterAsSphere(options: {
  60169. diameter: number;
  60170. segments: number;
  60171. color: Color3;
  60172. }, renderingGroupId: number, scene: Scene): void;
  60173. /**
  60174. * Starts all particle systems of the set
  60175. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60176. */
  60177. start(emitter?: AbstractMesh): void;
  60178. /**
  60179. * Release all associated resources
  60180. */
  60181. dispose(): void;
  60182. /**
  60183. * Serialize the set into a JSON compatible object
  60184. * @returns a JSON compatible representation of the set
  60185. */
  60186. serialize(): any;
  60187. /**
  60188. * Parse a new ParticleSystemSet from a serialized source
  60189. * @param data defines a JSON compatible representation of the set
  60190. * @param scene defines the hosting scene
  60191. * @param gpu defines if we want GPU particles or CPU particles
  60192. * @returns a new ParticleSystemSet
  60193. */
  60194. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60195. }
  60196. }
  60197. declare module "babylonjs/Particles/particleHelper" {
  60198. import { Nullable } from "babylonjs/types";
  60199. import { Scene } from "babylonjs/scene";
  60200. import { Vector3 } from "babylonjs/Maths/math.vector";
  60201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60202. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60203. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  60204. /**
  60205. * This class is made for on one-liner static method to help creating particle system set.
  60206. */
  60207. export class ParticleHelper {
  60208. /**
  60209. * Gets or sets base Assets URL
  60210. */
  60211. static BaseAssetsUrl: string;
  60212. /**
  60213. * Create a default particle system that you can tweak
  60214. * @param emitter defines the emitter to use
  60215. * @param capacity defines the system capacity (default is 500 particles)
  60216. * @param scene defines the hosting scene
  60217. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60218. * @returns the new Particle system
  60219. */
  60220. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60221. /**
  60222. * This is the main static method (one-liner) of this helper to create different particle systems
  60223. * @param type This string represents the type to the particle system to create
  60224. * @param scene The scene where the particle system should live
  60225. * @param gpu If the system will use gpu
  60226. * @returns the ParticleSystemSet created
  60227. */
  60228. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60229. /**
  60230. * Static function used to export a particle system to a ParticleSystemSet variable.
  60231. * Please note that the emitter shape is not exported
  60232. * @param systems defines the particle systems to export
  60233. * @returns the created particle system set
  60234. */
  60235. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60236. }
  60237. }
  60238. declare module "babylonjs/Particles/particleSystemComponent" {
  60239. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60240. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  60241. import "babylonjs/Shaders/particles.vertex";
  60242. module "babylonjs/Engines/engine" {
  60243. interface Engine {
  60244. /**
  60245. * Create an effect to use with particle systems.
  60246. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60247. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60248. * @param uniformsNames defines a list of attribute names
  60249. * @param samplers defines an array of string used to represent textures
  60250. * @param defines defines the string containing the defines to use to compile the shaders
  60251. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60252. * @param onCompiled defines a function to call when the effect creation is successful
  60253. * @param onError defines a function to call when the effect creation has failed
  60254. * @returns the new Effect
  60255. */
  60256. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60257. }
  60258. }
  60259. module "babylonjs/Meshes/mesh" {
  60260. interface Mesh {
  60261. /**
  60262. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60263. * @returns an array of IParticleSystem
  60264. */
  60265. getEmittedParticleSystems(): IParticleSystem[];
  60266. /**
  60267. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60268. * @returns an array of IParticleSystem
  60269. */
  60270. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60271. }
  60272. }
  60273. /**
  60274. * @hidden
  60275. */
  60276. export var _IDoNeedToBeInTheBuild: number;
  60277. }
  60278. declare module "babylonjs/Particles/index" {
  60279. export * from "babylonjs/Particles/baseParticleSystem";
  60280. export * from "babylonjs/Particles/EmitterTypes/index";
  60281. export * from "babylonjs/Particles/gpuParticleSystem";
  60282. export * from "babylonjs/Particles/IParticleSystem";
  60283. export * from "babylonjs/Particles/particle";
  60284. export * from "babylonjs/Particles/particleHelper";
  60285. export * from "babylonjs/Particles/particleSystem";
  60286. export * from "babylonjs/Particles/particleSystemComponent";
  60287. export * from "babylonjs/Particles/particleSystemSet";
  60288. export * from "babylonjs/Particles/solidParticle";
  60289. export * from "babylonjs/Particles/solidParticleSystem";
  60290. export * from "babylonjs/Particles/subEmitter";
  60291. }
  60292. declare module "babylonjs/Physics/physicsEngineComponent" {
  60293. import { Nullable } from "babylonjs/types";
  60294. import { Observable, Observer } from "babylonjs/Misc/observable";
  60295. import { Vector3 } from "babylonjs/Maths/math.vector";
  60296. import { Mesh } from "babylonjs/Meshes/mesh";
  60297. import { ISceneComponent } from "babylonjs/sceneComponent";
  60298. import { Scene } from "babylonjs/scene";
  60299. import { Node } from "babylonjs/node";
  60300. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60301. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60302. module "babylonjs/scene" {
  60303. interface Scene {
  60304. /** @hidden (Backing field) */
  60305. _physicsEngine: Nullable<IPhysicsEngine>;
  60306. /**
  60307. * Gets the current physics engine
  60308. * @returns a IPhysicsEngine or null if none attached
  60309. */
  60310. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60311. /**
  60312. * Enables physics to the current scene
  60313. * @param gravity defines the scene's gravity for the physics engine
  60314. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60315. * @return a boolean indicating if the physics engine was initialized
  60316. */
  60317. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60318. /**
  60319. * Disables and disposes the physics engine associated with the scene
  60320. */
  60321. disablePhysicsEngine(): void;
  60322. /**
  60323. * Gets a boolean indicating if there is an active physics engine
  60324. * @returns a boolean indicating if there is an active physics engine
  60325. */
  60326. isPhysicsEnabled(): boolean;
  60327. /**
  60328. * Deletes a physics compound impostor
  60329. * @param compound defines the compound to delete
  60330. */
  60331. deleteCompoundImpostor(compound: any): void;
  60332. /**
  60333. * An event triggered when physic simulation is about to be run
  60334. */
  60335. onBeforePhysicsObservable: Observable<Scene>;
  60336. /**
  60337. * An event triggered when physic simulation has been done
  60338. */
  60339. onAfterPhysicsObservable: Observable<Scene>;
  60340. }
  60341. }
  60342. module "babylonjs/Meshes/abstractMesh" {
  60343. interface AbstractMesh {
  60344. /** @hidden */
  60345. _physicsImpostor: Nullable<PhysicsImpostor>;
  60346. /**
  60347. * Gets or sets impostor used for physic simulation
  60348. * @see http://doc.babylonjs.com/features/physics_engine
  60349. */
  60350. physicsImpostor: Nullable<PhysicsImpostor>;
  60351. /**
  60352. * Gets the current physics impostor
  60353. * @see http://doc.babylonjs.com/features/physics_engine
  60354. * @returns a physics impostor or null
  60355. */
  60356. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60357. /** Apply a physic impulse to the mesh
  60358. * @param force defines the force to apply
  60359. * @param contactPoint defines where to apply the force
  60360. * @returns the current mesh
  60361. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60362. */
  60363. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60364. /**
  60365. * Creates a physic joint between two meshes
  60366. * @param otherMesh defines the other mesh to use
  60367. * @param pivot1 defines the pivot to use on this mesh
  60368. * @param pivot2 defines the pivot to use on the other mesh
  60369. * @param options defines additional options (can be plugin dependent)
  60370. * @returns the current mesh
  60371. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60372. */
  60373. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60374. /** @hidden */
  60375. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60376. }
  60377. }
  60378. /**
  60379. * Defines the physics engine scene component responsible to manage a physics engine
  60380. */
  60381. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60382. /**
  60383. * The component name helpful to identify the component in the list of scene components.
  60384. */
  60385. readonly name: string;
  60386. /**
  60387. * The scene the component belongs to.
  60388. */
  60389. scene: Scene;
  60390. /**
  60391. * Creates a new instance of the component for the given scene
  60392. * @param scene Defines the scene to register the component in
  60393. */
  60394. constructor(scene: Scene);
  60395. /**
  60396. * Registers the component in a given scene
  60397. */
  60398. register(): void;
  60399. /**
  60400. * Rebuilds the elements related to this component in case of
  60401. * context lost for instance.
  60402. */
  60403. rebuild(): void;
  60404. /**
  60405. * Disposes the component and the associated ressources
  60406. */
  60407. dispose(): void;
  60408. }
  60409. }
  60410. declare module "babylonjs/Physics/physicsHelper" {
  60411. import { Nullable } from "babylonjs/types";
  60412. import { Vector3 } from "babylonjs/Maths/math.vector";
  60413. import { Mesh } from "babylonjs/Meshes/mesh";
  60414. import { Scene } from "babylonjs/scene";
  60415. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60416. /**
  60417. * A helper for physics simulations
  60418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60419. */
  60420. export class PhysicsHelper {
  60421. private _scene;
  60422. private _physicsEngine;
  60423. /**
  60424. * Initializes the Physics helper
  60425. * @param scene Babylon.js scene
  60426. */
  60427. constructor(scene: Scene);
  60428. /**
  60429. * Applies a radial explosion impulse
  60430. * @param origin the origin of the explosion
  60431. * @param radiusOrEventOptions the radius or the options of radial explosion
  60432. * @param strength the explosion strength
  60433. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60434. * @returns A physics radial explosion event, or null
  60435. */
  60436. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60437. /**
  60438. * Applies a radial explosion force
  60439. * @param origin the origin of the explosion
  60440. * @param radiusOrEventOptions the radius or the options of radial explosion
  60441. * @param strength the explosion strength
  60442. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60443. * @returns A physics radial explosion event, or null
  60444. */
  60445. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60446. /**
  60447. * Creates a gravitational field
  60448. * @param origin the origin of the explosion
  60449. * @param radiusOrEventOptions the radius or the options of radial explosion
  60450. * @param strength the explosion strength
  60451. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60452. * @returns A physics gravitational field event, or null
  60453. */
  60454. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60455. /**
  60456. * Creates a physics updraft event
  60457. * @param origin the origin of the updraft
  60458. * @param radiusOrEventOptions the radius or the options of the updraft
  60459. * @param strength the strength of the updraft
  60460. * @param height the height of the updraft
  60461. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60462. * @returns A physics updraft event, or null
  60463. */
  60464. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60465. /**
  60466. * Creates a physics vortex event
  60467. * @param origin the of the vortex
  60468. * @param radiusOrEventOptions the radius or the options of the vortex
  60469. * @param strength the strength of the vortex
  60470. * @param height the height of the vortex
  60471. * @returns a Physics vortex event, or null
  60472. * A physics vortex event or null
  60473. */
  60474. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60475. }
  60476. /**
  60477. * Represents a physics radial explosion event
  60478. */
  60479. class PhysicsRadialExplosionEvent {
  60480. private _scene;
  60481. private _options;
  60482. private _sphere;
  60483. private _dataFetched;
  60484. /**
  60485. * Initializes a radial explosioin event
  60486. * @param _scene BabylonJS scene
  60487. * @param _options The options for the vortex event
  60488. */
  60489. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60490. /**
  60491. * Returns the data related to the radial explosion event (sphere).
  60492. * @returns The radial explosion event data
  60493. */
  60494. getData(): PhysicsRadialExplosionEventData;
  60495. /**
  60496. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60497. * @param impostor A physics imposter
  60498. * @param origin the origin of the explosion
  60499. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60500. */
  60501. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60502. /**
  60503. * Triggers affecterd impostors callbacks
  60504. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60505. */
  60506. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60507. /**
  60508. * Disposes the sphere.
  60509. * @param force Specifies if the sphere should be disposed by force
  60510. */
  60511. dispose(force?: boolean): void;
  60512. /*** Helpers ***/
  60513. private _prepareSphere;
  60514. private _intersectsWithSphere;
  60515. }
  60516. /**
  60517. * Represents a gravitational field event
  60518. */
  60519. class PhysicsGravitationalFieldEvent {
  60520. private _physicsHelper;
  60521. private _scene;
  60522. private _origin;
  60523. private _options;
  60524. private _tickCallback;
  60525. private _sphere;
  60526. private _dataFetched;
  60527. /**
  60528. * Initializes the physics gravitational field event
  60529. * @param _physicsHelper A physics helper
  60530. * @param _scene BabylonJS scene
  60531. * @param _origin The origin position of the gravitational field event
  60532. * @param _options The options for the vortex event
  60533. */
  60534. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60535. /**
  60536. * Returns the data related to the gravitational field event (sphere).
  60537. * @returns A gravitational field event
  60538. */
  60539. getData(): PhysicsGravitationalFieldEventData;
  60540. /**
  60541. * Enables the gravitational field.
  60542. */
  60543. enable(): void;
  60544. /**
  60545. * Disables the gravitational field.
  60546. */
  60547. disable(): void;
  60548. /**
  60549. * Disposes the sphere.
  60550. * @param force The force to dispose from the gravitational field event
  60551. */
  60552. dispose(force?: boolean): void;
  60553. private _tick;
  60554. }
  60555. /**
  60556. * Represents a physics updraft event
  60557. */
  60558. class PhysicsUpdraftEvent {
  60559. private _scene;
  60560. private _origin;
  60561. private _options;
  60562. private _physicsEngine;
  60563. private _originTop;
  60564. private _originDirection;
  60565. private _tickCallback;
  60566. private _cylinder;
  60567. private _cylinderPosition;
  60568. private _dataFetched;
  60569. /**
  60570. * Initializes the physics updraft event
  60571. * @param _scene BabylonJS scene
  60572. * @param _origin The origin position of the updraft
  60573. * @param _options The options for the updraft event
  60574. */
  60575. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60576. /**
  60577. * Returns the data related to the updraft event (cylinder).
  60578. * @returns A physics updraft event
  60579. */
  60580. getData(): PhysicsUpdraftEventData;
  60581. /**
  60582. * Enables the updraft.
  60583. */
  60584. enable(): void;
  60585. /**
  60586. * Disables the updraft.
  60587. */
  60588. disable(): void;
  60589. /**
  60590. * Disposes the cylinder.
  60591. * @param force Specifies if the updraft should be disposed by force
  60592. */
  60593. dispose(force?: boolean): void;
  60594. private getImpostorHitData;
  60595. private _tick;
  60596. /*** Helpers ***/
  60597. private _prepareCylinder;
  60598. private _intersectsWithCylinder;
  60599. }
  60600. /**
  60601. * Represents a physics vortex event
  60602. */
  60603. class PhysicsVortexEvent {
  60604. private _scene;
  60605. private _origin;
  60606. private _options;
  60607. private _physicsEngine;
  60608. private _originTop;
  60609. private _tickCallback;
  60610. private _cylinder;
  60611. private _cylinderPosition;
  60612. private _dataFetched;
  60613. /**
  60614. * Initializes the physics vortex event
  60615. * @param _scene The BabylonJS scene
  60616. * @param _origin The origin position of the vortex
  60617. * @param _options The options for the vortex event
  60618. */
  60619. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60620. /**
  60621. * Returns the data related to the vortex event (cylinder).
  60622. * @returns The physics vortex event data
  60623. */
  60624. getData(): PhysicsVortexEventData;
  60625. /**
  60626. * Enables the vortex.
  60627. */
  60628. enable(): void;
  60629. /**
  60630. * Disables the cortex.
  60631. */
  60632. disable(): void;
  60633. /**
  60634. * Disposes the sphere.
  60635. * @param force
  60636. */
  60637. dispose(force?: boolean): void;
  60638. private getImpostorHitData;
  60639. private _tick;
  60640. /*** Helpers ***/
  60641. private _prepareCylinder;
  60642. private _intersectsWithCylinder;
  60643. }
  60644. /**
  60645. * Options fot the radial explosion event
  60646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60647. */
  60648. export class PhysicsRadialExplosionEventOptions {
  60649. /**
  60650. * The radius of the sphere for the radial explosion.
  60651. */
  60652. radius: number;
  60653. /**
  60654. * The strenth of the explosion.
  60655. */
  60656. strength: number;
  60657. /**
  60658. * The strenght of the force in correspondence to the distance of the affected object
  60659. */
  60660. falloff: PhysicsRadialImpulseFalloff;
  60661. /**
  60662. * Sphere options for the radial explosion.
  60663. */
  60664. sphere: {
  60665. segments: number;
  60666. diameter: number;
  60667. };
  60668. /**
  60669. * Sphere options for the radial explosion.
  60670. */
  60671. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60672. }
  60673. /**
  60674. * Options fot the updraft event
  60675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60676. */
  60677. export class PhysicsUpdraftEventOptions {
  60678. /**
  60679. * The radius of the cylinder for the vortex
  60680. */
  60681. radius: number;
  60682. /**
  60683. * The strenth of the updraft.
  60684. */
  60685. strength: number;
  60686. /**
  60687. * The height of the cylinder for the updraft.
  60688. */
  60689. height: number;
  60690. /**
  60691. * The mode for the the updraft.
  60692. */
  60693. updraftMode: PhysicsUpdraftMode;
  60694. }
  60695. /**
  60696. * Options fot the vortex event
  60697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60698. */
  60699. export class PhysicsVortexEventOptions {
  60700. /**
  60701. * The radius of the cylinder for the vortex
  60702. */
  60703. radius: number;
  60704. /**
  60705. * The strenth of the vortex.
  60706. */
  60707. strength: number;
  60708. /**
  60709. * The height of the cylinder for the vortex.
  60710. */
  60711. height: number;
  60712. /**
  60713. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60714. */
  60715. centripetalForceThreshold: number;
  60716. /**
  60717. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60718. */
  60719. centripetalForceMultiplier: number;
  60720. /**
  60721. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60722. */
  60723. centrifugalForceMultiplier: number;
  60724. /**
  60725. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60726. */
  60727. updraftForceMultiplier: number;
  60728. }
  60729. /**
  60730. * The strenght of the force in correspondence to the distance of the affected object
  60731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60732. */
  60733. export enum PhysicsRadialImpulseFalloff {
  60734. /** Defines that impulse is constant in strength across it's whole radius */
  60735. Constant = 0,
  60736. /** Defines that impulse gets weaker if it's further from the origin */
  60737. Linear = 1
  60738. }
  60739. /**
  60740. * The strength of the force in correspondence to the distance of the affected object
  60741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60742. */
  60743. export enum PhysicsUpdraftMode {
  60744. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60745. Center = 0,
  60746. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60747. Perpendicular = 1
  60748. }
  60749. /**
  60750. * Interface for a physics hit data
  60751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60752. */
  60753. export interface PhysicsHitData {
  60754. /**
  60755. * The force applied at the contact point
  60756. */
  60757. force: Vector3;
  60758. /**
  60759. * The contact point
  60760. */
  60761. contactPoint: Vector3;
  60762. /**
  60763. * The distance from the origin to the contact point
  60764. */
  60765. distanceFromOrigin: number;
  60766. }
  60767. /**
  60768. * Interface for radial explosion event data
  60769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60770. */
  60771. export interface PhysicsRadialExplosionEventData {
  60772. /**
  60773. * A sphere used for the radial explosion event
  60774. */
  60775. sphere: Mesh;
  60776. }
  60777. /**
  60778. * Interface for gravitational field event data
  60779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60780. */
  60781. export interface PhysicsGravitationalFieldEventData {
  60782. /**
  60783. * A sphere mesh used for the gravitational field event
  60784. */
  60785. sphere: Mesh;
  60786. }
  60787. /**
  60788. * Interface for updraft event data
  60789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60790. */
  60791. export interface PhysicsUpdraftEventData {
  60792. /**
  60793. * A cylinder used for the updraft event
  60794. */
  60795. cylinder: Mesh;
  60796. }
  60797. /**
  60798. * Interface for vortex event data
  60799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60800. */
  60801. export interface PhysicsVortexEventData {
  60802. /**
  60803. * A cylinder used for the vortex event
  60804. */
  60805. cylinder: Mesh;
  60806. }
  60807. /**
  60808. * Interface for an affected physics impostor
  60809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60810. */
  60811. export interface PhysicsAffectedImpostorWithData {
  60812. /**
  60813. * The impostor affected by the effect
  60814. */
  60815. impostor: PhysicsImpostor;
  60816. /**
  60817. * The data about the hit/horce from the explosion
  60818. */
  60819. hitData: PhysicsHitData;
  60820. }
  60821. }
  60822. declare module "babylonjs/Physics/Plugins/index" {
  60823. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  60824. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  60825. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  60826. }
  60827. declare module "babylonjs/Physics/index" {
  60828. export * from "babylonjs/Physics/IPhysicsEngine";
  60829. export * from "babylonjs/Physics/physicsEngine";
  60830. export * from "babylonjs/Physics/physicsEngineComponent";
  60831. export * from "babylonjs/Physics/physicsHelper";
  60832. export * from "babylonjs/Physics/physicsImpostor";
  60833. export * from "babylonjs/Physics/physicsJoint";
  60834. export * from "babylonjs/Physics/Plugins/index";
  60835. }
  60836. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  60837. /** @hidden */
  60838. export var blackAndWhitePixelShader: {
  60839. name: string;
  60840. shader: string;
  60841. };
  60842. }
  60843. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  60844. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60845. import { Camera } from "babylonjs/Cameras/camera";
  60846. import { Engine } from "babylonjs/Engines/engine";
  60847. import "babylonjs/Shaders/blackAndWhite.fragment";
  60848. /**
  60849. * Post process used to render in black and white
  60850. */
  60851. export class BlackAndWhitePostProcess extends PostProcess {
  60852. /**
  60853. * Linear about to convert he result to black and white (default: 1)
  60854. */
  60855. degree: number;
  60856. /**
  60857. * Creates a black and white post process
  60858. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60859. * @param name The name of the effect.
  60860. * @param options The required width/height ratio to downsize to before computing the render pass.
  60861. * @param camera The camera to apply the render pass to.
  60862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60863. * @param engine The engine which the post process will be applied. (default: current engine)
  60864. * @param reusable If the post process can be reused on the same frame. (default: false)
  60865. */
  60866. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60867. }
  60868. }
  60869. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  60870. import { Nullable } from "babylonjs/types";
  60871. import { Camera } from "babylonjs/Cameras/camera";
  60872. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60873. import { Engine } from "babylonjs/Engines/engine";
  60874. /**
  60875. * This represents a set of one or more post processes in Babylon.
  60876. * A post process can be used to apply a shader to a texture after it is rendered.
  60877. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60878. */
  60879. export class PostProcessRenderEffect {
  60880. private _postProcesses;
  60881. private _getPostProcesses;
  60882. private _singleInstance;
  60883. private _cameras;
  60884. private _indicesForCamera;
  60885. /**
  60886. * Name of the effect
  60887. * @hidden
  60888. */
  60889. _name: string;
  60890. /**
  60891. * Instantiates a post process render effect.
  60892. * A post process can be used to apply a shader to a texture after it is rendered.
  60893. * @param engine The engine the effect is tied to
  60894. * @param name The name of the effect
  60895. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60896. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60897. */
  60898. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60899. /**
  60900. * Checks if all the post processes in the effect are supported.
  60901. */
  60902. readonly isSupported: boolean;
  60903. /**
  60904. * Updates the current state of the effect
  60905. * @hidden
  60906. */
  60907. _update(): void;
  60908. /**
  60909. * Attaches the effect on cameras
  60910. * @param cameras The camera to attach to.
  60911. * @hidden
  60912. */
  60913. _attachCameras(cameras: Camera): void;
  60914. /**
  60915. * Attaches the effect on cameras
  60916. * @param cameras The camera to attach to.
  60917. * @hidden
  60918. */
  60919. _attachCameras(cameras: Camera[]): void;
  60920. /**
  60921. * Detaches the effect on cameras
  60922. * @param cameras The camera to detatch from.
  60923. * @hidden
  60924. */
  60925. _detachCameras(cameras: Camera): void;
  60926. /**
  60927. * Detatches the effect on cameras
  60928. * @param cameras The camera to detatch from.
  60929. * @hidden
  60930. */
  60931. _detachCameras(cameras: Camera[]): void;
  60932. /**
  60933. * Enables the effect on given cameras
  60934. * @param cameras The camera to enable.
  60935. * @hidden
  60936. */
  60937. _enable(cameras: Camera): void;
  60938. /**
  60939. * Enables the effect on given cameras
  60940. * @param cameras The camera to enable.
  60941. * @hidden
  60942. */
  60943. _enable(cameras: Nullable<Camera[]>): void;
  60944. /**
  60945. * Disables the effect on the given cameras
  60946. * @param cameras The camera to disable.
  60947. * @hidden
  60948. */
  60949. _disable(cameras: Camera): void;
  60950. /**
  60951. * Disables the effect on the given cameras
  60952. * @param cameras The camera to disable.
  60953. * @hidden
  60954. */
  60955. _disable(cameras: Nullable<Camera[]>): void;
  60956. /**
  60957. * Gets a list of the post processes contained in the effect.
  60958. * @param camera The camera to get the post processes on.
  60959. * @returns The list of the post processes in the effect.
  60960. */
  60961. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60962. }
  60963. }
  60964. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  60965. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60966. /** @hidden */
  60967. export var extractHighlightsPixelShader: {
  60968. name: string;
  60969. shader: string;
  60970. };
  60971. }
  60972. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  60973. import { Nullable } from "babylonjs/types";
  60974. import { Camera } from "babylonjs/Cameras/camera";
  60975. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60976. import { Engine } from "babylonjs/Engines/engine";
  60977. import "babylonjs/Shaders/extractHighlights.fragment";
  60978. /**
  60979. * 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.
  60980. */
  60981. export class ExtractHighlightsPostProcess extends PostProcess {
  60982. /**
  60983. * The luminance threshold, pixels below this value will be set to black.
  60984. */
  60985. threshold: number;
  60986. /** @hidden */
  60987. _exposure: number;
  60988. /**
  60989. * Post process which has the input texture to be used when performing highlight extraction
  60990. * @hidden
  60991. */
  60992. _inputPostProcess: Nullable<PostProcess>;
  60993. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60994. }
  60995. }
  60996. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  60997. /** @hidden */
  60998. export var bloomMergePixelShader: {
  60999. name: string;
  61000. shader: string;
  61001. };
  61002. }
  61003. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61004. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61005. import { Nullable } from "babylonjs/types";
  61006. import { Engine } from "babylonjs/Engines/engine";
  61007. import { Camera } from "babylonjs/Cameras/camera";
  61008. import "babylonjs/Shaders/bloomMerge.fragment";
  61009. /**
  61010. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61011. */
  61012. export class BloomMergePostProcess extends PostProcess {
  61013. /** Weight of the bloom to be added to the original input. */
  61014. weight: number;
  61015. /**
  61016. * Creates a new instance of @see BloomMergePostProcess
  61017. * @param name The name of the effect.
  61018. * @param originalFromInput Post process which's input will be used for the merge.
  61019. * @param blurred Blurred highlights post process which's output will be used.
  61020. * @param weight Weight of the bloom to be added to the original input.
  61021. * @param options The required width/height ratio to downsize to before computing the render pass.
  61022. * @param camera The camera to apply the render pass to.
  61023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61024. * @param engine The engine which the post process will be applied. (default: current engine)
  61025. * @param reusable If the post process can be reused on the same frame. (default: false)
  61026. * @param textureType Type of textures used when performing the post process. (default: 0)
  61027. * @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)
  61028. */
  61029. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61030. /** Weight of the bloom to be added to the original input. */
  61031. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61032. }
  61033. }
  61034. declare module "babylonjs/PostProcesses/bloomEffect" {
  61035. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61036. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61037. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61038. import { Camera } from "babylonjs/Cameras/camera";
  61039. import { Scene } from "babylonjs/scene";
  61040. /**
  61041. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61042. */
  61043. export class BloomEffect extends PostProcessRenderEffect {
  61044. private bloomScale;
  61045. /**
  61046. * @hidden Internal
  61047. */
  61048. _effects: Array<PostProcess>;
  61049. /**
  61050. * @hidden Internal
  61051. */
  61052. _downscale: ExtractHighlightsPostProcess;
  61053. private _blurX;
  61054. private _blurY;
  61055. private _merge;
  61056. /**
  61057. * The luminance threshold to find bright areas of the image to bloom.
  61058. */
  61059. threshold: number;
  61060. /**
  61061. * The strength of the bloom.
  61062. */
  61063. weight: number;
  61064. /**
  61065. * Specifies the size of the bloom blur kernel, relative to the final output size
  61066. */
  61067. kernel: number;
  61068. /**
  61069. * Creates a new instance of @see BloomEffect
  61070. * @param scene The scene the effect belongs to.
  61071. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61072. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61073. * @param bloomWeight The the strength of bloom.
  61074. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61075. * @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)
  61076. */
  61077. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61078. /**
  61079. * Disposes each of the internal effects for a given camera.
  61080. * @param camera The camera to dispose the effect on.
  61081. */
  61082. disposeEffects(camera: Camera): void;
  61083. /**
  61084. * @hidden Internal
  61085. */
  61086. _updateEffects(): void;
  61087. /**
  61088. * Internal
  61089. * @returns if all the contained post processes are ready.
  61090. * @hidden
  61091. */
  61092. _isReady(): boolean;
  61093. }
  61094. }
  61095. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  61096. /** @hidden */
  61097. export var chromaticAberrationPixelShader: {
  61098. name: string;
  61099. shader: string;
  61100. };
  61101. }
  61102. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  61103. import { Vector2 } from "babylonjs/Maths/math.vector";
  61104. import { Nullable } from "babylonjs/types";
  61105. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61106. import { Camera } from "babylonjs/Cameras/camera";
  61107. import { Engine } from "babylonjs/Engines/engine";
  61108. import "babylonjs/Shaders/chromaticAberration.fragment";
  61109. /**
  61110. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61111. */
  61112. export class ChromaticAberrationPostProcess extends PostProcess {
  61113. /**
  61114. * The amount of seperation of rgb channels (default: 30)
  61115. */
  61116. aberrationAmount: number;
  61117. /**
  61118. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61119. */
  61120. radialIntensity: number;
  61121. /**
  61122. * 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))
  61123. */
  61124. direction: Vector2;
  61125. /**
  61126. * 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))
  61127. */
  61128. centerPosition: Vector2;
  61129. /**
  61130. * Creates a new instance ChromaticAberrationPostProcess
  61131. * @param name The name of the effect.
  61132. * @param screenWidth The width of the screen to apply the effect on.
  61133. * @param screenHeight The height of the screen to apply the effect on.
  61134. * @param options The required width/height ratio to downsize to before computing the render pass.
  61135. * @param camera The camera to apply the render pass to.
  61136. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61137. * @param engine The engine which the post process will be applied. (default: current engine)
  61138. * @param reusable If the post process can be reused on the same frame. (default: false)
  61139. * @param textureType Type of textures used when performing the post process. (default: 0)
  61140. * @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)
  61141. */
  61142. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61143. }
  61144. }
  61145. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  61146. /** @hidden */
  61147. export var circleOfConfusionPixelShader: {
  61148. name: string;
  61149. shader: string;
  61150. };
  61151. }
  61152. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  61153. import { Nullable } from "babylonjs/types";
  61154. import { Engine } from "babylonjs/Engines/engine";
  61155. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61156. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61157. import { Camera } from "babylonjs/Cameras/camera";
  61158. import "babylonjs/Shaders/circleOfConfusion.fragment";
  61159. /**
  61160. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61161. */
  61162. export class CircleOfConfusionPostProcess extends PostProcess {
  61163. /**
  61164. * 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.
  61165. */
  61166. lensSize: number;
  61167. /**
  61168. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61169. */
  61170. fStop: number;
  61171. /**
  61172. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61173. */
  61174. focusDistance: number;
  61175. /**
  61176. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61177. */
  61178. focalLength: number;
  61179. private _depthTexture;
  61180. /**
  61181. * Creates a new instance CircleOfConfusionPostProcess
  61182. * @param name The name of the effect.
  61183. * @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.
  61184. * @param options The required width/height ratio to downsize to before computing the render pass.
  61185. * @param camera The camera to apply the render pass to.
  61186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61187. * @param engine The engine which the post process will be applied. (default: current engine)
  61188. * @param reusable If the post process can be reused on the same frame. (default: false)
  61189. * @param textureType Type of textures used when performing the post process. (default: 0)
  61190. * @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)
  61191. */
  61192. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61193. /**
  61194. * 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.
  61195. */
  61196. depthTexture: RenderTargetTexture;
  61197. }
  61198. }
  61199. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  61200. /** @hidden */
  61201. export var colorCorrectionPixelShader: {
  61202. name: string;
  61203. shader: string;
  61204. };
  61205. }
  61206. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  61207. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61208. import { Engine } from "babylonjs/Engines/engine";
  61209. import { Camera } from "babylonjs/Cameras/camera";
  61210. import "babylonjs/Shaders/colorCorrection.fragment";
  61211. /**
  61212. *
  61213. * This post-process allows the modification of rendered colors by using
  61214. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61215. *
  61216. * The object needs to be provided an url to a texture containing the color
  61217. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61218. * Use an image editing software to tweak the LUT to match your needs.
  61219. *
  61220. * For an example of a color LUT, see here:
  61221. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61222. * For explanations on color grading, see here:
  61223. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61224. *
  61225. */
  61226. export class ColorCorrectionPostProcess extends PostProcess {
  61227. private _colorTableTexture;
  61228. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61229. }
  61230. }
  61231. declare module "babylonjs/Shaders/convolution.fragment" {
  61232. /** @hidden */
  61233. export var convolutionPixelShader: {
  61234. name: string;
  61235. shader: string;
  61236. };
  61237. }
  61238. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  61239. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61240. import { Nullable } from "babylonjs/types";
  61241. import { Camera } from "babylonjs/Cameras/camera";
  61242. import { Engine } from "babylonjs/Engines/engine";
  61243. import "babylonjs/Shaders/convolution.fragment";
  61244. /**
  61245. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61246. * input texture to perform effects such as edge detection or sharpening
  61247. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61248. */
  61249. export class ConvolutionPostProcess extends PostProcess {
  61250. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61251. kernel: number[];
  61252. /**
  61253. * Creates a new instance ConvolutionPostProcess
  61254. * @param name The name of the effect.
  61255. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61256. * @param options The required width/height ratio to downsize to before computing the render pass.
  61257. * @param camera The camera to apply the render pass to.
  61258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61259. * @param engine The engine which the post process will be applied. (default: current engine)
  61260. * @param reusable If the post process can be reused on the same frame. (default: false)
  61261. * @param textureType Type of textures used when performing the post process. (default: 0)
  61262. */
  61263. constructor(name: string,
  61264. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61265. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61266. /**
  61267. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61268. */
  61269. static EdgeDetect0Kernel: number[];
  61270. /**
  61271. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61272. */
  61273. static EdgeDetect1Kernel: number[];
  61274. /**
  61275. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61276. */
  61277. static EdgeDetect2Kernel: number[];
  61278. /**
  61279. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61280. */
  61281. static SharpenKernel: number[];
  61282. /**
  61283. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61284. */
  61285. static EmbossKernel: number[];
  61286. /**
  61287. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61288. */
  61289. static GaussianKernel: number[];
  61290. }
  61291. }
  61292. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  61293. import { Nullable } from "babylonjs/types";
  61294. import { Vector2 } from "babylonjs/Maths/math.vector";
  61295. import { Camera } from "babylonjs/Cameras/camera";
  61296. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61297. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61298. import { Engine } from "babylonjs/Engines/engine";
  61299. import { Scene } from "babylonjs/scene";
  61300. /**
  61301. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61302. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61303. * based on samples that have a large difference in distance than the center pixel.
  61304. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61305. */
  61306. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61307. direction: Vector2;
  61308. /**
  61309. * Creates a new instance CircleOfConfusionPostProcess
  61310. * @param name The name of the effect.
  61311. * @param scene The scene the effect belongs to.
  61312. * @param direction The direction the blur should be applied.
  61313. * @param kernel The size of the kernel used to blur.
  61314. * @param options The required width/height ratio to downsize to before computing the render pass.
  61315. * @param camera The camera to apply the render pass to.
  61316. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61317. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61319. * @param engine The engine which the post process will be applied. (default: current engine)
  61320. * @param reusable If the post process can be reused on the same frame. (default: false)
  61321. * @param textureType Type of textures used when performing the post process. (default: 0)
  61322. * @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)
  61323. */
  61324. 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);
  61325. }
  61326. }
  61327. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61328. /** @hidden */
  61329. export var depthOfFieldMergePixelShader: {
  61330. name: string;
  61331. shader: string;
  61332. };
  61333. }
  61334. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61335. import { Nullable } from "babylonjs/types";
  61336. import { Camera } from "babylonjs/Cameras/camera";
  61337. import { Effect } from "babylonjs/Materials/effect";
  61338. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61339. import { Engine } from "babylonjs/Engines/engine";
  61340. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61341. /**
  61342. * Options to be set when merging outputs from the default pipeline.
  61343. */
  61344. export class DepthOfFieldMergePostProcessOptions {
  61345. /**
  61346. * The original image to merge on top of
  61347. */
  61348. originalFromInput: PostProcess;
  61349. /**
  61350. * Parameters to perform the merge of the depth of field effect
  61351. */
  61352. depthOfField?: {
  61353. circleOfConfusion: PostProcess;
  61354. blurSteps: Array<PostProcess>;
  61355. };
  61356. /**
  61357. * Parameters to perform the merge of bloom effect
  61358. */
  61359. bloom?: {
  61360. blurred: PostProcess;
  61361. weight: number;
  61362. };
  61363. }
  61364. /**
  61365. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61366. */
  61367. export class DepthOfFieldMergePostProcess extends PostProcess {
  61368. private blurSteps;
  61369. /**
  61370. * Creates a new instance of DepthOfFieldMergePostProcess
  61371. * @param name The name of the effect.
  61372. * @param originalFromInput Post process which's input will be used for the merge.
  61373. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61374. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61375. * @param options The required width/height ratio to downsize to before computing the render pass.
  61376. * @param camera The camera to apply the render pass to.
  61377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61378. * @param engine The engine which the post process will be applied. (default: current engine)
  61379. * @param reusable If the post process can be reused on the same frame. (default: false)
  61380. * @param textureType Type of textures used when performing the post process. (default: 0)
  61381. * @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)
  61382. */
  61383. 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);
  61384. /**
  61385. * Updates the effect with the current post process compile time values and recompiles the shader.
  61386. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61387. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61388. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61389. * @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
  61390. * @param onCompiled Called when the shader has been compiled.
  61391. * @param onError Called if there is an error when compiling a shader.
  61392. */
  61393. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61394. }
  61395. }
  61396. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61397. import { Nullable } from "babylonjs/types";
  61398. import { Camera } from "babylonjs/Cameras/camera";
  61399. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61400. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61401. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61402. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61403. import { Scene } from "babylonjs/scene";
  61404. /**
  61405. * Specifies the level of max blur that should be applied when using the depth of field effect
  61406. */
  61407. export enum DepthOfFieldEffectBlurLevel {
  61408. /**
  61409. * Subtle blur
  61410. */
  61411. Low = 0,
  61412. /**
  61413. * Medium blur
  61414. */
  61415. Medium = 1,
  61416. /**
  61417. * Large blur
  61418. */
  61419. High = 2
  61420. }
  61421. /**
  61422. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61423. */
  61424. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61425. private _circleOfConfusion;
  61426. /**
  61427. * @hidden Internal, blurs from high to low
  61428. */
  61429. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61430. private _depthOfFieldBlurY;
  61431. private _dofMerge;
  61432. /**
  61433. * @hidden Internal post processes in depth of field effect
  61434. */
  61435. _effects: Array<PostProcess>;
  61436. /**
  61437. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61438. */
  61439. focalLength: number;
  61440. /**
  61441. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61442. */
  61443. fStop: number;
  61444. /**
  61445. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61446. */
  61447. focusDistance: number;
  61448. /**
  61449. * 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.
  61450. */
  61451. lensSize: number;
  61452. /**
  61453. * Creates a new instance DepthOfFieldEffect
  61454. * @param scene The scene the effect belongs to.
  61455. * @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.
  61456. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61457. * @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)
  61458. */
  61459. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61460. /**
  61461. * Get the current class name of the current effet
  61462. * @returns "DepthOfFieldEffect"
  61463. */
  61464. getClassName(): string;
  61465. /**
  61466. * 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.
  61467. */
  61468. depthTexture: RenderTargetTexture;
  61469. /**
  61470. * Disposes each of the internal effects for a given camera.
  61471. * @param camera The camera to dispose the effect on.
  61472. */
  61473. disposeEffects(camera: Camera): void;
  61474. /**
  61475. * @hidden Internal
  61476. */
  61477. _updateEffects(): void;
  61478. /**
  61479. * Internal
  61480. * @returns if all the contained post processes are ready.
  61481. * @hidden
  61482. */
  61483. _isReady(): boolean;
  61484. }
  61485. }
  61486. declare module "babylonjs/Shaders/displayPass.fragment" {
  61487. /** @hidden */
  61488. export var displayPassPixelShader: {
  61489. name: string;
  61490. shader: string;
  61491. };
  61492. }
  61493. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  61494. import { Nullable } from "babylonjs/types";
  61495. import { Camera } from "babylonjs/Cameras/camera";
  61496. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61497. import { Engine } from "babylonjs/Engines/engine";
  61498. import "babylonjs/Shaders/displayPass.fragment";
  61499. /**
  61500. * DisplayPassPostProcess which produces an output the same as it's input
  61501. */
  61502. export class DisplayPassPostProcess extends PostProcess {
  61503. /**
  61504. * Creates the DisplayPassPostProcess
  61505. * @param name The name of the effect.
  61506. * @param options The required width/height ratio to downsize to before computing the render pass.
  61507. * @param camera The camera to apply the render pass to.
  61508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61509. * @param engine The engine which the post process will be applied. (default: current engine)
  61510. * @param reusable If the post process can be reused on the same frame. (default: false)
  61511. */
  61512. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61513. }
  61514. }
  61515. declare module "babylonjs/Shaders/filter.fragment" {
  61516. /** @hidden */
  61517. export var filterPixelShader: {
  61518. name: string;
  61519. shader: string;
  61520. };
  61521. }
  61522. declare module "babylonjs/PostProcesses/filterPostProcess" {
  61523. import { Nullable } from "babylonjs/types";
  61524. import { Matrix } from "babylonjs/Maths/math.vector";
  61525. import { Camera } from "babylonjs/Cameras/camera";
  61526. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61527. import { Engine } from "babylonjs/Engines/engine";
  61528. import "babylonjs/Shaders/filter.fragment";
  61529. /**
  61530. * Applies a kernel filter to the image
  61531. */
  61532. export class FilterPostProcess extends PostProcess {
  61533. /** The matrix to be applied to the image */
  61534. kernelMatrix: Matrix;
  61535. /**
  61536. *
  61537. * @param name The name of the effect.
  61538. * @param kernelMatrix The matrix to be applied to the image
  61539. * @param options The required width/height ratio to downsize to before computing the render pass.
  61540. * @param camera The camera to apply the render pass to.
  61541. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61542. * @param engine The engine which the post process will be applied. (default: current engine)
  61543. * @param reusable If the post process can be reused on the same frame. (default: false)
  61544. */
  61545. constructor(name: string,
  61546. /** The matrix to be applied to the image */
  61547. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61548. }
  61549. }
  61550. declare module "babylonjs/Shaders/fxaa.fragment" {
  61551. /** @hidden */
  61552. export var fxaaPixelShader: {
  61553. name: string;
  61554. shader: string;
  61555. };
  61556. }
  61557. declare module "babylonjs/Shaders/fxaa.vertex" {
  61558. /** @hidden */
  61559. export var fxaaVertexShader: {
  61560. name: string;
  61561. shader: string;
  61562. };
  61563. }
  61564. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  61565. import { Nullable } from "babylonjs/types";
  61566. import { Camera } from "babylonjs/Cameras/camera";
  61567. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61568. import { Engine } from "babylonjs/Engines/engine";
  61569. import "babylonjs/Shaders/fxaa.fragment";
  61570. import "babylonjs/Shaders/fxaa.vertex";
  61571. /**
  61572. * Fxaa post process
  61573. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61574. */
  61575. export class FxaaPostProcess extends PostProcess {
  61576. /** @hidden */
  61577. texelWidth: number;
  61578. /** @hidden */
  61579. texelHeight: number;
  61580. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61581. private _getDefines;
  61582. }
  61583. }
  61584. declare module "babylonjs/Shaders/grain.fragment" {
  61585. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61586. /** @hidden */
  61587. export var grainPixelShader: {
  61588. name: string;
  61589. shader: string;
  61590. };
  61591. }
  61592. declare module "babylonjs/PostProcesses/grainPostProcess" {
  61593. import { Nullable } from "babylonjs/types";
  61594. import { Camera } from "babylonjs/Cameras/camera";
  61595. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61596. import { Engine } from "babylonjs/Engines/engine";
  61597. import "babylonjs/Shaders/grain.fragment";
  61598. /**
  61599. * The GrainPostProcess adds noise to the image at mid luminance levels
  61600. */
  61601. export class GrainPostProcess extends PostProcess {
  61602. /**
  61603. * The intensity of the grain added (default: 30)
  61604. */
  61605. intensity: number;
  61606. /**
  61607. * If the grain should be randomized on every frame
  61608. */
  61609. animated: boolean;
  61610. /**
  61611. * Creates a new instance of @see GrainPostProcess
  61612. * @param name The name of the effect.
  61613. * @param options The required width/height ratio to downsize to before computing the render pass.
  61614. * @param camera The camera to apply the render pass to.
  61615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61616. * @param engine The engine which the post process will be applied. (default: current engine)
  61617. * @param reusable If the post process can be reused on the same frame. (default: false)
  61618. * @param textureType Type of textures used when performing the post process. (default: 0)
  61619. * @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)
  61620. */
  61621. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61622. }
  61623. }
  61624. declare module "babylonjs/Shaders/highlights.fragment" {
  61625. /** @hidden */
  61626. export var highlightsPixelShader: {
  61627. name: string;
  61628. shader: string;
  61629. };
  61630. }
  61631. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  61632. import { Nullable } from "babylonjs/types";
  61633. import { Camera } from "babylonjs/Cameras/camera";
  61634. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61635. import { Engine } from "babylonjs/Engines/engine";
  61636. import "babylonjs/Shaders/highlights.fragment";
  61637. /**
  61638. * Extracts highlights from the image
  61639. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61640. */
  61641. export class HighlightsPostProcess extends PostProcess {
  61642. /**
  61643. * Extracts highlights from the image
  61644. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61645. * @param name The name of the effect.
  61646. * @param options The required width/height ratio to downsize to before computing the render pass.
  61647. * @param camera The camera to apply the render pass to.
  61648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61649. * @param engine The engine which the post process will be applied. (default: current engine)
  61650. * @param reusable If the post process can be reused on the same frame. (default: false)
  61651. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61652. */
  61653. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61654. }
  61655. }
  61656. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  61657. /** @hidden */
  61658. export var mrtFragmentDeclaration: {
  61659. name: string;
  61660. shader: string;
  61661. };
  61662. }
  61663. declare module "babylonjs/Shaders/geometry.fragment" {
  61664. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  61665. /** @hidden */
  61666. export var geometryPixelShader: {
  61667. name: string;
  61668. shader: string;
  61669. };
  61670. }
  61671. declare module "babylonjs/Shaders/geometry.vertex" {
  61672. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61673. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61674. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61675. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61676. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61677. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61678. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61679. /** @hidden */
  61680. export var geometryVertexShader: {
  61681. name: string;
  61682. shader: string;
  61683. };
  61684. }
  61685. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  61686. import { Matrix } from "babylonjs/Maths/math.vector";
  61687. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61688. import { Mesh } from "babylonjs/Meshes/mesh";
  61689. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  61690. import { Effect } from "babylonjs/Materials/effect";
  61691. import { Scene } from "babylonjs/scene";
  61692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61693. import "babylonjs/Shaders/geometry.fragment";
  61694. import "babylonjs/Shaders/geometry.vertex";
  61695. /** @hidden */
  61696. interface ISavedTransformationMatrix {
  61697. world: Matrix;
  61698. viewProjection: Matrix;
  61699. }
  61700. /**
  61701. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61702. */
  61703. export class GeometryBufferRenderer {
  61704. /**
  61705. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61706. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61707. */
  61708. static readonly POSITION_TEXTURE_TYPE: number;
  61709. /**
  61710. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61711. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61712. */
  61713. static readonly VELOCITY_TEXTURE_TYPE: number;
  61714. /**
  61715. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61716. * in order to compute objects velocities when enableVelocity is set to "true"
  61717. * @hidden
  61718. */
  61719. _previousTransformationMatrices: {
  61720. [index: number]: ISavedTransformationMatrix;
  61721. };
  61722. /**
  61723. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61724. * in order to compute objects velocities when enableVelocity is set to "true"
  61725. * @hidden
  61726. */
  61727. _previousBonesTransformationMatrices: {
  61728. [index: number]: Float32Array;
  61729. };
  61730. /**
  61731. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61732. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61733. */
  61734. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61735. private _scene;
  61736. private _multiRenderTarget;
  61737. private _ratio;
  61738. private _enablePosition;
  61739. private _enableVelocity;
  61740. private _positionIndex;
  61741. private _velocityIndex;
  61742. protected _effect: Effect;
  61743. protected _cachedDefines: string;
  61744. /**
  61745. * Set the render list (meshes to be rendered) used in the G buffer.
  61746. */
  61747. renderList: Mesh[];
  61748. /**
  61749. * Gets wether or not G buffer are supported by the running hardware.
  61750. * This requires draw buffer supports
  61751. */
  61752. readonly isSupported: boolean;
  61753. /**
  61754. * Returns the index of the given texture type in the G-Buffer textures array
  61755. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61756. * @returns the index of the given texture type in the G-Buffer textures array
  61757. */
  61758. getTextureIndex(textureType: number): number;
  61759. /**
  61760. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61761. */
  61762. /**
  61763. * Sets whether or not objects positions are enabled for the G buffer.
  61764. */
  61765. enablePosition: boolean;
  61766. /**
  61767. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61768. */
  61769. /**
  61770. * Sets wether or not objects velocities are enabled for the G buffer.
  61771. */
  61772. enableVelocity: boolean;
  61773. /**
  61774. * Gets the scene associated with the buffer.
  61775. */
  61776. readonly scene: Scene;
  61777. /**
  61778. * Gets the ratio used by the buffer during its creation.
  61779. * How big is the buffer related to the main canvas.
  61780. */
  61781. readonly ratio: number;
  61782. /** @hidden */
  61783. static _SceneComponentInitialization: (scene: Scene) => void;
  61784. /**
  61785. * Creates a new G Buffer for the scene
  61786. * @param scene The scene the buffer belongs to
  61787. * @param ratio How big is the buffer related to the main canvas.
  61788. */
  61789. constructor(scene: Scene, ratio?: number);
  61790. /**
  61791. * Checks wether everything is ready to render a submesh to the G buffer.
  61792. * @param subMesh the submesh to check readiness for
  61793. * @param useInstances is the mesh drawn using instance or not
  61794. * @returns true if ready otherwise false
  61795. */
  61796. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61797. /**
  61798. * Gets the current underlying G Buffer.
  61799. * @returns the buffer
  61800. */
  61801. getGBuffer(): MultiRenderTarget;
  61802. /**
  61803. * Gets the number of samples used to render the buffer (anti aliasing).
  61804. */
  61805. /**
  61806. * Sets the number of samples used to render the buffer (anti aliasing).
  61807. */
  61808. samples: number;
  61809. /**
  61810. * Disposes the renderer and frees up associated resources.
  61811. */
  61812. dispose(): void;
  61813. protected _createRenderTargets(): void;
  61814. private _copyBonesTransformationMatrices;
  61815. }
  61816. }
  61817. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  61818. import { Nullable } from "babylonjs/types";
  61819. import { Scene } from "babylonjs/scene";
  61820. import { ISceneComponent } from "babylonjs/sceneComponent";
  61821. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  61822. module "babylonjs/scene" {
  61823. interface Scene {
  61824. /** @hidden (Backing field) */
  61825. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61826. /**
  61827. * Gets or Sets the current geometry buffer associated to the scene.
  61828. */
  61829. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61830. /**
  61831. * Enables a GeometryBufferRender and associates it with the scene
  61832. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61833. * @returns the GeometryBufferRenderer
  61834. */
  61835. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61836. /**
  61837. * Disables the GeometryBufferRender associated with the scene
  61838. */
  61839. disableGeometryBufferRenderer(): void;
  61840. }
  61841. }
  61842. /**
  61843. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61844. * in several rendering techniques.
  61845. */
  61846. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61847. /**
  61848. * The component name helpful to identify the component in the list of scene components.
  61849. */
  61850. readonly name: string;
  61851. /**
  61852. * The scene the component belongs to.
  61853. */
  61854. scene: Scene;
  61855. /**
  61856. * Creates a new instance of the component for the given scene
  61857. * @param scene Defines the scene to register the component in
  61858. */
  61859. constructor(scene: Scene);
  61860. /**
  61861. * Registers the component in a given scene
  61862. */
  61863. register(): void;
  61864. /**
  61865. * Rebuilds the elements related to this component in case of
  61866. * context lost for instance.
  61867. */
  61868. rebuild(): void;
  61869. /**
  61870. * Disposes the component and the associated ressources
  61871. */
  61872. dispose(): void;
  61873. private _gatherRenderTargets;
  61874. }
  61875. }
  61876. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61877. /** @hidden */
  61878. export var motionBlurPixelShader: {
  61879. name: string;
  61880. shader: string;
  61881. };
  61882. }
  61883. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61884. import { Nullable } from "babylonjs/types";
  61885. import { Camera } from "babylonjs/Cameras/camera";
  61886. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61887. import { Scene } from "babylonjs/scene";
  61888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61889. import "babylonjs/Animations/animatable";
  61890. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61891. import "babylonjs/Shaders/motionBlur.fragment";
  61892. import { Engine } from "babylonjs/Engines/engine";
  61893. /**
  61894. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61895. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61896. * As an example, all you have to do is to create the post-process:
  61897. * var mb = new BABYLON.MotionBlurPostProcess(
  61898. * 'mb', // The name of the effect.
  61899. * scene, // The scene containing the objects to blur according to their velocity.
  61900. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61901. * camera // The camera to apply the render pass to.
  61902. * );
  61903. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61904. */
  61905. export class MotionBlurPostProcess extends PostProcess {
  61906. /**
  61907. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61908. */
  61909. motionStrength: number;
  61910. /**
  61911. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61912. */
  61913. /**
  61914. * Sets the number of iterations to be used for motion blur quality
  61915. */
  61916. motionBlurSamples: number;
  61917. private _motionBlurSamples;
  61918. private _geometryBufferRenderer;
  61919. /**
  61920. * Creates a new instance MotionBlurPostProcess
  61921. * @param name The name of the effect.
  61922. * @param scene The scene containing the objects to blur according to their velocity.
  61923. * @param options The required width/height ratio to downsize to before computing the render pass.
  61924. * @param camera The camera to apply the render pass to.
  61925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61926. * @param engine The engine which the post process will be applied. (default: current engine)
  61927. * @param reusable If the post process can be reused on the same frame. (default: false)
  61928. * @param textureType Type of textures used when performing the post process. (default: 0)
  61929. * @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)
  61930. */
  61931. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61932. /**
  61933. * Excludes the given skinned mesh from computing bones velocities.
  61934. * 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.
  61935. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61936. */
  61937. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61938. /**
  61939. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61940. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61941. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61942. */
  61943. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61944. /**
  61945. * Disposes the post process.
  61946. * @param camera The camera to dispose the post process on.
  61947. */
  61948. dispose(camera?: Camera): void;
  61949. }
  61950. }
  61951. declare module "babylonjs/Shaders/refraction.fragment" {
  61952. /** @hidden */
  61953. export var refractionPixelShader: {
  61954. name: string;
  61955. shader: string;
  61956. };
  61957. }
  61958. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  61959. import { Color3 } from "babylonjs/Maths/math.color";
  61960. import { Camera } from "babylonjs/Cameras/camera";
  61961. import { Texture } from "babylonjs/Materials/Textures/texture";
  61962. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61963. import { Engine } from "babylonjs/Engines/engine";
  61964. import "babylonjs/Shaders/refraction.fragment";
  61965. /**
  61966. * Post process which applies a refractin texture
  61967. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61968. */
  61969. export class RefractionPostProcess extends PostProcess {
  61970. /** the base color of the refraction (used to taint the rendering) */
  61971. color: Color3;
  61972. /** simulated refraction depth */
  61973. depth: number;
  61974. /** the coefficient of the base color (0 to remove base color tainting) */
  61975. colorLevel: number;
  61976. private _refTexture;
  61977. private _ownRefractionTexture;
  61978. /**
  61979. * Gets or sets the refraction texture
  61980. * Please note that you are responsible for disposing the texture if you set it manually
  61981. */
  61982. refractionTexture: Texture;
  61983. /**
  61984. * Initializes the RefractionPostProcess
  61985. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61986. * @param name The name of the effect.
  61987. * @param refractionTextureUrl Url of the refraction texture to use
  61988. * @param color the base color of the refraction (used to taint the rendering)
  61989. * @param depth simulated refraction depth
  61990. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61991. * @param camera The camera to apply the render pass to.
  61992. * @param options The required width/height ratio to downsize to before computing the render pass.
  61993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61994. * @param engine The engine which the post process will be applied. (default: current engine)
  61995. * @param reusable If the post process can be reused on the same frame. (default: false)
  61996. */
  61997. constructor(name: string, refractionTextureUrl: string,
  61998. /** the base color of the refraction (used to taint the rendering) */
  61999. color: Color3,
  62000. /** simulated refraction depth */
  62001. depth: number,
  62002. /** the coefficient of the base color (0 to remove base color tainting) */
  62003. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62004. /**
  62005. * Disposes of the post process
  62006. * @param camera Camera to dispose post process on
  62007. */
  62008. dispose(camera: Camera): void;
  62009. }
  62010. }
  62011. declare module "babylonjs/Shaders/sharpen.fragment" {
  62012. /** @hidden */
  62013. export var sharpenPixelShader: {
  62014. name: string;
  62015. shader: string;
  62016. };
  62017. }
  62018. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62019. import { Nullable } from "babylonjs/types";
  62020. import { Camera } from "babylonjs/Cameras/camera";
  62021. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62022. import "babylonjs/Shaders/sharpen.fragment";
  62023. import { Engine } from "babylonjs/Engines/engine";
  62024. /**
  62025. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62026. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62027. */
  62028. export class SharpenPostProcess extends PostProcess {
  62029. /**
  62030. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62031. */
  62032. colorAmount: number;
  62033. /**
  62034. * How much sharpness should be applied (default: 0.3)
  62035. */
  62036. edgeAmount: number;
  62037. /**
  62038. * Creates a new instance ConvolutionPostProcess
  62039. * @param name The name of the effect.
  62040. * @param options The required width/height ratio to downsize to before computing the render pass.
  62041. * @param camera The camera to apply the render pass to.
  62042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62043. * @param engine The engine which the post process will be applied. (default: current engine)
  62044. * @param reusable If the post process can be reused on the same frame. (default: false)
  62045. * @param textureType Type of textures used when performing the post process. (default: 0)
  62046. * @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)
  62047. */
  62048. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62049. }
  62050. }
  62051. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62052. import { Nullable } from "babylonjs/types";
  62053. import { Camera } from "babylonjs/Cameras/camera";
  62054. import { Engine } from "babylonjs/Engines/engine";
  62055. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62056. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62057. /**
  62058. * PostProcessRenderPipeline
  62059. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62060. */
  62061. export class PostProcessRenderPipeline {
  62062. private engine;
  62063. private _renderEffects;
  62064. private _renderEffectsForIsolatedPass;
  62065. /**
  62066. * List of inspectable custom properties (used by the Inspector)
  62067. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62068. */
  62069. inspectableCustomProperties: IInspectable[];
  62070. /**
  62071. * @hidden
  62072. */
  62073. protected _cameras: Camera[];
  62074. /** @hidden */
  62075. _name: string;
  62076. /**
  62077. * Gets pipeline name
  62078. */
  62079. readonly name: string;
  62080. /**
  62081. * Initializes a PostProcessRenderPipeline
  62082. * @param engine engine to add the pipeline to
  62083. * @param name name of the pipeline
  62084. */
  62085. constructor(engine: Engine, name: string);
  62086. /**
  62087. * Gets the class name
  62088. * @returns "PostProcessRenderPipeline"
  62089. */
  62090. getClassName(): string;
  62091. /**
  62092. * If all the render effects in the pipeline are supported
  62093. */
  62094. readonly isSupported: boolean;
  62095. /**
  62096. * Adds an effect to the pipeline
  62097. * @param renderEffect the effect to add
  62098. */
  62099. addEffect(renderEffect: PostProcessRenderEffect): void;
  62100. /** @hidden */
  62101. _rebuild(): void;
  62102. /** @hidden */
  62103. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62104. /** @hidden */
  62105. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62106. /** @hidden */
  62107. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62108. /** @hidden */
  62109. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62110. /** @hidden */
  62111. _attachCameras(cameras: Camera, unique: boolean): void;
  62112. /** @hidden */
  62113. _attachCameras(cameras: Camera[], unique: boolean): void;
  62114. /** @hidden */
  62115. _detachCameras(cameras: Camera): void;
  62116. /** @hidden */
  62117. _detachCameras(cameras: Nullable<Camera[]>): void;
  62118. /** @hidden */
  62119. _update(): void;
  62120. /** @hidden */
  62121. _reset(): void;
  62122. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62123. /**
  62124. * Disposes of the pipeline
  62125. */
  62126. dispose(): void;
  62127. }
  62128. }
  62129. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  62130. import { Camera } from "babylonjs/Cameras/camera";
  62131. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62132. /**
  62133. * PostProcessRenderPipelineManager class
  62134. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62135. */
  62136. export class PostProcessRenderPipelineManager {
  62137. private _renderPipelines;
  62138. /**
  62139. * Initializes a PostProcessRenderPipelineManager
  62140. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62141. */
  62142. constructor();
  62143. /**
  62144. * Gets the list of supported render pipelines
  62145. */
  62146. readonly supportedPipelines: PostProcessRenderPipeline[];
  62147. /**
  62148. * Adds a pipeline to the manager
  62149. * @param renderPipeline The pipeline to add
  62150. */
  62151. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62152. /**
  62153. * Attaches a camera to the pipeline
  62154. * @param renderPipelineName The name of the pipeline to attach to
  62155. * @param cameras the camera to attach
  62156. * @param unique if the camera can be attached multiple times to the pipeline
  62157. */
  62158. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62159. /**
  62160. * Detaches a camera from the pipeline
  62161. * @param renderPipelineName The name of the pipeline to detach from
  62162. * @param cameras the camera to detach
  62163. */
  62164. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62165. /**
  62166. * Enables an effect by name on a pipeline
  62167. * @param renderPipelineName the name of the pipeline to enable the effect in
  62168. * @param renderEffectName the name of the effect to enable
  62169. * @param cameras the cameras that the effect should be enabled on
  62170. */
  62171. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62172. /**
  62173. * Disables an effect by name on a pipeline
  62174. * @param renderPipelineName the name of the pipeline to disable the effect in
  62175. * @param renderEffectName the name of the effect to disable
  62176. * @param cameras the cameras that the effect should be disabled on
  62177. */
  62178. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62179. /**
  62180. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62181. */
  62182. update(): void;
  62183. /** @hidden */
  62184. _rebuild(): void;
  62185. /**
  62186. * Disposes of the manager and pipelines
  62187. */
  62188. dispose(): void;
  62189. }
  62190. }
  62191. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  62192. import { ISceneComponent } from "babylonjs/sceneComponent";
  62193. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62194. import { Scene } from "babylonjs/scene";
  62195. module "babylonjs/scene" {
  62196. interface Scene {
  62197. /** @hidden (Backing field) */
  62198. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62199. /**
  62200. * Gets the postprocess render pipeline manager
  62201. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62202. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62203. */
  62204. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62205. }
  62206. }
  62207. /**
  62208. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62209. */
  62210. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62211. /**
  62212. * The component name helpfull to identify the component in the list of scene components.
  62213. */
  62214. readonly name: string;
  62215. /**
  62216. * The scene the component belongs to.
  62217. */
  62218. scene: Scene;
  62219. /**
  62220. * Creates a new instance of the component for the given scene
  62221. * @param scene Defines the scene to register the component in
  62222. */
  62223. constructor(scene: Scene);
  62224. /**
  62225. * Registers the component in a given scene
  62226. */
  62227. register(): void;
  62228. /**
  62229. * Rebuilds the elements related to this component in case of
  62230. * context lost for instance.
  62231. */
  62232. rebuild(): void;
  62233. /**
  62234. * Disposes the component and the associated ressources
  62235. */
  62236. dispose(): void;
  62237. private _gatherRenderTargets;
  62238. }
  62239. }
  62240. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  62241. import { Nullable } from "babylonjs/types";
  62242. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62243. import { Camera } from "babylonjs/Cameras/camera";
  62244. import { IDisposable } from "babylonjs/scene";
  62245. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  62246. import { Scene } from "babylonjs/scene";
  62247. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  62248. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62249. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62250. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  62251. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62252. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62253. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  62254. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62255. import { Animation } from "babylonjs/Animations/animation";
  62256. /**
  62257. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62258. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62259. */
  62260. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62261. private _scene;
  62262. private _camerasToBeAttached;
  62263. /**
  62264. * ID of the sharpen post process,
  62265. */
  62266. private readonly SharpenPostProcessId;
  62267. /**
  62268. * @ignore
  62269. * ID of the image processing post process;
  62270. */
  62271. readonly ImageProcessingPostProcessId: string;
  62272. /**
  62273. * @ignore
  62274. * ID of the Fast Approximate Anti-Aliasing post process;
  62275. */
  62276. readonly FxaaPostProcessId: string;
  62277. /**
  62278. * ID of the chromatic aberration post process,
  62279. */
  62280. private readonly ChromaticAberrationPostProcessId;
  62281. /**
  62282. * ID of the grain post process
  62283. */
  62284. private readonly GrainPostProcessId;
  62285. /**
  62286. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62287. */
  62288. sharpen: SharpenPostProcess;
  62289. private _sharpenEffect;
  62290. private bloom;
  62291. /**
  62292. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62293. */
  62294. depthOfField: DepthOfFieldEffect;
  62295. /**
  62296. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62297. */
  62298. fxaa: FxaaPostProcess;
  62299. /**
  62300. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62301. */
  62302. imageProcessing: ImageProcessingPostProcess;
  62303. /**
  62304. * Chromatic aberration post process which will shift rgb colors in the image
  62305. */
  62306. chromaticAberration: ChromaticAberrationPostProcess;
  62307. private _chromaticAberrationEffect;
  62308. /**
  62309. * Grain post process which add noise to the image
  62310. */
  62311. grain: GrainPostProcess;
  62312. private _grainEffect;
  62313. /**
  62314. * Glow post process which adds a glow to emissive areas of the image
  62315. */
  62316. private _glowLayer;
  62317. /**
  62318. * Animations which can be used to tweak settings over a period of time
  62319. */
  62320. animations: Animation[];
  62321. private _imageProcessingConfigurationObserver;
  62322. private _sharpenEnabled;
  62323. private _bloomEnabled;
  62324. private _depthOfFieldEnabled;
  62325. private _depthOfFieldBlurLevel;
  62326. private _fxaaEnabled;
  62327. private _imageProcessingEnabled;
  62328. private _defaultPipelineTextureType;
  62329. private _bloomScale;
  62330. private _chromaticAberrationEnabled;
  62331. private _grainEnabled;
  62332. private _buildAllowed;
  62333. /**
  62334. * Gets active scene
  62335. */
  62336. readonly scene: Scene;
  62337. /**
  62338. * Enable or disable the sharpen process from the pipeline
  62339. */
  62340. sharpenEnabled: boolean;
  62341. private _resizeObserver;
  62342. private _hardwareScaleLevel;
  62343. private _bloomKernel;
  62344. /**
  62345. * Specifies the size of the bloom blur kernel, relative to the final output size
  62346. */
  62347. bloomKernel: number;
  62348. /**
  62349. * Specifies the weight of the bloom in the final rendering
  62350. */
  62351. private _bloomWeight;
  62352. /**
  62353. * Specifies the luma threshold for the area that will be blurred by the bloom
  62354. */
  62355. private _bloomThreshold;
  62356. private _hdr;
  62357. /**
  62358. * The strength of the bloom.
  62359. */
  62360. bloomWeight: number;
  62361. /**
  62362. * The strength of the bloom.
  62363. */
  62364. bloomThreshold: number;
  62365. /**
  62366. * The scale of the bloom, lower value will provide better performance.
  62367. */
  62368. bloomScale: number;
  62369. /**
  62370. * Enable or disable the bloom from the pipeline
  62371. */
  62372. bloomEnabled: boolean;
  62373. private _rebuildBloom;
  62374. /**
  62375. * If the depth of field is enabled.
  62376. */
  62377. depthOfFieldEnabled: boolean;
  62378. /**
  62379. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62380. */
  62381. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62382. /**
  62383. * If the anti aliasing is enabled.
  62384. */
  62385. fxaaEnabled: boolean;
  62386. private _samples;
  62387. /**
  62388. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62389. */
  62390. samples: number;
  62391. /**
  62392. * If image processing is enabled.
  62393. */
  62394. imageProcessingEnabled: boolean;
  62395. /**
  62396. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62397. */
  62398. glowLayerEnabled: boolean;
  62399. /**
  62400. * Gets the glow layer (or null if not defined)
  62401. */
  62402. readonly glowLayer: Nullable<GlowLayer>;
  62403. /**
  62404. * Enable or disable the chromaticAberration process from the pipeline
  62405. */
  62406. chromaticAberrationEnabled: boolean;
  62407. /**
  62408. * Enable or disable the grain process from the pipeline
  62409. */
  62410. grainEnabled: boolean;
  62411. /**
  62412. * @constructor
  62413. * @param name - The rendering pipeline name (default: "")
  62414. * @param hdr - If high dynamic range textures should be used (default: true)
  62415. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62416. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62417. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62418. */
  62419. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62420. /**
  62421. * Get the class name
  62422. * @returns "DefaultRenderingPipeline"
  62423. */
  62424. getClassName(): string;
  62425. /**
  62426. * Force the compilation of the entire pipeline.
  62427. */
  62428. prepare(): void;
  62429. private _hasCleared;
  62430. private _prevPostProcess;
  62431. private _prevPrevPostProcess;
  62432. private _setAutoClearAndTextureSharing;
  62433. private _depthOfFieldSceneObserver;
  62434. private _buildPipeline;
  62435. private _disposePostProcesses;
  62436. /**
  62437. * Adds a camera to the pipeline
  62438. * @param camera the camera to be added
  62439. */
  62440. addCamera(camera: Camera): void;
  62441. /**
  62442. * Removes a camera from the pipeline
  62443. * @param camera the camera to remove
  62444. */
  62445. removeCamera(camera: Camera): void;
  62446. /**
  62447. * Dispose of the pipeline and stop all post processes
  62448. */
  62449. dispose(): void;
  62450. /**
  62451. * Serialize the rendering pipeline (Used when exporting)
  62452. * @returns the serialized object
  62453. */
  62454. serialize(): any;
  62455. /**
  62456. * Parse the serialized pipeline
  62457. * @param source Source pipeline.
  62458. * @param scene The scene to load the pipeline to.
  62459. * @param rootUrl The URL of the serialized pipeline.
  62460. * @returns An instantiated pipeline from the serialized object.
  62461. */
  62462. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62463. }
  62464. }
  62465. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  62466. /** @hidden */
  62467. export var lensHighlightsPixelShader: {
  62468. name: string;
  62469. shader: string;
  62470. };
  62471. }
  62472. declare module "babylonjs/Shaders/depthOfField.fragment" {
  62473. /** @hidden */
  62474. export var depthOfFieldPixelShader: {
  62475. name: string;
  62476. shader: string;
  62477. };
  62478. }
  62479. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  62480. import { Camera } from "babylonjs/Cameras/camera";
  62481. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62482. import { Scene } from "babylonjs/scene";
  62483. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62484. import "babylonjs/Shaders/chromaticAberration.fragment";
  62485. import "babylonjs/Shaders/lensHighlights.fragment";
  62486. import "babylonjs/Shaders/depthOfField.fragment";
  62487. /**
  62488. * BABYLON.JS Chromatic Aberration GLSL Shader
  62489. * Author: Olivier Guyot
  62490. * Separates very slightly R, G and B colors on the edges of the screen
  62491. * Inspired by Francois Tarlier & Martins Upitis
  62492. */
  62493. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62494. /**
  62495. * @ignore
  62496. * The chromatic aberration PostProcess id in the pipeline
  62497. */
  62498. LensChromaticAberrationEffect: string;
  62499. /**
  62500. * @ignore
  62501. * The highlights enhancing PostProcess id in the pipeline
  62502. */
  62503. HighlightsEnhancingEffect: string;
  62504. /**
  62505. * @ignore
  62506. * The depth-of-field PostProcess id in the pipeline
  62507. */
  62508. LensDepthOfFieldEffect: string;
  62509. private _scene;
  62510. private _depthTexture;
  62511. private _grainTexture;
  62512. private _chromaticAberrationPostProcess;
  62513. private _highlightsPostProcess;
  62514. private _depthOfFieldPostProcess;
  62515. private _edgeBlur;
  62516. private _grainAmount;
  62517. private _chromaticAberration;
  62518. private _distortion;
  62519. private _highlightsGain;
  62520. private _highlightsThreshold;
  62521. private _dofDistance;
  62522. private _dofAperture;
  62523. private _dofDarken;
  62524. private _dofPentagon;
  62525. private _blurNoise;
  62526. /**
  62527. * @constructor
  62528. *
  62529. * Effect parameters are as follow:
  62530. * {
  62531. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62532. * edge_blur: number; // from 0 to x (1 for realism)
  62533. * distortion: number; // from 0 to x (1 for realism)
  62534. * grain_amount: number; // from 0 to 1
  62535. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62536. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62537. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62538. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62539. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62540. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62541. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62542. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62543. * }
  62544. * Note: if an effect parameter is unset, effect is disabled
  62545. *
  62546. * @param name The rendering pipeline name
  62547. * @param parameters - An object containing all parameters (see above)
  62548. * @param scene The scene linked to this pipeline
  62549. * @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)
  62550. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62551. */
  62552. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62553. /**
  62554. * Get the class name
  62555. * @returns "LensRenderingPipeline"
  62556. */
  62557. getClassName(): string;
  62558. /**
  62559. * Gets associated scene
  62560. */
  62561. readonly scene: Scene;
  62562. /**
  62563. * Gets or sets the edge blur
  62564. */
  62565. edgeBlur: number;
  62566. /**
  62567. * Gets or sets the grain amount
  62568. */
  62569. grainAmount: number;
  62570. /**
  62571. * Gets or sets the chromatic aberration amount
  62572. */
  62573. chromaticAberration: number;
  62574. /**
  62575. * Gets or sets the depth of field aperture
  62576. */
  62577. dofAperture: number;
  62578. /**
  62579. * Gets or sets the edge distortion
  62580. */
  62581. edgeDistortion: number;
  62582. /**
  62583. * Gets or sets the depth of field distortion
  62584. */
  62585. dofDistortion: number;
  62586. /**
  62587. * Gets or sets the darken out of focus amount
  62588. */
  62589. darkenOutOfFocus: number;
  62590. /**
  62591. * Gets or sets a boolean indicating if blur noise is enabled
  62592. */
  62593. blurNoise: boolean;
  62594. /**
  62595. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62596. */
  62597. pentagonBokeh: boolean;
  62598. /**
  62599. * Gets or sets the highlight grain amount
  62600. */
  62601. highlightsGain: number;
  62602. /**
  62603. * Gets or sets the highlight threshold
  62604. */
  62605. highlightsThreshold: number;
  62606. /**
  62607. * Sets the amount of blur at the edges
  62608. * @param amount blur amount
  62609. */
  62610. setEdgeBlur(amount: number): void;
  62611. /**
  62612. * Sets edge blur to 0
  62613. */
  62614. disableEdgeBlur(): void;
  62615. /**
  62616. * Sets the amout of grain
  62617. * @param amount Amount of grain
  62618. */
  62619. setGrainAmount(amount: number): void;
  62620. /**
  62621. * Set grain amount to 0
  62622. */
  62623. disableGrain(): void;
  62624. /**
  62625. * Sets the chromatic aberration amount
  62626. * @param amount amount of chromatic aberration
  62627. */
  62628. setChromaticAberration(amount: number): void;
  62629. /**
  62630. * Sets chromatic aberration amount to 0
  62631. */
  62632. disableChromaticAberration(): void;
  62633. /**
  62634. * Sets the EdgeDistortion amount
  62635. * @param amount amount of EdgeDistortion
  62636. */
  62637. setEdgeDistortion(amount: number): void;
  62638. /**
  62639. * Sets edge distortion to 0
  62640. */
  62641. disableEdgeDistortion(): void;
  62642. /**
  62643. * Sets the FocusDistance amount
  62644. * @param amount amount of FocusDistance
  62645. */
  62646. setFocusDistance(amount: number): void;
  62647. /**
  62648. * Disables depth of field
  62649. */
  62650. disableDepthOfField(): void;
  62651. /**
  62652. * Sets the Aperture amount
  62653. * @param amount amount of Aperture
  62654. */
  62655. setAperture(amount: number): void;
  62656. /**
  62657. * Sets the DarkenOutOfFocus amount
  62658. * @param amount amount of DarkenOutOfFocus
  62659. */
  62660. setDarkenOutOfFocus(amount: number): void;
  62661. private _pentagonBokehIsEnabled;
  62662. /**
  62663. * Creates a pentagon bokeh effect
  62664. */
  62665. enablePentagonBokeh(): void;
  62666. /**
  62667. * Disables the pentagon bokeh effect
  62668. */
  62669. disablePentagonBokeh(): void;
  62670. /**
  62671. * Enables noise blur
  62672. */
  62673. enableNoiseBlur(): void;
  62674. /**
  62675. * Disables noise blur
  62676. */
  62677. disableNoiseBlur(): void;
  62678. /**
  62679. * Sets the HighlightsGain amount
  62680. * @param amount amount of HighlightsGain
  62681. */
  62682. setHighlightsGain(amount: number): void;
  62683. /**
  62684. * Sets the HighlightsThreshold amount
  62685. * @param amount amount of HighlightsThreshold
  62686. */
  62687. setHighlightsThreshold(amount: number): void;
  62688. /**
  62689. * Disables highlights
  62690. */
  62691. disableHighlights(): void;
  62692. /**
  62693. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62694. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62695. */
  62696. dispose(disableDepthRender?: boolean): void;
  62697. private _createChromaticAberrationPostProcess;
  62698. private _createHighlightsPostProcess;
  62699. private _createDepthOfFieldPostProcess;
  62700. private _createGrainTexture;
  62701. }
  62702. }
  62703. declare module "babylonjs/Shaders/ssao2.fragment" {
  62704. /** @hidden */
  62705. export var ssao2PixelShader: {
  62706. name: string;
  62707. shader: string;
  62708. };
  62709. }
  62710. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  62711. /** @hidden */
  62712. export var ssaoCombinePixelShader: {
  62713. name: string;
  62714. shader: string;
  62715. };
  62716. }
  62717. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  62718. import { Camera } from "babylonjs/Cameras/camera";
  62719. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62720. import { Scene } from "babylonjs/scene";
  62721. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62722. import "babylonjs/Shaders/ssao2.fragment";
  62723. import "babylonjs/Shaders/ssaoCombine.fragment";
  62724. /**
  62725. * Render pipeline to produce ssao effect
  62726. */
  62727. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62728. /**
  62729. * @ignore
  62730. * The PassPostProcess id in the pipeline that contains the original scene color
  62731. */
  62732. SSAOOriginalSceneColorEffect: string;
  62733. /**
  62734. * @ignore
  62735. * The SSAO PostProcess id in the pipeline
  62736. */
  62737. SSAORenderEffect: string;
  62738. /**
  62739. * @ignore
  62740. * The horizontal blur PostProcess id in the pipeline
  62741. */
  62742. SSAOBlurHRenderEffect: string;
  62743. /**
  62744. * @ignore
  62745. * The vertical blur PostProcess id in the pipeline
  62746. */
  62747. SSAOBlurVRenderEffect: string;
  62748. /**
  62749. * @ignore
  62750. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62751. */
  62752. SSAOCombineRenderEffect: string;
  62753. /**
  62754. * The output strength of the SSAO post-process. Default value is 1.0.
  62755. */
  62756. totalStrength: number;
  62757. /**
  62758. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62759. */
  62760. maxZ: number;
  62761. /**
  62762. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62763. */
  62764. minZAspect: number;
  62765. private _samples;
  62766. /**
  62767. * Number of samples used for the SSAO calculations. Default value is 8
  62768. */
  62769. samples: number;
  62770. private _textureSamples;
  62771. /**
  62772. * Number of samples to use for antialiasing
  62773. */
  62774. textureSamples: number;
  62775. /**
  62776. * Ratio object used for SSAO ratio and blur ratio
  62777. */
  62778. private _ratio;
  62779. /**
  62780. * Dynamically generated sphere sampler.
  62781. */
  62782. private _sampleSphere;
  62783. /**
  62784. * Blur filter offsets
  62785. */
  62786. private _samplerOffsets;
  62787. private _expensiveBlur;
  62788. /**
  62789. * If bilateral blur should be used
  62790. */
  62791. expensiveBlur: boolean;
  62792. /**
  62793. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62794. */
  62795. radius: number;
  62796. /**
  62797. * The base color of the SSAO post-process
  62798. * The final result is "base + ssao" between [0, 1]
  62799. */
  62800. base: number;
  62801. /**
  62802. * Support test.
  62803. */
  62804. static readonly IsSupported: boolean;
  62805. private _scene;
  62806. private _depthTexture;
  62807. private _normalTexture;
  62808. private _randomTexture;
  62809. private _originalColorPostProcess;
  62810. private _ssaoPostProcess;
  62811. private _blurHPostProcess;
  62812. private _blurVPostProcess;
  62813. private _ssaoCombinePostProcess;
  62814. private _firstUpdate;
  62815. /**
  62816. * Gets active scene
  62817. */
  62818. readonly scene: Scene;
  62819. /**
  62820. * @constructor
  62821. * @param name The rendering pipeline name
  62822. * @param scene The scene linked to this pipeline
  62823. * @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 }
  62824. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62825. */
  62826. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62827. /**
  62828. * Get the class name
  62829. * @returns "SSAO2RenderingPipeline"
  62830. */
  62831. getClassName(): string;
  62832. /**
  62833. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62834. */
  62835. dispose(disableGeometryBufferRenderer?: boolean): void;
  62836. private _createBlurPostProcess;
  62837. /** @hidden */
  62838. _rebuild(): void;
  62839. private _bits;
  62840. private _radicalInverse_VdC;
  62841. private _hammersley;
  62842. private _hemisphereSample_uniform;
  62843. private _generateHemisphere;
  62844. private _createSSAOPostProcess;
  62845. private _createSSAOCombinePostProcess;
  62846. private _createRandomTexture;
  62847. /**
  62848. * Serialize the rendering pipeline (Used when exporting)
  62849. * @returns the serialized object
  62850. */
  62851. serialize(): any;
  62852. /**
  62853. * Parse the serialized pipeline
  62854. * @param source Source pipeline.
  62855. * @param scene The scene to load the pipeline to.
  62856. * @param rootUrl The URL of the serialized pipeline.
  62857. * @returns An instantiated pipeline from the serialized object.
  62858. */
  62859. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62860. }
  62861. }
  62862. declare module "babylonjs/Shaders/ssao.fragment" {
  62863. /** @hidden */
  62864. export var ssaoPixelShader: {
  62865. name: string;
  62866. shader: string;
  62867. };
  62868. }
  62869. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  62870. import { Camera } from "babylonjs/Cameras/camera";
  62871. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62872. import { Scene } from "babylonjs/scene";
  62873. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62874. import "babylonjs/Shaders/ssao.fragment";
  62875. import "babylonjs/Shaders/ssaoCombine.fragment";
  62876. /**
  62877. * Render pipeline to produce ssao effect
  62878. */
  62879. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62880. /**
  62881. * @ignore
  62882. * The PassPostProcess id in the pipeline that contains the original scene color
  62883. */
  62884. SSAOOriginalSceneColorEffect: string;
  62885. /**
  62886. * @ignore
  62887. * The SSAO PostProcess id in the pipeline
  62888. */
  62889. SSAORenderEffect: string;
  62890. /**
  62891. * @ignore
  62892. * The horizontal blur PostProcess id in the pipeline
  62893. */
  62894. SSAOBlurHRenderEffect: string;
  62895. /**
  62896. * @ignore
  62897. * The vertical blur PostProcess id in the pipeline
  62898. */
  62899. SSAOBlurVRenderEffect: string;
  62900. /**
  62901. * @ignore
  62902. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62903. */
  62904. SSAOCombineRenderEffect: string;
  62905. /**
  62906. * The output strength of the SSAO post-process. Default value is 1.0.
  62907. */
  62908. totalStrength: number;
  62909. /**
  62910. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62911. */
  62912. radius: number;
  62913. /**
  62914. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62915. * Must not be equal to fallOff and superior to fallOff.
  62916. * Default value is 0.0075
  62917. */
  62918. area: number;
  62919. /**
  62920. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62921. * Must not be equal to area and inferior to area.
  62922. * Default value is 0.000001
  62923. */
  62924. fallOff: number;
  62925. /**
  62926. * The base color of the SSAO post-process
  62927. * The final result is "base + ssao" between [0, 1]
  62928. */
  62929. base: number;
  62930. private _scene;
  62931. private _depthTexture;
  62932. private _randomTexture;
  62933. private _originalColorPostProcess;
  62934. private _ssaoPostProcess;
  62935. private _blurHPostProcess;
  62936. private _blurVPostProcess;
  62937. private _ssaoCombinePostProcess;
  62938. private _firstUpdate;
  62939. /**
  62940. * Gets active scene
  62941. */
  62942. readonly scene: Scene;
  62943. /**
  62944. * @constructor
  62945. * @param name - The rendering pipeline name
  62946. * @param scene - The scene linked to this pipeline
  62947. * @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 }
  62948. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62949. */
  62950. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62951. /**
  62952. * Get the class name
  62953. * @returns "SSAORenderingPipeline"
  62954. */
  62955. getClassName(): string;
  62956. /**
  62957. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62958. */
  62959. dispose(disableDepthRender?: boolean): void;
  62960. private _createBlurPostProcess;
  62961. /** @hidden */
  62962. _rebuild(): void;
  62963. private _createSSAOPostProcess;
  62964. private _createSSAOCombinePostProcess;
  62965. private _createRandomTexture;
  62966. }
  62967. }
  62968. declare module "babylonjs/Shaders/standard.fragment" {
  62969. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62970. /** @hidden */
  62971. export var standardPixelShader: {
  62972. name: string;
  62973. shader: string;
  62974. };
  62975. }
  62976. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  62977. import { Nullable } from "babylonjs/types";
  62978. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62979. import { Camera } from "babylonjs/Cameras/camera";
  62980. import { Texture } from "babylonjs/Materials/Textures/texture";
  62981. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62982. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62983. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62984. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62985. import { IDisposable } from "babylonjs/scene";
  62986. import { SpotLight } from "babylonjs/Lights/spotLight";
  62987. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62988. import { Scene } from "babylonjs/scene";
  62989. import { Animation } from "babylonjs/Animations/animation";
  62990. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62991. import "babylonjs/Shaders/standard.fragment";
  62992. /**
  62993. * Standard rendering pipeline
  62994. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62995. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62996. */
  62997. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62998. /**
  62999. * Public members
  63000. */
  63001. /**
  63002. * Post-process which contains the original scene color before the pipeline applies all the effects
  63003. */
  63004. originalPostProcess: Nullable<PostProcess>;
  63005. /**
  63006. * Post-process used to down scale an image x4
  63007. */
  63008. downSampleX4PostProcess: Nullable<PostProcess>;
  63009. /**
  63010. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63011. */
  63012. brightPassPostProcess: Nullable<PostProcess>;
  63013. /**
  63014. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63015. */
  63016. blurHPostProcesses: PostProcess[];
  63017. /**
  63018. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63019. */
  63020. blurVPostProcesses: PostProcess[];
  63021. /**
  63022. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63023. */
  63024. textureAdderPostProcess: Nullable<PostProcess>;
  63025. /**
  63026. * Post-process used to create volumetric lighting effect
  63027. */
  63028. volumetricLightPostProcess: Nullable<PostProcess>;
  63029. /**
  63030. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63031. */
  63032. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63033. /**
  63034. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63035. */
  63036. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63037. /**
  63038. * Post-process used to merge the volumetric light effect and the real scene color
  63039. */
  63040. volumetricLightMergePostProces: Nullable<PostProcess>;
  63041. /**
  63042. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63043. */
  63044. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63045. /**
  63046. * Base post-process used to calculate the average luminance of the final image for HDR
  63047. */
  63048. luminancePostProcess: Nullable<PostProcess>;
  63049. /**
  63050. * Post-processes used to create down sample post-processes in order to get
  63051. * the average luminance of the final image for HDR
  63052. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63053. */
  63054. luminanceDownSamplePostProcesses: PostProcess[];
  63055. /**
  63056. * Post-process used to create a HDR effect (light adaptation)
  63057. */
  63058. hdrPostProcess: Nullable<PostProcess>;
  63059. /**
  63060. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63061. */
  63062. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63063. /**
  63064. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63065. */
  63066. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63067. /**
  63068. * Post-process used to merge the final HDR post-process and the real scene color
  63069. */
  63070. hdrFinalPostProcess: Nullable<PostProcess>;
  63071. /**
  63072. * Post-process used to create a lens flare effect
  63073. */
  63074. lensFlarePostProcess: Nullable<PostProcess>;
  63075. /**
  63076. * Post-process that merges the result of the lens flare post-process and the real scene color
  63077. */
  63078. lensFlareComposePostProcess: Nullable<PostProcess>;
  63079. /**
  63080. * Post-process used to create a motion blur effect
  63081. */
  63082. motionBlurPostProcess: Nullable<PostProcess>;
  63083. /**
  63084. * Post-process used to create a depth of field effect
  63085. */
  63086. depthOfFieldPostProcess: Nullable<PostProcess>;
  63087. /**
  63088. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63089. */
  63090. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63091. /**
  63092. * Represents the brightness threshold in order to configure the illuminated surfaces
  63093. */
  63094. brightThreshold: number;
  63095. /**
  63096. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63097. */
  63098. blurWidth: number;
  63099. /**
  63100. * Sets if the blur for highlighted surfaces must be only horizontal
  63101. */
  63102. horizontalBlur: boolean;
  63103. /**
  63104. * Gets the overall exposure used by the pipeline
  63105. */
  63106. /**
  63107. * Sets the overall exposure used by the pipeline
  63108. */
  63109. exposure: number;
  63110. /**
  63111. * Texture used typically to simulate "dirty" on camera lens
  63112. */
  63113. lensTexture: Nullable<Texture>;
  63114. /**
  63115. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63116. */
  63117. volumetricLightCoefficient: number;
  63118. /**
  63119. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63120. */
  63121. volumetricLightPower: number;
  63122. /**
  63123. * Used the set the blur intensity to smooth the volumetric lights
  63124. */
  63125. volumetricLightBlurScale: number;
  63126. /**
  63127. * Light (spot or directional) used to generate the volumetric lights rays
  63128. * The source light must have a shadow generate so the pipeline can get its
  63129. * depth map
  63130. */
  63131. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63132. /**
  63133. * For eye adaptation, represents the minimum luminance the eye can see
  63134. */
  63135. hdrMinimumLuminance: number;
  63136. /**
  63137. * For eye adaptation, represents the decrease luminance speed
  63138. */
  63139. hdrDecreaseRate: number;
  63140. /**
  63141. * For eye adaptation, represents the increase luminance speed
  63142. */
  63143. hdrIncreaseRate: number;
  63144. /**
  63145. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63146. */
  63147. /**
  63148. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63149. */
  63150. hdrAutoExposure: boolean;
  63151. /**
  63152. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63153. */
  63154. lensColorTexture: Nullable<Texture>;
  63155. /**
  63156. * The overall strengh for the lens flare effect
  63157. */
  63158. lensFlareStrength: number;
  63159. /**
  63160. * Dispersion coefficient for lens flare ghosts
  63161. */
  63162. lensFlareGhostDispersal: number;
  63163. /**
  63164. * Main lens flare halo width
  63165. */
  63166. lensFlareHaloWidth: number;
  63167. /**
  63168. * Based on the lens distortion effect, defines how much the lens flare result
  63169. * is distorted
  63170. */
  63171. lensFlareDistortionStrength: number;
  63172. /**
  63173. * Configures the blur intensity used for for lens flare (halo)
  63174. */
  63175. lensFlareBlurWidth: number;
  63176. /**
  63177. * Lens star texture must be used to simulate rays on the flares and is available
  63178. * in the documentation
  63179. */
  63180. lensStarTexture: Nullable<Texture>;
  63181. /**
  63182. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63183. * flare effect by taking account of the dirt texture
  63184. */
  63185. lensFlareDirtTexture: Nullable<Texture>;
  63186. /**
  63187. * Represents the focal length for the depth of field effect
  63188. */
  63189. depthOfFieldDistance: number;
  63190. /**
  63191. * Represents the blur intensity for the blurred part of the depth of field effect
  63192. */
  63193. depthOfFieldBlurWidth: number;
  63194. /**
  63195. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63196. */
  63197. /**
  63198. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63199. */
  63200. motionStrength: number;
  63201. /**
  63202. * Gets wether or not the motion blur post-process is object based or screen based.
  63203. */
  63204. /**
  63205. * Sets wether or not the motion blur post-process should be object based or screen based
  63206. */
  63207. objectBasedMotionBlur: boolean;
  63208. /**
  63209. * List of animations for the pipeline (IAnimatable implementation)
  63210. */
  63211. animations: Animation[];
  63212. /**
  63213. * Private members
  63214. */
  63215. private _scene;
  63216. private _currentDepthOfFieldSource;
  63217. private _basePostProcess;
  63218. private _fixedExposure;
  63219. private _currentExposure;
  63220. private _hdrAutoExposure;
  63221. private _hdrCurrentLuminance;
  63222. private _motionStrength;
  63223. private _isObjectBasedMotionBlur;
  63224. private _floatTextureType;
  63225. private _camerasToBeAttached;
  63226. private _ratio;
  63227. private _bloomEnabled;
  63228. private _depthOfFieldEnabled;
  63229. private _vlsEnabled;
  63230. private _lensFlareEnabled;
  63231. private _hdrEnabled;
  63232. private _motionBlurEnabled;
  63233. private _fxaaEnabled;
  63234. private _motionBlurSamples;
  63235. private _volumetricLightStepsCount;
  63236. private _samples;
  63237. /**
  63238. * @ignore
  63239. * Specifies if the bloom pipeline is enabled
  63240. */
  63241. BloomEnabled: boolean;
  63242. /**
  63243. * @ignore
  63244. * Specifies if the depth of field pipeline is enabed
  63245. */
  63246. DepthOfFieldEnabled: boolean;
  63247. /**
  63248. * @ignore
  63249. * Specifies if the lens flare pipeline is enabed
  63250. */
  63251. LensFlareEnabled: boolean;
  63252. /**
  63253. * @ignore
  63254. * Specifies if the HDR pipeline is enabled
  63255. */
  63256. HDREnabled: boolean;
  63257. /**
  63258. * @ignore
  63259. * Specifies if the volumetric lights scattering effect is enabled
  63260. */
  63261. VLSEnabled: boolean;
  63262. /**
  63263. * @ignore
  63264. * Specifies if the motion blur effect is enabled
  63265. */
  63266. MotionBlurEnabled: boolean;
  63267. /**
  63268. * Specifies if anti-aliasing is enabled
  63269. */
  63270. fxaaEnabled: boolean;
  63271. /**
  63272. * Specifies the number of steps used to calculate the volumetric lights
  63273. * Typically in interval [50, 200]
  63274. */
  63275. volumetricLightStepsCount: number;
  63276. /**
  63277. * Specifies the number of samples used for the motion blur effect
  63278. * Typically in interval [16, 64]
  63279. */
  63280. motionBlurSamples: number;
  63281. /**
  63282. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63283. */
  63284. samples: number;
  63285. /**
  63286. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63287. * @constructor
  63288. * @param name The rendering pipeline name
  63289. * @param scene The scene linked to this pipeline
  63290. * @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)
  63291. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63292. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63293. */
  63294. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63295. private _buildPipeline;
  63296. private _createDownSampleX4PostProcess;
  63297. private _createBrightPassPostProcess;
  63298. private _createBlurPostProcesses;
  63299. private _createTextureAdderPostProcess;
  63300. private _createVolumetricLightPostProcess;
  63301. private _createLuminancePostProcesses;
  63302. private _createHdrPostProcess;
  63303. private _createLensFlarePostProcess;
  63304. private _createDepthOfFieldPostProcess;
  63305. private _createMotionBlurPostProcess;
  63306. private _getDepthTexture;
  63307. private _disposePostProcesses;
  63308. /**
  63309. * Dispose of the pipeline and stop all post processes
  63310. */
  63311. dispose(): void;
  63312. /**
  63313. * Serialize the rendering pipeline (Used when exporting)
  63314. * @returns the serialized object
  63315. */
  63316. serialize(): any;
  63317. /**
  63318. * Parse the serialized pipeline
  63319. * @param source Source pipeline.
  63320. * @param scene The scene to load the pipeline to.
  63321. * @param rootUrl The URL of the serialized pipeline.
  63322. * @returns An instantiated pipeline from the serialized object.
  63323. */
  63324. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63325. /**
  63326. * Luminance steps
  63327. */
  63328. static LuminanceSteps: number;
  63329. }
  63330. }
  63331. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63332. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63333. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63334. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63335. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63336. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63337. }
  63338. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63339. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63340. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63341. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63342. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63343. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63344. }
  63345. declare module "babylonjs/Shaders/tonemap.fragment" {
  63346. /** @hidden */
  63347. export var tonemapPixelShader: {
  63348. name: string;
  63349. shader: string;
  63350. };
  63351. }
  63352. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63353. import { Camera } from "babylonjs/Cameras/camera";
  63354. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63355. import "babylonjs/Shaders/tonemap.fragment";
  63356. import { Engine } from "babylonjs/Engines/engine";
  63357. /** Defines operator used for tonemapping */
  63358. export enum TonemappingOperator {
  63359. /** Hable */
  63360. Hable = 0,
  63361. /** Reinhard */
  63362. Reinhard = 1,
  63363. /** HejiDawson */
  63364. HejiDawson = 2,
  63365. /** Photographic */
  63366. Photographic = 3
  63367. }
  63368. /**
  63369. * Defines a post process to apply tone mapping
  63370. */
  63371. export class TonemapPostProcess extends PostProcess {
  63372. private _operator;
  63373. /** Defines the required exposure adjustement */
  63374. exposureAdjustment: number;
  63375. /**
  63376. * Creates a new TonemapPostProcess
  63377. * @param name defines the name of the postprocess
  63378. * @param _operator defines the operator to use
  63379. * @param exposureAdjustment defines the required exposure adjustement
  63380. * @param camera defines the camera to use (can be null)
  63381. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63382. * @param engine defines the hosting engine (can be ignore if camera is set)
  63383. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63384. */
  63385. constructor(name: string, _operator: TonemappingOperator,
  63386. /** Defines the required exposure adjustement */
  63387. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63388. }
  63389. }
  63390. declare module "babylonjs/Shaders/depth.vertex" {
  63391. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63392. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63393. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63394. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63395. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63396. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63397. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63398. /** @hidden */
  63399. export var depthVertexShader: {
  63400. name: string;
  63401. shader: string;
  63402. };
  63403. }
  63404. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63405. /** @hidden */
  63406. export var volumetricLightScatteringPixelShader: {
  63407. name: string;
  63408. shader: string;
  63409. };
  63410. }
  63411. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  63412. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63413. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63414. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63415. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63416. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63417. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63418. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63419. /** @hidden */
  63420. export var volumetricLightScatteringPassVertexShader: {
  63421. name: string;
  63422. shader: string;
  63423. };
  63424. }
  63425. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  63426. /** @hidden */
  63427. export var volumetricLightScatteringPassPixelShader: {
  63428. name: string;
  63429. shader: string;
  63430. };
  63431. }
  63432. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  63433. import { Vector3 } from "babylonjs/Maths/math.vector";
  63434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63435. import { Mesh } from "babylonjs/Meshes/mesh";
  63436. import { Camera } from "babylonjs/Cameras/camera";
  63437. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63438. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63439. import { Scene } from "babylonjs/scene";
  63440. import "babylonjs/Meshes/Builders/planeBuilder";
  63441. import "babylonjs/Shaders/depth.vertex";
  63442. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  63443. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  63444. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  63445. import { Engine } from "babylonjs/Engines/engine";
  63446. /**
  63447. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63448. */
  63449. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63450. private _volumetricLightScatteringPass;
  63451. private _volumetricLightScatteringRTT;
  63452. private _viewPort;
  63453. private _screenCoordinates;
  63454. private _cachedDefines;
  63455. /**
  63456. * If not undefined, the mesh position is computed from the attached node position
  63457. */
  63458. attachedNode: {
  63459. position: Vector3;
  63460. };
  63461. /**
  63462. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63463. */
  63464. customMeshPosition: Vector3;
  63465. /**
  63466. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63467. */
  63468. useCustomMeshPosition: boolean;
  63469. /**
  63470. * If the post-process should inverse the light scattering direction
  63471. */
  63472. invert: boolean;
  63473. /**
  63474. * The internal mesh used by the post-process
  63475. */
  63476. mesh: Mesh;
  63477. /**
  63478. * @hidden
  63479. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63480. */
  63481. useDiffuseColor: boolean;
  63482. /**
  63483. * Array containing the excluded meshes not rendered in the internal pass
  63484. */
  63485. excludedMeshes: AbstractMesh[];
  63486. /**
  63487. * Controls the overall intensity of the post-process
  63488. */
  63489. exposure: number;
  63490. /**
  63491. * Dissipates each sample's contribution in range [0, 1]
  63492. */
  63493. decay: number;
  63494. /**
  63495. * Controls the overall intensity of each sample
  63496. */
  63497. weight: number;
  63498. /**
  63499. * Controls the density of each sample
  63500. */
  63501. density: number;
  63502. /**
  63503. * @constructor
  63504. * @param name The post-process name
  63505. * @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)
  63506. * @param camera The camera that the post-process will be attached to
  63507. * @param mesh The mesh used to create the light scattering
  63508. * @param samples The post-process quality, default 100
  63509. * @param samplingModeThe post-process filtering mode
  63510. * @param engine The babylon engine
  63511. * @param reusable If the post-process is reusable
  63512. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63513. */
  63514. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63515. /**
  63516. * Returns the string "VolumetricLightScatteringPostProcess"
  63517. * @returns "VolumetricLightScatteringPostProcess"
  63518. */
  63519. getClassName(): string;
  63520. private _isReady;
  63521. /**
  63522. * Sets the new light position for light scattering effect
  63523. * @param position The new custom light position
  63524. */
  63525. setCustomMeshPosition(position: Vector3): void;
  63526. /**
  63527. * Returns the light position for light scattering effect
  63528. * @return Vector3 The custom light position
  63529. */
  63530. getCustomMeshPosition(): Vector3;
  63531. /**
  63532. * Disposes the internal assets and detaches the post-process from the camera
  63533. */
  63534. dispose(camera: Camera): void;
  63535. /**
  63536. * Returns the render target texture used by the post-process
  63537. * @return the render target texture used by the post-process
  63538. */
  63539. getPass(): RenderTargetTexture;
  63540. private _meshExcluded;
  63541. private _createPass;
  63542. private _updateMeshScreenCoordinates;
  63543. /**
  63544. * Creates a default mesh for the Volumeric Light Scattering post-process
  63545. * @param name The mesh name
  63546. * @param scene The scene where to create the mesh
  63547. * @return the default mesh
  63548. */
  63549. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63550. }
  63551. }
  63552. declare module "babylonjs/PostProcesses/index" {
  63553. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  63554. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  63555. export * from "babylonjs/PostProcesses/bloomEffect";
  63556. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  63557. export * from "babylonjs/PostProcesses/blurPostProcess";
  63558. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63559. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  63560. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  63561. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  63562. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63563. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  63564. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  63565. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  63566. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63567. export * from "babylonjs/PostProcesses/filterPostProcess";
  63568. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  63569. export * from "babylonjs/PostProcesses/grainPostProcess";
  63570. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  63571. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63572. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  63573. export * from "babylonjs/PostProcesses/passPostProcess";
  63574. export * from "babylonjs/PostProcesses/postProcess";
  63575. export * from "babylonjs/PostProcesses/postProcessManager";
  63576. export * from "babylonjs/PostProcesses/refractionPostProcess";
  63577. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  63578. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  63579. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  63580. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  63581. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  63582. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  63583. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  63584. }
  63585. declare module "babylonjs/Probes/index" {
  63586. export * from "babylonjs/Probes/reflectionProbe";
  63587. }
  63588. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  63589. import { Scene } from "babylonjs/scene";
  63590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63591. import { SmartArray } from "babylonjs/Misc/smartArray";
  63592. import { ISceneComponent } from "babylonjs/sceneComponent";
  63593. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  63594. import "babylonjs/Meshes/Builders/boxBuilder";
  63595. import "babylonjs/Shaders/color.fragment";
  63596. import "babylonjs/Shaders/color.vertex";
  63597. import { Color3 } from "babylonjs/Maths/math.color";
  63598. module "babylonjs/scene" {
  63599. interface Scene {
  63600. /** @hidden (Backing field) */
  63601. _boundingBoxRenderer: BoundingBoxRenderer;
  63602. /** @hidden (Backing field) */
  63603. _forceShowBoundingBoxes: boolean;
  63604. /**
  63605. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63606. */
  63607. forceShowBoundingBoxes: boolean;
  63608. /**
  63609. * Gets the bounding box renderer associated with the scene
  63610. * @returns a BoundingBoxRenderer
  63611. */
  63612. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63613. }
  63614. }
  63615. module "babylonjs/Meshes/abstractMesh" {
  63616. interface AbstractMesh {
  63617. /** @hidden (Backing field) */
  63618. _showBoundingBox: boolean;
  63619. /**
  63620. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63621. */
  63622. showBoundingBox: boolean;
  63623. }
  63624. }
  63625. /**
  63626. * Component responsible of rendering the bounding box of the meshes in a scene.
  63627. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63628. */
  63629. export class BoundingBoxRenderer implements ISceneComponent {
  63630. /**
  63631. * The component name helpfull to identify the component in the list of scene components.
  63632. */
  63633. readonly name: string;
  63634. /**
  63635. * The scene the component belongs to.
  63636. */
  63637. scene: Scene;
  63638. /**
  63639. * Color of the bounding box lines placed in front of an object
  63640. */
  63641. frontColor: Color3;
  63642. /**
  63643. * Color of the bounding box lines placed behind an object
  63644. */
  63645. backColor: Color3;
  63646. /**
  63647. * Defines if the renderer should show the back lines or not
  63648. */
  63649. showBackLines: boolean;
  63650. /**
  63651. * @hidden
  63652. */
  63653. renderList: SmartArray<BoundingBox>;
  63654. private _colorShader;
  63655. private _vertexBuffers;
  63656. private _indexBuffer;
  63657. private _fillIndexBuffer;
  63658. private _fillIndexData;
  63659. /**
  63660. * Instantiates a new bounding box renderer in a scene.
  63661. * @param scene the scene the renderer renders in
  63662. */
  63663. constructor(scene: Scene);
  63664. /**
  63665. * Registers the component in a given scene
  63666. */
  63667. register(): void;
  63668. private _evaluateSubMesh;
  63669. private _activeMesh;
  63670. private _prepareRessources;
  63671. private _createIndexBuffer;
  63672. /**
  63673. * Rebuilds the elements related to this component in case of
  63674. * context lost for instance.
  63675. */
  63676. rebuild(): void;
  63677. /**
  63678. * @hidden
  63679. */
  63680. reset(): void;
  63681. /**
  63682. * Render the bounding boxes of a specific rendering group
  63683. * @param renderingGroupId defines the rendering group to render
  63684. */
  63685. render(renderingGroupId: number): void;
  63686. /**
  63687. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63688. * @param mesh Define the mesh to render the occlusion bounding box for
  63689. */
  63690. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63691. /**
  63692. * Dispose and release the resources attached to this renderer.
  63693. */
  63694. dispose(): void;
  63695. }
  63696. }
  63697. declare module "babylonjs/Shaders/depth.fragment" {
  63698. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63699. /** @hidden */
  63700. export var depthPixelShader: {
  63701. name: string;
  63702. shader: string;
  63703. };
  63704. }
  63705. declare module "babylonjs/Rendering/depthRenderer" {
  63706. import { Nullable } from "babylonjs/types";
  63707. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63708. import { Scene } from "babylonjs/scene";
  63709. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63710. import { Camera } from "babylonjs/Cameras/camera";
  63711. import "babylonjs/Shaders/depth.fragment";
  63712. import "babylonjs/Shaders/depth.vertex";
  63713. /**
  63714. * This represents a depth renderer in Babylon.
  63715. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63716. */
  63717. export class DepthRenderer {
  63718. private _scene;
  63719. private _depthMap;
  63720. private _effect;
  63721. private readonly _storeNonLinearDepth;
  63722. private readonly _clearColor;
  63723. /** Get if the depth renderer is using packed depth or not */
  63724. readonly isPacked: boolean;
  63725. private _cachedDefines;
  63726. private _camera;
  63727. /**
  63728. * Specifiess that the depth renderer will only be used within
  63729. * the camera it is created for.
  63730. * This can help forcing its rendering during the camera processing.
  63731. */
  63732. useOnlyInActiveCamera: boolean;
  63733. /** @hidden */
  63734. static _SceneComponentInitialization: (scene: Scene) => void;
  63735. /**
  63736. * Instantiates a depth renderer
  63737. * @param scene The scene the renderer belongs to
  63738. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63739. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63740. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63741. */
  63742. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63743. /**
  63744. * Creates the depth rendering effect and checks if the effect is ready.
  63745. * @param subMesh The submesh to be used to render the depth map of
  63746. * @param useInstances If multiple world instances should be used
  63747. * @returns if the depth renderer is ready to render the depth map
  63748. */
  63749. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63750. /**
  63751. * Gets the texture which the depth map will be written to.
  63752. * @returns The depth map texture
  63753. */
  63754. getDepthMap(): RenderTargetTexture;
  63755. /**
  63756. * Disposes of the depth renderer.
  63757. */
  63758. dispose(): void;
  63759. }
  63760. }
  63761. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  63762. import { Nullable } from "babylonjs/types";
  63763. import { Scene } from "babylonjs/scene";
  63764. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63765. import { Camera } from "babylonjs/Cameras/camera";
  63766. import { ISceneComponent } from "babylonjs/sceneComponent";
  63767. module "babylonjs/scene" {
  63768. interface Scene {
  63769. /** @hidden (Backing field) */
  63770. _depthRenderer: {
  63771. [id: string]: DepthRenderer;
  63772. };
  63773. /**
  63774. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63775. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63776. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63777. * @returns the created depth renderer
  63778. */
  63779. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63780. /**
  63781. * Disables a depth renderer for a given camera
  63782. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63783. */
  63784. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63785. }
  63786. }
  63787. /**
  63788. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63789. * in several rendering techniques.
  63790. */
  63791. export class DepthRendererSceneComponent implements ISceneComponent {
  63792. /**
  63793. * The component name helpfull to identify the component in the list of scene components.
  63794. */
  63795. readonly name: string;
  63796. /**
  63797. * The scene the component belongs to.
  63798. */
  63799. scene: Scene;
  63800. /**
  63801. * Creates a new instance of the component for the given scene
  63802. * @param scene Defines the scene to register the component in
  63803. */
  63804. constructor(scene: Scene);
  63805. /**
  63806. * Registers the component in a given scene
  63807. */
  63808. register(): void;
  63809. /**
  63810. * Rebuilds the elements related to this component in case of
  63811. * context lost for instance.
  63812. */
  63813. rebuild(): void;
  63814. /**
  63815. * Disposes the component and the associated ressources
  63816. */
  63817. dispose(): void;
  63818. private _gatherRenderTargets;
  63819. private _gatherActiveCameraRenderTargets;
  63820. }
  63821. }
  63822. declare module "babylonjs/Shaders/outline.fragment" {
  63823. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63824. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  63825. /** @hidden */
  63826. export var outlinePixelShader: {
  63827. name: string;
  63828. shader: string;
  63829. };
  63830. }
  63831. declare module "babylonjs/Shaders/outline.vertex" {
  63832. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63833. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63834. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63835. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63836. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63837. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63838. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63839. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63840. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  63841. /** @hidden */
  63842. export var outlineVertexShader: {
  63843. name: string;
  63844. shader: string;
  63845. };
  63846. }
  63847. declare module "babylonjs/Rendering/outlineRenderer" {
  63848. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63849. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  63850. import { Scene } from "babylonjs/scene";
  63851. import { ISceneComponent } from "babylonjs/sceneComponent";
  63852. import "babylonjs/Shaders/outline.fragment";
  63853. import "babylonjs/Shaders/outline.vertex";
  63854. module "babylonjs/scene" {
  63855. interface Scene {
  63856. /** @hidden */
  63857. _outlineRenderer: OutlineRenderer;
  63858. /**
  63859. * Gets the outline renderer associated with the scene
  63860. * @returns a OutlineRenderer
  63861. */
  63862. getOutlineRenderer(): OutlineRenderer;
  63863. }
  63864. }
  63865. module "babylonjs/Meshes/abstractMesh" {
  63866. interface AbstractMesh {
  63867. /** @hidden (Backing field) */
  63868. _renderOutline: boolean;
  63869. /**
  63870. * Gets or sets a boolean indicating if the outline must be rendered as well
  63871. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63872. */
  63873. renderOutline: boolean;
  63874. /** @hidden (Backing field) */
  63875. _renderOverlay: boolean;
  63876. /**
  63877. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63878. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63879. */
  63880. renderOverlay: boolean;
  63881. }
  63882. }
  63883. /**
  63884. * This class is responsible to draw bothe outline/overlay of meshes.
  63885. * It should not be used directly but through the available method on mesh.
  63886. */
  63887. export class OutlineRenderer implements ISceneComponent {
  63888. /**
  63889. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63890. */
  63891. private static _StencilReference;
  63892. /**
  63893. * The name of the component. Each component must have a unique name.
  63894. */
  63895. name: string;
  63896. /**
  63897. * The scene the component belongs to.
  63898. */
  63899. scene: Scene;
  63900. /**
  63901. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63902. */
  63903. zOffset: number;
  63904. private _engine;
  63905. private _effect;
  63906. private _cachedDefines;
  63907. private _savedDepthWrite;
  63908. /**
  63909. * Instantiates a new outline renderer. (There could be only one per scene).
  63910. * @param scene Defines the scene it belongs to
  63911. */
  63912. constructor(scene: Scene);
  63913. /**
  63914. * Register the component to one instance of a scene.
  63915. */
  63916. register(): void;
  63917. /**
  63918. * Rebuilds the elements related to this component in case of
  63919. * context lost for instance.
  63920. */
  63921. rebuild(): void;
  63922. /**
  63923. * Disposes the component and the associated ressources.
  63924. */
  63925. dispose(): void;
  63926. /**
  63927. * Renders the outline in the canvas.
  63928. * @param subMesh Defines the sumesh to render
  63929. * @param batch Defines the batch of meshes in case of instances
  63930. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63931. */
  63932. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63933. /**
  63934. * Returns whether or not the outline renderer is ready for a given submesh.
  63935. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63936. * @param subMesh Defines the submesh to check readyness for
  63937. * @param useInstances Defines wheter wee are trying to render instances or not
  63938. * @returns true if ready otherwise false
  63939. */
  63940. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63941. private _beforeRenderingMesh;
  63942. private _afterRenderingMesh;
  63943. }
  63944. }
  63945. declare module "babylonjs/Rendering/index" {
  63946. export * from "babylonjs/Rendering/boundingBoxRenderer";
  63947. export * from "babylonjs/Rendering/depthRenderer";
  63948. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  63949. export * from "babylonjs/Rendering/edgesRenderer";
  63950. export * from "babylonjs/Rendering/geometryBufferRenderer";
  63951. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63952. export * from "babylonjs/Rendering/outlineRenderer";
  63953. export * from "babylonjs/Rendering/renderingGroup";
  63954. export * from "babylonjs/Rendering/renderingManager";
  63955. export * from "babylonjs/Rendering/utilityLayerRenderer";
  63956. }
  63957. declare module "babylonjs/Sprites/spritePackedManager" {
  63958. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  63959. import { Scene } from "babylonjs/scene";
  63960. /**
  63961. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63962. * @see http://doc.babylonjs.com/babylon101/sprites
  63963. */
  63964. export class SpritePackedManager extends SpriteManager {
  63965. /** defines the packed manager's name */
  63966. name: string;
  63967. /**
  63968. * Creates a new sprite manager from a packed sprite sheet
  63969. * @param name defines the manager's name
  63970. * @param imgUrl defines the sprite sheet url
  63971. * @param capacity defines the maximum allowed number of sprites
  63972. * @param scene defines the hosting scene
  63973. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63974. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63975. * @param samplingMode defines the smapling mode to use with spritesheet
  63976. * @param fromPacked set to true; do not alter
  63977. */
  63978. constructor(
  63979. /** defines the packed manager's name */
  63980. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63981. }
  63982. }
  63983. declare module "babylonjs/Sprites/index" {
  63984. export * from "babylonjs/Sprites/sprite";
  63985. export * from "babylonjs/Sprites/spriteManager";
  63986. export * from "babylonjs/Sprites/spritePackedManager";
  63987. export * from "babylonjs/Sprites/spriteSceneComponent";
  63988. }
  63989. declare module "babylonjs/Misc/assetsManager" {
  63990. import { Scene } from "babylonjs/scene";
  63991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63992. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63993. import { Skeleton } from "babylonjs/Bones/skeleton";
  63994. import { Observable } from "babylonjs/Misc/observable";
  63995. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63996. import { Texture } from "babylonjs/Materials/Textures/texture";
  63997. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63998. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  63999. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64000. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64001. /**
  64002. * Defines the list of states available for a task inside a AssetsManager
  64003. */
  64004. export enum AssetTaskState {
  64005. /**
  64006. * Initialization
  64007. */
  64008. INIT = 0,
  64009. /**
  64010. * Running
  64011. */
  64012. RUNNING = 1,
  64013. /**
  64014. * Done
  64015. */
  64016. DONE = 2,
  64017. /**
  64018. * Error
  64019. */
  64020. ERROR = 3
  64021. }
  64022. /**
  64023. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64024. */
  64025. export abstract class AbstractAssetTask {
  64026. /**
  64027. * Task name
  64028. */ name: string;
  64029. /**
  64030. * Callback called when the task is successful
  64031. */
  64032. onSuccess: (task: any) => void;
  64033. /**
  64034. * Callback called when the task is not successful
  64035. */
  64036. onError: (task: any, message?: string, exception?: any) => void;
  64037. /**
  64038. * Creates a new AssetsManager
  64039. * @param name defines the name of the task
  64040. */
  64041. constructor(
  64042. /**
  64043. * Task name
  64044. */ name: string);
  64045. private _isCompleted;
  64046. private _taskState;
  64047. private _errorObject;
  64048. /**
  64049. * Get if the task is completed
  64050. */
  64051. readonly isCompleted: boolean;
  64052. /**
  64053. * Gets the current state of the task
  64054. */
  64055. readonly taskState: AssetTaskState;
  64056. /**
  64057. * Gets the current error object (if task is in error)
  64058. */
  64059. readonly errorObject: {
  64060. message?: string;
  64061. exception?: any;
  64062. };
  64063. /**
  64064. * Internal only
  64065. * @hidden
  64066. */
  64067. _setErrorObject(message?: string, exception?: any): void;
  64068. /**
  64069. * Execute the current task
  64070. * @param scene defines the scene where you want your assets to be loaded
  64071. * @param onSuccess is a callback called when the task is successfully executed
  64072. * @param onError is a callback called if an error occurs
  64073. */
  64074. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64075. /**
  64076. * Execute the current task
  64077. * @param scene defines the scene where you want your assets to be loaded
  64078. * @param onSuccess is a callback called when the task is successfully executed
  64079. * @param onError is a callback called if an error occurs
  64080. */
  64081. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64082. /**
  64083. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64084. * This can be used with failed tasks that have the reason for failure fixed.
  64085. */
  64086. reset(): void;
  64087. private onErrorCallback;
  64088. private onDoneCallback;
  64089. }
  64090. /**
  64091. * Define the interface used by progress events raised during assets loading
  64092. */
  64093. export interface IAssetsProgressEvent {
  64094. /**
  64095. * Defines the number of remaining tasks to process
  64096. */
  64097. remainingCount: number;
  64098. /**
  64099. * Defines the total number of tasks
  64100. */
  64101. totalCount: number;
  64102. /**
  64103. * Defines the task that was just processed
  64104. */
  64105. task: AbstractAssetTask;
  64106. }
  64107. /**
  64108. * Class used to share progress information about assets loading
  64109. */
  64110. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64111. /**
  64112. * Defines the number of remaining tasks to process
  64113. */
  64114. remainingCount: number;
  64115. /**
  64116. * Defines the total number of tasks
  64117. */
  64118. totalCount: number;
  64119. /**
  64120. * Defines the task that was just processed
  64121. */
  64122. task: AbstractAssetTask;
  64123. /**
  64124. * Creates a AssetsProgressEvent
  64125. * @param remainingCount defines the number of remaining tasks to process
  64126. * @param totalCount defines the total number of tasks
  64127. * @param task defines the task that was just processed
  64128. */
  64129. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64130. }
  64131. /**
  64132. * Define a task used by AssetsManager to load meshes
  64133. */
  64134. export class MeshAssetTask extends AbstractAssetTask {
  64135. /**
  64136. * Defines the name of the task
  64137. */
  64138. name: string;
  64139. /**
  64140. * Defines the list of mesh's names you want to load
  64141. */
  64142. meshesNames: any;
  64143. /**
  64144. * Defines the root url to use as a base to load your meshes and associated resources
  64145. */
  64146. rootUrl: string;
  64147. /**
  64148. * Defines the filename of the scene to load from
  64149. */
  64150. sceneFilename: string;
  64151. /**
  64152. * Gets the list of loaded meshes
  64153. */
  64154. loadedMeshes: Array<AbstractMesh>;
  64155. /**
  64156. * Gets the list of loaded particle systems
  64157. */
  64158. loadedParticleSystems: Array<IParticleSystem>;
  64159. /**
  64160. * Gets the list of loaded skeletons
  64161. */
  64162. loadedSkeletons: Array<Skeleton>;
  64163. /**
  64164. * Gets the list of loaded animation groups
  64165. */
  64166. loadedAnimationGroups: Array<AnimationGroup>;
  64167. /**
  64168. * Callback called when the task is successful
  64169. */
  64170. onSuccess: (task: MeshAssetTask) => void;
  64171. /**
  64172. * Callback called when the task is successful
  64173. */
  64174. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64175. /**
  64176. * Creates a new MeshAssetTask
  64177. * @param name defines the name of the task
  64178. * @param meshesNames defines the list of mesh's names you want to load
  64179. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64180. * @param sceneFilename defines the filename of the scene to load from
  64181. */
  64182. constructor(
  64183. /**
  64184. * Defines the name of the task
  64185. */
  64186. name: string,
  64187. /**
  64188. * Defines the list of mesh's names you want to load
  64189. */
  64190. meshesNames: any,
  64191. /**
  64192. * Defines the root url to use as a base to load your meshes and associated resources
  64193. */
  64194. rootUrl: string,
  64195. /**
  64196. * Defines the filename of the scene to load from
  64197. */
  64198. sceneFilename: string);
  64199. /**
  64200. * Execute the current task
  64201. * @param scene defines the scene where you want your assets to be loaded
  64202. * @param onSuccess is a callback called when the task is successfully executed
  64203. * @param onError is a callback called if an error occurs
  64204. */
  64205. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64206. }
  64207. /**
  64208. * Define a task used by AssetsManager to load text content
  64209. */
  64210. export class TextFileAssetTask extends AbstractAssetTask {
  64211. /**
  64212. * Defines the name of the task
  64213. */
  64214. name: string;
  64215. /**
  64216. * Defines the location of the file to load
  64217. */
  64218. url: string;
  64219. /**
  64220. * Gets the loaded text string
  64221. */
  64222. text: string;
  64223. /**
  64224. * Callback called when the task is successful
  64225. */
  64226. onSuccess: (task: TextFileAssetTask) => void;
  64227. /**
  64228. * Callback called when the task is successful
  64229. */
  64230. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64231. /**
  64232. * Creates a new TextFileAssetTask object
  64233. * @param name defines the name of the task
  64234. * @param url defines the location of the file to load
  64235. */
  64236. constructor(
  64237. /**
  64238. * Defines the name of the task
  64239. */
  64240. name: string,
  64241. /**
  64242. * Defines the location of the file to load
  64243. */
  64244. url: string);
  64245. /**
  64246. * Execute the current task
  64247. * @param scene defines the scene where you want your assets to be loaded
  64248. * @param onSuccess is a callback called when the task is successfully executed
  64249. * @param onError is a callback called if an error occurs
  64250. */
  64251. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64252. }
  64253. /**
  64254. * Define a task used by AssetsManager to load binary data
  64255. */
  64256. export class BinaryFileAssetTask extends AbstractAssetTask {
  64257. /**
  64258. * Defines the name of the task
  64259. */
  64260. name: string;
  64261. /**
  64262. * Defines the location of the file to load
  64263. */
  64264. url: string;
  64265. /**
  64266. * Gets the lodaded data (as an array buffer)
  64267. */
  64268. data: ArrayBuffer;
  64269. /**
  64270. * Callback called when the task is successful
  64271. */
  64272. onSuccess: (task: BinaryFileAssetTask) => void;
  64273. /**
  64274. * Callback called when the task is successful
  64275. */
  64276. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64277. /**
  64278. * Creates a new BinaryFileAssetTask object
  64279. * @param name defines the name of the new task
  64280. * @param url defines the location of the file to load
  64281. */
  64282. constructor(
  64283. /**
  64284. * Defines the name of the task
  64285. */
  64286. name: string,
  64287. /**
  64288. * Defines the location of the file to load
  64289. */
  64290. url: string);
  64291. /**
  64292. * Execute the current task
  64293. * @param scene defines the scene where you want your assets to be loaded
  64294. * @param onSuccess is a callback called when the task is successfully executed
  64295. * @param onError is a callback called if an error occurs
  64296. */
  64297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64298. }
  64299. /**
  64300. * Define a task used by AssetsManager to load images
  64301. */
  64302. export class ImageAssetTask extends AbstractAssetTask {
  64303. /**
  64304. * Defines the name of the task
  64305. */
  64306. name: string;
  64307. /**
  64308. * Defines the location of the image to load
  64309. */
  64310. url: string;
  64311. /**
  64312. * Gets the loaded images
  64313. */
  64314. image: HTMLImageElement;
  64315. /**
  64316. * Callback called when the task is successful
  64317. */
  64318. onSuccess: (task: ImageAssetTask) => void;
  64319. /**
  64320. * Callback called when the task is successful
  64321. */
  64322. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64323. /**
  64324. * Creates a new ImageAssetTask
  64325. * @param name defines the name of the task
  64326. * @param url defines the location of the image to load
  64327. */
  64328. constructor(
  64329. /**
  64330. * Defines the name of the task
  64331. */
  64332. name: string,
  64333. /**
  64334. * Defines the location of the image to load
  64335. */
  64336. url: string);
  64337. /**
  64338. * Execute the current task
  64339. * @param scene defines the scene where you want your assets to be loaded
  64340. * @param onSuccess is a callback called when the task is successfully executed
  64341. * @param onError is a callback called if an error occurs
  64342. */
  64343. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64344. }
  64345. /**
  64346. * Defines the interface used by texture loading tasks
  64347. */
  64348. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64349. /**
  64350. * Gets the loaded texture
  64351. */
  64352. texture: TEX;
  64353. }
  64354. /**
  64355. * Define a task used by AssetsManager to load 2D textures
  64356. */
  64357. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64358. /**
  64359. * Defines the name of the task
  64360. */
  64361. name: string;
  64362. /**
  64363. * Defines the location of the file to load
  64364. */
  64365. url: string;
  64366. /**
  64367. * Defines if mipmap should not be generated (default is false)
  64368. */
  64369. noMipmap?: boolean | undefined;
  64370. /**
  64371. * Defines if texture must be inverted on Y axis (default is false)
  64372. */
  64373. invertY?: boolean | undefined;
  64374. /**
  64375. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64376. */
  64377. samplingMode: number;
  64378. /**
  64379. * Gets the loaded texture
  64380. */
  64381. texture: Texture;
  64382. /**
  64383. * Callback called when the task is successful
  64384. */
  64385. onSuccess: (task: TextureAssetTask) => void;
  64386. /**
  64387. * Callback called when the task is successful
  64388. */
  64389. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64390. /**
  64391. * Creates a new TextureAssetTask object
  64392. * @param name defines the name of the task
  64393. * @param url defines the location of the file to load
  64394. * @param noMipmap defines if mipmap should not be generated (default is false)
  64395. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64396. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64397. */
  64398. constructor(
  64399. /**
  64400. * Defines the name of the task
  64401. */
  64402. name: string,
  64403. /**
  64404. * Defines the location of the file to load
  64405. */
  64406. url: string,
  64407. /**
  64408. * Defines if mipmap should not be generated (default is false)
  64409. */
  64410. noMipmap?: boolean | undefined,
  64411. /**
  64412. * Defines if texture must be inverted on Y axis (default is false)
  64413. */
  64414. invertY?: boolean | undefined,
  64415. /**
  64416. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64417. */
  64418. samplingMode?: number);
  64419. /**
  64420. * Execute the current task
  64421. * @param scene defines the scene where you want your assets to be loaded
  64422. * @param onSuccess is a callback called when the task is successfully executed
  64423. * @param onError is a callback called if an error occurs
  64424. */
  64425. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64426. }
  64427. /**
  64428. * Define a task used by AssetsManager to load cube textures
  64429. */
  64430. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64431. /**
  64432. * Defines the name of the task
  64433. */
  64434. name: string;
  64435. /**
  64436. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64437. */
  64438. url: string;
  64439. /**
  64440. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64441. */
  64442. extensions?: string[] | undefined;
  64443. /**
  64444. * Defines if mipmaps should not be generated (default is false)
  64445. */
  64446. noMipmap?: boolean | undefined;
  64447. /**
  64448. * Defines the explicit list of files (undefined by default)
  64449. */
  64450. files?: string[] | undefined;
  64451. /**
  64452. * Gets the loaded texture
  64453. */
  64454. texture: CubeTexture;
  64455. /**
  64456. * Callback called when the task is successful
  64457. */
  64458. onSuccess: (task: CubeTextureAssetTask) => void;
  64459. /**
  64460. * Callback called when the task is successful
  64461. */
  64462. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64463. /**
  64464. * Creates a new CubeTextureAssetTask
  64465. * @param name defines the name of the task
  64466. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64467. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64468. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64469. * @param files defines the explicit list of files (undefined by default)
  64470. */
  64471. constructor(
  64472. /**
  64473. * Defines the name of the task
  64474. */
  64475. name: string,
  64476. /**
  64477. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64478. */
  64479. url: string,
  64480. /**
  64481. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64482. */
  64483. extensions?: string[] | undefined,
  64484. /**
  64485. * Defines if mipmaps should not be generated (default is false)
  64486. */
  64487. noMipmap?: boolean | undefined,
  64488. /**
  64489. * Defines the explicit list of files (undefined by default)
  64490. */
  64491. files?: string[] | undefined);
  64492. /**
  64493. * Execute the current task
  64494. * @param scene defines the scene where you want your assets to be loaded
  64495. * @param onSuccess is a callback called when the task is successfully executed
  64496. * @param onError is a callback called if an error occurs
  64497. */
  64498. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64499. }
  64500. /**
  64501. * Define a task used by AssetsManager to load HDR cube textures
  64502. */
  64503. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64504. /**
  64505. * Defines the name of the task
  64506. */
  64507. name: string;
  64508. /**
  64509. * Defines the location of the file to load
  64510. */
  64511. url: string;
  64512. /**
  64513. * Defines the desired size (the more it increases the longer the generation will be)
  64514. */
  64515. size: number;
  64516. /**
  64517. * Defines if mipmaps should not be generated (default is false)
  64518. */
  64519. noMipmap: boolean;
  64520. /**
  64521. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64522. */
  64523. generateHarmonics: boolean;
  64524. /**
  64525. * 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)
  64526. */
  64527. gammaSpace: boolean;
  64528. /**
  64529. * Internal Use Only
  64530. */
  64531. reserved: boolean;
  64532. /**
  64533. * Gets the loaded texture
  64534. */
  64535. texture: HDRCubeTexture;
  64536. /**
  64537. * Callback called when the task is successful
  64538. */
  64539. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64540. /**
  64541. * Callback called when the task is successful
  64542. */
  64543. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64544. /**
  64545. * Creates a new HDRCubeTextureAssetTask object
  64546. * @param name defines the name of the task
  64547. * @param url defines the location of the file to load
  64548. * @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.
  64549. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64550. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64551. * @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)
  64552. * @param reserved Internal use only
  64553. */
  64554. constructor(
  64555. /**
  64556. * Defines the name of the task
  64557. */
  64558. name: string,
  64559. /**
  64560. * Defines the location of the file to load
  64561. */
  64562. url: string,
  64563. /**
  64564. * Defines the desired size (the more it increases the longer the generation will be)
  64565. */
  64566. size: number,
  64567. /**
  64568. * Defines if mipmaps should not be generated (default is false)
  64569. */
  64570. noMipmap?: boolean,
  64571. /**
  64572. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64573. */
  64574. generateHarmonics?: boolean,
  64575. /**
  64576. * 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)
  64577. */
  64578. gammaSpace?: boolean,
  64579. /**
  64580. * Internal Use Only
  64581. */
  64582. reserved?: boolean);
  64583. /**
  64584. * Execute the current task
  64585. * @param scene defines the scene where you want your assets to be loaded
  64586. * @param onSuccess is a callback called when the task is successfully executed
  64587. * @param onError is a callback called if an error occurs
  64588. */
  64589. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64590. }
  64591. /**
  64592. * Define a task used by AssetsManager to load Equirectangular cube textures
  64593. */
  64594. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64595. /**
  64596. * Defines the name of the task
  64597. */
  64598. name: string;
  64599. /**
  64600. * Defines the location of the file to load
  64601. */
  64602. url: string;
  64603. /**
  64604. * Defines the desired size (the more it increases the longer the generation will be)
  64605. */
  64606. size: number;
  64607. /**
  64608. * Defines if mipmaps should not be generated (default is false)
  64609. */
  64610. noMipmap: boolean;
  64611. /**
  64612. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64613. * but the standard material would require them in Gamma space) (default is true)
  64614. */
  64615. gammaSpace: boolean;
  64616. /**
  64617. * Gets the loaded texture
  64618. */
  64619. texture: EquiRectangularCubeTexture;
  64620. /**
  64621. * Callback called when the task is successful
  64622. */
  64623. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64624. /**
  64625. * Callback called when the task is successful
  64626. */
  64627. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64628. /**
  64629. * Creates a new EquiRectangularCubeTextureAssetTask object
  64630. * @param name defines the name of the task
  64631. * @param url defines the location of the file to load
  64632. * @param size defines the desired size (the more it increases the longer the generation will be)
  64633. * If the size is omitted this implies you are using a preprocessed cubemap.
  64634. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64635. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64636. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64637. * (default is true)
  64638. */
  64639. constructor(
  64640. /**
  64641. * Defines the name of the task
  64642. */
  64643. name: string,
  64644. /**
  64645. * Defines the location of the file to load
  64646. */
  64647. url: string,
  64648. /**
  64649. * Defines the desired size (the more it increases the longer the generation will be)
  64650. */
  64651. size: number,
  64652. /**
  64653. * Defines if mipmaps should not be generated (default is false)
  64654. */
  64655. noMipmap?: boolean,
  64656. /**
  64657. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64658. * but the standard material would require them in Gamma space) (default is true)
  64659. */
  64660. gammaSpace?: boolean);
  64661. /**
  64662. * Execute the current task
  64663. * @param scene defines the scene where you want your assets to be loaded
  64664. * @param onSuccess is a callback called when the task is successfully executed
  64665. * @param onError is a callback called if an error occurs
  64666. */
  64667. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64668. }
  64669. /**
  64670. * This class can be used to easily import assets into a scene
  64671. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64672. */
  64673. export class AssetsManager {
  64674. private _scene;
  64675. private _isLoading;
  64676. protected _tasks: AbstractAssetTask[];
  64677. protected _waitingTasksCount: number;
  64678. protected _totalTasksCount: number;
  64679. /**
  64680. * Callback called when all tasks are processed
  64681. */
  64682. onFinish: (tasks: AbstractAssetTask[]) => void;
  64683. /**
  64684. * Callback called when a task is successful
  64685. */
  64686. onTaskSuccess: (task: AbstractAssetTask) => void;
  64687. /**
  64688. * Callback called when a task had an error
  64689. */
  64690. onTaskError: (task: AbstractAssetTask) => void;
  64691. /**
  64692. * Callback called when a task is done (whatever the result is)
  64693. */
  64694. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64695. /**
  64696. * Observable called when all tasks are processed
  64697. */
  64698. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64699. /**
  64700. * Observable called when a task had an error
  64701. */
  64702. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64703. /**
  64704. * Observable called when all tasks were executed
  64705. */
  64706. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64707. /**
  64708. * Observable called when a task is done (whatever the result is)
  64709. */
  64710. onProgressObservable: Observable<IAssetsProgressEvent>;
  64711. /**
  64712. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64713. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64714. */
  64715. useDefaultLoadingScreen: boolean;
  64716. /**
  64717. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64718. * when all assets have been downloaded.
  64719. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64720. */
  64721. autoHideLoadingUI: boolean;
  64722. /**
  64723. * Creates a new AssetsManager
  64724. * @param scene defines the scene to work on
  64725. */
  64726. constructor(scene: Scene);
  64727. /**
  64728. * Add a MeshAssetTask to the list of active tasks
  64729. * @param taskName defines the name of the new task
  64730. * @param meshesNames defines the name of meshes to load
  64731. * @param rootUrl defines the root url to use to locate files
  64732. * @param sceneFilename defines the filename of the scene file
  64733. * @returns a new MeshAssetTask object
  64734. */
  64735. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64736. /**
  64737. * Add a TextFileAssetTask to the list of active tasks
  64738. * @param taskName defines the name of the new task
  64739. * @param url defines the url of the file to load
  64740. * @returns a new TextFileAssetTask object
  64741. */
  64742. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64743. /**
  64744. * Add a BinaryFileAssetTask to the list of active tasks
  64745. * @param taskName defines the name of the new task
  64746. * @param url defines the url of the file to load
  64747. * @returns a new BinaryFileAssetTask object
  64748. */
  64749. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64750. /**
  64751. * Add a ImageAssetTask to the list of active tasks
  64752. * @param taskName defines the name of the new task
  64753. * @param url defines the url of the file to load
  64754. * @returns a new ImageAssetTask object
  64755. */
  64756. addImageTask(taskName: string, url: string): ImageAssetTask;
  64757. /**
  64758. * Add a TextureAssetTask to the list of active tasks
  64759. * @param taskName defines the name of the new task
  64760. * @param url defines the url of the file to load
  64761. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64762. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64763. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64764. * @returns a new TextureAssetTask object
  64765. */
  64766. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64767. /**
  64768. * Add a CubeTextureAssetTask to the list of active tasks
  64769. * @param taskName defines the name of the new task
  64770. * @param url defines the url of the file to load
  64771. * @param extensions defines the extension to use to load the cube map (can be null)
  64772. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64773. * @param files defines the list of files to load (can be null)
  64774. * @returns a new CubeTextureAssetTask object
  64775. */
  64776. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64777. /**
  64778. *
  64779. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64780. * @param taskName defines the name of the new task
  64781. * @param url defines the url of the file to load
  64782. * @param size defines the size you want for the cubemap (can be null)
  64783. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64784. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64785. * @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)
  64786. * @param reserved Internal use only
  64787. * @returns a new HDRCubeTextureAssetTask object
  64788. */
  64789. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64790. /**
  64791. *
  64792. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64793. * @param taskName defines the name of the new task
  64794. * @param url defines the url of the file to load
  64795. * @param size defines the size you want for the cubemap (can be null)
  64796. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64797. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64798. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64799. * @returns a new EquiRectangularCubeTextureAssetTask object
  64800. */
  64801. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64802. /**
  64803. * Remove a task from the assets manager.
  64804. * @param task the task to remove
  64805. */
  64806. removeTask(task: AbstractAssetTask): void;
  64807. private _decreaseWaitingTasksCount;
  64808. private _runTask;
  64809. /**
  64810. * Reset the AssetsManager and remove all tasks
  64811. * @return the current instance of the AssetsManager
  64812. */
  64813. reset(): AssetsManager;
  64814. /**
  64815. * Start the loading process
  64816. * @return the current instance of the AssetsManager
  64817. */
  64818. load(): AssetsManager;
  64819. /**
  64820. * Start the loading process as an async operation
  64821. * @return a promise returning the list of failed tasks
  64822. */
  64823. loadAsync(): Promise<void>;
  64824. }
  64825. }
  64826. declare module "babylonjs/Misc/deferred" {
  64827. /**
  64828. * Wrapper class for promise with external resolve and reject.
  64829. */
  64830. export class Deferred<T> {
  64831. /**
  64832. * The promise associated with this deferred object.
  64833. */
  64834. readonly promise: Promise<T>;
  64835. private _resolve;
  64836. private _reject;
  64837. /**
  64838. * The resolve method of the promise associated with this deferred object.
  64839. */
  64840. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64841. /**
  64842. * The reject method of the promise associated with this deferred object.
  64843. */
  64844. readonly reject: (reason?: any) => void;
  64845. /**
  64846. * Constructor for this deferred object.
  64847. */
  64848. constructor();
  64849. }
  64850. }
  64851. declare module "babylonjs/Misc/meshExploder" {
  64852. import { Mesh } from "babylonjs/Meshes/mesh";
  64853. /**
  64854. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64855. */
  64856. export class MeshExploder {
  64857. private _centerMesh;
  64858. private _meshes;
  64859. private _meshesOrigins;
  64860. private _toCenterVectors;
  64861. private _scaledDirection;
  64862. private _newPosition;
  64863. private _centerPosition;
  64864. /**
  64865. * Explodes meshes from a center mesh.
  64866. * @param meshes The meshes to explode.
  64867. * @param centerMesh The mesh to be center of explosion.
  64868. */
  64869. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64870. private _setCenterMesh;
  64871. /**
  64872. * Get class name
  64873. * @returns "MeshExploder"
  64874. */
  64875. getClassName(): string;
  64876. /**
  64877. * "Exploded meshes"
  64878. * @returns Array of meshes with the centerMesh at index 0.
  64879. */
  64880. getMeshes(): Array<Mesh>;
  64881. /**
  64882. * Explodes meshes giving a specific direction
  64883. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64884. */
  64885. explode(direction?: number): void;
  64886. }
  64887. }
  64888. declare module "babylonjs/Misc/filesInput" {
  64889. import { Engine } from "babylonjs/Engines/engine";
  64890. import { Scene } from "babylonjs/scene";
  64891. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64892. /**
  64893. * Class used to help managing file picking and drag'n'drop
  64894. */
  64895. export class FilesInput {
  64896. /**
  64897. * List of files ready to be loaded
  64898. */
  64899. static readonly FilesToLoad: {
  64900. [key: string]: File;
  64901. };
  64902. /**
  64903. * Callback called when a file is processed
  64904. */
  64905. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64906. private _engine;
  64907. private _currentScene;
  64908. private _sceneLoadedCallback;
  64909. private _progressCallback;
  64910. private _additionalRenderLoopLogicCallback;
  64911. private _textureLoadingCallback;
  64912. private _startingProcessingFilesCallback;
  64913. private _onReloadCallback;
  64914. private _errorCallback;
  64915. private _elementToMonitor;
  64916. private _sceneFileToLoad;
  64917. private _filesToLoad;
  64918. /**
  64919. * Creates a new FilesInput
  64920. * @param engine defines the rendering engine
  64921. * @param scene defines the hosting scene
  64922. * @param sceneLoadedCallback callback called when scene is loaded
  64923. * @param progressCallback callback called to track progress
  64924. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64925. * @param textureLoadingCallback callback called when a texture is loading
  64926. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64927. * @param onReloadCallback callback called when a reload is requested
  64928. * @param errorCallback callback call if an error occurs
  64929. */
  64930. 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);
  64931. private _dragEnterHandler;
  64932. private _dragOverHandler;
  64933. private _dropHandler;
  64934. /**
  64935. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64936. * @param elementToMonitor defines the DOM element to track
  64937. */
  64938. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64939. /**
  64940. * Release all associated resources
  64941. */
  64942. dispose(): void;
  64943. private renderFunction;
  64944. private drag;
  64945. private drop;
  64946. private _traverseFolder;
  64947. private _processFiles;
  64948. /**
  64949. * Load files from a drop event
  64950. * @param event defines the drop event to use as source
  64951. */
  64952. loadFiles(event: any): void;
  64953. private _processReload;
  64954. /**
  64955. * Reload the current scene from the loaded files
  64956. */
  64957. reload(): void;
  64958. }
  64959. }
  64960. declare module "babylonjs/Misc/HighDynamicRange/index" {
  64961. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  64962. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  64963. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64964. }
  64965. declare module "babylonjs/Misc/sceneOptimizer" {
  64966. import { Scene, IDisposable } from "babylonjs/scene";
  64967. import { Observable } from "babylonjs/Misc/observable";
  64968. /**
  64969. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64970. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64971. */
  64972. export class SceneOptimization {
  64973. /**
  64974. * Defines the priority of this optimization (0 by default which means first in the list)
  64975. */
  64976. priority: number;
  64977. /**
  64978. * Gets a string describing the action executed by the current optimization
  64979. * @returns description string
  64980. */
  64981. getDescription(): string;
  64982. /**
  64983. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64984. * @param scene defines the current scene where to apply this optimization
  64985. * @param optimizer defines the current optimizer
  64986. * @returns true if everything that can be done was applied
  64987. */
  64988. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64989. /**
  64990. * Creates the SceneOptimization object
  64991. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64992. * @param desc defines the description associated with the optimization
  64993. */
  64994. constructor(
  64995. /**
  64996. * Defines the priority of this optimization (0 by default which means first in the list)
  64997. */
  64998. priority?: number);
  64999. }
  65000. /**
  65001. * Defines an optimization used to reduce the size of render target textures
  65002. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65003. */
  65004. export class TextureOptimization extends SceneOptimization {
  65005. /**
  65006. * Defines the priority of this optimization (0 by default which means first in the list)
  65007. */
  65008. priority: number;
  65009. /**
  65010. * 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
  65011. */
  65012. maximumSize: number;
  65013. /**
  65014. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65015. */
  65016. step: number;
  65017. /**
  65018. * Gets a string describing the action executed by the current optimization
  65019. * @returns description string
  65020. */
  65021. getDescription(): string;
  65022. /**
  65023. * Creates the TextureOptimization object
  65024. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65025. * @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
  65026. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65027. */
  65028. constructor(
  65029. /**
  65030. * Defines the priority of this optimization (0 by default which means first in the list)
  65031. */
  65032. priority?: number,
  65033. /**
  65034. * 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
  65035. */
  65036. maximumSize?: number,
  65037. /**
  65038. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65039. */
  65040. step?: number);
  65041. /**
  65042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65043. * @param scene defines the current scene where to apply this optimization
  65044. * @param optimizer defines the current optimizer
  65045. * @returns true if everything that can be done was applied
  65046. */
  65047. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65048. }
  65049. /**
  65050. * Defines an optimization used to increase or decrease the rendering resolution
  65051. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65052. */
  65053. export class HardwareScalingOptimization extends SceneOptimization {
  65054. /**
  65055. * Defines the priority of this optimization (0 by default which means first in the list)
  65056. */
  65057. priority: number;
  65058. /**
  65059. * Defines the maximum scale to use (2 by default)
  65060. */
  65061. maximumScale: number;
  65062. /**
  65063. * Defines the step to use between two passes (0.5 by default)
  65064. */
  65065. step: number;
  65066. private _currentScale;
  65067. private _directionOffset;
  65068. /**
  65069. * Gets a string describing the action executed by the current optimization
  65070. * @return description string
  65071. */
  65072. getDescription(): string;
  65073. /**
  65074. * Creates the HardwareScalingOptimization object
  65075. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65076. * @param maximumScale defines the maximum scale to use (2 by default)
  65077. * @param step defines the step to use between two passes (0.5 by default)
  65078. */
  65079. constructor(
  65080. /**
  65081. * Defines the priority of this optimization (0 by default which means first in the list)
  65082. */
  65083. priority?: number,
  65084. /**
  65085. * Defines the maximum scale to use (2 by default)
  65086. */
  65087. maximumScale?: number,
  65088. /**
  65089. * Defines the step to use between two passes (0.5 by default)
  65090. */
  65091. step?: number);
  65092. /**
  65093. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65094. * @param scene defines the current scene where to apply this optimization
  65095. * @param optimizer defines the current optimizer
  65096. * @returns true if everything that can be done was applied
  65097. */
  65098. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65099. }
  65100. /**
  65101. * Defines an optimization used to remove shadows
  65102. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65103. */
  65104. export class ShadowsOptimization extends SceneOptimization {
  65105. /**
  65106. * Gets a string describing the action executed by the current optimization
  65107. * @return description string
  65108. */
  65109. getDescription(): string;
  65110. /**
  65111. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65112. * @param scene defines the current scene where to apply this optimization
  65113. * @param optimizer defines the current optimizer
  65114. * @returns true if everything that can be done was applied
  65115. */
  65116. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65117. }
  65118. /**
  65119. * Defines an optimization used to turn post-processes off
  65120. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65121. */
  65122. export class PostProcessesOptimization extends SceneOptimization {
  65123. /**
  65124. * Gets a string describing the action executed by the current optimization
  65125. * @return description string
  65126. */
  65127. getDescription(): string;
  65128. /**
  65129. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65130. * @param scene defines the current scene where to apply this optimization
  65131. * @param optimizer defines the current optimizer
  65132. * @returns true if everything that can be done was applied
  65133. */
  65134. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65135. }
  65136. /**
  65137. * Defines an optimization used to turn lens flares off
  65138. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65139. */
  65140. export class LensFlaresOptimization extends SceneOptimization {
  65141. /**
  65142. * Gets a string describing the action executed by the current optimization
  65143. * @return description string
  65144. */
  65145. getDescription(): string;
  65146. /**
  65147. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65148. * @param scene defines the current scene where to apply this optimization
  65149. * @param optimizer defines the current optimizer
  65150. * @returns true if everything that can be done was applied
  65151. */
  65152. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65153. }
  65154. /**
  65155. * Defines an optimization based on user defined callback.
  65156. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65157. */
  65158. export class CustomOptimization extends SceneOptimization {
  65159. /**
  65160. * Callback called to apply the custom optimization.
  65161. */
  65162. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65163. /**
  65164. * Callback called to get custom description
  65165. */
  65166. onGetDescription: () => string;
  65167. /**
  65168. * Gets a string describing the action executed by the current optimization
  65169. * @returns description string
  65170. */
  65171. getDescription(): string;
  65172. /**
  65173. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65174. * @param scene defines the current scene where to apply this optimization
  65175. * @param optimizer defines the current optimizer
  65176. * @returns true if everything that can be done was applied
  65177. */
  65178. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65179. }
  65180. /**
  65181. * Defines an optimization used to turn particles off
  65182. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65183. */
  65184. export class ParticlesOptimization extends SceneOptimization {
  65185. /**
  65186. * Gets a string describing the action executed by the current optimization
  65187. * @return description string
  65188. */
  65189. getDescription(): string;
  65190. /**
  65191. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65192. * @param scene defines the current scene where to apply this optimization
  65193. * @param optimizer defines the current optimizer
  65194. * @returns true if everything that can be done was applied
  65195. */
  65196. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65197. }
  65198. /**
  65199. * Defines an optimization used to turn render targets off
  65200. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65201. */
  65202. export class RenderTargetsOptimization extends SceneOptimization {
  65203. /**
  65204. * Gets a string describing the action executed by the current optimization
  65205. * @return description string
  65206. */
  65207. getDescription(): string;
  65208. /**
  65209. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65210. * @param scene defines the current scene where to apply this optimization
  65211. * @param optimizer defines the current optimizer
  65212. * @returns true if everything that can be done was applied
  65213. */
  65214. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65215. }
  65216. /**
  65217. * Defines an optimization used to merge meshes with compatible materials
  65218. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65219. */
  65220. export class MergeMeshesOptimization extends SceneOptimization {
  65221. private static _UpdateSelectionTree;
  65222. /**
  65223. * Gets or sets a boolean which defines if optimization octree has to be updated
  65224. */
  65225. /**
  65226. * Gets or sets a boolean which defines if optimization octree has to be updated
  65227. */
  65228. static UpdateSelectionTree: boolean;
  65229. /**
  65230. * Gets a string describing the action executed by the current optimization
  65231. * @return description string
  65232. */
  65233. getDescription(): string;
  65234. private _canBeMerged;
  65235. /**
  65236. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65237. * @param scene defines the current scene where to apply this optimization
  65238. * @param optimizer defines the current optimizer
  65239. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65240. * @returns true if everything that can be done was applied
  65241. */
  65242. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65243. }
  65244. /**
  65245. * Defines a list of options used by SceneOptimizer
  65246. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65247. */
  65248. export class SceneOptimizerOptions {
  65249. /**
  65250. * Defines the target frame rate to reach (60 by default)
  65251. */
  65252. targetFrameRate: number;
  65253. /**
  65254. * Defines the interval between two checkes (2000ms by default)
  65255. */
  65256. trackerDuration: number;
  65257. /**
  65258. * Gets the list of optimizations to apply
  65259. */
  65260. optimizations: SceneOptimization[];
  65261. /**
  65262. * Creates a new list of options used by SceneOptimizer
  65263. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65264. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65265. */
  65266. constructor(
  65267. /**
  65268. * Defines the target frame rate to reach (60 by default)
  65269. */
  65270. targetFrameRate?: number,
  65271. /**
  65272. * Defines the interval between two checkes (2000ms by default)
  65273. */
  65274. trackerDuration?: number);
  65275. /**
  65276. * Add a new optimization
  65277. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65278. * @returns the current SceneOptimizerOptions
  65279. */
  65280. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65281. /**
  65282. * Add a new custom optimization
  65283. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65284. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65285. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65286. * @returns the current SceneOptimizerOptions
  65287. */
  65288. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65289. /**
  65290. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65291. * @param targetFrameRate defines the target frame rate (60 by default)
  65292. * @returns a SceneOptimizerOptions object
  65293. */
  65294. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65295. /**
  65296. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65297. * @param targetFrameRate defines the target frame rate (60 by default)
  65298. * @returns a SceneOptimizerOptions object
  65299. */
  65300. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65301. /**
  65302. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65303. * @param targetFrameRate defines the target frame rate (60 by default)
  65304. * @returns a SceneOptimizerOptions object
  65305. */
  65306. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65307. }
  65308. /**
  65309. * Class used to run optimizations in order to reach a target frame rate
  65310. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65311. */
  65312. export class SceneOptimizer implements IDisposable {
  65313. private _isRunning;
  65314. private _options;
  65315. private _scene;
  65316. private _currentPriorityLevel;
  65317. private _targetFrameRate;
  65318. private _trackerDuration;
  65319. private _currentFrameRate;
  65320. private _sceneDisposeObserver;
  65321. private _improvementMode;
  65322. /**
  65323. * Defines an observable called when the optimizer reaches the target frame rate
  65324. */
  65325. onSuccessObservable: Observable<SceneOptimizer>;
  65326. /**
  65327. * Defines an observable called when the optimizer enables an optimization
  65328. */
  65329. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65330. /**
  65331. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65332. */
  65333. onFailureObservable: Observable<SceneOptimizer>;
  65334. /**
  65335. * Gets a boolean indicating if the optimizer is in improvement mode
  65336. */
  65337. readonly isInImprovementMode: boolean;
  65338. /**
  65339. * Gets the current priority level (0 at start)
  65340. */
  65341. readonly currentPriorityLevel: number;
  65342. /**
  65343. * Gets the current frame rate checked by the SceneOptimizer
  65344. */
  65345. readonly currentFrameRate: number;
  65346. /**
  65347. * Gets or sets the current target frame rate (60 by default)
  65348. */
  65349. /**
  65350. * Gets or sets the current target frame rate (60 by default)
  65351. */
  65352. targetFrameRate: number;
  65353. /**
  65354. * Gets or sets the current interval between two checks (every 2000ms by default)
  65355. */
  65356. /**
  65357. * Gets or sets the current interval between two checks (every 2000ms by default)
  65358. */
  65359. trackerDuration: number;
  65360. /**
  65361. * Gets the list of active optimizations
  65362. */
  65363. readonly optimizations: SceneOptimization[];
  65364. /**
  65365. * Creates a new SceneOptimizer
  65366. * @param scene defines the scene to work on
  65367. * @param options defines the options to use with the SceneOptimizer
  65368. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65369. * @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)
  65370. */
  65371. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65372. /**
  65373. * Stops the current optimizer
  65374. */
  65375. stop(): void;
  65376. /**
  65377. * Reset the optimizer to initial step (current priority level = 0)
  65378. */
  65379. reset(): void;
  65380. /**
  65381. * Start the optimizer. By default it will try to reach a specific framerate
  65382. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65383. */
  65384. start(): void;
  65385. private _checkCurrentState;
  65386. /**
  65387. * Release all resources
  65388. */
  65389. dispose(): void;
  65390. /**
  65391. * Helper function to create a SceneOptimizer with one single line of code
  65392. * @param scene defines the scene to work on
  65393. * @param options defines the options to use with the SceneOptimizer
  65394. * @param onSuccess defines a callback to call on success
  65395. * @param onFailure defines a callback to call on failure
  65396. * @returns the new SceneOptimizer object
  65397. */
  65398. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65399. }
  65400. }
  65401. declare module "babylonjs/Misc/sceneSerializer" {
  65402. import { Scene } from "babylonjs/scene";
  65403. /**
  65404. * Class used to serialize a scene into a string
  65405. */
  65406. export class SceneSerializer {
  65407. /**
  65408. * Clear cache used by a previous serialization
  65409. */
  65410. static ClearCache(): void;
  65411. /**
  65412. * Serialize a scene into a JSON compatible object
  65413. * @param scene defines the scene to serialize
  65414. * @returns a JSON compatible object
  65415. */
  65416. static Serialize(scene: Scene): any;
  65417. /**
  65418. * Serialize a mesh into a JSON compatible object
  65419. * @param toSerialize defines the mesh to serialize
  65420. * @param withParents defines if parents must be serialized as well
  65421. * @param withChildren defines if children must be serialized as well
  65422. * @returns a JSON compatible object
  65423. */
  65424. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65425. }
  65426. }
  65427. declare module "babylonjs/Misc/textureTools" {
  65428. import { Texture } from "babylonjs/Materials/Textures/texture";
  65429. /**
  65430. * Class used to host texture specific utilities
  65431. */
  65432. export class TextureTools {
  65433. /**
  65434. * Uses the GPU to create a copy texture rescaled at a given size
  65435. * @param texture Texture to copy from
  65436. * @param width defines the desired width
  65437. * @param height defines the desired height
  65438. * @param useBilinearMode defines if bilinear mode has to be used
  65439. * @return the generated texture
  65440. */
  65441. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65442. }
  65443. }
  65444. declare module "babylonjs/Misc/videoRecorder" {
  65445. import { Nullable } from "babylonjs/types";
  65446. import { Engine } from "babylonjs/Engines/engine";
  65447. /**
  65448. * This represents the different options available for the video capture.
  65449. */
  65450. export interface VideoRecorderOptions {
  65451. /** Defines the mime type of the video. */
  65452. mimeType: string;
  65453. /** Defines the FPS the video should be recorded at. */
  65454. fps: number;
  65455. /** Defines the chunk size for the recording data. */
  65456. recordChunckSize: number;
  65457. /** The audio tracks to attach to the recording. */
  65458. audioTracks?: MediaStreamTrack[];
  65459. }
  65460. /**
  65461. * This can help with recording videos from BabylonJS.
  65462. * This is based on the available WebRTC functionalities of the browser.
  65463. *
  65464. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65465. */
  65466. export class VideoRecorder {
  65467. private static readonly _defaultOptions;
  65468. /**
  65469. * Returns whether or not the VideoRecorder is available in your browser.
  65470. * @param engine Defines the Babylon Engine.
  65471. * @returns true if supported otherwise false.
  65472. */
  65473. static IsSupported(engine: Engine): boolean;
  65474. private readonly _options;
  65475. private _canvas;
  65476. private _mediaRecorder;
  65477. private _recordedChunks;
  65478. private _fileName;
  65479. private _resolve;
  65480. private _reject;
  65481. /**
  65482. * True when a recording is already in progress.
  65483. */
  65484. readonly isRecording: boolean;
  65485. /**
  65486. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65487. * @param engine Defines the BabylonJS Engine you wish to record.
  65488. * @param options Defines options that can be used to customize the capture.
  65489. */
  65490. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65491. /**
  65492. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65493. */
  65494. stopRecording(): void;
  65495. /**
  65496. * Starts recording the canvas for a max duration specified in parameters.
  65497. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65498. * If null no automatic download will start and you can rely on the promise to get the data back.
  65499. * @param maxDuration Defines the maximum recording time in seconds.
  65500. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65501. * @return A promise callback at the end of the recording with the video data in Blob.
  65502. */
  65503. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65504. /**
  65505. * Releases internal resources used during the recording.
  65506. */
  65507. dispose(): void;
  65508. private _handleDataAvailable;
  65509. private _handleError;
  65510. private _handleStop;
  65511. }
  65512. }
  65513. declare module "babylonjs/Misc/screenshotTools" {
  65514. import { Camera } from "babylonjs/Cameras/camera";
  65515. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  65516. import { Engine } from "babylonjs/Engines/engine";
  65517. /**
  65518. * Class containing a set of static utilities functions for screenshots
  65519. */
  65520. export class ScreenshotTools {
  65521. /**
  65522. * Captures a screenshot of the current rendering
  65523. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65524. * @param engine defines the rendering engine
  65525. * @param camera defines the source camera
  65526. * @param size This parameter can be set to a single number or to an object with the
  65527. * following (optional) properties: precision, width, height. If a single number is passed,
  65528. * it will be used for both width and height. If an object is passed, the screenshot size
  65529. * will be derived from the parameters. The precision property is a multiplier allowing
  65530. * rendering at a higher or lower resolution
  65531. * @param successCallback defines the callback receives a single parameter which contains the
  65532. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65533. * src parameter of an <img> to display it
  65534. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65535. * Check your browser for supported MIME types
  65536. */
  65537. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65538. /**
  65539. * Captures a screenshot of the current rendering
  65540. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65541. * @param engine defines the rendering engine
  65542. * @param camera defines the source camera
  65543. * @param size This parameter can be set to a single number or to an object with the
  65544. * following (optional) properties: precision, width, height. If a single number is passed,
  65545. * it will be used for both width and height. If an object is passed, the screenshot size
  65546. * will be derived from the parameters. The precision property is a multiplier allowing
  65547. * rendering at a higher or lower resolution
  65548. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65549. * Check your browser for supported MIME types
  65550. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65551. * to the src parameter of an <img> to display it
  65552. */
  65553. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65554. /**
  65555. * Generates an image screenshot from the specified camera.
  65556. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65557. * @param engine The engine to use for rendering
  65558. * @param camera The camera to use for rendering
  65559. * @param size This parameter can be set to a single number or to an object with the
  65560. * following (optional) properties: precision, width, height. If a single number is passed,
  65561. * it will be used for both width and height. If an object is passed, the screenshot size
  65562. * will be derived from the parameters. The precision property is a multiplier allowing
  65563. * rendering at a higher or lower resolution
  65564. * @param successCallback The callback receives a single parameter which contains the
  65565. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65566. * src parameter of an <img> to display it
  65567. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65568. * Check your browser for supported MIME types
  65569. * @param samples Texture samples (default: 1)
  65570. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65571. * @param fileName A name for for the downloaded file.
  65572. */
  65573. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65574. /**
  65575. * Generates an image screenshot from the specified camera.
  65576. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65577. * @param engine The engine to use for rendering
  65578. * @param camera The camera to use for rendering
  65579. * @param size This parameter can be set to a single number or to an object with the
  65580. * following (optional) properties: precision, width, height. If a single number is passed,
  65581. * it will be used for both width and height. If an object is passed, the screenshot size
  65582. * will be derived from the parameters. The precision property is a multiplier allowing
  65583. * rendering at a higher or lower resolution
  65584. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65585. * Check your browser for supported MIME types
  65586. * @param samples Texture samples (default: 1)
  65587. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65588. * @param fileName A name for for the downloaded file.
  65589. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65590. * to the src parameter of an <img> to display it
  65591. */
  65592. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65593. /**
  65594. * Gets height and width for screenshot size
  65595. * @private
  65596. */
  65597. private static _getScreenshotSize;
  65598. }
  65599. }
  65600. declare module "babylonjs/Misc/index" {
  65601. export * from "babylonjs/Misc/andOrNotEvaluator";
  65602. export * from "babylonjs/Misc/assetsManager";
  65603. export * from "babylonjs/Misc/dds";
  65604. export * from "babylonjs/Misc/decorators";
  65605. export * from "babylonjs/Misc/deferred";
  65606. export * from "babylonjs/Misc/environmentTextureTools";
  65607. export * from "babylonjs/Misc/meshExploder";
  65608. export * from "babylonjs/Misc/filesInput";
  65609. export * from "babylonjs/Misc/HighDynamicRange/index";
  65610. export * from "babylonjs/Misc/khronosTextureContainer";
  65611. export * from "babylonjs/Misc/observable";
  65612. export * from "babylonjs/Misc/performanceMonitor";
  65613. export * from "babylonjs/Misc/promise";
  65614. export * from "babylonjs/Misc/sceneOptimizer";
  65615. export * from "babylonjs/Misc/sceneSerializer";
  65616. export * from "babylonjs/Misc/smartArray";
  65617. export * from "babylonjs/Misc/stringDictionary";
  65618. export * from "babylonjs/Misc/tags";
  65619. export * from "babylonjs/Misc/textureTools";
  65620. export * from "babylonjs/Misc/tga";
  65621. export * from "babylonjs/Misc/tools";
  65622. export * from "babylonjs/Misc/videoRecorder";
  65623. export * from "babylonjs/Misc/virtualJoystick";
  65624. export * from "babylonjs/Misc/workerPool";
  65625. export * from "babylonjs/Misc/logger";
  65626. export * from "babylonjs/Misc/typeStore";
  65627. export * from "babylonjs/Misc/filesInputStore";
  65628. export * from "babylonjs/Misc/deepCopier";
  65629. export * from "babylonjs/Misc/pivotTools";
  65630. export * from "babylonjs/Misc/precisionDate";
  65631. export * from "babylonjs/Misc/screenshotTools";
  65632. export * from "babylonjs/Misc/typeStore";
  65633. export * from "babylonjs/Misc/webRequest";
  65634. export * from "babylonjs/Misc/iInspectable";
  65635. export * from "babylonjs/Misc/brdfTextureTools";
  65636. export * from "babylonjs/Misc/rgbdTextureTools";
  65637. export * from "babylonjs/Misc/gradients";
  65638. export * from "babylonjs/Misc/perfCounter";
  65639. export * from "babylonjs/Misc/fileRequest";
  65640. export * from "babylonjs/Misc/customAnimationFrameRequester";
  65641. export * from "babylonjs/Misc/retryStrategy";
  65642. export * from "babylonjs/Misc/loadFileError";
  65643. }
  65644. declare module "babylonjs/index" {
  65645. export * from "babylonjs/abstractScene";
  65646. export * from "babylonjs/Actions/index";
  65647. export * from "babylonjs/Animations/index";
  65648. export * from "babylonjs/assetContainer";
  65649. export * from "babylonjs/Audio/index";
  65650. export * from "babylonjs/Behaviors/index";
  65651. export * from "babylonjs/Bones/index";
  65652. export * from "babylonjs/Cameras/index";
  65653. export * from "babylonjs/Collisions/index";
  65654. export * from "babylonjs/Culling/index";
  65655. export * from "babylonjs/Debug/index";
  65656. export * from "babylonjs/Engines/index";
  65657. export * from "babylonjs/Events/index";
  65658. export * from "babylonjs/Gamepads/index";
  65659. export * from "babylonjs/Gizmos/index";
  65660. export * from "babylonjs/Helpers/index";
  65661. export * from "babylonjs/Instrumentation/index";
  65662. export * from "babylonjs/Layers/index";
  65663. export * from "babylonjs/LensFlares/index";
  65664. export * from "babylonjs/Lights/index";
  65665. export * from "babylonjs/Loading/index";
  65666. export * from "babylonjs/Materials/index";
  65667. export * from "babylonjs/Maths/index";
  65668. export * from "babylonjs/Meshes/index";
  65669. export * from "babylonjs/Morph/index";
  65670. export * from "babylonjs/Navigation/index";
  65671. export * from "babylonjs/node";
  65672. export * from "babylonjs/Offline/index";
  65673. export * from "babylonjs/Particles/index";
  65674. export * from "babylonjs/Physics/index";
  65675. export * from "babylonjs/PostProcesses/index";
  65676. export * from "babylonjs/Probes/index";
  65677. export * from "babylonjs/Rendering/index";
  65678. export * from "babylonjs/scene";
  65679. export * from "babylonjs/sceneComponent";
  65680. export * from "babylonjs/Sprites/index";
  65681. export * from "babylonjs/States/index";
  65682. export * from "babylonjs/Misc/index";
  65683. export * from "babylonjs/types";
  65684. }
  65685. declare module "babylonjs/Animations/pathCursor" {
  65686. import { Vector3 } from "babylonjs/Maths/math.vector";
  65687. import { Path2 } from "babylonjs/Maths/math.path";
  65688. /**
  65689. * A cursor which tracks a point on a path
  65690. */
  65691. export class PathCursor {
  65692. private path;
  65693. /**
  65694. * Stores path cursor callbacks for when an onchange event is triggered
  65695. */
  65696. private _onchange;
  65697. /**
  65698. * The value of the path cursor
  65699. */
  65700. value: number;
  65701. /**
  65702. * The animation array of the path cursor
  65703. */
  65704. animations: Animation[];
  65705. /**
  65706. * Initializes the path cursor
  65707. * @param path The path to track
  65708. */
  65709. constructor(path: Path2);
  65710. /**
  65711. * Gets the cursor point on the path
  65712. * @returns A point on the path cursor at the cursor location
  65713. */
  65714. getPoint(): Vector3;
  65715. /**
  65716. * Moves the cursor ahead by the step amount
  65717. * @param step The amount to move the cursor forward
  65718. * @returns This path cursor
  65719. */
  65720. moveAhead(step?: number): PathCursor;
  65721. /**
  65722. * Moves the cursor behind by the step amount
  65723. * @param step The amount to move the cursor back
  65724. * @returns This path cursor
  65725. */
  65726. moveBack(step?: number): PathCursor;
  65727. /**
  65728. * Moves the cursor by the step amount
  65729. * If the step amount is greater than one, an exception is thrown
  65730. * @param step The amount to move the cursor
  65731. * @returns This path cursor
  65732. */
  65733. move(step: number): PathCursor;
  65734. /**
  65735. * Ensures that the value is limited between zero and one
  65736. * @returns This path cursor
  65737. */
  65738. private ensureLimits;
  65739. /**
  65740. * Runs onchange callbacks on change (used by the animation engine)
  65741. * @returns This path cursor
  65742. */
  65743. private raiseOnChange;
  65744. /**
  65745. * Executes a function on change
  65746. * @param f A path cursor onchange callback
  65747. * @returns This path cursor
  65748. */
  65749. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65750. }
  65751. }
  65752. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  65753. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  65754. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  65755. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  65756. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  65757. }
  65758. declare module "babylonjs/Engines/Processors/Expressions/index" {
  65759. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  65760. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  65761. }
  65762. declare module "babylonjs/Engines/Processors/index" {
  65763. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  65764. export * from "babylonjs/Engines/Processors/Expressions/index";
  65765. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  65766. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  65767. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  65768. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  65769. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  65770. export * from "babylonjs/Engines/Processors/shaderProcessor";
  65771. }
  65772. declare module "babylonjs/Legacy/legacy" {
  65773. import * as Babylon from "babylonjs/index";
  65774. export * from "babylonjs/index";
  65775. }
  65776. declare module "babylonjs/Shaders/blur.fragment" {
  65777. /** @hidden */
  65778. export var blurPixelShader: {
  65779. name: string;
  65780. shader: string;
  65781. };
  65782. }
  65783. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  65784. /** @hidden */
  65785. export var pointCloudVertexDeclaration: {
  65786. name: string;
  65787. shader: string;
  65788. };
  65789. }
  65790. declare module "babylonjs" {
  65791. export * from "babylonjs/Legacy/legacy";
  65792. }
  65793. declare module BABYLON {
  65794. /** Alias type for value that can be null */
  65795. export type Nullable<T> = T | null;
  65796. /**
  65797. * Alias type for number that are floats
  65798. * @ignorenaming
  65799. */
  65800. export type float = number;
  65801. /**
  65802. * Alias type for number that are doubles.
  65803. * @ignorenaming
  65804. */
  65805. export type double = number;
  65806. /**
  65807. * Alias type for number that are integer
  65808. * @ignorenaming
  65809. */
  65810. export type int = number;
  65811. /** Alias type for number array or Float32Array */
  65812. export type FloatArray = number[] | Float32Array;
  65813. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  65814. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  65815. /**
  65816. * Alias for types that can be used by a Buffer or VertexBuffer.
  65817. */
  65818. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  65819. /**
  65820. * Alias type for primitive types
  65821. * @ignorenaming
  65822. */
  65823. type Primitive = undefined | null | boolean | string | number | Function;
  65824. /**
  65825. * Type modifier to make all the properties of an object Readonly
  65826. */
  65827. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  65828. /**
  65829. * Type modifier to make all the properties of an object Readonly recursively
  65830. */
  65831. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  65832. /** @hidden */
  65833. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  65834. }
  65835. /** @hidden */
  65836. /** @hidden */
  65837. type DeepImmutableObject<T> = {
  65838. readonly [K in keyof T]: DeepImmutable<T[K]>;
  65839. };
  65840. }
  65841. declare module BABYLON {
  65842. /**
  65843. * A class serves as a medium between the observable and its observers
  65844. */
  65845. export class EventState {
  65846. /**
  65847. * Create a new EventState
  65848. * @param mask defines the mask associated with this state
  65849. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65850. * @param target defines the original target of the state
  65851. * @param currentTarget defines the current target of the state
  65852. */
  65853. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  65854. /**
  65855. * Initialize the current event state
  65856. * @param mask defines the mask associated with this state
  65857. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65858. * @param target defines the original target of the state
  65859. * @param currentTarget defines the current target of the state
  65860. * @returns the current event state
  65861. */
  65862. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  65863. /**
  65864. * An Observer can set this property to true to prevent subsequent observers of being notified
  65865. */
  65866. skipNextObservers: boolean;
  65867. /**
  65868. * Get the mask value that were used to trigger the event corresponding to this EventState object
  65869. */
  65870. mask: number;
  65871. /**
  65872. * The object that originally notified the event
  65873. */
  65874. target?: any;
  65875. /**
  65876. * The current object in the bubbling phase
  65877. */
  65878. currentTarget?: any;
  65879. /**
  65880. * This will be populated with the return value of the last function that was executed.
  65881. * If it is the first function in the callback chain it will be the event data.
  65882. */
  65883. lastReturnValue?: any;
  65884. }
  65885. /**
  65886. * Represent an Observer registered to a given Observable object.
  65887. */
  65888. export class Observer<T> {
  65889. /**
  65890. * Defines the callback to call when the observer is notified
  65891. */
  65892. callback: (eventData: T, eventState: EventState) => void;
  65893. /**
  65894. * Defines the mask of the observer (used to filter notifications)
  65895. */
  65896. mask: number;
  65897. /**
  65898. * Defines the current scope used to restore the JS context
  65899. */
  65900. scope: any;
  65901. /** @hidden */
  65902. _willBeUnregistered: boolean;
  65903. /**
  65904. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  65905. */
  65906. unregisterOnNextCall: boolean;
  65907. /**
  65908. * Creates a new observer
  65909. * @param callback defines the callback to call when the observer is notified
  65910. * @param mask defines the mask of the observer (used to filter notifications)
  65911. * @param scope defines the current scope used to restore the JS context
  65912. */
  65913. constructor(
  65914. /**
  65915. * Defines the callback to call when the observer is notified
  65916. */
  65917. callback: (eventData: T, eventState: EventState) => void,
  65918. /**
  65919. * Defines the mask of the observer (used to filter notifications)
  65920. */
  65921. mask: number,
  65922. /**
  65923. * Defines the current scope used to restore the JS context
  65924. */
  65925. scope?: any);
  65926. }
  65927. /**
  65928. * Represent a list of observers registered to multiple Observables object.
  65929. */
  65930. export class MultiObserver<T> {
  65931. private _observers;
  65932. private _observables;
  65933. /**
  65934. * Release associated resources
  65935. */
  65936. dispose(): void;
  65937. /**
  65938. * Raise a callback when one of the observable will notify
  65939. * @param observables defines a list of observables to watch
  65940. * @param callback defines the callback to call on notification
  65941. * @param mask defines the mask used to filter notifications
  65942. * @param scope defines the current scope used to restore the JS context
  65943. * @returns the new MultiObserver
  65944. */
  65945. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  65946. }
  65947. /**
  65948. * The Observable class is a simple implementation of the Observable pattern.
  65949. *
  65950. * 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.
  65951. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  65952. * 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).
  65953. * 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.
  65954. */
  65955. export class Observable<T> {
  65956. private _observers;
  65957. private _eventState;
  65958. private _onObserverAdded;
  65959. /**
  65960. * Gets the list of observers
  65961. */
  65962. readonly observers: Array<Observer<T>>;
  65963. /**
  65964. * Creates a new observable
  65965. * @param onObserverAdded defines a callback to call when a new observer is added
  65966. */
  65967. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  65968. /**
  65969. * Create a new Observer with the specified callback
  65970. * @param callback the callback that will be executed for that Observer
  65971. * @param mask the mask used to filter observers
  65972. * @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.
  65973. * @param scope optional scope for the callback to be called from
  65974. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  65975. * @returns the new observer created for the callback
  65976. */
  65977. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  65978. /**
  65979. * Create a new Observer with the specified callback and unregisters after the next notification
  65980. * @param callback the callback that will be executed for that Observer
  65981. * @returns the new observer created for the callback
  65982. */
  65983. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  65984. /**
  65985. * Remove an Observer from the Observable object
  65986. * @param observer the instance of the Observer to remove
  65987. * @returns false if it doesn't belong to this Observable
  65988. */
  65989. remove(observer: Nullable<Observer<T>>): boolean;
  65990. /**
  65991. * Remove a callback from the Observable object
  65992. * @param callback the callback to remove
  65993. * @param scope optional scope. If used only the callbacks with this scope will be removed
  65994. * @returns false if it doesn't belong to this Observable
  65995. */
  65996. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  65997. private _deferUnregister;
  65998. private _remove;
  65999. /**
  66000. * Moves the observable to the top of the observer list making it get called first when notified
  66001. * @param observer the observer to move
  66002. */
  66003. makeObserverTopPriority(observer: Observer<T>): void;
  66004. /**
  66005. * Moves the observable to the bottom of the observer list making it get called last when notified
  66006. * @param observer the observer to move
  66007. */
  66008. makeObserverBottomPriority(observer: Observer<T>): void;
  66009. /**
  66010. * Notify all Observers by calling their respective callback with the given data
  66011. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66012. * @param eventData defines the data to send to all observers
  66013. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66014. * @param target defines the original target of the state
  66015. * @param currentTarget defines the current target of the state
  66016. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66017. */
  66018. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66019. /**
  66020. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66021. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66022. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66023. * and it is crucial that all callbacks will be executed.
  66024. * The order of the callbacks is kept, callbacks are not executed parallel.
  66025. *
  66026. * @param eventData The data to be sent to each callback
  66027. * @param mask is used to filter observers defaults to -1
  66028. * @param target defines the callback target (see EventState)
  66029. * @param currentTarget defines he current object in the bubbling phase
  66030. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66031. */
  66032. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66033. /**
  66034. * Notify a specific observer
  66035. * @param observer defines the observer to notify
  66036. * @param eventData defines the data to be sent to each callback
  66037. * @param mask is used to filter observers defaults to -1
  66038. */
  66039. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66040. /**
  66041. * Gets a boolean indicating if the observable has at least one observer
  66042. * @returns true is the Observable has at least one Observer registered
  66043. */
  66044. hasObservers(): boolean;
  66045. /**
  66046. * Clear the list of observers
  66047. */
  66048. clear(): void;
  66049. /**
  66050. * Clone the current observable
  66051. * @returns a new observable
  66052. */
  66053. clone(): Observable<T>;
  66054. /**
  66055. * Does this observable handles observer registered with a given mask
  66056. * @param mask defines the mask to be tested
  66057. * @return whether or not one observer registered with the given mask is handeled
  66058. **/
  66059. hasSpecificMask(mask?: number): boolean;
  66060. }
  66061. }
  66062. declare module BABYLON {
  66063. /**
  66064. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66065. * Babylon.js
  66066. */
  66067. export class DomManagement {
  66068. /**
  66069. * Checks if the window object exists
  66070. * @returns true if the window object exists
  66071. */
  66072. static IsWindowObjectExist(): boolean;
  66073. /**
  66074. * Checks if the navigator object exists
  66075. * @returns true if the navigator object exists
  66076. */
  66077. static IsNavigatorAvailable(): boolean;
  66078. /**
  66079. * Extracts text content from a DOM element hierarchy
  66080. * @param element defines the root element
  66081. * @returns a string
  66082. */
  66083. static GetDOMTextContent(element: HTMLElement): string;
  66084. }
  66085. }
  66086. declare module BABYLON {
  66087. /**
  66088. * Logger used througouht the application to allow configuration of
  66089. * the log level required for the messages.
  66090. */
  66091. export class Logger {
  66092. /**
  66093. * No log
  66094. */
  66095. static readonly NoneLogLevel: number;
  66096. /**
  66097. * Only message logs
  66098. */
  66099. static readonly MessageLogLevel: number;
  66100. /**
  66101. * Only warning logs
  66102. */
  66103. static readonly WarningLogLevel: number;
  66104. /**
  66105. * Only error logs
  66106. */
  66107. static readonly ErrorLogLevel: number;
  66108. /**
  66109. * All logs
  66110. */
  66111. static readonly AllLogLevel: number;
  66112. private static _LogCache;
  66113. /**
  66114. * Gets a value indicating the number of loading errors
  66115. * @ignorenaming
  66116. */
  66117. static errorsCount: number;
  66118. /**
  66119. * Callback called when a new log is added
  66120. */
  66121. static OnNewCacheEntry: (entry: string) => void;
  66122. private static _AddLogEntry;
  66123. private static _FormatMessage;
  66124. private static _LogDisabled;
  66125. private static _LogEnabled;
  66126. private static _WarnDisabled;
  66127. private static _WarnEnabled;
  66128. private static _ErrorDisabled;
  66129. private static _ErrorEnabled;
  66130. /**
  66131. * Log a message to the console
  66132. */
  66133. static Log: (message: string) => void;
  66134. /**
  66135. * Write a warning message to the console
  66136. */
  66137. static Warn: (message: string) => void;
  66138. /**
  66139. * Write an error message to the console
  66140. */
  66141. static Error: (message: string) => void;
  66142. /**
  66143. * Gets current log cache (list of logs)
  66144. */
  66145. static readonly LogCache: string;
  66146. /**
  66147. * Clears the log cache
  66148. */
  66149. static ClearLogCache(): void;
  66150. /**
  66151. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66152. */
  66153. static LogLevels: number;
  66154. }
  66155. }
  66156. declare module BABYLON {
  66157. /** @hidden */
  66158. export class _TypeStore {
  66159. /** @hidden */
  66160. static RegisteredTypes: {
  66161. [key: string]: Object;
  66162. };
  66163. /** @hidden */
  66164. static GetClass(fqdn: string): any;
  66165. }
  66166. }
  66167. declare module BABYLON {
  66168. /**
  66169. * Class containing a set of static utilities functions for deep copy.
  66170. */
  66171. export class DeepCopier {
  66172. /**
  66173. * Tries to copy an object by duplicating every property
  66174. * @param source defines the source object
  66175. * @param destination defines the target object
  66176. * @param doNotCopyList defines a list of properties to avoid
  66177. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  66178. */
  66179. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  66180. }
  66181. }
  66182. declare module BABYLON {
  66183. /**
  66184. * Class containing a set of static utilities functions for precision date
  66185. */
  66186. export class PrecisionDate {
  66187. /**
  66188. * Gets either window.performance.now() if supported or Date.now() else
  66189. */
  66190. static readonly Now: number;
  66191. }
  66192. }
  66193. declare module BABYLON {
  66194. /** @hidden */
  66195. export class _DevTools {
  66196. static WarnImport(name: string): string;
  66197. }
  66198. }
  66199. declare module BABYLON {
  66200. /**
  66201. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66202. */
  66203. export class WebRequest {
  66204. private _xhr;
  66205. /**
  66206. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  66207. * i.e. when loading files, where the server/service expects an Authorization header
  66208. */
  66209. static CustomRequestHeaders: {
  66210. [key: string]: string;
  66211. };
  66212. /**
  66213. * Add callback functions in this array to update all the requests before they get sent to the network
  66214. */
  66215. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  66216. private _injectCustomRequestHeaders;
  66217. /**
  66218. * Gets or sets a function to be called when loading progress changes
  66219. */
  66220. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  66221. /**
  66222. * Returns client's state
  66223. */
  66224. readonly readyState: number;
  66225. /**
  66226. * Returns client's status
  66227. */
  66228. readonly status: number;
  66229. /**
  66230. * Returns client's status as a text
  66231. */
  66232. readonly statusText: string;
  66233. /**
  66234. * Returns client's response
  66235. */
  66236. readonly response: any;
  66237. /**
  66238. * Returns client's response url
  66239. */
  66240. readonly responseURL: string;
  66241. /**
  66242. * Returns client's response as text
  66243. */
  66244. readonly responseText: string;
  66245. /**
  66246. * Gets or sets the expected response type
  66247. */
  66248. responseType: XMLHttpRequestResponseType;
  66249. /** @hidden */
  66250. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  66251. /** @hidden */
  66252. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  66253. /**
  66254. * Cancels any network activity
  66255. */
  66256. abort(): void;
  66257. /**
  66258. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  66259. * @param body defines an optional request body
  66260. */
  66261. send(body?: Document | BodyInit | null): void;
  66262. /**
  66263. * Sets the request method, request URL
  66264. * @param method defines the method to use (GET, POST, etc..)
  66265. * @param url defines the url to connect with
  66266. */
  66267. open(method: string, url: string): void;
  66268. }
  66269. }
  66270. declare module BABYLON {
  66271. /**
  66272. * File request interface
  66273. */
  66274. export interface IFileRequest {
  66275. /**
  66276. * Raised when the request is complete (success or error).
  66277. */
  66278. onCompleteObservable: Observable<IFileRequest>;
  66279. /**
  66280. * Aborts the request for a file.
  66281. */
  66282. abort: () => void;
  66283. }
  66284. }
  66285. declare module BABYLON {
  66286. /**
  66287. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  66288. */
  66289. export class PerformanceMonitor {
  66290. private _enabled;
  66291. private _rollingFrameTime;
  66292. private _lastFrameTimeMs;
  66293. /**
  66294. * constructor
  66295. * @param frameSampleSize The number of samples required to saturate the sliding window
  66296. */
  66297. constructor(frameSampleSize?: number);
  66298. /**
  66299. * Samples current frame
  66300. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  66301. */
  66302. sampleFrame(timeMs?: number): void;
  66303. /**
  66304. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66305. */
  66306. readonly averageFrameTime: number;
  66307. /**
  66308. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66309. */
  66310. readonly averageFrameTimeVariance: number;
  66311. /**
  66312. * Returns the frame time of the most recent frame
  66313. */
  66314. readonly instantaneousFrameTime: number;
  66315. /**
  66316. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  66317. */
  66318. readonly averageFPS: number;
  66319. /**
  66320. * Returns the average framerate in frames per second using the most recent frame time
  66321. */
  66322. readonly instantaneousFPS: number;
  66323. /**
  66324. * Returns true if enough samples have been taken to completely fill the sliding window
  66325. */
  66326. readonly isSaturated: boolean;
  66327. /**
  66328. * Enables contributions to the sliding window sample set
  66329. */
  66330. enable(): void;
  66331. /**
  66332. * Disables contributions to the sliding window sample set
  66333. * Samples will not be interpolated over the disabled period
  66334. */
  66335. disable(): void;
  66336. /**
  66337. * Returns true if sampling is enabled
  66338. */
  66339. readonly isEnabled: boolean;
  66340. /**
  66341. * Resets performance monitor
  66342. */
  66343. reset(): void;
  66344. }
  66345. /**
  66346. * RollingAverage
  66347. *
  66348. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  66349. */
  66350. export class RollingAverage {
  66351. /**
  66352. * Current average
  66353. */
  66354. average: number;
  66355. /**
  66356. * Current variance
  66357. */
  66358. variance: number;
  66359. protected _samples: Array<number>;
  66360. protected _sampleCount: number;
  66361. protected _pos: number;
  66362. protected _m2: number;
  66363. /**
  66364. * constructor
  66365. * @param length The number of samples required to saturate the sliding window
  66366. */
  66367. constructor(length: number);
  66368. /**
  66369. * Adds a sample to the sample set
  66370. * @param v The sample value
  66371. */
  66372. add(v: number): void;
  66373. /**
  66374. * Returns previously added values or null if outside of history or outside the sliding window domain
  66375. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  66376. * @return Value previously recorded with add() or null if outside of range
  66377. */
  66378. history(i: number): number;
  66379. /**
  66380. * Returns true if enough samples have been taken to completely fill the sliding window
  66381. * @return true if sample-set saturated
  66382. */
  66383. isSaturated(): boolean;
  66384. /**
  66385. * Resets the rolling average (equivalent to 0 samples taken so far)
  66386. */
  66387. reset(): void;
  66388. /**
  66389. * Wraps a value around the sample range boundaries
  66390. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  66391. * @return Wrapped position in sample range
  66392. */
  66393. protected _wrapPosition(i: number): number;
  66394. }
  66395. }
  66396. declare module BABYLON {
  66397. /**
  66398. * This class implement a typical dictionary using a string as key and the generic type T as value.
  66399. * The underlying implementation relies on an associative array to ensure the best performances.
  66400. * The value can be anything including 'null' but except 'undefined'
  66401. */
  66402. export class StringDictionary<T> {
  66403. /**
  66404. * This will clear this dictionary and copy the content from the 'source' one.
  66405. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  66406. * @param source the dictionary to take the content from and copy to this dictionary
  66407. */
  66408. copyFrom(source: StringDictionary<T>): void;
  66409. /**
  66410. * Get a value based from its key
  66411. * @param key the given key to get the matching value from
  66412. * @return the value if found, otherwise undefined is returned
  66413. */
  66414. get(key: string): T | undefined;
  66415. /**
  66416. * Get a value from its key or add it if it doesn't exist.
  66417. * This method will ensure you that a given key/data will be present in the dictionary.
  66418. * @param key the given key to get the matching value from
  66419. * @param factory the factory that will create the value if the key is not present in the dictionary.
  66420. * The factory will only be invoked if there's no data for the given key.
  66421. * @return the value corresponding to the key.
  66422. */
  66423. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  66424. /**
  66425. * Get a value from its key if present in the dictionary otherwise add it
  66426. * @param key the key to get the value from
  66427. * @param val if there's no such key/value pair in the dictionary add it with this value
  66428. * @return the value corresponding to the key
  66429. */
  66430. getOrAdd(key: string, val: T): T;
  66431. /**
  66432. * Check if there's a given key in the dictionary
  66433. * @param key the key to check for
  66434. * @return true if the key is present, false otherwise
  66435. */
  66436. contains(key: string): boolean;
  66437. /**
  66438. * Add a new key and its corresponding value
  66439. * @param key the key to add
  66440. * @param value the value corresponding to the key
  66441. * @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
  66442. */
  66443. add(key: string, value: T): boolean;
  66444. /**
  66445. * Update a specific value associated to a key
  66446. * @param key defines the key to use
  66447. * @param value defines the value to store
  66448. * @returns true if the value was updated (or false if the key was not found)
  66449. */
  66450. set(key: string, value: T): boolean;
  66451. /**
  66452. * Get the element of the given key and remove it from the dictionary
  66453. * @param key defines the key to search
  66454. * @returns the value associated with the key or null if not found
  66455. */
  66456. getAndRemove(key: string): Nullable<T>;
  66457. /**
  66458. * Remove a key/value from the dictionary.
  66459. * @param key the key to remove
  66460. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  66461. */
  66462. remove(key: string): boolean;
  66463. /**
  66464. * Clear the whole content of the dictionary
  66465. */
  66466. clear(): void;
  66467. /**
  66468. * Gets the current count
  66469. */
  66470. readonly count: number;
  66471. /**
  66472. * Execute a callback on each key/val of the dictionary.
  66473. * Note that you can remove any element in this dictionary in the callback implementation
  66474. * @param callback the callback to execute on a given key/value pair
  66475. */
  66476. forEach(callback: (key: string, val: T) => void): void;
  66477. /**
  66478. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  66479. * If the callback returns null or undefined the method will iterate to the next key/value pair
  66480. * Note that you can remove any element in this dictionary in the callback implementation
  66481. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  66482. * @returns the first item
  66483. */
  66484. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  66485. private _count;
  66486. private _data;
  66487. }
  66488. }
  66489. declare module BABYLON {
  66490. /**
  66491. * Class used to store gfx data (like WebGLBuffer)
  66492. */
  66493. export class DataBuffer {
  66494. /**
  66495. * Gets or sets the number of objects referencing this buffer
  66496. */
  66497. references: number;
  66498. /** Gets or sets the size of the underlying buffer */
  66499. capacity: number;
  66500. /**
  66501. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  66502. */
  66503. is32Bits: boolean;
  66504. /**
  66505. * Gets the underlying buffer
  66506. */
  66507. readonly underlyingResource: any;
  66508. }
  66509. }
  66510. declare module BABYLON {
  66511. /**
  66512. * Class used to store data that will be store in GPU memory
  66513. */
  66514. export class Buffer {
  66515. private _engine;
  66516. private _buffer;
  66517. /** @hidden */
  66518. _data: Nullable<DataArray>;
  66519. private _updatable;
  66520. private _instanced;
  66521. /**
  66522. * Gets the byte stride.
  66523. */
  66524. readonly byteStride: number;
  66525. /**
  66526. * Constructor
  66527. * @param engine the engine
  66528. * @param data the data to use for this buffer
  66529. * @param updatable whether the data is updatable
  66530. * @param stride the stride (optional)
  66531. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66532. * @param instanced whether the buffer is instanced (optional)
  66533. * @param useBytes set to true if the stride in in bytes (optional)
  66534. */
  66535. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  66536. /**
  66537. * Create a new VertexBuffer based on the current buffer
  66538. * @param kind defines the vertex buffer kind (position, normal, etc.)
  66539. * @param offset defines offset in the buffer (0 by default)
  66540. * @param size defines the size in floats of attributes (position is 3 for instance)
  66541. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  66542. * @param instanced defines if the vertex buffer contains indexed data
  66543. * @param useBytes defines if the offset and stride are in bytes
  66544. * @returns the new vertex buffer
  66545. */
  66546. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  66547. /**
  66548. * Gets a boolean indicating if the Buffer is updatable?
  66549. * @returns true if the buffer is updatable
  66550. */
  66551. isUpdatable(): boolean;
  66552. /**
  66553. * Gets current buffer's data
  66554. * @returns a DataArray or null
  66555. */
  66556. getData(): Nullable<DataArray>;
  66557. /**
  66558. * Gets underlying native buffer
  66559. * @returns underlying native buffer
  66560. */
  66561. getBuffer(): Nullable<DataBuffer>;
  66562. /**
  66563. * Gets the stride in float32 units (i.e. byte stride / 4).
  66564. * May not be an integer if the byte stride is not divisible by 4.
  66565. * DEPRECATED. Use byteStride instead.
  66566. * @returns the stride in float32 units
  66567. */
  66568. getStrideSize(): number;
  66569. /**
  66570. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66571. * @param data defines the data to store
  66572. */
  66573. create(data?: Nullable<DataArray>): void;
  66574. /** @hidden */
  66575. _rebuild(): void;
  66576. /**
  66577. * Update current buffer data
  66578. * @param data defines the data to store
  66579. */
  66580. update(data: DataArray): void;
  66581. /**
  66582. * Updates the data directly.
  66583. * @param data the new data
  66584. * @param offset the new offset
  66585. * @param vertexCount the vertex count (optional)
  66586. * @param useBytes set to true if the offset is in bytes
  66587. */
  66588. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  66589. /**
  66590. * Release all resources
  66591. */
  66592. dispose(): void;
  66593. }
  66594. /**
  66595. * Specialized buffer used to store vertex data
  66596. */
  66597. export class VertexBuffer {
  66598. /** @hidden */
  66599. _buffer: Buffer;
  66600. private _kind;
  66601. private _size;
  66602. private _ownsBuffer;
  66603. private _instanced;
  66604. private _instanceDivisor;
  66605. /**
  66606. * The byte type.
  66607. */
  66608. static readonly BYTE: number;
  66609. /**
  66610. * The unsigned byte type.
  66611. */
  66612. static readonly UNSIGNED_BYTE: number;
  66613. /**
  66614. * The short type.
  66615. */
  66616. static readonly SHORT: number;
  66617. /**
  66618. * The unsigned short type.
  66619. */
  66620. static readonly UNSIGNED_SHORT: number;
  66621. /**
  66622. * The integer type.
  66623. */
  66624. static readonly INT: number;
  66625. /**
  66626. * The unsigned integer type.
  66627. */
  66628. static readonly UNSIGNED_INT: number;
  66629. /**
  66630. * The float type.
  66631. */
  66632. static readonly FLOAT: number;
  66633. /**
  66634. * Gets or sets the instance divisor when in instanced mode
  66635. */
  66636. instanceDivisor: number;
  66637. /**
  66638. * Gets the byte stride.
  66639. */
  66640. readonly byteStride: number;
  66641. /**
  66642. * Gets the byte offset.
  66643. */
  66644. readonly byteOffset: number;
  66645. /**
  66646. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  66647. */
  66648. readonly normalized: boolean;
  66649. /**
  66650. * Gets the data type of each component in the array.
  66651. */
  66652. readonly type: number;
  66653. /**
  66654. * Constructor
  66655. * @param engine the engine
  66656. * @param data the data to use for this vertex buffer
  66657. * @param kind the vertex buffer kind
  66658. * @param updatable whether the data is updatable
  66659. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66660. * @param stride the stride (optional)
  66661. * @param instanced whether the buffer is instanced (optional)
  66662. * @param offset the offset of the data (optional)
  66663. * @param size the number of components (optional)
  66664. * @param type the type of the component (optional)
  66665. * @param normalized whether the data contains normalized data (optional)
  66666. * @param useBytes set to true if stride and offset are in bytes (optional)
  66667. */
  66668. 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);
  66669. /** @hidden */
  66670. _rebuild(): void;
  66671. /**
  66672. * Returns the kind of the VertexBuffer (string)
  66673. * @returns a string
  66674. */
  66675. getKind(): string;
  66676. /**
  66677. * Gets a boolean indicating if the VertexBuffer is updatable?
  66678. * @returns true if the buffer is updatable
  66679. */
  66680. isUpdatable(): boolean;
  66681. /**
  66682. * Gets current buffer's data
  66683. * @returns a DataArray or null
  66684. */
  66685. getData(): Nullable<DataArray>;
  66686. /**
  66687. * Gets underlying native buffer
  66688. * @returns underlying native buffer
  66689. */
  66690. getBuffer(): Nullable<DataBuffer>;
  66691. /**
  66692. * Gets the stride in float32 units (i.e. byte stride / 4).
  66693. * May not be an integer if the byte stride is not divisible by 4.
  66694. * DEPRECATED. Use byteStride instead.
  66695. * @returns the stride in float32 units
  66696. */
  66697. getStrideSize(): number;
  66698. /**
  66699. * Returns the offset as a multiple of the type byte length.
  66700. * DEPRECATED. Use byteOffset instead.
  66701. * @returns the offset in bytes
  66702. */
  66703. getOffset(): number;
  66704. /**
  66705. * Returns the number of components per vertex attribute (integer)
  66706. * @returns the size in float
  66707. */
  66708. getSize(): number;
  66709. /**
  66710. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  66711. * @returns true if this buffer is instanced
  66712. */
  66713. getIsInstanced(): boolean;
  66714. /**
  66715. * Returns the instancing divisor, zero for non-instanced (integer).
  66716. * @returns a number
  66717. */
  66718. getInstanceDivisor(): number;
  66719. /**
  66720. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66721. * @param data defines the data to store
  66722. */
  66723. create(data?: DataArray): void;
  66724. /**
  66725. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  66726. * This function will create a new buffer if the current one is not updatable
  66727. * @param data defines the data to store
  66728. */
  66729. update(data: DataArray): void;
  66730. /**
  66731. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  66732. * Returns the directly updated WebGLBuffer.
  66733. * @param data the new data
  66734. * @param offset the new offset
  66735. * @param useBytes set to true if the offset is in bytes
  66736. */
  66737. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  66738. /**
  66739. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  66740. */
  66741. dispose(): void;
  66742. /**
  66743. * Enumerates each value of this vertex buffer as numbers.
  66744. * @param count the number of values to enumerate
  66745. * @param callback the callback function called for each value
  66746. */
  66747. forEach(count: number, callback: (value: number, index: number) => void): void;
  66748. /**
  66749. * Positions
  66750. */
  66751. static readonly PositionKind: string;
  66752. /**
  66753. * Normals
  66754. */
  66755. static readonly NormalKind: string;
  66756. /**
  66757. * Tangents
  66758. */
  66759. static readonly TangentKind: string;
  66760. /**
  66761. * Texture coordinates
  66762. */
  66763. static readonly UVKind: string;
  66764. /**
  66765. * Texture coordinates 2
  66766. */
  66767. static readonly UV2Kind: string;
  66768. /**
  66769. * Texture coordinates 3
  66770. */
  66771. static readonly UV3Kind: string;
  66772. /**
  66773. * Texture coordinates 4
  66774. */
  66775. static readonly UV4Kind: string;
  66776. /**
  66777. * Texture coordinates 5
  66778. */
  66779. static readonly UV5Kind: string;
  66780. /**
  66781. * Texture coordinates 6
  66782. */
  66783. static readonly UV6Kind: string;
  66784. /**
  66785. * Colors
  66786. */
  66787. static readonly ColorKind: string;
  66788. /**
  66789. * Matrix indices (for bones)
  66790. */
  66791. static readonly MatricesIndicesKind: string;
  66792. /**
  66793. * Matrix weights (for bones)
  66794. */
  66795. static readonly MatricesWeightsKind: string;
  66796. /**
  66797. * Additional matrix indices (for bones)
  66798. */
  66799. static readonly MatricesIndicesExtraKind: string;
  66800. /**
  66801. * Additional matrix weights (for bones)
  66802. */
  66803. static readonly MatricesWeightsExtraKind: string;
  66804. /**
  66805. * Deduces the stride given a kind.
  66806. * @param kind The kind string to deduce
  66807. * @returns The deduced stride
  66808. */
  66809. static DeduceStride(kind: string): number;
  66810. /**
  66811. * Gets the byte length of the given type.
  66812. * @param type the type
  66813. * @returns the number of bytes
  66814. */
  66815. static GetTypeByteLength(type: number): number;
  66816. /**
  66817. * Enumerates each value of the given parameters as numbers.
  66818. * @param data the data to enumerate
  66819. * @param byteOffset the byte offset of the data
  66820. * @param byteStride the byte stride of the data
  66821. * @param componentCount the number of components per element
  66822. * @param componentType the type of the component
  66823. * @param count the number of values to enumerate
  66824. * @param normalized whether the data is normalized
  66825. * @param callback the callback function called for each value
  66826. */
  66827. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  66828. private static _GetFloatValue;
  66829. }
  66830. }
  66831. declare module BABYLON {
  66832. /**
  66833. * Scalar computation library
  66834. */
  66835. export class Scalar {
  66836. /**
  66837. * Two pi constants convenient for computation.
  66838. */
  66839. static TwoPi: number;
  66840. /**
  66841. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66842. * @param a number
  66843. * @param b number
  66844. * @param epsilon (default = 1.401298E-45)
  66845. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66846. */
  66847. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66848. /**
  66849. * Returns a string : the upper case translation of the number i to hexadecimal.
  66850. * @param i number
  66851. * @returns the upper case translation of the number i to hexadecimal.
  66852. */
  66853. static ToHex(i: number): string;
  66854. /**
  66855. * Returns -1 if value is negative and +1 is value is positive.
  66856. * @param value the value
  66857. * @returns the value itself if it's equal to zero.
  66858. */
  66859. static Sign(value: number): number;
  66860. /**
  66861. * Returns the value itself if it's between min and max.
  66862. * Returns min if the value is lower than min.
  66863. * Returns max if the value is greater than max.
  66864. * @param value the value to clmap
  66865. * @param min the min value to clamp to (default: 0)
  66866. * @param max the max value to clamp to (default: 1)
  66867. * @returns the clamped value
  66868. */
  66869. static Clamp(value: number, min?: number, max?: number): number;
  66870. /**
  66871. * the log2 of value.
  66872. * @param value the value to compute log2 of
  66873. * @returns the log2 of value.
  66874. */
  66875. static Log2(value: number): number;
  66876. /**
  66877. * Loops the value, so that it is never larger than length and never smaller than 0.
  66878. *
  66879. * This is similar to the modulo operator but it works with floating point numbers.
  66880. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66881. * With t = 5 and length = 2.5, the result would be 0.0.
  66882. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66883. * @param value the value
  66884. * @param length the length
  66885. * @returns the looped value
  66886. */
  66887. static Repeat(value: number, length: number): number;
  66888. /**
  66889. * Normalize the value between 0.0 and 1.0 using min and max values
  66890. * @param value value to normalize
  66891. * @param min max to normalize between
  66892. * @param max min to normalize between
  66893. * @returns the normalized value
  66894. */
  66895. static Normalize(value: number, min: number, max: number): number;
  66896. /**
  66897. * Denormalize the value from 0.0 and 1.0 using min and max values
  66898. * @param normalized value to denormalize
  66899. * @param min max to denormalize between
  66900. * @param max min to denormalize between
  66901. * @returns the denormalized value
  66902. */
  66903. static Denormalize(normalized: number, min: number, max: number): number;
  66904. /**
  66905. * Calculates the shortest difference between two given angles given in degrees.
  66906. * @param current current angle in degrees
  66907. * @param target target angle in degrees
  66908. * @returns the delta
  66909. */
  66910. static DeltaAngle(current: number, target: number): number;
  66911. /**
  66912. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66913. * @param tx value
  66914. * @param length length
  66915. * @returns The returned value will move back and forth between 0 and length
  66916. */
  66917. static PingPong(tx: number, length: number): number;
  66918. /**
  66919. * Interpolates between min and max with smoothing at the limits.
  66920. *
  66921. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66922. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66923. * @param from from
  66924. * @param to to
  66925. * @param tx value
  66926. * @returns the smooth stepped value
  66927. */
  66928. static SmoothStep(from: number, to: number, tx: number): number;
  66929. /**
  66930. * Moves a value current towards target.
  66931. *
  66932. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66933. * Negative values of maxDelta pushes the value away from target.
  66934. * @param current current value
  66935. * @param target target value
  66936. * @param maxDelta max distance to move
  66937. * @returns resulting value
  66938. */
  66939. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66940. /**
  66941. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66942. *
  66943. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66944. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66945. * @param current current value
  66946. * @param target target value
  66947. * @param maxDelta max distance to move
  66948. * @returns resulting angle
  66949. */
  66950. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66951. /**
  66952. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66953. * @param start start value
  66954. * @param end target value
  66955. * @param amount amount to lerp between
  66956. * @returns the lerped value
  66957. */
  66958. static Lerp(start: number, end: number, amount: number): number;
  66959. /**
  66960. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66961. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66962. * @param start start value
  66963. * @param end target value
  66964. * @param amount amount to lerp between
  66965. * @returns the lerped value
  66966. */
  66967. static LerpAngle(start: number, end: number, amount: number): number;
  66968. /**
  66969. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66970. * @param a start value
  66971. * @param b target value
  66972. * @param value value between a and b
  66973. * @returns the inverseLerp value
  66974. */
  66975. static InverseLerp(a: number, b: number, value: number): number;
  66976. /**
  66977. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66978. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66979. * @param value1 spline value
  66980. * @param tangent1 spline value
  66981. * @param value2 spline value
  66982. * @param tangent2 spline value
  66983. * @param amount input value
  66984. * @returns hermite result
  66985. */
  66986. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  66987. /**
  66988. * Returns a random float number between and min and max values
  66989. * @param min min value of random
  66990. * @param max max value of random
  66991. * @returns random value
  66992. */
  66993. static RandomRange(min: number, max: number): number;
  66994. /**
  66995. * This function returns percentage of a number in a given range.
  66996. *
  66997. * RangeToPercent(40,20,60) will return 0.5 (50%)
  66998. * RangeToPercent(34,0,100) will return 0.34 (34%)
  66999. * @param number to convert to percentage
  67000. * @param min min range
  67001. * @param max max range
  67002. * @returns the percentage
  67003. */
  67004. static RangeToPercent(number: number, min: number, max: number): number;
  67005. /**
  67006. * This function returns number that corresponds to the percentage in a given range.
  67007. *
  67008. * PercentToRange(0.34,0,100) will return 34.
  67009. * @param percent to convert to number
  67010. * @param min min range
  67011. * @param max max range
  67012. * @returns the number
  67013. */
  67014. static PercentToRange(percent: number, min: number, max: number): number;
  67015. /**
  67016. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67017. * @param angle The angle to normalize in radian.
  67018. * @return The converted angle.
  67019. */
  67020. static NormalizeRadians(angle: number): number;
  67021. }
  67022. }
  67023. declare module BABYLON {
  67024. /**
  67025. * Constant used to convert a value to gamma space
  67026. * @ignorenaming
  67027. */
  67028. export const ToGammaSpace: number;
  67029. /**
  67030. * Constant used to convert a value to linear space
  67031. * @ignorenaming
  67032. */
  67033. export const ToLinearSpace = 2.2;
  67034. /**
  67035. * Constant used to define the minimal number value in Babylon.js
  67036. * @ignorenaming
  67037. */
  67038. let Epsilon: number;
  67039. }
  67040. declare module BABYLON {
  67041. /**
  67042. * Class used to represent a viewport on screen
  67043. */
  67044. export class Viewport {
  67045. /** viewport left coordinate */
  67046. x: number;
  67047. /** viewport top coordinate */
  67048. y: number;
  67049. /**viewport width */
  67050. width: number;
  67051. /** viewport height */
  67052. height: number;
  67053. /**
  67054. * Creates a Viewport object located at (x, y) and sized (width, height)
  67055. * @param x defines viewport left coordinate
  67056. * @param y defines viewport top coordinate
  67057. * @param width defines the viewport width
  67058. * @param height defines the viewport height
  67059. */
  67060. constructor(
  67061. /** viewport left coordinate */
  67062. x: number,
  67063. /** viewport top coordinate */
  67064. y: number,
  67065. /**viewport width */
  67066. width: number,
  67067. /** viewport height */
  67068. height: number);
  67069. /**
  67070. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67071. * @param renderWidth defines the rendering width
  67072. * @param renderHeight defines the rendering height
  67073. * @returns a new Viewport
  67074. */
  67075. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67076. /**
  67077. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67078. * @param renderWidth defines the rendering width
  67079. * @param renderHeight defines the rendering height
  67080. * @param ref defines the target viewport
  67081. * @returns the current viewport
  67082. */
  67083. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67084. /**
  67085. * Returns a new Viewport copied from the current one
  67086. * @returns a new Viewport
  67087. */
  67088. clone(): Viewport;
  67089. }
  67090. }
  67091. declare module BABYLON {
  67092. /**
  67093. * Class containing a set of static utilities functions for arrays.
  67094. */
  67095. export class ArrayTools {
  67096. /**
  67097. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67098. * @param size the number of element to construct and put in the array
  67099. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67100. * @returns a new array filled with new objects
  67101. */
  67102. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67103. }
  67104. }
  67105. declare module BABYLON {
  67106. /**
  67107. * @hidden
  67108. */
  67109. export interface IColor4Like {
  67110. r: float;
  67111. g: float;
  67112. b: float;
  67113. a: float;
  67114. }
  67115. /**
  67116. * @hidden
  67117. */
  67118. export interface IColor3Like {
  67119. r: float;
  67120. g: float;
  67121. b: float;
  67122. }
  67123. /**
  67124. * @hidden
  67125. */
  67126. export interface IVector4Like {
  67127. x: float;
  67128. y: float;
  67129. z: float;
  67130. w: float;
  67131. }
  67132. /**
  67133. * @hidden
  67134. */
  67135. export interface IVector3Like {
  67136. x: float;
  67137. y: float;
  67138. z: float;
  67139. }
  67140. /**
  67141. * @hidden
  67142. */
  67143. export interface IVector2Like {
  67144. x: float;
  67145. y: float;
  67146. }
  67147. /**
  67148. * @hidden
  67149. */
  67150. export interface IMatrixLike {
  67151. toArray(): DeepImmutable<Float32Array>;
  67152. updateFlag: int;
  67153. }
  67154. /**
  67155. * @hidden
  67156. */
  67157. export interface IViewportLike {
  67158. x: float;
  67159. y: float;
  67160. width: float;
  67161. height: float;
  67162. }
  67163. /**
  67164. * @hidden
  67165. */
  67166. export interface IPlaneLike {
  67167. normal: IVector3Like;
  67168. d: float;
  67169. normalize(): void;
  67170. }
  67171. }
  67172. declare module BABYLON {
  67173. /**
  67174. * Class representing a vector containing 2 coordinates
  67175. */
  67176. export class Vector2 {
  67177. /** defines the first coordinate */
  67178. x: number;
  67179. /** defines the second coordinate */
  67180. y: number;
  67181. /**
  67182. * Creates a new Vector2 from the given x and y coordinates
  67183. * @param x defines the first coordinate
  67184. * @param y defines the second coordinate
  67185. */
  67186. constructor(
  67187. /** defines the first coordinate */
  67188. x?: number,
  67189. /** defines the second coordinate */
  67190. y?: number);
  67191. /**
  67192. * Gets a string with the Vector2 coordinates
  67193. * @returns a string with the Vector2 coordinates
  67194. */
  67195. toString(): string;
  67196. /**
  67197. * Gets class name
  67198. * @returns the string "Vector2"
  67199. */
  67200. getClassName(): string;
  67201. /**
  67202. * Gets current vector hash code
  67203. * @returns the Vector2 hash code as a number
  67204. */
  67205. getHashCode(): number;
  67206. /**
  67207. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67208. * @param array defines the source array
  67209. * @param index defines the offset in source array
  67210. * @returns the current Vector2
  67211. */
  67212. toArray(array: FloatArray, index?: number): Vector2;
  67213. /**
  67214. * Copy the current vector to an array
  67215. * @returns a new array with 2 elements: the Vector2 coordinates.
  67216. */
  67217. asArray(): number[];
  67218. /**
  67219. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67220. * @param source defines the source Vector2
  67221. * @returns the current updated Vector2
  67222. */
  67223. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67224. /**
  67225. * Sets the Vector2 coordinates with the given floats
  67226. * @param x defines the first coordinate
  67227. * @param y defines the second coordinate
  67228. * @returns the current updated Vector2
  67229. */
  67230. copyFromFloats(x: number, y: number): Vector2;
  67231. /**
  67232. * Sets the Vector2 coordinates with the given floats
  67233. * @param x defines the first coordinate
  67234. * @param y defines the second coordinate
  67235. * @returns the current updated Vector2
  67236. */
  67237. set(x: number, y: number): Vector2;
  67238. /**
  67239. * Add another vector with the current one
  67240. * @param otherVector defines the other vector
  67241. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67242. */
  67243. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67244. /**
  67245. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67246. * @param otherVector defines the other vector
  67247. * @param result defines the target vector
  67248. * @returns the unmodified current Vector2
  67249. */
  67250. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67251. /**
  67252. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67253. * @param otherVector defines the other vector
  67254. * @returns the current updated Vector2
  67255. */
  67256. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67257. /**
  67258. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67259. * @param otherVector defines the other vector
  67260. * @returns a new Vector2
  67261. */
  67262. addVector3(otherVector: Vector3): Vector2;
  67263. /**
  67264. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67265. * @param otherVector defines the other vector
  67266. * @returns a new Vector2
  67267. */
  67268. subtract(otherVector: Vector2): Vector2;
  67269. /**
  67270. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67271. * @param otherVector defines the other vector
  67272. * @param result defines the target vector
  67273. * @returns the unmodified current Vector2
  67274. */
  67275. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67276. /**
  67277. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67278. * @param otherVector defines the other vector
  67279. * @returns the current updated Vector2
  67280. */
  67281. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67282. /**
  67283. * Multiplies in place the current Vector2 coordinates by the given ones
  67284. * @param otherVector defines the other vector
  67285. * @returns the current updated Vector2
  67286. */
  67287. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67288. /**
  67289. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67290. * @param otherVector defines the other vector
  67291. * @returns a new Vector2
  67292. */
  67293. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67294. /**
  67295. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67296. * @param otherVector defines the other vector
  67297. * @param result defines the target vector
  67298. * @returns the unmodified current Vector2
  67299. */
  67300. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67301. /**
  67302. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67303. * @param x defines the first coordinate
  67304. * @param y defines the second coordinate
  67305. * @returns a new Vector2
  67306. */
  67307. multiplyByFloats(x: number, y: number): Vector2;
  67308. /**
  67309. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67310. * @param otherVector defines the other vector
  67311. * @returns a new Vector2
  67312. */
  67313. divide(otherVector: Vector2): Vector2;
  67314. /**
  67315. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67316. * @param otherVector defines the other vector
  67317. * @param result defines the target vector
  67318. * @returns the unmodified current Vector2
  67319. */
  67320. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67321. /**
  67322. * Divides the current Vector2 coordinates by the given ones
  67323. * @param otherVector defines the other vector
  67324. * @returns the current updated Vector2
  67325. */
  67326. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67327. /**
  67328. * Gets a new Vector2 with current Vector2 negated coordinates
  67329. * @returns a new Vector2
  67330. */
  67331. negate(): Vector2;
  67332. /**
  67333. * Multiply the Vector2 coordinates by scale
  67334. * @param scale defines the scaling factor
  67335. * @returns the current updated Vector2
  67336. */
  67337. scaleInPlace(scale: number): Vector2;
  67338. /**
  67339. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67340. * @param scale defines the scaling factor
  67341. * @returns a new Vector2
  67342. */
  67343. scale(scale: number): Vector2;
  67344. /**
  67345. * Scale the current Vector2 values by a factor to a given Vector2
  67346. * @param scale defines the scale factor
  67347. * @param result defines the Vector2 object where to store the result
  67348. * @returns the unmodified current Vector2
  67349. */
  67350. scaleToRef(scale: number, result: Vector2): Vector2;
  67351. /**
  67352. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67353. * @param scale defines the scale factor
  67354. * @param result defines the Vector2 object where to store the result
  67355. * @returns the unmodified current Vector2
  67356. */
  67357. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67358. /**
  67359. * Gets a boolean if two vectors are equals
  67360. * @param otherVector defines the other vector
  67361. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67362. */
  67363. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67364. /**
  67365. * Gets a boolean if two vectors are equals (using an epsilon value)
  67366. * @param otherVector defines the other vector
  67367. * @param epsilon defines the minimal distance to consider equality
  67368. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67369. */
  67370. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67371. /**
  67372. * Gets a new Vector2 from current Vector2 floored values
  67373. * @returns a new Vector2
  67374. */
  67375. floor(): Vector2;
  67376. /**
  67377. * Gets a new Vector2 from current Vector2 floored values
  67378. * @returns a new Vector2
  67379. */
  67380. fract(): Vector2;
  67381. /**
  67382. * Gets the length of the vector
  67383. * @returns the vector length (float)
  67384. */
  67385. length(): number;
  67386. /**
  67387. * Gets the vector squared length
  67388. * @returns the vector squared length (float)
  67389. */
  67390. lengthSquared(): number;
  67391. /**
  67392. * Normalize the vector
  67393. * @returns the current updated Vector2
  67394. */
  67395. normalize(): Vector2;
  67396. /**
  67397. * Gets a new Vector2 copied from the Vector2
  67398. * @returns a new Vector2
  67399. */
  67400. clone(): Vector2;
  67401. /**
  67402. * Gets a new Vector2(0, 0)
  67403. * @returns a new Vector2
  67404. */
  67405. static Zero(): Vector2;
  67406. /**
  67407. * Gets a new Vector2(1, 1)
  67408. * @returns a new Vector2
  67409. */
  67410. static One(): Vector2;
  67411. /**
  67412. * Gets a new Vector2 set from the given index element of the given array
  67413. * @param array defines the data source
  67414. * @param offset defines the offset in the data source
  67415. * @returns a new Vector2
  67416. */
  67417. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67418. /**
  67419. * Sets "result" from the given index element of the given array
  67420. * @param array defines the data source
  67421. * @param offset defines the offset in the data source
  67422. * @param result defines the target vector
  67423. */
  67424. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67425. /**
  67426. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67427. * @param value1 defines 1st point of control
  67428. * @param value2 defines 2nd point of control
  67429. * @param value3 defines 3rd point of control
  67430. * @param value4 defines 4th point of control
  67431. * @param amount defines the interpolation factor
  67432. * @returns a new Vector2
  67433. */
  67434. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67435. /**
  67436. * 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".
  67437. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67438. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67439. * @param value defines the value to clamp
  67440. * @param min defines the lower limit
  67441. * @param max defines the upper limit
  67442. * @returns a new Vector2
  67443. */
  67444. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67445. /**
  67446. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67447. * @param value1 defines the 1st control point
  67448. * @param tangent1 defines the outgoing tangent
  67449. * @param value2 defines the 2nd control point
  67450. * @param tangent2 defines the incoming tangent
  67451. * @param amount defines the interpolation factor
  67452. * @returns a new Vector2
  67453. */
  67454. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67455. /**
  67456. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67457. * @param start defines the start vector
  67458. * @param end defines the end vector
  67459. * @param amount defines the interpolation factor
  67460. * @returns a new Vector2
  67461. */
  67462. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67463. /**
  67464. * Gets the dot product of the vector "left" and the vector "right"
  67465. * @param left defines first vector
  67466. * @param right defines second vector
  67467. * @returns the dot product (float)
  67468. */
  67469. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67470. /**
  67471. * Returns a new Vector2 equal to the normalized given vector
  67472. * @param vector defines the vector to normalize
  67473. * @returns a new Vector2
  67474. */
  67475. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67476. /**
  67477. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67478. * @param left defines 1st vector
  67479. * @param right defines 2nd vector
  67480. * @returns a new Vector2
  67481. */
  67482. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67483. /**
  67484. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67485. * @param left defines 1st vector
  67486. * @param right defines 2nd vector
  67487. * @returns a new Vector2
  67488. */
  67489. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67490. /**
  67491. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67492. * @param vector defines the vector to transform
  67493. * @param transformation defines the matrix to apply
  67494. * @returns a new Vector2
  67495. */
  67496. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67497. /**
  67498. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67499. * @param vector defines the vector to transform
  67500. * @param transformation defines the matrix to apply
  67501. * @param result defines the target vector
  67502. */
  67503. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67504. /**
  67505. * Determines if a given vector is included in a triangle
  67506. * @param p defines the vector to test
  67507. * @param p0 defines 1st triangle point
  67508. * @param p1 defines 2nd triangle point
  67509. * @param p2 defines 3rd triangle point
  67510. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67511. */
  67512. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67513. /**
  67514. * Gets the distance between the vectors "value1" and "value2"
  67515. * @param value1 defines first vector
  67516. * @param value2 defines second vector
  67517. * @returns the distance between vectors
  67518. */
  67519. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67520. /**
  67521. * Returns the squared distance between the vectors "value1" and "value2"
  67522. * @param value1 defines first vector
  67523. * @param value2 defines second vector
  67524. * @returns the squared distance between vectors
  67525. */
  67526. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67527. /**
  67528. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67529. * @param value1 defines first vector
  67530. * @param value2 defines second vector
  67531. * @returns a new Vector2
  67532. */
  67533. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67534. /**
  67535. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67536. * @param p defines the middle point
  67537. * @param segA defines one point of the segment
  67538. * @param segB defines the other point of the segment
  67539. * @returns the shortest distance
  67540. */
  67541. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67542. }
  67543. /**
  67544. * Classed used to store (x,y,z) vector representation
  67545. * A Vector3 is the main object used in 3D geometry
  67546. * It can represent etiher the coordinates of a point the space, either a direction
  67547. * Reminder: js uses a left handed forward facing system
  67548. */
  67549. export class Vector3 {
  67550. /**
  67551. * Defines the first coordinates (on X axis)
  67552. */
  67553. x: number;
  67554. /**
  67555. * Defines the second coordinates (on Y axis)
  67556. */
  67557. y: number;
  67558. /**
  67559. * Defines the third coordinates (on Z axis)
  67560. */
  67561. z: number;
  67562. private static _UpReadOnly;
  67563. private static _ZeroReadOnly;
  67564. /**
  67565. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67566. * @param x defines the first coordinates (on X axis)
  67567. * @param y defines the second coordinates (on Y axis)
  67568. * @param z defines the third coordinates (on Z axis)
  67569. */
  67570. constructor(
  67571. /**
  67572. * Defines the first coordinates (on X axis)
  67573. */
  67574. x?: number,
  67575. /**
  67576. * Defines the second coordinates (on Y axis)
  67577. */
  67578. y?: number,
  67579. /**
  67580. * Defines the third coordinates (on Z axis)
  67581. */
  67582. z?: number);
  67583. /**
  67584. * Creates a string representation of the Vector3
  67585. * @returns a string with the Vector3 coordinates.
  67586. */
  67587. toString(): string;
  67588. /**
  67589. * Gets the class name
  67590. * @returns the string "Vector3"
  67591. */
  67592. getClassName(): string;
  67593. /**
  67594. * Creates the Vector3 hash code
  67595. * @returns a number which tends to be unique between Vector3 instances
  67596. */
  67597. getHashCode(): number;
  67598. /**
  67599. * Creates an array containing three elements : the coordinates of the Vector3
  67600. * @returns a new array of numbers
  67601. */
  67602. asArray(): number[];
  67603. /**
  67604. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67605. * @param array defines the destination array
  67606. * @param index defines the offset in the destination array
  67607. * @returns the current Vector3
  67608. */
  67609. toArray(array: FloatArray, index?: number): Vector3;
  67610. /**
  67611. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67612. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67613. */
  67614. toQuaternion(): Quaternion;
  67615. /**
  67616. * Adds the given vector to the current Vector3
  67617. * @param otherVector defines the second operand
  67618. * @returns the current updated Vector3
  67619. */
  67620. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67621. /**
  67622. * Adds the given coordinates to the current Vector3
  67623. * @param x defines the x coordinate of the operand
  67624. * @param y defines the y coordinate of the operand
  67625. * @param z defines the z coordinate of the operand
  67626. * @returns the current updated Vector3
  67627. */
  67628. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67629. /**
  67630. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67631. * @param otherVector defines the second operand
  67632. * @returns the resulting Vector3
  67633. */
  67634. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67635. /**
  67636. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67637. * @param otherVector defines the second operand
  67638. * @param result defines the Vector3 object where to store the result
  67639. * @returns the current Vector3
  67640. */
  67641. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67642. /**
  67643. * Subtract the given vector from the current Vector3
  67644. * @param otherVector defines the second operand
  67645. * @returns the current updated Vector3
  67646. */
  67647. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67648. /**
  67649. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67650. * @param otherVector defines the second operand
  67651. * @returns the resulting Vector3
  67652. */
  67653. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67654. /**
  67655. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67656. * @param otherVector defines the second operand
  67657. * @param result defines the Vector3 object where to store the result
  67658. * @returns the current Vector3
  67659. */
  67660. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67661. /**
  67662. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67663. * @param x defines the x coordinate of the operand
  67664. * @param y defines the y coordinate of the operand
  67665. * @param z defines the z coordinate of the operand
  67666. * @returns the resulting Vector3
  67667. */
  67668. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67669. /**
  67670. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67671. * @param x defines the x coordinate of the operand
  67672. * @param y defines the y coordinate of the operand
  67673. * @param z defines the z coordinate of the operand
  67674. * @param result defines the Vector3 object where to store the result
  67675. * @returns the current Vector3
  67676. */
  67677. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67678. /**
  67679. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67680. * @returns a new Vector3
  67681. */
  67682. negate(): Vector3;
  67683. /**
  67684. * Multiplies the Vector3 coordinates by the float "scale"
  67685. * @param scale defines the multiplier factor
  67686. * @returns the current updated Vector3
  67687. */
  67688. scaleInPlace(scale: number): Vector3;
  67689. /**
  67690. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67691. * @param scale defines the multiplier factor
  67692. * @returns a new Vector3
  67693. */
  67694. scale(scale: number): Vector3;
  67695. /**
  67696. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67697. * @param scale defines the multiplier factor
  67698. * @param result defines the Vector3 object where to store the result
  67699. * @returns the current Vector3
  67700. */
  67701. scaleToRef(scale: number, result: Vector3): Vector3;
  67702. /**
  67703. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67704. * @param scale defines the scale factor
  67705. * @param result defines the Vector3 object where to store the result
  67706. * @returns the unmodified current Vector3
  67707. */
  67708. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67709. /**
  67710. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67711. * @param otherVector defines the second operand
  67712. * @returns true if both vectors are equals
  67713. */
  67714. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67715. /**
  67716. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67717. * @param otherVector defines the second operand
  67718. * @param epsilon defines the minimal distance to define values as equals
  67719. * @returns true if both vectors are distant less than epsilon
  67720. */
  67721. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67722. /**
  67723. * Returns true if the current Vector3 coordinates equals the given floats
  67724. * @param x defines the x coordinate of the operand
  67725. * @param y defines the y coordinate of the operand
  67726. * @param z defines the z coordinate of the operand
  67727. * @returns true if both vectors are equals
  67728. */
  67729. equalsToFloats(x: number, y: number, z: number): boolean;
  67730. /**
  67731. * Multiplies the current Vector3 coordinates by the given ones
  67732. * @param otherVector defines the second operand
  67733. * @returns the current updated Vector3
  67734. */
  67735. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67736. /**
  67737. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67738. * @param otherVector defines the second operand
  67739. * @returns the new Vector3
  67740. */
  67741. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67742. /**
  67743. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67744. * @param otherVector defines the second operand
  67745. * @param result defines the Vector3 object where to store the result
  67746. * @returns the current Vector3
  67747. */
  67748. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67749. /**
  67750. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67751. * @param x defines the x coordinate of the operand
  67752. * @param y defines the y coordinate of the operand
  67753. * @param z defines the z coordinate of the operand
  67754. * @returns the new Vector3
  67755. */
  67756. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67757. /**
  67758. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67759. * @param otherVector defines the second operand
  67760. * @returns the new Vector3
  67761. */
  67762. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67763. /**
  67764. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67765. * @param otherVector defines the second operand
  67766. * @param result defines the Vector3 object where to store the result
  67767. * @returns the current Vector3
  67768. */
  67769. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67770. /**
  67771. * Divides the current Vector3 coordinates by the given ones.
  67772. * @param otherVector defines the second operand
  67773. * @returns the current updated Vector3
  67774. */
  67775. divideInPlace(otherVector: Vector3): Vector3;
  67776. /**
  67777. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67778. * @param other defines the second operand
  67779. * @returns the current updated Vector3
  67780. */
  67781. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67782. /**
  67783. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67784. * @param other defines the second operand
  67785. * @returns the current updated Vector3
  67786. */
  67787. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67788. /**
  67789. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67790. * @param x defines the x coordinate of the operand
  67791. * @param y defines the y coordinate of the operand
  67792. * @param z defines the z coordinate of the operand
  67793. * @returns the current updated Vector3
  67794. */
  67795. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67796. /**
  67797. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67798. * @param x defines the x coordinate of the operand
  67799. * @param y defines the y coordinate of the operand
  67800. * @param z defines the z coordinate of the operand
  67801. * @returns the current updated Vector3
  67802. */
  67803. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67804. /**
  67805. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67806. * Check if is non uniform within a certain amount of decimal places to account for this
  67807. * @param epsilon the amount the values can differ
  67808. * @returns if the the vector is non uniform to a certain number of decimal places
  67809. */
  67810. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67811. /**
  67812. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67813. */
  67814. readonly isNonUniform: boolean;
  67815. /**
  67816. * Gets a new Vector3 from current Vector3 floored values
  67817. * @returns a new Vector3
  67818. */
  67819. floor(): Vector3;
  67820. /**
  67821. * Gets a new Vector3 from current Vector3 floored values
  67822. * @returns a new Vector3
  67823. */
  67824. fract(): Vector3;
  67825. /**
  67826. * Gets the length of the Vector3
  67827. * @returns the length of the Vector3
  67828. */
  67829. length(): number;
  67830. /**
  67831. * Gets the squared length of the Vector3
  67832. * @returns squared length of the Vector3
  67833. */
  67834. lengthSquared(): number;
  67835. /**
  67836. * Normalize the current Vector3.
  67837. * Please note that this is an in place operation.
  67838. * @returns the current updated Vector3
  67839. */
  67840. normalize(): Vector3;
  67841. /**
  67842. * Reorders the x y z properties of the vector in place
  67843. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67844. * @returns the current updated vector
  67845. */
  67846. reorderInPlace(order: string): this;
  67847. /**
  67848. * Rotates the vector around 0,0,0 by a quaternion
  67849. * @param quaternion the rotation quaternion
  67850. * @param result vector to store the result
  67851. * @returns the resulting vector
  67852. */
  67853. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67854. /**
  67855. * Rotates a vector around a given point
  67856. * @param quaternion the rotation quaternion
  67857. * @param point the point to rotate around
  67858. * @param result vector to store the result
  67859. * @returns the resulting vector
  67860. */
  67861. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67862. /**
  67863. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  67864. * The cross product is then orthogonal to both current and "other"
  67865. * @param other defines the right operand
  67866. * @returns the cross product
  67867. */
  67868. cross(other: Vector3): Vector3;
  67869. /**
  67870. * Normalize the current Vector3 with the given input length.
  67871. * Please note that this is an in place operation.
  67872. * @param len the length of the vector
  67873. * @returns the current updated Vector3
  67874. */
  67875. normalizeFromLength(len: number): Vector3;
  67876. /**
  67877. * Normalize the current Vector3 to a new vector
  67878. * @returns the new Vector3
  67879. */
  67880. normalizeToNew(): Vector3;
  67881. /**
  67882. * Normalize the current Vector3 to the reference
  67883. * @param reference define the Vector3 to update
  67884. * @returns the updated Vector3
  67885. */
  67886. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67887. /**
  67888. * Creates a new Vector3 copied from the current Vector3
  67889. * @returns the new Vector3
  67890. */
  67891. clone(): Vector3;
  67892. /**
  67893. * Copies the given vector coordinates to the current Vector3 ones
  67894. * @param source defines the source Vector3
  67895. * @returns the current updated Vector3
  67896. */
  67897. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67898. /**
  67899. * Copies the given floats to the current Vector3 coordinates
  67900. * @param x defines the x coordinate of the operand
  67901. * @param y defines the y coordinate of the operand
  67902. * @param z defines the z coordinate of the operand
  67903. * @returns the current updated Vector3
  67904. */
  67905. copyFromFloats(x: number, y: number, z: number): Vector3;
  67906. /**
  67907. * Copies the given floats to the current Vector3 coordinates
  67908. * @param x defines the x coordinate of the operand
  67909. * @param y defines the y coordinate of the operand
  67910. * @param z defines the z coordinate of the operand
  67911. * @returns the current updated Vector3
  67912. */
  67913. set(x: number, y: number, z: number): Vector3;
  67914. /**
  67915. * Copies the given float to the current Vector3 coordinates
  67916. * @param v defines the x, y and z coordinates of the operand
  67917. * @returns the current updated Vector3
  67918. */
  67919. setAll(v: number): Vector3;
  67920. /**
  67921. * Get the clip factor between two vectors
  67922. * @param vector0 defines the first operand
  67923. * @param vector1 defines the second operand
  67924. * @param axis defines the axis to use
  67925. * @param size defines the size along the axis
  67926. * @returns the clip factor
  67927. */
  67928. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67929. /**
  67930. * Get angle between two vectors
  67931. * @param vector0 angle between vector0 and vector1
  67932. * @param vector1 angle between vector0 and vector1
  67933. * @param normal direction of the normal
  67934. * @return the angle between vector0 and vector1
  67935. */
  67936. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67937. /**
  67938. * Returns a new Vector3 set from the index "offset" of the given array
  67939. * @param array defines the source array
  67940. * @param offset defines the offset in the source array
  67941. * @returns the new Vector3
  67942. */
  67943. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67944. /**
  67945. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67946. * This function is deprecated. Use FromArray instead
  67947. * @param array defines the source array
  67948. * @param offset defines the offset in the source array
  67949. * @returns the new Vector3
  67950. */
  67951. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67952. /**
  67953. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67954. * @param array defines the source array
  67955. * @param offset defines the offset in the source array
  67956. * @param result defines the Vector3 where to store the result
  67957. */
  67958. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67959. /**
  67960. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  67961. * This function is deprecated. Use FromArrayToRef instead.
  67962. * @param array defines the source array
  67963. * @param offset defines the offset in the source array
  67964. * @param result defines the Vector3 where to store the result
  67965. */
  67966. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  67967. /**
  67968. * Sets the given vector "result" with the given floats.
  67969. * @param x defines the x coordinate of the source
  67970. * @param y defines the y coordinate of the source
  67971. * @param z defines the z coordinate of the source
  67972. * @param result defines the Vector3 where to store the result
  67973. */
  67974. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  67975. /**
  67976. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  67977. * @returns a new empty Vector3
  67978. */
  67979. static Zero(): Vector3;
  67980. /**
  67981. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  67982. * @returns a new unit Vector3
  67983. */
  67984. static One(): Vector3;
  67985. /**
  67986. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  67987. * @returns a new up Vector3
  67988. */
  67989. static Up(): Vector3;
  67990. /**
  67991. * Gets a up Vector3 that must not be updated
  67992. */
  67993. static readonly UpReadOnly: DeepImmutable<Vector3>;
  67994. /**
  67995. * Gets a zero Vector3 that must not be updated
  67996. */
  67997. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  67998. /**
  67999. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68000. * @returns a new down Vector3
  68001. */
  68002. static Down(): Vector3;
  68003. /**
  68004. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68005. * @returns a new forward Vector3
  68006. */
  68007. static Forward(): Vector3;
  68008. /**
  68009. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68010. * @returns a new forward Vector3
  68011. */
  68012. static Backward(): Vector3;
  68013. /**
  68014. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68015. * @returns a new right Vector3
  68016. */
  68017. static Right(): Vector3;
  68018. /**
  68019. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68020. * @returns a new left Vector3
  68021. */
  68022. static Left(): Vector3;
  68023. /**
  68024. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68025. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68026. * @param vector defines the Vector3 to transform
  68027. * @param transformation defines the transformation matrix
  68028. * @returns the transformed Vector3
  68029. */
  68030. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68031. /**
  68032. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68033. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68034. * @param vector defines the Vector3 to transform
  68035. * @param transformation defines the transformation matrix
  68036. * @param result defines the Vector3 where to store the result
  68037. */
  68038. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68039. /**
  68040. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68041. * This method computes tranformed coordinates only, not transformed direction vectors
  68042. * @param x define the x coordinate of the source vector
  68043. * @param y define the y coordinate of the source vector
  68044. * @param z define the z coordinate of the source vector
  68045. * @param transformation defines the transformation matrix
  68046. * @param result defines the Vector3 where to store the result
  68047. */
  68048. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68049. /**
  68050. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68051. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68052. * @param vector defines the Vector3 to transform
  68053. * @param transformation defines the transformation matrix
  68054. * @returns the new Vector3
  68055. */
  68056. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68057. /**
  68058. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68059. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68060. * @param vector defines the Vector3 to transform
  68061. * @param transformation defines the transformation matrix
  68062. * @param result defines the Vector3 where to store the result
  68063. */
  68064. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68065. /**
  68066. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68067. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68068. * @param x define the x coordinate of the source vector
  68069. * @param y define the y coordinate of the source vector
  68070. * @param z define the z coordinate of the source vector
  68071. * @param transformation defines the transformation matrix
  68072. * @param result defines the Vector3 where to store the result
  68073. */
  68074. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68075. /**
  68076. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68077. * @param value1 defines the first control point
  68078. * @param value2 defines the second control point
  68079. * @param value3 defines the third control point
  68080. * @param value4 defines the fourth control point
  68081. * @param amount defines the amount on the spline to use
  68082. * @returns the new Vector3
  68083. */
  68084. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68085. /**
  68086. * 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"
  68087. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68088. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68089. * @param value defines the current value
  68090. * @param min defines the lower range value
  68091. * @param max defines the upper range value
  68092. * @returns the new Vector3
  68093. */
  68094. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68095. /**
  68096. * 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"
  68097. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68098. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68099. * @param value defines the current value
  68100. * @param min defines the lower range value
  68101. * @param max defines the upper range value
  68102. * @param result defines the Vector3 where to store the result
  68103. */
  68104. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68105. /**
  68106. * Checks if a given vector is inside a specific range
  68107. * @param v defines the vector to test
  68108. * @param min defines the minimum range
  68109. * @param max defines the maximum range
  68110. */
  68111. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68112. /**
  68113. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68114. * @param value1 defines the first control point
  68115. * @param tangent1 defines the first tangent vector
  68116. * @param value2 defines the second control point
  68117. * @param tangent2 defines the second tangent vector
  68118. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68119. * @returns the new Vector3
  68120. */
  68121. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68122. /**
  68123. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68124. * @param start defines the start value
  68125. * @param end defines the end value
  68126. * @param amount max defines amount between both (between 0 and 1)
  68127. * @returns the new Vector3
  68128. */
  68129. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68130. /**
  68131. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68132. * @param start defines the start value
  68133. * @param end defines the end value
  68134. * @param amount max defines amount between both (between 0 and 1)
  68135. * @param result defines the Vector3 where to store the result
  68136. */
  68137. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68138. /**
  68139. * Returns the dot product (float) between the vectors "left" and "right"
  68140. * @param left defines the left operand
  68141. * @param right defines the right operand
  68142. * @returns the dot product
  68143. */
  68144. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68145. /**
  68146. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68147. * The cross product is then orthogonal to both "left" and "right"
  68148. * @param left defines the left operand
  68149. * @param right defines the right operand
  68150. * @returns the cross product
  68151. */
  68152. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68153. /**
  68154. * Sets the given vector "result" with the cross product of "left" and "right"
  68155. * The cross product is then orthogonal to both "left" and "right"
  68156. * @param left defines the left operand
  68157. * @param right defines the right operand
  68158. * @param result defines the Vector3 where to store the result
  68159. */
  68160. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68161. /**
  68162. * Returns a new Vector3 as the normalization of the given vector
  68163. * @param vector defines the Vector3 to normalize
  68164. * @returns the new Vector3
  68165. */
  68166. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68167. /**
  68168. * Sets the given vector "result" with the normalization of the given first vector
  68169. * @param vector defines the Vector3 to normalize
  68170. * @param result defines the Vector3 where to store the result
  68171. */
  68172. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68173. /**
  68174. * Project a Vector3 onto screen space
  68175. * @param vector defines the Vector3 to project
  68176. * @param world defines the world matrix to use
  68177. * @param transform defines the transform (view x projection) matrix to use
  68178. * @param viewport defines the screen viewport to use
  68179. * @returns the new Vector3
  68180. */
  68181. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68182. /** @hidden */
  68183. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68184. /**
  68185. * Unproject from screen space to object space
  68186. * @param source defines the screen space Vector3 to use
  68187. * @param viewportWidth defines the current width of the viewport
  68188. * @param viewportHeight defines the current height of the viewport
  68189. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68190. * @param transform defines the transform (view x projection) matrix to use
  68191. * @returns the new Vector3
  68192. */
  68193. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68194. /**
  68195. * Unproject from screen space to object space
  68196. * @param source defines the screen space Vector3 to use
  68197. * @param viewportWidth defines the current width of the viewport
  68198. * @param viewportHeight defines the current height of the viewport
  68199. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68200. * @param view defines the view matrix to use
  68201. * @param projection defines the projection matrix to use
  68202. * @returns the new Vector3
  68203. */
  68204. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68205. /**
  68206. * Unproject from screen space to object space
  68207. * @param source defines the screen space Vector3 to use
  68208. * @param viewportWidth defines the current width of the viewport
  68209. * @param viewportHeight defines the current height of the viewport
  68210. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68211. * @param view defines the view matrix to use
  68212. * @param projection defines the projection matrix to use
  68213. * @param result defines the Vector3 where to store the result
  68214. */
  68215. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68216. /**
  68217. * Unproject from screen space to object space
  68218. * @param sourceX defines the screen space x coordinate to use
  68219. * @param sourceY defines the screen space y coordinate to use
  68220. * @param sourceZ defines the screen space z coordinate to use
  68221. * @param viewportWidth defines the current width of the viewport
  68222. * @param viewportHeight defines the current height of the viewport
  68223. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68224. * @param view defines the view matrix to use
  68225. * @param projection defines the projection matrix to use
  68226. * @param result defines the Vector3 where to store the result
  68227. */
  68228. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68229. /**
  68230. * Gets the minimal coordinate values between two Vector3
  68231. * @param left defines the first operand
  68232. * @param right defines the second operand
  68233. * @returns the new Vector3
  68234. */
  68235. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68236. /**
  68237. * Gets the maximal coordinate values between two Vector3
  68238. * @param left defines the first operand
  68239. * @param right defines the second operand
  68240. * @returns the new Vector3
  68241. */
  68242. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68243. /**
  68244. * Returns the distance between the vectors "value1" and "value2"
  68245. * @param value1 defines the first operand
  68246. * @param value2 defines the second operand
  68247. * @returns the distance
  68248. */
  68249. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68250. /**
  68251. * Returns the squared distance between the vectors "value1" and "value2"
  68252. * @param value1 defines the first operand
  68253. * @param value2 defines the second operand
  68254. * @returns the squared distance
  68255. */
  68256. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68257. /**
  68258. * Returns a new Vector3 located at the center between "value1" and "value2"
  68259. * @param value1 defines the first operand
  68260. * @param value2 defines the second operand
  68261. * @returns the new Vector3
  68262. */
  68263. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68264. /**
  68265. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68266. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68267. * to something in order to rotate it from its local system to the given target system
  68268. * Note: axis1, axis2 and axis3 are normalized during this operation
  68269. * @param axis1 defines the first axis
  68270. * @param axis2 defines the second axis
  68271. * @param axis3 defines the third axis
  68272. * @returns a new Vector3
  68273. */
  68274. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68275. /**
  68276. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68277. * @param axis1 defines the first axis
  68278. * @param axis2 defines the second axis
  68279. * @param axis3 defines the third axis
  68280. * @param ref defines the Vector3 where to store the result
  68281. */
  68282. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68283. }
  68284. /**
  68285. * Vector4 class created for EulerAngle class conversion to Quaternion
  68286. */
  68287. export class Vector4 {
  68288. /** x value of the vector */
  68289. x: number;
  68290. /** y value of the vector */
  68291. y: number;
  68292. /** z value of the vector */
  68293. z: number;
  68294. /** w value of the vector */
  68295. w: number;
  68296. /**
  68297. * Creates a Vector4 object from the given floats.
  68298. * @param x x value of the vector
  68299. * @param y y value of the vector
  68300. * @param z z value of the vector
  68301. * @param w w value of the vector
  68302. */
  68303. constructor(
  68304. /** x value of the vector */
  68305. x: number,
  68306. /** y value of the vector */
  68307. y: number,
  68308. /** z value of the vector */
  68309. z: number,
  68310. /** w value of the vector */
  68311. w: number);
  68312. /**
  68313. * Returns the string with the Vector4 coordinates.
  68314. * @returns a string containing all the vector values
  68315. */
  68316. toString(): string;
  68317. /**
  68318. * Returns the string "Vector4".
  68319. * @returns "Vector4"
  68320. */
  68321. getClassName(): string;
  68322. /**
  68323. * Returns the Vector4 hash code.
  68324. * @returns a unique hash code
  68325. */
  68326. getHashCode(): number;
  68327. /**
  68328. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68329. * @returns the resulting array
  68330. */
  68331. asArray(): number[];
  68332. /**
  68333. * Populates the given array from the given index with the Vector4 coordinates.
  68334. * @param array array to populate
  68335. * @param index index of the array to start at (default: 0)
  68336. * @returns the Vector4.
  68337. */
  68338. toArray(array: FloatArray, index?: number): Vector4;
  68339. /**
  68340. * Adds the given vector to the current Vector4.
  68341. * @param otherVector the vector to add
  68342. * @returns the updated Vector4.
  68343. */
  68344. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68345. /**
  68346. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68347. * @param otherVector the vector to add
  68348. * @returns the resulting vector
  68349. */
  68350. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68351. /**
  68352. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68353. * @param otherVector the vector to add
  68354. * @param result the vector to store the result
  68355. * @returns the current Vector4.
  68356. */
  68357. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68358. /**
  68359. * Subtract in place the given vector from the current Vector4.
  68360. * @param otherVector the vector to subtract
  68361. * @returns the updated Vector4.
  68362. */
  68363. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68364. /**
  68365. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68366. * @param otherVector the vector to add
  68367. * @returns the new vector with the result
  68368. */
  68369. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68370. /**
  68371. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68372. * @param otherVector the vector to subtract
  68373. * @param result the vector to store the result
  68374. * @returns the current Vector4.
  68375. */
  68376. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68377. /**
  68378. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68379. */
  68380. /**
  68381. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68382. * @param x value to subtract
  68383. * @param y value to subtract
  68384. * @param z value to subtract
  68385. * @param w value to subtract
  68386. * @returns new vector containing the result
  68387. */
  68388. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68389. /**
  68390. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68391. * @param x value to subtract
  68392. * @param y value to subtract
  68393. * @param z value to subtract
  68394. * @param w value to subtract
  68395. * @param result the vector to store the result in
  68396. * @returns the current Vector4.
  68397. */
  68398. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68399. /**
  68400. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68401. * @returns a new vector with the negated values
  68402. */
  68403. negate(): Vector4;
  68404. /**
  68405. * Multiplies the current Vector4 coordinates by scale (float).
  68406. * @param scale the number to scale with
  68407. * @returns the updated Vector4.
  68408. */
  68409. scaleInPlace(scale: number): Vector4;
  68410. /**
  68411. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68412. * @param scale the number to scale with
  68413. * @returns a new vector with the result
  68414. */
  68415. scale(scale: number): Vector4;
  68416. /**
  68417. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68418. * @param scale the number to scale with
  68419. * @param result a vector to store the result in
  68420. * @returns the current Vector4.
  68421. */
  68422. scaleToRef(scale: number, result: Vector4): Vector4;
  68423. /**
  68424. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68425. * @param scale defines the scale factor
  68426. * @param result defines the Vector4 object where to store the result
  68427. * @returns the unmodified current Vector4
  68428. */
  68429. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68430. /**
  68431. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68432. * @param otherVector the vector to compare against
  68433. * @returns true if they are equal
  68434. */
  68435. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68436. /**
  68437. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68438. * @param otherVector vector to compare against
  68439. * @param epsilon (Default: very small number)
  68440. * @returns true if they are equal
  68441. */
  68442. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68443. /**
  68444. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68445. * @param x x value to compare against
  68446. * @param y y value to compare against
  68447. * @param z z value to compare against
  68448. * @param w w value to compare against
  68449. * @returns true if equal
  68450. */
  68451. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68452. /**
  68453. * Multiplies in place the current Vector4 by the given one.
  68454. * @param otherVector vector to multiple with
  68455. * @returns the updated Vector4.
  68456. */
  68457. multiplyInPlace(otherVector: Vector4): Vector4;
  68458. /**
  68459. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68460. * @param otherVector vector to multiple with
  68461. * @returns resulting new vector
  68462. */
  68463. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68464. /**
  68465. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68466. * @param otherVector vector to multiple with
  68467. * @param result vector to store the result
  68468. * @returns the current Vector4.
  68469. */
  68470. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68471. /**
  68472. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68473. * @param x x value multiply with
  68474. * @param y y value multiply with
  68475. * @param z z value multiply with
  68476. * @param w w value multiply with
  68477. * @returns resulting new vector
  68478. */
  68479. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68480. /**
  68481. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68482. * @param otherVector vector to devide with
  68483. * @returns resulting new vector
  68484. */
  68485. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68486. /**
  68487. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68488. * @param otherVector vector to devide with
  68489. * @param result vector to store the result
  68490. * @returns the current Vector4.
  68491. */
  68492. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68493. /**
  68494. * Divides the current Vector3 coordinates by the given ones.
  68495. * @param otherVector vector to devide with
  68496. * @returns the updated Vector3.
  68497. */
  68498. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68499. /**
  68500. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68501. * @param other defines the second operand
  68502. * @returns the current updated Vector4
  68503. */
  68504. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68505. /**
  68506. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68507. * @param other defines the second operand
  68508. * @returns the current updated Vector4
  68509. */
  68510. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68511. /**
  68512. * Gets a new Vector4 from current Vector4 floored values
  68513. * @returns a new Vector4
  68514. */
  68515. floor(): Vector4;
  68516. /**
  68517. * Gets a new Vector4 from current Vector3 floored values
  68518. * @returns a new Vector4
  68519. */
  68520. fract(): Vector4;
  68521. /**
  68522. * Returns the Vector4 length (float).
  68523. * @returns the length
  68524. */
  68525. length(): number;
  68526. /**
  68527. * Returns the Vector4 squared length (float).
  68528. * @returns the length squared
  68529. */
  68530. lengthSquared(): number;
  68531. /**
  68532. * Normalizes in place the Vector4.
  68533. * @returns the updated Vector4.
  68534. */
  68535. normalize(): Vector4;
  68536. /**
  68537. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68538. * @returns this converted to a new vector3
  68539. */
  68540. toVector3(): Vector3;
  68541. /**
  68542. * Returns a new Vector4 copied from the current one.
  68543. * @returns the new cloned vector
  68544. */
  68545. clone(): Vector4;
  68546. /**
  68547. * Updates the current Vector4 with the given one coordinates.
  68548. * @param source the source vector to copy from
  68549. * @returns the updated Vector4.
  68550. */
  68551. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68552. /**
  68553. * Updates the current Vector4 coordinates with the given floats.
  68554. * @param x float to copy from
  68555. * @param y float to copy from
  68556. * @param z float to copy from
  68557. * @param w float to copy from
  68558. * @returns the updated Vector4.
  68559. */
  68560. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68561. /**
  68562. * Updates the current Vector4 coordinates with the given floats.
  68563. * @param x float to set from
  68564. * @param y float to set from
  68565. * @param z float to set from
  68566. * @param w float to set from
  68567. * @returns the updated Vector4.
  68568. */
  68569. set(x: number, y: number, z: number, w: number): Vector4;
  68570. /**
  68571. * Copies the given float to the current Vector3 coordinates
  68572. * @param v defines the x, y, z and w coordinates of the operand
  68573. * @returns the current updated Vector3
  68574. */
  68575. setAll(v: number): Vector4;
  68576. /**
  68577. * Returns a new Vector4 set from the starting index of the given array.
  68578. * @param array the array to pull values from
  68579. * @param offset the offset into the array to start at
  68580. * @returns the new vector
  68581. */
  68582. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68583. /**
  68584. * Updates the given vector "result" from the starting index of the given array.
  68585. * @param array the array to pull values from
  68586. * @param offset the offset into the array to start at
  68587. * @param result the vector to store the result in
  68588. */
  68589. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68590. /**
  68591. * Updates the given vector "result" from the starting index of the given Float32Array.
  68592. * @param array the array to pull values from
  68593. * @param offset the offset into the array to start at
  68594. * @param result the vector to store the result in
  68595. */
  68596. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68597. /**
  68598. * Updates the given vector "result" coordinates from the given floats.
  68599. * @param x float to set from
  68600. * @param y float to set from
  68601. * @param z float to set from
  68602. * @param w float to set from
  68603. * @param result the vector to the floats in
  68604. */
  68605. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68606. /**
  68607. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68608. * @returns the new vector
  68609. */
  68610. static Zero(): Vector4;
  68611. /**
  68612. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68613. * @returns the new vector
  68614. */
  68615. static One(): Vector4;
  68616. /**
  68617. * Returns a new normalized Vector4 from the given one.
  68618. * @param vector the vector to normalize
  68619. * @returns the vector
  68620. */
  68621. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68622. /**
  68623. * Updates the given vector "result" from the normalization of the given one.
  68624. * @param vector the vector to normalize
  68625. * @param result the vector to store the result in
  68626. */
  68627. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68628. /**
  68629. * Returns a vector with the minimum values from the left and right vectors
  68630. * @param left left vector to minimize
  68631. * @param right right vector to minimize
  68632. * @returns a new vector with the minimum of the left and right vector values
  68633. */
  68634. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68635. /**
  68636. * Returns a vector with the maximum values from the left and right vectors
  68637. * @param left left vector to maximize
  68638. * @param right right vector to maximize
  68639. * @returns a new vector with the maximum of the left and right vector values
  68640. */
  68641. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68642. /**
  68643. * Returns the distance (float) between the vectors "value1" and "value2".
  68644. * @param value1 value to calulate the distance between
  68645. * @param value2 value to calulate the distance between
  68646. * @return the distance between the two vectors
  68647. */
  68648. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68649. /**
  68650. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68651. * @param value1 value to calulate the distance between
  68652. * @param value2 value to calulate the distance between
  68653. * @return the distance between the two vectors squared
  68654. */
  68655. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68656. /**
  68657. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68658. * @param value1 value to calulate the center between
  68659. * @param value2 value to calulate the center between
  68660. * @return the center between the two vectors
  68661. */
  68662. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68663. /**
  68664. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68665. * This methods computes transformed normalized direction vectors only.
  68666. * @param vector the vector to transform
  68667. * @param transformation the transformation matrix to apply
  68668. * @returns the new vector
  68669. */
  68670. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68671. /**
  68672. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68673. * This methods computes transformed normalized direction vectors only.
  68674. * @param vector the vector to transform
  68675. * @param transformation the transformation matrix to apply
  68676. * @param result the vector to store the result in
  68677. */
  68678. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68679. /**
  68680. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68681. * This methods computes transformed normalized direction vectors only.
  68682. * @param x value to transform
  68683. * @param y value to transform
  68684. * @param z value to transform
  68685. * @param w value to transform
  68686. * @param transformation the transformation matrix to apply
  68687. * @param result the vector to store the results in
  68688. */
  68689. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68690. /**
  68691. * Creates a new Vector4 from a Vector3
  68692. * @param source defines the source data
  68693. * @param w defines the 4th component (default is 0)
  68694. * @returns a new Vector4
  68695. */
  68696. static FromVector3(source: Vector3, w?: number): Vector4;
  68697. }
  68698. /**
  68699. * Class used to store quaternion data
  68700. * @see https://en.wikipedia.org/wiki/Quaternion
  68701. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68702. */
  68703. export class Quaternion {
  68704. /** defines the first component (0 by default) */
  68705. x: number;
  68706. /** defines the second component (0 by default) */
  68707. y: number;
  68708. /** defines the third component (0 by default) */
  68709. z: number;
  68710. /** defines the fourth component (1.0 by default) */
  68711. w: number;
  68712. /**
  68713. * Creates a new Quaternion from the given floats
  68714. * @param x defines the first component (0 by default)
  68715. * @param y defines the second component (0 by default)
  68716. * @param z defines the third component (0 by default)
  68717. * @param w defines the fourth component (1.0 by default)
  68718. */
  68719. constructor(
  68720. /** defines the first component (0 by default) */
  68721. x?: number,
  68722. /** defines the second component (0 by default) */
  68723. y?: number,
  68724. /** defines the third component (0 by default) */
  68725. z?: number,
  68726. /** defines the fourth component (1.0 by default) */
  68727. w?: number);
  68728. /**
  68729. * Gets a string representation for the current quaternion
  68730. * @returns a string with the Quaternion coordinates
  68731. */
  68732. toString(): string;
  68733. /**
  68734. * Gets the class name of the quaternion
  68735. * @returns the string "Quaternion"
  68736. */
  68737. getClassName(): string;
  68738. /**
  68739. * Gets a hash code for this quaternion
  68740. * @returns the quaternion hash code
  68741. */
  68742. getHashCode(): number;
  68743. /**
  68744. * Copy the quaternion to an array
  68745. * @returns a new array populated with 4 elements from the quaternion coordinates
  68746. */
  68747. asArray(): number[];
  68748. /**
  68749. * Check if two quaternions are equals
  68750. * @param otherQuaternion defines the second operand
  68751. * @return true if the current quaternion and the given one coordinates are strictly equals
  68752. */
  68753. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68754. /**
  68755. * Clone the current quaternion
  68756. * @returns a new quaternion copied from the current one
  68757. */
  68758. clone(): Quaternion;
  68759. /**
  68760. * Copy a quaternion to the current one
  68761. * @param other defines the other quaternion
  68762. * @returns the updated current quaternion
  68763. */
  68764. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68765. /**
  68766. * Updates the current quaternion with the given float coordinates
  68767. * @param x defines the x coordinate
  68768. * @param y defines the y coordinate
  68769. * @param z defines the z coordinate
  68770. * @param w defines the w coordinate
  68771. * @returns the updated current quaternion
  68772. */
  68773. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68774. /**
  68775. * Updates the current quaternion from the given float coordinates
  68776. * @param x defines the x coordinate
  68777. * @param y defines the y coordinate
  68778. * @param z defines the z coordinate
  68779. * @param w defines the w coordinate
  68780. * @returns the updated current quaternion
  68781. */
  68782. set(x: number, y: number, z: number, w: number): Quaternion;
  68783. /**
  68784. * Adds two quaternions
  68785. * @param other defines the second operand
  68786. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68787. */
  68788. add(other: DeepImmutable<Quaternion>): Quaternion;
  68789. /**
  68790. * Add a quaternion to the current one
  68791. * @param other defines the quaternion to add
  68792. * @returns the current quaternion
  68793. */
  68794. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68795. /**
  68796. * Subtract two quaternions
  68797. * @param other defines the second operand
  68798. * @returns a new quaternion as the subtraction result of the given one from the current one
  68799. */
  68800. subtract(other: Quaternion): Quaternion;
  68801. /**
  68802. * Multiplies the current quaternion by a scale factor
  68803. * @param value defines the scale factor
  68804. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68805. */
  68806. scale(value: number): Quaternion;
  68807. /**
  68808. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68809. * @param scale defines the scale factor
  68810. * @param result defines the Quaternion object where to store the result
  68811. * @returns the unmodified current quaternion
  68812. */
  68813. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68814. /**
  68815. * Multiplies in place the current quaternion by a scale factor
  68816. * @param value defines the scale factor
  68817. * @returns the current modified quaternion
  68818. */
  68819. scaleInPlace(value: number): Quaternion;
  68820. /**
  68821. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68822. * @param scale defines the scale factor
  68823. * @param result defines the Quaternion object where to store the result
  68824. * @returns the unmodified current quaternion
  68825. */
  68826. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68827. /**
  68828. * Multiplies two quaternions
  68829. * @param q1 defines the second operand
  68830. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68831. */
  68832. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68833. /**
  68834. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68835. * @param q1 defines the second operand
  68836. * @param result defines the target quaternion
  68837. * @returns the current quaternion
  68838. */
  68839. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68840. /**
  68841. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68842. * @param q1 defines the second operand
  68843. * @returns the currentupdated quaternion
  68844. */
  68845. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68846. /**
  68847. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68848. * @param ref defines the target quaternion
  68849. * @returns the current quaternion
  68850. */
  68851. conjugateToRef(ref: Quaternion): Quaternion;
  68852. /**
  68853. * Conjugates in place (1-q) the current quaternion
  68854. * @returns the current updated quaternion
  68855. */
  68856. conjugateInPlace(): Quaternion;
  68857. /**
  68858. * Conjugates in place (1-q) the current quaternion
  68859. * @returns a new quaternion
  68860. */
  68861. conjugate(): Quaternion;
  68862. /**
  68863. * Gets length of current quaternion
  68864. * @returns the quaternion length (float)
  68865. */
  68866. length(): number;
  68867. /**
  68868. * Normalize in place the current quaternion
  68869. * @returns the current updated quaternion
  68870. */
  68871. normalize(): Quaternion;
  68872. /**
  68873. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68874. * @param order is a reserved parameter and is ignore for now
  68875. * @returns a new Vector3 containing the Euler angles
  68876. */
  68877. toEulerAngles(order?: string): Vector3;
  68878. /**
  68879. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68880. * @param result defines the vector which will be filled with the Euler angles
  68881. * @param order is a reserved parameter and is ignore for now
  68882. * @returns the current unchanged quaternion
  68883. */
  68884. toEulerAnglesToRef(result: Vector3): Quaternion;
  68885. /**
  68886. * Updates the given rotation matrix with the current quaternion values
  68887. * @param result defines the target matrix
  68888. * @returns the current unchanged quaternion
  68889. */
  68890. toRotationMatrix(result: Matrix): Quaternion;
  68891. /**
  68892. * Updates the current quaternion from the given rotation matrix values
  68893. * @param matrix defines the source matrix
  68894. * @returns the current updated quaternion
  68895. */
  68896. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68897. /**
  68898. * Creates a new quaternion from a rotation matrix
  68899. * @param matrix defines the source matrix
  68900. * @returns a new quaternion created from the given rotation matrix values
  68901. */
  68902. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68903. /**
  68904. * Updates the given quaternion with the given rotation matrix values
  68905. * @param matrix defines the source matrix
  68906. * @param result defines the target quaternion
  68907. */
  68908. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68909. /**
  68910. * Returns the dot product (float) between the quaternions "left" and "right"
  68911. * @param left defines the left operand
  68912. * @param right defines the right operand
  68913. * @returns the dot product
  68914. */
  68915. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68916. /**
  68917. * Checks if the two quaternions are close to each other
  68918. * @param quat0 defines the first quaternion to check
  68919. * @param quat1 defines the second quaternion to check
  68920. * @returns true if the two quaternions are close to each other
  68921. */
  68922. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68923. /**
  68924. * Creates an empty quaternion
  68925. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68926. */
  68927. static Zero(): Quaternion;
  68928. /**
  68929. * Inverse a given quaternion
  68930. * @param q defines the source quaternion
  68931. * @returns a new quaternion as the inverted current quaternion
  68932. */
  68933. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68934. /**
  68935. * Inverse a given quaternion
  68936. * @param q defines the source quaternion
  68937. * @param result the quaternion the result will be stored in
  68938. * @returns the result quaternion
  68939. */
  68940. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68941. /**
  68942. * Creates an identity quaternion
  68943. * @returns the identity quaternion
  68944. */
  68945. static Identity(): Quaternion;
  68946. /**
  68947. * Gets a boolean indicating if the given quaternion is identity
  68948. * @param quaternion defines the quaternion to check
  68949. * @returns true if the quaternion is identity
  68950. */
  68951. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68952. /**
  68953. * Creates a quaternion from a rotation around an axis
  68954. * @param axis defines the axis to use
  68955. * @param angle defines the angle to use
  68956. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68957. */
  68958. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68959. /**
  68960. * Creates a rotation around an axis and stores it into the given quaternion
  68961. * @param axis defines the axis to use
  68962. * @param angle defines the angle to use
  68963. * @param result defines the target quaternion
  68964. * @returns the target quaternion
  68965. */
  68966. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  68967. /**
  68968. * Creates a new quaternion from data stored into an array
  68969. * @param array defines the data source
  68970. * @param offset defines the offset in the source array where the data starts
  68971. * @returns a new quaternion
  68972. */
  68973. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  68974. /**
  68975. * Create a quaternion from Euler rotation angles
  68976. * @param x Pitch
  68977. * @param y Yaw
  68978. * @param z Roll
  68979. * @returns the new Quaternion
  68980. */
  68981. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  68982. /**
  68983. * Updates a quaternion from Euler rotation angles
  68984. * @param x Pitch
  68985. * @param y Yaw
  68986. * @param z Roll
  68987. * @param result the quaternion to store the result
  68988. * @returns the updated quaternion
  68989. */
  68990. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  68991. /**
  68992. * Create a quaternion from Euler rotation vector
  68993. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68994. * @returns the new Quaternion
  68995. */
  68996. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  68997. /**
  68998. * Updates a quaternion from Euler rotation vector
  68999. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69000. * @param result the quaternion to store the result
  69001. * @returns the updated quaternion
  69002. */
  69003. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69004. /**
  69005. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69006. * @param yaw defines the rotation around Y axis
  69007. * @param pitch defines the rotation around X axis
  69008. * @param roll defines the rotation around Z axis
  69009. * @returns the new quaternion
  69010. */
  69011. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69012. /**
  69013. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69014. * @param yaw defines the rotation around Y axis
  69015. * @param pitch defines the rotation around X axis
  69016. * @param roll defines the rotation around Z axis
  69017. * @param result defines the target quaternion
  69018. */
  69019. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69020. /**
  69021. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69022. * @param alpha defines the rotation around first axis
  69023. * @param beta defines the rotation around second axis
  69024. * @param gamma defines the rotation around third axis
  69025. * @returns the new quaternion
  69026. */
  69027. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69028. /**
  69029. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69030. * @param alpha defines the rotation around first axis
  69031. * @param beta defines the rotation around second axis
  69032. * @param gamma defines the rotation around third axis
  69033. * @param result defines the target quaternion
  69034. */
  69035. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69036. /**
  69037. * 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)
  69038. * @param axis1 defines the first axis
  69039. * @param axis2 defines the second axis
  69040. * @param axis3 defines the third axis
  69041. * @returns the new quaternion
  69042. */
  69043. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69044. /**
  69045. * 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
  69046. * @param axis1 defines the first axis
  69047. * @param axis2 defines the second axis
  69048. * @param axis3 defines the third axis
  69049. * @param ref defines the target quaternion
  69050. */
  69051. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69052. /**
  69053. * Interpolates between two quaternions
  69054. * @param left defines first quaternion
  69055. * @param right defines second quaternion
  69056. * @param amount defines the gradient to use
  69057. * @returns the new interpolated quaternion
  69058. */
  69059. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69060. /**
  69061. * Interpolates between two quaternions and stores it into a target quaternion
  69062. * @param left defines first quaternion
  69063. * @param right defines second quaternion
  69064. * @param amount defines the gradient to use
  69065. * @param result defines the target quaternion
  69066. */
  69067. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69068. /**
  69069. * Interpolate between two quaternions using Hermite interpolation
  69070. * @param value1 defines first quaternion
  69071. * @param tangent1 defines the incoming tangent
  69072. * @param value2 defines second quaternion
  69073. * @param tangent2 defines the outgoing tangent
  69074. * @param amount defines the target quaternion
  69075. * @returns the new interpolated quaternion
  69076. */
  69077. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69078. }
  69079. /**
  69080. * Class used to store matrix data (4x4)
  69081. */
  69082. export class Matrix {
  69083. private static _updateFlagSeed;
  69084. private static _identityReadOnly;
  69085. private _isIdentity;
  69086. private _isIdentityDirty;
  69087. private _isIdentity3x2;
  69088. private _isIdentity3x2Dirty;
  69089. /**
  69090. * Gets the update flag of the matrix which is an unique number for the matrix.
  69091. * It will be incremented every time the matrix data change.
  69092. * You can use it to speed the comparison between two versions of the same matrix.
  69093. */
  69094. updateFlag: number;
  69095. private readonly _m;
  69096. /**
  69097. * Gets the internal data of the matrix
  69098. */
  69099. readonly m: DeepImmutable<Float32Array>;
  69100. /** @hidden */
  69101. _markAsUpdated(): void;
  69102. /** @hidden */
  69103. private _updateIdentityStatus;
  69104. /**
  69105. * Creates an empty matrix (filled with zeros)
  69106. */
  69107. constructor();
  69108. /**
  69109. * Check if the current matrix is identity
  69110. * @returns true is the matrix is the identity matrix
  69111. */
  69112. isIdentity(): boolean;
  69113. /**
  69114. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69115. * @returns true is the matrix is the identity matrix
  69116. */
  69117. isIdentityAs3x2(): boolean;
  69118. /**
  69119. * Gets the determinant of the matrix
  69120. * @returns the matrix determinant
  69121. */
  69122. determinant(): number;
  69123. /**
  69124. * Returns the matrix as a Float32Array
  69125. * @returns the matrix underlying array
  69126. */
  69127. toArray(): DeepImmutable<Float32Array>;
  69128. /**
  69129. * Returns the matrix as a Float32Array
  69130. * @returns the matrix underlying array.
  69131. */
  69132. asArray(): DeepImmutable<Float32Array>;
  69133. /**
  69134. * Inverts the current matrix in place
  69135. * @returns the current inverted matrix
  69136. */
  69137. invert(): Matrix;
  69138. /**
  69139. * Sets all the matrix elements to zero
  69140. * @returns the current matrix
  69141. */
  69142. reset(): Matrix;
  69143. /**
  69144. * Adds the current matrix with a second one
  69145. * @param other defines the matrix to add
  69146. * @returns a new matrix as the addition of the current matrix and the given one
  69147. */
  69148. add(other: DeepImmutable<Matrix>): Matrix;
  69149. /**
  69150. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69151. * @param other defines the matrix to add
  69152. * @param result defines the target matrix
  69153. * @returns the current matrix
  69154. */
  69155. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69156. /**
  69157. * Adds in place the given matrix to the current matrix
  69158. * @param other defines the second operand
  69159. * @returns the current updated matrix
  69160. */
  69161. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69162. /**
  69163. * Sets the given matrix to the current inverted Matrix
  69164. * @param other defines the target matrix
  69165. * @returns the unmodified current matrix
  69166. */
  69167. invertToRef(other: Matrix): Matrix;
  69168. /**
  69169. * add a value at the specified position in the current Matrix
  69170. * @param index the index of the value within the matrix. between 0 and 15.
  69171. * @param value the value to be added
  69172. * @returns the current updated matrix
  69173. */
  69174. addAtIndex(index: number, value: number): Matrix;
  69175. /**
  69176. * mutiply the specified position in the current Matrix by a value
  69177. * @param index the index of the value within the matrix. between 0 and 15.
  69178. * @param value the value to be added
  69179. * @returns the current updated matrix
  69180. */
  69181. multiplyAtIndex(index: number, value: number): Matrix;
  69182. /**
  69183. * Inserts the translation vector (using 3 floats) in the current matrix
  69184. * @param x defines the 1st component of the translation
  69185. * @param y defines the 2nd component of the translation
  69186. * @param z defines the 3rd component of the translation
  69187. * @returns the current updated matrix
  69188. */
  69189. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69190. /**
  69191. * Adds the translation vector (using 3 floats) in the current matrix
  69192. * @param x defines the 1st component of the translation
  69193. * @param y defines the 2nd component of the translation
  69194. * @param z defines the 3rd component of the translation
  69195. * @returns the current updated matrix
  69196. */
  69197. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69198. /**
  69199. * Inserts the translation vector in the current matrix
  69200. * @param vector3 defines the translation to insert
  69201. * @returns the current updated matrix
  69202. */
  69203. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69204. /**
  69205. * Gets the translation value of the current matrix
  69206. * @returns a new Vector3 as the extracted translation from the matrix
  69207. */
  69208. getTranslation(): Vector3;
  69209. /**
  69210. * Fill a Vector3 with the extracted translation from the matrix
  69211. * @param result defines the Vector3 where to store the translation
  69212. * @returns the current matrix
  69213. */
  69214. getTranslationToRef(result: Vector3): Matrix;
  69215. /**
  69216. * Remove rotation and scaling part from the matrix
  69217. * @returns the updated matrix
  69218. */
  69219. removeRotationAndScaling(): Matrix;
  69220. /**
  69221. * Multiply two matrices
  69222. * @param other defines the second operand
  69223. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69224. */
  69225. multiply(other: DeepImmutable<Matrix>): Matrix;
  69226. /**
  69227. * Copy the current matrix from the given one
  69228. * @param other defines the source matrix
  69229. * @returns the current updated matrix
  69230. */
  69231. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69232. /**
  69233. * Populates the given array from the starting index with the current matrix values
  69234. * @param array defines the target array
  69235. * @param offset defines the offset in the target array where to start storing values
  69236. * @returns the current matrix
  69237. */
  69238. copyToArray(array: Float32Array, offset?: number): Matrix;
  69239. /**
  69240. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69241. * @param other defines the second operand
  69242. * @param result defines the matrix where to store the multiplication
  69243. * @returns the current matrix
  69244. */
  69245. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69246. /**
  69247. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69248. * @param other defines the second operand
  69249. * @param result defines the array where to store the multiplication
  69250. * @param offset defines the offset in the target array where to start storing values
  69251. * @returns the current matrix
  69252. */
  69253. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69254. /**
  69255. * Check equality between this matrix and a second one
  69256. * @param value defines the second matrix to compare
  69257. * @returns true is the current matrix and the given one values are strictly equal
  69258. */
  69259. equals(value: DeepImmutable<Matrix>): boolean;
  69260. /**
  69261. * Clone the current matrix
  69262. * @returns a new matrix from the current matrix
  69263. */
  69264. clone(): Matrix;
  69265. /**
  69266. * Returns the name of the current matrix class
  69267. * @returns the string "Matrix"
  69268. */
  69269. getClassName(): string;
  69270. /**
  69271. * Gets the hash code of the current matrix
  69272. * @returns the hash code
  69273. */
  69274. getHashCode(): number;
  69275. /**
  69276. * Decomposes the current Matrix into a translation, rotation and scaling components
  69277. * @param scale defines the scale vector3 given as a reference to update
  69278. * @param rotation defines the rotation quaternion given as a reference to update
  69279. * @param translation defines the translation vector3 given as a reference to update
  69280. * @returns true if operation was successful
  69281. */
  69282. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69283. /**
  69284. * Gets specific row of the matrix
  69285. * @param index defines the number of the row to get
  69286. * @returns the index-th row of the current matrix as a new Vector4
  69287. */
  69288. getRow(index: number): Nullable<Vector4>;
  69289. /**
  69290. * Sets the index-th row of the current matrix to the vector4 values
  69291. * @param index defines the number of the row to set
  69292. * @param row defines the target vector4
  69293. * @returns the updated current matrix
  69294. */
  69295. setRow(index: number, row: Vector4): Matrix;
  69296. /**
  69297. * Compute the transpose of the matrix
  69298. * @returns the new transposed matrix
  69299. */
  69300. transpose(): Matrix;
  69301. /**
  69302. * Compute the transpose of the matrix and store it in a given matrix
  69303. * @param result defines the target matrix
  69304. * @returns the current matrix
  69305. */
  69306. transposeToRef(result: Matrix): Matrix;
  69307. /**
  69308. * Sets the index-th row of the current matrix with the given 4 x float values
  69309. * @param index defines the row index
  69310. * @param x defines the x component to set
  69311. * @param y defines the y component to set
  69312. * @param z defines the z component to set
  69313. * @param w defines the w component to set
  69314. * @returns the updated current matrix
  69315. */
  69316. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69317. /**
  69318. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69319. * @param scale defines the scale factor
  69320. * @returns a new matrix
  69321. */
  69322. scale(scale: number): Matrix;
  69323. /**
  69324. * Scale the current matrix values by a factor to a given result matrix
  69325. * @param scale defines the scale factor
  69326. * @param result defines the matrix to store the result
  69327. * @returns the current matrix
  69328. */
  69329. scaleToRef(scale: number, result: Matrix): Matrix;
  69330. /**
  69331. * Scale the current matrix values by a factor and add the result to a given matrix
  69332. * @param scale defines the scale factor
  69333. * @param result defines the Matrix to store the result
  69334. * @returns the current matrix
  69335. */
  69336. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69337. /**
  69338. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69339. * @param ref matrix to store the result
  69340. */
  69341. toNormalMatrix(ref: Matrix): void;
  69342. /**
  69343. * Gets only rotation part of the current matrix
  69344. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69345. */
  69346. getRotationMatrix(): Matrix;
  69347. /**
  69348. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69349. * @param result defines the target matrix to store data to
  69350. * @returns the current matrix
  69351. */
  69352. getRotationMatrixToRef(result: Matrix): Matrix;
  69353. /**
  69354. * Toggles model matrix from being right handed to left handed in place and vice versa
  69355. */
  69356. toggleModelMatrixHandInPlace(): void;
  69357. /**
  69358. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69359. */
  69360. toggleProjectionMatrixHandInPlace(): void;
  69361. /**
  69362. * Creates a matrix from an array
  69363. * @param array defines the source array
  69364. * @param offset defines an offset in the source array
  69365. * @returns a new Matrix set from the starting index of the given array
  69366. */
  69367. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69368. /**
  69369. * Copy the content of an array into a given matrix
  69370. * @param array defines the source array
  69371. * @param offset defines an offset in the source array
  69372. * @param result defines the target matrix
  69373. */
  69374. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69375. /**
  69376. * Stores an array into a matrix after having multiplied each component by a given factor
  69377. * @param array defines the source array
  69378. * @param offset defines the offset in the source array
  69379. * @param scale defines the scaling factor
  69380. * @param result defines the target matrix
  69381. */
  69382. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69383. /**
  69384. * Gets an identity matrix that must not be updated
  69385. */
  69386. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69387. /**
  69388. * Stores a list of values (16) inside a given matrix
  69389. * @param initialM11 defines 1st value of 1st row
  69390. * @param initialM12 defines 2nd value of 1st row
  69391. * @param initialM13 defines 3rd value of 1st row
  69392. * @param initialM14 defines 4th value of 1st row
  69393. * @param initialM21 defines 1st value of 2nd row
  69394. * @param initialM22 defines 2nd value of 2nd row
  69395. * @param initialM23 defines 3rd value of 2nd row
  69396. * @param initialM24 defines 4th value of 2nd row
  69397. * @param initialM31 defines 1st value of 3rd row
  69398. * @param initialM32 defines 2nd value of 3rd row
  69399. * @param initialM33 defines 3rd value of 3rd row
  69400. * @param initialM34 defines 4th value of 3rd row
  69401. * @param initialM41 defines 1st value of 4th row
  69402. * @param initialM42 defines 2nd value of 4th row
  69403. * @param initialM43 defines 3rd value of 4th row
  69404. * @param initialM44 defines 4th value of 4th row
  69405. * @param result defines the target matrix
  69406. */
  69407. 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;
  69408. /**
  69409. * Creates new matrix from a list of values (16)
  69410. * @param initialM11 defines 1st value of 1st row
  69411. * @param initialM12 defines 2nd value of 1st row
  69412. * @param initialM13 defines 3rd value of 1st row
  69413. * @param initialM14 defines 4th value of 1st row
  69414. * @param initialM21 defines 1st value of 2nd row
  69415. * @param initialM22 defines 2nd value of 2nd row
  69416. * @param initialM23 defines 3rd value of 2nd row
  69417. * @param initialM24 defines 4th value of 2nd row
  69418. * @param initialM31 defines 1st value of 3rd row
  69419. * @param initialM32 defines 2nd value of 3rd row
  69420. * @param initialM33 defines 3rd value of 3rd row
  69421. * @param initialM34 defines 4th value of 3rd row
  69422. * @param initialM41 defines 1st value of 4th row
  69423. * @param initialM42 defines 2nd value of 4th row
  69424. * @param initialM43 defines 3rd value of 4th row
  69425. * @param initialM44 defines 4th value of 4th row
  69426. * @returns the new matrix
  69427. */
  69428. 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;
  69429. /**
  69430. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69431. * @param scale defines the scale vector3
  69432. * @param rotation defines the rotation quaternion
  69433. * @param translation defines the translation vector3
  69434. * @returns a new matrix
  69435. */
  69436. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69437. /**
  69438. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69439. * @param scale defines the scale vector3
  69440. * @param rotation defines the rotation quaternion
  69441. * @param translation defines the translation vector3
  69442. * @param result defines the target matrix
  69443. */
  69444. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69445. /**
  69446. * Creates a new identity matrix
  69447. * @returns a new identity matrix
  69448. */
  69449. static Identity(): Matrix;
  69450. /**
  69451. * Creates a new identity matrix and stores the result in a given matrix
  69452. * @param result defines the target matrix
  69453. */
  69454. static IdentityToRef(result: Matrix): void;
  69455. /**
  69456. * Creates a new zero matrix
  69457. * @returns a new zero matrix
  69458. */
  69459. static Zero(): Matrix;
  69460. /**
  69461. * Creates a new rotation matrix for "angle" radians around the X axis
  69462. * @param angle defines the angle (in radians) to use
  69463. * @return the new matrix
  69464. */
  69465. static RotationX(angle: number): Matrix;
  69466. /**
  69467. * Creates a new matrix as the invert of a given matrix
  69468. * @param source defines the source matrix
  69469. * @returns the new matrix
  69470. */
  69471. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69472. /**
  69473. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69474. * @param angle defines the angle (in radians) to use
  69475. * @param result defines the target matrix
  69476. */
  69477. static RotationXToRef(angle: number, result: Matrix): void;
  69478. /**
  69479. * Creates a new rotation matrix for "angle" radians around the Y axis
  69480. * @param angle defines the angle (in radians) to use
  69481. * @return the new matrix
  69482. */
  69483. static RotationY(angle: number): Matrix;
  69484. /**
  69485. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69486. * @param angle defines the angle (in radians) to use
  69487. * @param result defines the target matrix
  69488. */
  69489. static RotationYToRef(angle: number, result: Matrix): void;
  69490. /**
  69491. * Creates a new rotation matrix for "angle" radians around the Z axis
  69492. * @param angle defines the angle (in radians) to use
  69493. * @return the new matrix
  69494. */
  69495. static RotationZ(angle: number): Matrix;
  69496. /**
  69497. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69498. * @param angle defines the angle (in radians) to use
  69499. * @param result defines the target matrix
  69500. */
  69501. static RotationZToRef(angle: number, result: Matrix): void;
  69502. /**
  69503. * Creates a new rotation matrix for "angle" radians around the given axis
  69504. * @param axis defines the axis to use
  69505. * @param angle defines the angle (in radians) to use
  69506. * @return the new matrix
  69507. */
  69508. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69509. /**
  69510. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69511. * @param axis defines the axis to use
  69512. * @param angle defines the angle (in radians) to use
  69513. * @param result defines the target matrix
  69514. */
  69515. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69516. /**
  69517. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69518. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69519. * @param from defines the vector to align
  69520. * @param to defines the vector to align to
  69521. * @param result defines the target matrix
  69522. */
  69523. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69524. /**
  69525. * Creates a rotation matrix
  69526. * @param yaw defines the yaw angle in radians (Y axis)
  69527. * @param pitch defines the pitch angle in radians (X axis)
  69528. * @param roll defines the roll angle in radians (X axis)
  69529. * @returns the new rotation matrix
  69530. */
  69531. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69532. /**
  69533. * Creates a rotation matrix and stores it in a given matrix
  69534. * @param yaw defines the yaw angle in radians (Y axis)
  69535. * @param pitch defines the pitch angle in radians (X axis)
  69536. * @param roll defines the roll angle in radians (X axis)
  69537. * @param result defines the target matrix
  69538. */
  69539. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69540. /**
  69541. * Creates a scaling matrix
  69542. * @param x defines the scale factor on X axis
  69543. * @param y defines the scale factor on Y axis
  69544. * @param z defines the scale factor on Z axis
  69545. * @returns the new matrix
  69546. */
  69547. static Scaling(x: number, y: number, z: number): Matrix;
  69548. /**
  69549. * Creates a scaling matrix and stores it in a given matrix
  69550. * @param x defines the scale factor on X axis
  69551. * @param y defines the scale factor on Y axis
  69552. * @param z defines the scale factor on Z axis
  69553. * @param result defines the target matrix
  69554. */
  69555. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69556. /**
  69557. * Creates a translation matrix
  69558. * @param x defines the translation on X axis
  69559. * @param y defines the translation on Y axis
  69560. * @param z defines the translationon Z axis
  69561. * @returns the new matrix
  69562. */
  69563. static Translation(x: number, y: number, z: number): Matrix;
  69564. /**
  69565. * Creates a translation matrix and stores it in a given matrix
  69566. * @param x defines the translation on X axis
  69567. * @param y defines the translation on Y axis
  69568. * @param z defines the translationon Z axis
  69569. * @param result defines the target matrix
  69570. */
  69571. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69572. /**
  69573. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69574. * @param startValue defines the start value
  69575. * @param endValue defines the end value
  69576. * @param gradient defines the gradient factor
  69577. * @returns the new matrix
  69578. */
  69579. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69580. /**
  69581. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69582. * @param startValue defines the start value
  69583. * @param endValue defines the end value
  69584. * @param gradient defines the gradient factor
  69585. * @param result defines the Matrix object where to store data
  69586. */
  69587. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69588. /**
  69589. * Builds a new matrix whose values are computed by:
  69590. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69591. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69592. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69593. * @param startValue defines the first matrix
  69594. * @param endValue defines the second matrix
  69595. * @param gradient defines the gradient between the two matrices
  69596. * @returns the new matrix
  69597. */
  69598. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69599. /**
  69600. * Update a matrix to values which are computed by:
  69601. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69602. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69603. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69604. * @param startValue defines the first matrix
  69605. * @param endValue defines the second matrix
  69606. * @param gradient defines the gradient between the two matrices
  69607. * @param result defines the target matrix
  69608. */
  69609. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69610. /**
  69611. * 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"
  69612. * This function works in left handed mode
  69613. * @param eye defines the final position of the entity
  69614. * @param target defines where the entity should look at
  69615. * @param up defines the up vector for the entity
  69616. * @returns the new matrix
  69617. */
  69618. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69619. /**
  69620. * 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".
  69621. * This function works in left handed mode
  69622. * @param eye defines the final position of the entity
  69623. * @param target defines where the entity should look at
  69624. * @param up defines the up vector for the entity
  69625. * @param result defines the target matrix
  69626. */
  69627. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69628. /**
  69629. * 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"
  69630. * This function works in right handed mode
  69631. * @param eye defines the final position of the entity
  69632. * @param target defines where the entity should look at
  69633. * @param up defines the up vector for the entity
  69634. * @returns the new matrix
  69635. */
  69636. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69637. /**
  69638. * 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".
  69639. * This function works in right handed mode
  69640. * @param eye defines the final position of the entity
  69641. * @param target defines where the entity should look at
  69642. * @param up defines the up vector for the entity
  69643. * @param result defines the target matrix
  69644. */
  69645. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69646. /**
  69647. * Create a left-handed orthographic projection matrix
  69648. * @param width defines the viewport width
  69649. * @param height defines the viewport height
  69650. * @param znear defines the near clip plane
  69651. * @param zfar defines the far clip plane
  69652. * @returns a new matrix as a left-handed orthographic projection matrix
  69653. */
  69654. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69655. /**
  69656. * Store a left-handed orthographic projection to a given matrix
  69657. * @param width defines the viewport width
  69658. * @param height defines the viewport height
  69659. * @param znear defines the near clip plane
  69660. * @param zfar defines the far clip plane
  69661. * @param result defines the target matrix
  69662. */
  69663. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69664. /**
  69665. * Create a left-handed orthographic projection matrix
  69666. * @param left defines the viewport left coordinate
  69667. * @param right defines the viewport right coordinate
  69668. * @param bottom defines the viewport bottom coordinate
  69669. * @param top defines the viewport top coordinate
  69670. * @param znear defines the near clip plane
  69671. * @param zfar defines the far clip plane
  69672. * @returns a new matrix as a left-handed orthographic projection matrix
  69673. */
  69674. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69675. /**
  69676. * Stores a left-handed orthographic projection into a given matrix
  69677. * @param left defines the viewport left coordinate
  69678. * @param right defines the viewport right coordinate
  69679. * @param bottom defines the viewport bottom coordinate
  69680. * @param top defines the viewport top coordinate
  69681. * @param znear defines the near clip plane
  69682. * @param zfar defines the far clip plane
  69683. * @param result defines the target matrix
  69684. */
  69685. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69686. /**
  69687. * Creates a right-handed orthographic projection matrix
  69688. * @param left defines the viewport left coordinate
  69689. * @param right defines the viewport right coordinate
  69690. * @param bottom defines the viewport bottom coordinate
  69691. * @param top defines the viewport top coordinate
  69692. * @param znear defines the near clip plane
  69693. * @param zfar defines the far clip plane
  69694. * @returns a new matrix as a right-handed orthographic projection matrix
  69695. */
  69696. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69697. /**
  69698. * Stores a right-handed orthographic projection into a given matrix
  69699. * @param left defines the viewport left coordinate
  69700. * @param right defines the viewport right coordinate
  69701. * @param bottom defines the viewport bottom coordinate
  69702. * @param top defines the viewport top coordinate
  69703. * @param znear defines the near clip plane
  69704. * @param zfar defines the far clip plane
  69705. * @param result defines the target matrix
  69706. */
  69707. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69708. /**
  69709. * Creates a left-handed perspective projection matrix
  69710. * @param width defines the viewport width
  69711. * @param height defines the viewport height
  69712. * @param znear defines the near clip plane
  69713. * @param zfar defines the far clip plane
  69714. * @returns a new matrix as a left-handed perspective projection matrix
  69715. */
  69716. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69717. /**
  69718. * Creates a left-handed perspective projection matrix
  69719. * @param fov defines the horizontal field of view
  69720. * @param aspect defines the aspect ratio
  69721. * @param znear defines the near clip plane
  69722. * @param zfar defines the far clip plane
  69723. * @returns a new matrix as a left-handed perspective projection matrix
  69724. */
  69725. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69726. /**
  69727. * Stores a left-handed perspective projection into a given matrix
  69728. * @param fov defines the horizontal field of view
  69729. * @param aspect defines the aspect ratio
  69730. * @param znear defines the near clip plane
  69731. * @param zfar defines the far clip plane
  69732. * @param result defines the target matrix
  69733. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69734. */
  69735. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69736. /**
  69737. * Creates a right-handed perspective projection matrix
  69738. * @param fov defines the horizontal field of view
  69739. * @param aspect defines the aspect ratio
  69740. * @param znear defines the near clip plane
  69741. * @param zfar defines the far clip plane
  69742. * @returns a new matrix as a right-handed perspective projection matrix
  69743. */
  69744. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69745. /**
  69746. * Stores a right-handed perspective projection into a given matrix
  69747. * @param fov defines the horizontal field of view
  69748. * @param aspect defines the aspect ratio
  69749. * @param znear defines the near clip plane
  69750. * @param zfar defines the far clip plane
  69751. * @param result defines the target matrix
  69752. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69753. */
  69754. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69755. /**
  69756. * Stores a perspective projection for WebVR info a given matrix
  69757. * @param fov defines the field of view
  69758. * @param znear defines the near clip plane
  69759. * @param zfar defines the far clip plane
  69760. * @param result defines the target matrix
  69761. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69762. */
  69763. static PerspectiveFovWebVRToRef(fov: {
  69764. upDegrees: number;
  69765. downDegrees: number;
  69766. leftDegrees: number;
  69767. rightDegrees: number;
  69768. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69769. /**
  69770. * Computes a complete transformation matrix
  69771. * @param viewport defines the viewport to use
  69772. * @param world defines the world matrix
  69773. * @param view defines the view matrix
  69774. * @param projection defines the projection matrix
  69775. * @param zmin defines the near clip plane
  69776. * @param zmax defines the far clip plane
  69777. * @returns the transformation matrix
  69778. */
  69779. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69780. /**
  69781. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69782. * @param matrix defines the matrix to use
  69783. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69784. */
  69785. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69786. /**
  69787. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69788. * @param matrix defines the matrix to use
  69789. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69790. */
  69791. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69792. /**
  69793. * Compute the transpose of a given matrix
  69794. * @param matrix defines the matrix to transpose
  69795. * @returns the new matrix
  69796. */
  69797. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69798. /**
  69799. * Compute the transpose of a matrix and store it in a target matrix
  69800. * @param matrix defines the matrix to transpose
  69801. * @param result defines the target matrix
  69802. */
  69803. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69804. /**
  69805. * Computes a reflection matrix from a plane
  69806. * @param plane defines the reflection plane
  69807. * @returns a new matrix
  69808. */
  69809. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69810. /**
  69811. * Computes a reflection matrix from a plane
  69812. * @param plane defines the reflection plane
  69813. * @param result defines the target matrix
  69814. */
  69815. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69816. /**
  69817. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69818. * @param xaxis defines the value of the 1st axis
  69819. * @param yaxis defines the value of the 2nd axis
  69820. * @param zaxis defines the value of the 3rd axis
  69821. * @param result defines the target matrix
  69822. */
  69823. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69824. /**
  69825. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69826. * @param quat defines the quaternion to use
  69827. * @param result defines the target matrix
  69828. */
  69829. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69830. }
  69831. /**
  69832. * @hidden
  69833. */
  69834. export class TmpVectors {
  69835. static Vector2: Vector2[];
  69836. static Vector3: Vector3[];
  69837. static Vector4: Vector4[];
  69838. static Quaternion: Quaternion[];
  69839. static Matrix: Matrix[];
  69840. }
  69841. }
  69842. declare module BABYLON {
  69843. /** Defines the cross module used constants to avoid circular dependncies */
  69844. export class Constants {
  69845. /** Defines that alpha blending is disabled */
  69846. static readonly ALPHA_DISABLE: number;
  69847. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69848. static readonly ALPHA_ADD: number;
  69849. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69850. static readonly ALPHA_COMBINE: number;
  69851. /** Defines that alpha blending to DEST - SRC * DEST */
  69852. static readonly ALPHA_SUBTRACT: number;
  69853. /** Defines that alpha blending to SRC * DEST */
  69854. static readonly ALPHA_MULTIPLY: number;
  69855. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69856. static readonly ALPHA_MAXIMIZED: number;
  69857. /** Defines that alpha blending to SRC + DEST */
  69858. static readonly ALPHA_ONEONE: number;
  69859. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69860. static readonly ALPHA_PREMULTIPLIED: number;
  69861. /**
  69862. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69863. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69864. */
  69865. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69866. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69867. static readonly ALPHA_INTERPOLATE: number;
  69868. /**
  69869. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69870. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69871. */
  69872. static readonly ALPHA_SCREENMODE: number;
  69873. /** Defines that the ressource is not delayed*/
  69874. static readonly DELAYLOADSTATE_NONE: number;
  69875. /** Defines that the ressource was successfully delay loaded */
  69876. static readonly DELAYLOADSTATE_LOADED: number;
  69877. /** Defines that the ressource is currently delay loading */
  69878. static readonly DELAYLOADSTATE_LOADING: number;
  69879. /** Defines that the ressource is delayed and has not started loading */
  69880. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69881. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69882. static readonly NEVER: number;
  69883. /** 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 */
  69884. static readonly ALWAYS: number;
  69885. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69886. static readonly LESS: number;
  69887. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69888. static readonly EQUAL: number;
  69889. /** 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 */
  69890. static readonly LEQUAL: number;
  69891. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69892. static readonly GREATER: number;
  69893. /** 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 */
  69894. static readonly GEQUAL: number;
  69895. /** 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 */
  69896. static readonly NOTEQUAL: number;
  69897. /** Passed to stencilOperation to specify that stencil value must be kept */
  69898. static readonly KEEP: number;
  69899. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69900. static readonly REPLACE: number;
  69901. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69902. static readonly INCR: number;
  69903. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69904. static readonly DECR: number;
  69905. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69906. static readonly INVERT: number;
  69907. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69908. static readonly INCR_WRAP: number;
  69909. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69910. static readonly DECR_WRAP: number;
  69911. /** Texture is not repeating outside of 0..1 UVs */
  69912. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69913. /** Texture is repeating outside of 0..1 UVs */
  69914. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69915. /** Texture is repeating and mirrored */
  69916. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69917. /** ALPHA */
  69918. static readonly TEXTUREFORMAT_ALPHA: number;
  69919. /** LUMINANCE */
  69920. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69921. /** LUMINANCE_ALPHA */
  69922. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69923. /** RGB */
  69924. static readonly TEXTUREFORMAT_RGB: number;
  69925. /** RGBA */
  69926. static readonly TEXTUREFORMAT_RGBA: number;
  69927. /** RED */
  69928. static readonly TEXTUREFORMAT_RED: number;
  69929. /** RED (2nd reference) */
  69930. static readonly TEXTUREFORMAT_R: number;
  69931. /** RG */
  69932. static readonly TEXTUREFORMAT_RG: number;
  69933. /** RED_INTEGER */
  69934. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69935. /** RED_INTEGER (2nd reference) */
  69936. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69937. /** RG_INTEGER */
  69938. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69939. /** RGB_INTEGER */
  69940. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69941. /** RGBA_INTEGER */
  69942. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69943. /** UNSIGNED_BYTE */
  69944. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69945. /** UNSIGNED_BYTE (2nd reference) */
  69946. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69947. /** FLOAT */
  69948. static readonly TEXTURETYPE_FLOAT: number;
  69949. /** HALF_FLOAT */
  69950. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69951. /** BYTE */
  69952. static readonly TEXTURETYPE_BYTE: number;
  69953. /** SHORT */
  69954. static readonly TEXTURETYPE_SHORT: number;
  69955. /** UNSIGNED_SHORT */
  69956. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69957. /** INT */
  69958. static readonly TEXTURETYPE_INT: number;
  69959. /** UNSIGNED_INT */
  69960. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69961. /** UNSIGNED_SHORT_4_4_4_4 */
  69962. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69963. /** UNSIGNED_SHORT_5_5_5_1 */
  69964. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69965. /** UNSIGNED_SHORT_5_6_5 */
  69966. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69967. /** UNSIGNED_INT_2_10_10_10_REV */
  69968. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69969. /** UNSIGNED_INT_24_8 */
  69970. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69971. /** UNSIGNED_INT_10F_11F_11F_REV */
  69972. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69973. /** UNSIGNED_INT_5_9_9_9_REV */
  69974. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69975. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69976. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69977. /** nearest is mag = nearest and min = nearest and mip = linear */
  69978. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69979. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69980. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69981. /** Trilinear is mag = linear and min = linear and mip = linear */
  69982. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69983. /** nearest is mag = nearest and min = nearest and mip = linear */
  69984. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69985. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69986. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69987. /** Trilinear is mag = linear and min = linear and mip = linear */
  69988. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69989. /** mag = nearest and min = nearest and mip = nearest */
  69990. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69991. /** mag = nearest and min = linear and mip = nearest */
  69992. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69993. /** mag = nearest and min = linear and mip = linear */
  69994. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69995. /** mag = nearest and min = linear and mip = none */
  69996. static readonly TEXTURE_NEAREST_LINEAR: number;
  69997. /** mag = nearest and min = nearest and mip = none */
  69998. static readonly TEXTURE_NEAREST_NEAREST: number;
  69999. /** mag = linear and min = nearest and mip = nearest */
  70000. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  70001. /** mag = linear and min = nearest and mip = linear */
  70002. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  70003. /** mag = linear and min = linear and mip = none */
  70004. static readonly TEXTURE_LINEAR_LINEAR: number;
  70005. /** mag = linear and min = nearest and mip = none */
  70006. static readonly TEXTURE_LINEAR_NEAREST: number;
  70007. /** Explicit coordinates mode */
  70008. static readonly TEXTURE_EXPLICIT_MODE: number;
  70009. /** Spherical coordinates mode */
  70010. static readonly TEXTURE_SPHERICAL_MODE: number;
  70011. /** Planar coordinates mode */
  70012. static readonly TEXTURE_PLANAR_MODE: number;
  70013. /** Cubic coordinates mode */
  70014. static readonly TEXTURE_CUBIC_MODE: number;
  70015. /** Projection coordinates mode */
  70016. static readonly TEXTURE_PROJECTION_MODE: number;
  70017. /** Skybox coordinates mode */
  70018. static readonly TEXTURE_SKYBOX_MODE: number;
  70019. /** Inverse Cubic coordinates mode */
  70020. static readonly TEXTURE_INVCUBIC_MODE: number;
  70021. /** Equirectangular coordinates mode */
  70022. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  70023. /** Equirectangular Fixed coordinates mode */
  70024. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  70025. /** Equirectangular Fixed Mirrored coordinates mode */
  70026. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  70027. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  70028. static readonly SCALEMODE_FLOOR: number;
  70029. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70030. static readonly SCALEMODE_NEAREST: number;
  70031. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70032. static readonly SCALEMODE_CEILING: number;
  70033. /**
  70034. * The dirty texture flag value
  70035. */
  70036. static readonly MATERIAL_TextureDirtyFlag: number;
  70037. /**
  70038. * The dirty light flag value
  70039. */
  70040. static readonly MATERIAL_LightDirtyFlag: number;
  70041. /**
  70042. * The dirty fresnel flag value
  70043. */
  70044. static readonly MATERIAL_FresnelDirtyFlag: number;
  70045. /**
  70046. * The dirty attribute flag value
  70047. */
  70048. static readonly MATERIAL_AttributesDirtyFlag: number;
  70049. /**
  70050. * The dirty misc flag value
  70051. */
  70052. static readonly MATERIAL_MiscDirtyFlag: number;
  70053. /**
  70054. * The all dirty flag value
  70055. */
  70056. static readonly MATERIAL_AllDirtyFlag: number;
  70057. /**
  70058. * Returns the triangle fill mode
  70059. */
  70060. static readonly MATERIAL_TriangleFillMode: number;
  70061. /**
  70062. * Returns the wireframe mode
  70063. */
  70064. static readonly MATERIAL_WireFrameFillMode: number;
  70065. /**
  70066. * Returns the point fill mode
  70067. */
  70068. static readonly MATERIAL_PointFillMode: number;
  70069. /**
  70070. * Returns the point list draw mode
  70071. */
  70072. static readonly MATERIAL_PointListDrawMode: number;
  70073. /**
  70074. * Returns the line list draw mode
  70075. */
  70076. static readonly MATERIAL_LineListDrawMode: number;
  70077. /**
  70078. * Returns the line loop draw mode
  70079. */
  70080. static readonly MATERIAL_LineLoopDrawMode: number;
  70081. /**
  70082. * Returns the line strip draw mode
  70083. */
  70084. static readonly MATERIAL_LineStripDrawMode: number;
  70085. /**
  70086. * Returns the triangle strip draw mode
  70087. */
  70088. static readonly MATERIAL_TriangleStripDrawMode: number;
  70089. /**
  70090. * Returns the triangle fan draw mode
  70091. */
  70092. static readonly MATERIAL_TriangleFanDrawMode: number;
  70093. /**
  70094. * Stores the clock-wise side orientation
  70095. */
  70096. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70097. /**
  70098. * Stores the counter clock-wise side orientation
  70099. */
  70100. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70101. /**
  70102. * Nothing
  70103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70104. */
  70105. static readonly ACTION_NothingTrigger: number;
  70106. /**
  70107. * On pick
  70108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70109. */
  70110. static readonly ACTION_OnPickTrigger: number;
  70111. /**
  70112. * On left pick
  70113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70114. */
  70115. static readonly ACTION_OnLeftPickTrigger: number;
  70116. /**
  70117. * On right pick
  70118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70119. */
  70120. static readonly ACTION_OnRightPickTrigger: number;
  70121. /**
  70122. * On center pick
  70123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70124. */
  70125. static readonly ACTION_OnCenterPickTrigger: number;
  70126. /**
  70127. * On pick down
  70128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70129. */
  70130. static readonly ACTION_OnPickDownTrigger: number;
  70131. /**
  70132. * On double pick
  70133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70134. */
  70135. static readonly ACTION_OnDoublePickTrigger: number;
  70136. /**
  70137. * On pick up
  70138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70139. */
  70140. static readonly ACTION_OnPickUpTrigger: number;
  70141. /**
  70142. * On pick out.
  70143. * This trigger will only be raised if you also declared a OnPickDown
  70144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70145. */
  70146. static readonly ACTION_OnPickOutTrigger: number;
  70147. /**
  70148. * On long press
  70149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70150. */
  70151. static readonly ACTION_OnLongPressTrigger: number;
  70152. /**
  70153. * On pointer over
  70154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70155. */
  70156. static readonly ACTION_OnPointerOverTrigger: number;
  70157. /**
  70158. * On pointer out
  70159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70160. */
  70161. static readonly ACTION_OnPointerOutTrigger: number;
  70162. /**
  70163. * On every frame
  70164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70165. */
  70166. static readonly ACTION_OnEveryFrameTrigger: number;
  70167. /**
  70168. * On intersection enter
  70169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70170. */
  70171. static readonly ACTION_OnIntersectionEnterTrigger: number;
  70172. /**
  70173. * On intersection exit
  70174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70175. */
  70176. static readonly ACTION_OnIntersectionExitTrigger: number;
  70177. /**
  70178. * On key down
  70179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70180. */
  70181. static readonly ACTION_OnKeyDownTrigger: number;
  70182. /**
  70183. * On key up
  70184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70185. */
  70186. static readonly ACTION_OnKeyUpTrigger: number;
  70187. /**
  70188. * Billboard mode will only apply to Y axis
  70189. */
  70190. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  70191. /**
  70192. * Billboard mode will apply to all axes
  70193. */
  70194. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  70195. /**
  70196. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70197. */
  70198. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70199. /**
  70200. * Gets or sets base Assets URL
  70201. */
  70202. static PARTICLES_BaseAssetsUrl: string;
  70203. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70204. * Test order :
  70205. * Is the bounding sphere outside the frustum ?
  70206. * If not, are the bounding box vertices outside the frustum ?
  70207. * It not, then the cullable object is in the frustum.
  70208. */
  70209. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70210. /** Culling strategy : Bounding Sphere Only.
  70211. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70212. * It's also less accurate than the standard because some not visible objects can still be selected.
  70213. * Test : is the bounding sphere outside the frustum ?
  70214. * If not, then the cullable object is in the frustum.
  70215. */
  70216. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70217. /** Culling strategy : Optimistic Inclusion.
  70218. * This in an inclusion test first, then the standard exclusion test.
  70219. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70220. * 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.
  70221. * Anyway, it's as accurate as the standard strategy.
  70222. * Test :
  70223. * Is the cullable object bounding sphere center in the frustum ?
  70224. * If not, apply the default culling strategy.
  70225. */
  70226. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  70227. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  70228. * This in an inclusion test first, then the bounding sphere only exclusion test.
  70229. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  70230. * 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.
  70231. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  70232. * Test :
  70233. * Is the cullable object bounding sphere center in the frustum ?
  70234. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  70235. */
  70236. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  70237. /**
  70238. * No logging while loading
  70239. */
  70240. static readonly SCENELOADER_NO_LOGGING: number;
  70241. /**
  70242. * Minimal logging while loading
  70243. */
  70244. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  70245. /**
  70246. * Summary logging while loading
  70247. */
  70248. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  70249. /**
  70250. * Detailled logging while loading
  70251. */
  70252. static readonly SCENELOADER_DETAILED_LOGGING: number;
  70253. }
  70254. }
  70255. declare module BABYLON {
  70256. /**
  70257. * Class used to store and describe the pipeline context associated with an effect
  70258. */
  70259. export interface IPipelineContext {
  70260. /**
  70261. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70262. */
  70263. isAsync: boolean;
  70264. /**
  70265. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70266. */
  70267. isReady: boolean;
  70268. /** @hidden */
  70269. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70270. }
  70271. }
  70272. declare module BABYLON {
  70273. /** @hidden */
  70274. export interface IShaderProcessor {
  70275. attributeProcessor?: (attribute: string) => string;
  70276. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70277. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70278. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70279. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70280. lineProcessor?: (line: string, isFragment: boolean) => string;
  70281. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70282. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70283. }
  70284. }
  70285. declare module BABYLON {
  70286. /** @hidden */
  70287. export interface ProcessingOptions {
  70288. defines: string[];
  70289. indexParameters: any;
  70290. isFragment: boolean;
  70291. shouldUseHighPrecisionShader: boolean;
  70292. supportsUniformBuffers: boolean;
  70293. shadersRepository: string;
  70294. includesShadersStore: {
  70295. [key: string]: string;
  70296. };
  70297. processor?: IShaderProcessor;
  70298. version: string;
  70299. platformName: string;
  70300. lookForClosingBracketForUniformBuffer?: boolean;
  70301. }
  70302. }
  70303. declare module BABYLON {
  70304. /**
  70305. * Helper to manipulate strings
  70306. */
  70307. export class StringTools {
  70308. /**
  70309. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70310. * @param str Source string
  70311. * @param suffix Suffix to search for in the source string
  70312. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70313. */
  70314. static EndsWith(str: string, suffix: string): boolean;
  70315. /**
  70316. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70317. * @param str Source string
  70318. * @param suffix Suffix to search for in the source string
  70319. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70320. */
  70321. static StartsWith(str: string, suffix: string): boolean;
  70322. }
  70323. }
  70324. declare module BABYLON {
  70325. /** @hidden */
  70326. export class ShaderCodeNode {
  70327. line: string;
  70328. children: ShaderCodeNode[];
  70329. additionalDefineKey?: string;
  70330. additionalDefineValue?: string;
  70331. isValid(preprocessors: {
  70332. [key: string]: string;
  70333. }): boolean;
  70334. process(preprocessors: {
  70335. [key: string]: string;
  70336. }, options: ProcessingOptions): string;
  70337. }
  70338. }
  70339. declare module BABYLON {
  70340. /** @hidden */
  70341. export class ShaderCodeCursor {
  70342. private _lines;
  70343. lineIndex: number;
  70344. readonly currentLine: string;
  70345. readonly canRead: boolean;
  70346. lines: string[];
  70347. }
  70348. }
  70349. declare module BABYLON {
  70350. /** @hidden */
  70351. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70352. process(preprocessors: {
  70353. [key: string]: string;
  70354. }, options: ProcessingOptions): string;
  70355. }
  70356. }
  70357. declare module BABYLON {
  70358. /** @hidden */
  70359. export class ShaderDefineExpression {
  70360. isTrue(preprocessors: {
  70361. [key: string]: string;
  70362. }): boolean;
  70363. }
  70364. }
  70365. declare module BABYLON {
  70366. /** @hidden */
  70367. export class ShaderCodeTestNode extends ShaderCodeNode {
  70368. testExpression: ShaderDefineExpression;
  70369. isValid(preprocessors: {
  70370. [key: string]: string;
  70371. }): boolean;
  70372. }
  70373. }
  70374. declare module BABYLON {
  70375. /** @hidden */
  70376. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70377. define: string;
  70378. not: boolean;
  70379. constructor(define: string, not?: boolean);
  70380. isTrue(preprocessors: {
  70381. [key: string]: string;
  70382. }): boolean;
  70383. }
  70384. }
  70385. declare module BABYLON {
  70386. /** @hidden */
  70387. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70388. leftOperand: ShaderDefineExpression;
  70389. rightOperand: ShaderDefineExpression;
  70390. isTrue(preprocessors: {
  70391. [key: string]: string;
  70392. }): boolean;
  70393. }
  70394. }
  70395. declare module BABYLON {
  70396. /** @hidden */
  70397. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70398. leftOperand: ShaderDefineExpression;
  70399. rightOperand: ShaderDefineExpression;
  70400. isTrue(preprocessors: {
  70401. [key: string]: string;
  70402. }): boolean;
  70403. }
  70404. }
  70405. declare module BABYLON {
  70406. /** @hidden */
  70407. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70408. define: string;
  70409. operand: string;
  70410. testValue: string;
  70411. constructor(define: string, operand: string, testValue: string);
  70412. isTrue(preprocessors: {
  70413. [key: string]: string;
  70414. }): boolean;
  70415. }
  70416. }
  70417. declare module BABYLON {
  70418. /**
  70419. * @ignore
  70420. * Application error to support additional information when loading a file
  70421. */
  70422. export class LoadFileError extends Error {
  70423. /** defines the optional web request */
  70424. request?: WebRequest | undefined;
  70425. private static _setPrototypeOf;
  70426. /**
  70427. * Creates a new LoadFileError
  70428. * @param message defines the message of the error
  70429. * @param request defines the optional web request
  70430. */
  70431. constructor(message: string,
  70432. /** defines the optional web request */
  70433. request?: WebRequest | undefined);
  70434. }
  70435. }
  70436. declare module BABYLON {
  70437. /**
  70438. * Class used to enable access to offline support
  70439. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70440. */
  70441. export interface IOfflineProvider {
  70442. /**
  70443. * Gets a boolean indicating if scene must be saved in the database
  70444. */
  70445. enableSceneOffline: boolean;
  70446. /**
  70447. * Gets a boolean indicating if textures must be saved in the database
  70448. */
  70449. enableTexturesOffline: boolean;
  70450. /**
  70451. * Open the offline support and make it available
  70452. * @param successCallback defines the callback to call on success
  70453. * @param errorCallback defines the callback to call on error
  70454. */
  70455. open(successCallback: () => void, errorCallback: () => void): void;
  70456. /**
  70457. * Loads an image from the offline support
  70458. * @param url defines the url to load from
  70459. * @param image defines the target DOM image
  70460. */
  70461. loadImage(url: string, image: HTMLImageElement): void;
  70462. /**
  70463. * Loads a file from offline support
  70464. * @param url defines the URL to load from
  70465. * @param sceneLoaded defines a callback to call on success
  70466. * @param progressCallBack defines a callback to call when progress changed
  70467. * @param errorCallback defines a callback to call on error
  70468. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70469. */
  70470. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70471. }
  70472. }
  70473. declare module BABYLON {
  70474. /**
  70475. * Class used to help managing file picking and drag'n'drop
  70476. * File Storage
  70477. */
  70478. export class FilesInputStore {
  70479. /**
  70480. * List of files ready to be loaded
  70481. */
  70482. static FilesToLoad: {
  70483. [key: string]: File;
  70484. };
  70485. }
  70486. }
  70487. declare module BABYLON {
  70488. /**
  70489. * Class used to define a retry strategy when error happens while loading assets
  70490. */
  70491. export class RetryStrategy {
  70492. /**
  70493. * Function used to defines an exponential back off strategy
  70494. * @param maxRetries defines the maximum number of retries (3 by default)
  70495. * @param baseInterval defines the interval between retries
  70496. * @returns the strategy function to use
  70497. */
  70498. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70499. }
  70500. }
  70501. declare module BABYLON {
  70502. /**
  70503. * @hidden
  70504. */
  70505. export class FileTools {
  70506. /**
  70507. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70508. */
  70509. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70510. /**
  70511. * Gets or sets the base URL to use to load assets
  70512. */
  70513. static BaseUrl: string;
  70514. /**
  70515. * Default behaviour for cors in the application.
  70516. * It can be a string if the expected behavior is identical in the entire app.
  70517. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70518. */
  70519. static CorsBehavior: string | ((url: string | string[]) => string);
  70520. /**
  70521. * Gets or sets a function used to pre-process url before using them to load assets
  70522. */
  70523. static PreprocessUrl: (url: string) => string;
  70524. /**
  70525. * Removes unwanted characters from an url
  70526. * @param url defines the url to clean
  70527. * @returns the cleaned url
  70528. */
  70529. private static _CleanUrl;
  70530. /**
  70531. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70532. * @param url define the url we are trying
  70533. * @param element define the dom element where to configure the cors policy
  70534. */
  70535. static SetCorsBehavior(url: string | string[], element: {
  70536. crossOrigin: string | null;
  70537. }): void;
  70538. /**
  70539. * Loads an image as an HTMLImageElement.
  70540. * @param input url string, ArrayBuffer, or Blob to load
  70541. * @param onLoad callback called when the image successfully loads
  70542. * @param onError callback called when the image fails to load
  70543. * @param offlineProvider offline provider for caching
  70544. * @returns the HTMLImageElement of the loaded image
  70545. */
  70546. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  70547. /**
  70548. * Loads a file
  70549. * @param fileToLoad defines the file to load
  70550. * @param callback defines the callback to call when data is loaded
  70551. * @param progressCallBack defines the callback to call during loading process
  70552. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70553. * @returns a file request object
  70554. */
  70555. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  70556. /**
  70557. * Loads a file
  70558. * @param url url string, ArrayBuffer, or Blob to load
  70559. * @param onSuccess callback called when the file successfully loads
  70560. * @param onProgress callback called while file is loading (if the server supports this mode)
  70561. * @param offlineProvider defines the offline provider for caching
  70562. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70563. * @param onError callback called when the file fails to load
  70564. * @returns a file request object
  70565. */
  70566. 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;
  70567. /**
  70568. * Checks if the loaded document was accessed via `file:`-Protocol.
  70569. * @returns boolean
  70570. */
  70571. static IsFileURL(): boolean;
  70572. }
  70573. }
  70574. declare module BABYLON {
  70575. /** @hidden */
  70576. export class ShaderProcessor {
  70577. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70578. private static _ProcessPrecision;
  70579. private static _ExtractOperation;
  70580. private static _BuildSubExpression;
  70581. private static _BuildExpression;
  70582. private static _MoveCursorWithinIf;
  70583. private static _MoveCursor;
  70584. private static _EvaluatePreProcessors;
  70585. private static _PreparePreProcessors;
  70586. private static _ProcessShaderConversion;
  70587. private static _ProcessIncludes;
  70588. }
  70589. }
  70590. declare module BABYLON {
  70591. /**
  70592. * Class used to hold a RBG color
  70593. */
  70594. export class Color3 {
  70595. /**
  70596. * Defines the red component (between 0 and 1, default is 0)
  70597. */
  70598. r: number;
  70599. /**
  70600. * Defines the green component (between 0 and 1, default is 0)
  70601. */
  70602. g: number;
  70603. /**
  70604. * Defines the blue component (between 0 and 1, default is 0)
  70605. */
  70606. b: number;
  70607. /**
  70608. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70609. * @param r defines the red component (between 0 and 1, default is 0)
  70610. * @param g defines the green component (between 0 and 1, default is 0)
  70611. * @param b defines the blue component (between 0 and 1, default is 0)
  70612. */
  70613. constructor(
  70614. /**
  70615. * Defines the red component (between 0 and 1, default is 0)
  70616. */
  70617. r?: number,
  70618. /**
  70619. * Defines the green component (between 0 and 1, default is 0)
  70620. */
  70621. g?: number,
  70622. /**
  70623. * Defines the blue component (between 0 and 1, default is 0)
  70624. */
  70625. b?: number);
  70626. /**
  70627. * Creates a string with the Color3 current values
  70628. * @returns the string representation of the Color3 object
  70629. */
  70630. toString(): string;
  70631. /**
  70632. * Returns the string "Color3"
  70633. * @returns "Color3"
  70634. */
  70635. getClassName(): string;
  70636. /**
  70637. * Compute the Color3 hash code
  70638. * @returns an unique number that can be used to hash Color3 objects
  70639. */
  70640. getHashCode(): number;
  70641. /**
  70642. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70643. * @param array defines the array where to store the r,g,b components
  70644. * @param index defines an optional index in the target array to define where to start storing values
  70645. * @returns the current Color3 object
  70646. */
  70647. toArray(array: FloatArray, index?: number): Color3;
  70648. /**
  70649. * Returns a new Color4 object from the current Color3 and the given alpha
  70650. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70651. * @returns a new Color4 object
  70652. */
  70653. toColor4(alpha?: number): Color4;
  70654. /**
  70655. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70656. * @returns the new array
  70657. */
  70658. asArray(): number[];
  70659. /**
  70660. * Returns the luminance value
  70661. * @returns a float value
  70662. */
  70663. toLuminance(): number;
  70664. /**
  70665. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70666. * @param otherColor defines the second operand
  70667. * @returns the new Color3 object
  70668. */
  70669. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70670. /**
  70671. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70672. * @param otherColor defines the second operand
  70673. * @param result defines the Color3 object where to store the result
  70674. * @returns the current Color3
  70675. */
  70676. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70677. /**
  70678. * Determines equality between Color3 objects
  70679. * @param otherColor defines the second operand
  70680. * @returns true if the rgb values are equal to the given ones
  70681. */
  70682. equals(otherColor: DeepImmutable<Color3>): boolean;
  70683. /**
  70684. * Determines equality between the current Color3 object and a set of r,b,g values
  70685. * @param r defines the red component to check
  70686. * @param g defines the green component to check
  70687. * @param b defines the blue component to check
  70688. * @returns true if the rgb values are equal to the given ones
  70689. */
  70690. equalsFloats(r: number, g: number, b: number): boolean;
  70691. /**
  70692. * Multiplies in place each rgb value by scale
  70693. * @param scale defines the scaling factor
  70694. * @returns the updated Color3
  70695. */
  70696. scale(scale: number): Color3;
  70697. /**
  70698. * Multiplies the rgb values by scale and stores the result into "result"
  70699. * @param scale defines the scaling factor
  70700. * @param result defines the Color3 object where to store the result
  70701. * @returns the unmodified current Color3
  70702. */
  70703. scaleToRef(scale: number, result: Color3): Color3;
  70704. /**
  70705. * Scale the current Color3 values by a factor and add the result to a given Color3
  70706. * @param scale defines the scale factor
  70707. * @param result defines color to store the result into
  70708. * @returns the unmodified current Color3
  70709. */
  70710. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70711. /**
  70712. * Clamps the rgb values by the min and max values and stores the result into "result"
  70713. * @param min defines minimum clamping value (default is 0)
  70714. * @param max defines maximum clamping value (default is 1)
  70715. * @param result defines color to store the result into
  70716. * @returns the original Color3
  70717. */
  70718. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70719. /**
  70720. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70721. * @param otherColor defines the second operand
  70722. * @returns the new Color3
  70723. */
  70724. add(otherColor: DeepImmutable<Color3>): Color3;
  70725. /**
  70726. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70727. * @param otherColor defines the second operand
  70728. * @param result defines Color3 object to store the result into
  70729. * @returns the unmodified current Color3
  70730. */
  70731. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70732. /**
  70733. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70734. * @param otherColor defines the second operand
  70735. * @returns the new Color3
  70736. */
  70737. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70738. /**
  70739. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70740. * @param otherColor defines the second operand
  70741. * @param result defines Color3 object to store the result into
  70742. * @returns the unmodified current Color3
  70743. */
  70744. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70745. /**
  70746. * Copy the current object
  70747. * @returns a new Color3 copied the current one
  70748. */
  70749. clone(): Color3;
  70750. /**
  70751. * Copies the rgb values from the source in the current Color3
  70752. * @param source defines the source Color3 object
  70753. * @returns the updated Color3 object
  70754. */
  70755. copyFrom(source: DeepImmutable<Color3>): Color3;
  70756. /**
  70757. * Updates the Color3 rgb values from the given floats
  70758. * @param r defines the red component to read from
  70759. * @param g defines the green component to read from
  70760. * @param b defines the blue component to read from
  70761. * @returns the current Color3 object
  70762. */
  70763. copyFromFloats(r: number, g: number, b: number): Color3;
  70764. /**
  70765. * Updates the Color3 rgb values from the given floats
  70766. * @param r defines the red component to read from
  70767. * @param g defines the green component to read from
  70768. * @param b defines the blue component to read from
  70769. * @returns the current Color3 object
  70770. */
  70771. set(r: number, g: number, b: number): Color3;
  70772. /**
  70773. * Compute the Color3 hexadecimal code as a string
  70774. * @returns a string containing the hexadecimal representation of the Color3 object
  70775. */
  70776. toHexString(): string;
  70777. /**
  70778. * Computes a new Color3 converted from the current one to linear space
  70779. * @returns a new Color3 object
  70780. */
  70781. toLinearSpace(): Color3;
  70782. /**
  70783. * Converts current color in rgb space to HSV values
  70784. * @returns a new color3 representing the HSV values
  70785. */
  70786. toHSV(): Color3;
  70787. /**
  70788. * Converts current color in rgb space to HSV values
  70789. * @param result defines the Color3 where to store the HSV values
  70790. */
  70791. toHSVToRef(result: Color3): void;
  70792. /**
  70793. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70794. * @param convertedColor defines the Color3 object where to store the linear space version
  70795. * @returns the unmodified Color3
  70796. */
  70797. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70798. /**
  70799. * Computes a new Color3 converted from the current one to gamma space
  70800. * @returns a new Color3 object
  70801. */
  70802. toGammaSpace(): Color3;
  70803. /**
  70804. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70805. * @param convertedColor defines the Color3 object where to store the gamma space version
  70806. * @returns the unmodified Color3
  70807. */
  70808. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70809. private static _BlackReadOnly;
  70810. /**
  70811. * Convert Hue, saturation and value to a Color3 (RGB)
  70812. * @param hue defines the hue
  70813. * @param saturation defines the saturation
  70814. * @param value defines the value
  70815. * @param result defines the Color3 where to store the RGB values
  70816. */
  70817. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70818. /**
  70819. * Creates a new Color3 from the string containing valid hexadecimal values
  70820. * @param hex defines a string containing valid hexadecimal values
  70821. * @returns a new Color3 object
  70822. */
  70823. static FromHexString(hex: string): Color3;
  70824. /**
  70825. * Creates a new Color3 from the starting index of the given array
  70826. * @param array defines the source array
  70827. * @param offset defines an offset in the source array
  70828. * @returns a new Color3 object
  70829. */
  70830. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70831. /**
  70832. * Creates a new Color3 from integer values (< 256)
  70833. * @param r defines the red component to read from (value between 0 and 255)
  70834. * @param g defines the green component to read from (value between 0 and 255)
  70835. * @param b defines the blue component to read from (value between 0 and 255)
  70836. * @returns a new Color3 object
  70837. */
  70838. static FromInts(r: number, g: number, b: number): Color3;
  70839. /**
  70840. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70841. * @param start defines the start Color3 value
  70842. * @param end defines the end Color3 value
  70843. * @param amount defines the gradient value between start and end
  70844. * @returns a new Color3 object
  70845. */
  70846. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70847. /**
  70848. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70849. * @param left defines the start value
  70850. * @param right defines the end value
  70851. * @param amount defines the gradient factor
  70852. * @param result defines the Color3 object where to store the result
  70853. */
  70854. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70855. /**
  70856. * Returns a Color3 value containing a red color
  70857. * @returns a new Color3 object
  70858. */
  70859. static Red(): Color3;
  70860. /**
  70861. * Returns a Color3 value containing a green color
  70862. * @returns a new Color3 object
  70863. */
  70864. static Green(): Color3;
  70865. /**
  70866. * Returns a Color3 value containing a blue color
  70867. * @returns a new Color3 object
  70868. */
  70869. static Blue(): Color3;
  70870. /**
  70871. * Returns a Color3 value containing a black color
  70872. * @returns a new Color3 object
  70873. */
  70874. static Black(): Color3;
  70875. /**
  70876. * Gets a Color3 value containing a black color that must not be updated
  70877. */
  70878. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70879. /**
  70880. * Returns a Color3 value containing a white color
  70881. * @returns a new Color3 object
  70882. */
  70883. static White(): Color3;
  70884. /**
  70885. * Returns a Color3 value containing a purple color
  70886. * @returns a new Color3 object
  70887. */
  70888. static Purple(): Color3;
  70889. /**
  70890. * Returns a Color3 value containing a magenta color
  70891. * @returns a new Color3 object
  70892. */
  70893. static Magenta(): Color3;
  70894. /**
  70895. * Returns a Color3 value containing a yellow color
  70896. * @returns a new Color3 object
  70897. */
  70898. static Yellow(): Color3;
  70899. /**
  70900. * Returns a Color3 value containing a gray color
  70901. * @returns a new Color3 object
  70902. */
  70903. static Gray(): Color3;
  70904. /**
  70905. * Returns a Color3 value containing a teal color
  70906. * @returns a new Color3 object
  70907. */
  70908. static Teal(): Color3;
  70909. /**
  70910. * Returns a Color3 value containing a random color
  70911. * @returns a new Color3 object
  70912. */
  70913. static Random(): Color3;
  70914. }
  70915. /**
  70916. * Class used to hold a RBGA color
  70917. */
  70918. export class Color4 {
  70919. /**
  70920. * Defines the red component (between 0 and 1, default is 0)
  70921. */
  70922. r: number;
  70923. /**
  70924. * Defines the green component (between 0 and 1, default is 0)
  70925. */
  70926. g: number;
  70927. /**
  70928. * Defines the blue component (between 0 and 1, default is 0)
  70929. */
  70930. b: number;
  70931. /**
  70932. * Defines the alpha component (between 0 and 1, default is 1)
  70933. */
  70934. a: number;
  70935. /**
  70936. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70937. * @param r defines the red component (between 0 and 1, default is 0)
  70938. * @param g defines the green component (between 0 and 1, default is 0)
  70939. * @param b defines the blue component (between 0 and 1, default is 0)
  70940. * @param a defines the alpha component (between 0 and 1, default is 1)
  70941. */
  70942. constructor(
  70943. /**
  70944. * Defines the red component (between 0 and 1, default is 0)
  70945. */
  70946. r?: number,
  70947. /**
  70948. * Defines the green component (between 0 and 1, default is 0)
  70949. */
  70950. g?: number,
  70951. /**
  70952. * Defines the blue component (between 0 and 1, default is 0)
  70953. */
  70954. b?: number,
  70955. /**
  70956. * Defines the alpha component (between 0 and 1, default is 1)
  70957. */
  70958. a?: number);
  70959. /**
  70960. * Adds in place the given Color4 values to the current Color4 object
  70961. * @param right defines the second operand
  70962. * @returns the current updated Color4 object
  70963. */
  70964. addInPlace(right: DeepImmutable<Color4>): Color4;
  70965. /**
  70966. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70967. * @returns the new array
  70968. */
  70969. asArray(): number[];
  70970. /**
  70971. * Stores from the starting index in the given array the Color4 successive values
  70972. * @param array defines the array where to store the r,g,b components
  70973. * @param index defines an optional index in the target array to define where to start storing values
  70974. * @returns the current Color4 object
  70975. */
  70976. toArray(array: number[], index?: number): Color4;
  70977. /**
  70978. * Determines equality between Color4 objects
  70979. * @param otherColor defines the second operand
  70980. * @returns true if the rgba values are equal to the given ones
  70981. */
  70982. equals(otherColor: DeepImmutable<Color4>): boolean;
  70983. /**
  70984. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70985. * @param right defines the second operand
  70986. * @returns a new Color4 object
  70987. */
  70988. add(right: DeepImmutable<Color4>): Color4;
  70989. /**
  70990. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70991. * @param right defines the second operand
  70992. * @returns a new Color4 object
  70993. */
  70994. subtract(right: DeepImmutable<Color4>): Color4;
  70995. /**
  70996. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70997. * @param right defines the second operand
  70998. * @param result defines the Color4 object where to store the result
  70999. * @returns the current Color4 object
  71000. */
  71001. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  71002. /**
  71003. * Creates a new Color4 with the current Color4 values multiplied by scale
  71004. * @param scale defines the scaling factor to apply
  71005. * @returns a new Color4 object
  71006. */
  71007. scale(scale: number): Color4;
  71008. /**
  71009. * Multiplies the current Color4 values by scale and stores the result in "result"
  71010. * @param scale defines the scaling factor to apply
  71011. * @param result defines the Color4 object where to store the result
  71012. * @returns the current unmodified Color4
  71013. */
  71014. scaleToRef(scale: number, result: Color4): Color4;
  71015. /**
  71016. * Scale the current Color4 values by a factor and add the result to a given Color4
  71017. * @param scale defines the scale factor
  71018. * @param result defines the Color4 object where to store the result
  71019. * @returns the unmodified current Color4
  71020. */
  71021. scaleAndAddToRef(scale: number, result: Color4): Color4;
  71022. /**
  71023. * Clamps the rgb values by the min and max values and stores the result into "result"
  71024. * @param min defines minimum clamping value (default is 0)
  71025. * @param max defines maximum clamping value (default is 1)
  71026. * @param result defines color to store the result into.
  71027. * @returns the cuurent Color4
  71028. */
  71029. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  71030. /**
  71031. * Multipy an Color4 value by another and return a new Color4 object
  71032. * @param color defines the Color4 value to multiply by
  71033. * @returns a new Color4 object
  71034. */
  71035. multiply(color: Color4): Color4;
  71036. /**
  71037. * Multipy a Color4 value by another and push the result in a reference value
  71038. * @param color defines the Color4 value to multiply by
  71039. * @param result defines the Color4 to fill the result in
  71040. * @returns the result Color4
  71041. */
  71042. multiplyToRef(color: Color4, result: Color4): Color4;
  71043. /**
  71044. * Creates a string with the Color4 current values
  71045. * @returns the string representation of the Color4 object
  71046. */
  71047. toString(): string;
  71048. /**
  71049. * Returns the string "Color4"
  71050. * @returns "Color4"
  71051. */
  71052. getClassName(): string;
  71053. /**
  71054. * Compute the Color4 hash code
  71055. * @returns an unique number that can be used to hash Color4 objects
  71056. */
  71057. getHashCode(): number;
  71058. /**
  71059. * Creates a new Color4 copied from the current one
  71060. * @returns a new Color4 object
  71061. */
  71062. clone(): Color4;
  71063. /**
  71064. * Copies the given Color4 values into the current one
  71065. * @param source defines the source Color4 object
  71066. * @returns the current updated Color4 object
  71067. */
  71068. copyFrom(source: Color4): Color4;
  71069. /**
  71070. * Copies the given float values into the current one
  71071. * @param r defines the red component to read from
  71072. * @param g defines the green component to read from
  71073. * @param b defines the blue component to read from
  71074. * @param a defines the alpha component to read from
  71075. * @returns the current updated Color4 object
  71076. */
  71077. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  71078. /**
  71079. * Copies the given float values into the current one
  71080. * @param r defines the red component to read from
  71081. * @param g defines the green component to read from
  71082. * @param b defines the blue component to read from
  71083. * @param a defines the alpha component to read from
  71084. * @returns the current updated Color4 object
  71085. */
  71086. set(r: number, g: number, b: number, a: number): Color4;
  71087. /**
  71088. * Compute the Color4 hexadecimal code as a string
  71089. * @returns a string containing the hexadecimal representation of the Color4 object
  71090. */
  71091. toHexString(): string;
  71092. /**
  71093. * Computes a new Color4 converted from the current one to linear space
  71094. * @returns a new Color4 object
  71095. */
  71096. toLinearSpace(): Color4;
  71097. /**
  71098. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  71099. * @param convertedColor defines the Color4 object where to store the linear space version
  71100. * @returns the unmodified Color4
  71101. */
  71102. toLinearSpaceToRef(convertedColor: Color4): Color4;
  71103. /**
  71104. * Computes a new Color4 converted from the current one to gamma space
  71105. * @returns a new Color4 object
  71106. */
  71107. toGammaSpace(): Color4;
  71108. /**
  71109. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  71110. * @param convertedColor defines the Color4 object where to store the gamma space version
  71111. * @returns the unmodified Color4
  71112. */
  71113. toGammaSpaceToRef(convertedColor: Color4): Color4;
  71114. /**
  71115. * Creates a new Color4 from the string containing valid hexadecimal values
  71116. * @param hex defines a string containing valid hexadecimal values
  71117. * @returns a new Color4 object
  71118. */
  71119. static FromHexString(hex: string): Color4;
  71120. /**
  71121. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71122. * @param left defines the start value
  71123. * @param right defines the end value
  71124. * @param amount defines the gradient factor
  71125. * @returns a new Color4 object
  71126. */
  71127. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  71128. /**
  71129. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71130. * @param left defines the start value
  71131. * @param right defines the end value
  71132. * @param amount defines the gradient factor
  71133. * @param result defines the Color4 object where to store data
  71134. */
  71135. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  71136. /**
  71137. * Creates a new Color4 from a Color3 and an alpha value
  71138. * @param color3 defines the source Color3 to read from
  71139. * @param alpha defines the alpha component (1.0 by default)
  71140. * @returns a new Color4 object
  71141. */
  71142. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  71143. /**
  71144. * Creates a new Color4 from the starting index element of the given array
  71145. * @param array defines the source array to read from
  71146. * @param offset defines the offset in the source array
  71147. * @returns a new Color4 object
  71148. */
  71149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  71150. /**
  71151. * Creates a new Color3 from integer values (< 256)
  71152. * @param r defines the red component to read from (value between 0 and 255)
  71153. * @param g defines the green component to read from (value between 0 and 255)
  71154. * @param b defines the blue component to read from (value between 0 and 255)
  71155. * @param a defines the alpha component to read from (value between 0 and 255)
  71156. * @returns a new Color3 object
  71157. */
  71158. static FromInts(r: number, g: number, b: number, a: number): Color4;
  71159. /**
  71160. * Check the content of a given array and convert it to an array containing RGBA data
  71161. * If the original array was already containing count * 4 values then it is returned directly
  71162. * @param colors defines the array to check
  71163. * @param count defines the number of RGBA data to expect
  71164. * @returns an array containing count * 4 values (RGBA)
  71165. */
  71166. static CheckColors4(colors: number[], count: number): number[];
  71167. }
  71168. /**
  71169. * @hidden
  71170. */
  71171. export class TmpColors {
  71172. static Color3: Color3[];
  71173. static Color4: Color4[];
  71174. }
  71175. }
  71176. declare module BABYLON {
  71177. /**
  71178. * Class representing spherical harmonics coefficients to the 3rd degree
  71179. */
  71180. export class SphericalHarmonics {
  71181. /**
  71182. * Defines whether or not the harmonics have been prescaled for rendering.
  71183. */
  71184. preScaled: boolean;
  71185. /**
  71186. * The l0,0 coefficients of the spherical harmonics
  71187. */
  71188. l00: Vector3;
  71189. /**
  71190. * The l1,-1 coefficients of the spherical harmonics
  71191. */
  71192. l1_1: Vector3;
  71193. /**
  71194. * The l1,0 coefficients of the spherical harmonics
  71195. */
  71196. l10: Vector3;
  71197. /**
  71198. * The l1,1 coefficients of the spherical harmonics
  71199. */
  71200. l11: Vector3;
  71201. /**
  71202. * The l2,-2 coefficients of the spherical harmonics
  71203. */
  71204. l2_2: Vector3;
  71205. /**
  71206. * The l2,-1 coefficients of the spherical harmonics
  71207. */
  71208. l2_1: Vector3;
  71209. /**
  71210. * The l2,0 coefficients of the spherical harmonics
  71211. */
  71212. l20: Vector3;
  71213. /**
  71214. * The l2,1 coefficients of the spherical harmonics
  71215. */
  71216. l21: Vector3;
  71217. /**
  71218. * The l2,2 coefficients of the spherical harmonics
  71219. */
  71220. l22: Vector3;
  71221. /**
  71222. * Adds a light to the spherical harmonics
  71223. * @param direction the direction of the light
  71224. * @param color the color of the light
  71225. * @param deltaSolidAngle the delta solid angle of the light
  71226. */
  71227. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  71228. /**
  71229. * Scales the spherical harmonics by the given amount
  71230. * @param scale the amount to scale
  71231. */
  71232. scaleInPlace(scale: number): void;
  71233. /**
  71234. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  71235. *
  71236. * ```
  71237. * E_lm = A_l * L_lm
  71238. * ```
  71239. *
  71240. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  71241. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  71242. * the scaling factors are given in equation 9.
  71243. */
  71244. convertIncidentRadianceToIrradiance(): void;
  71245. /**
  71246. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  71247. *
  71248. * ```
  71249. * L = (1/pi) * E * rho
  71250. * ```
  71251. *
  71252. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  71253. */
  71254. convertIrradianceToLambertianRadiance(): void;
  71255. /**
  71256. * Integrates the reconstruction coefficients directly in to the SH preventing further
  71257. * required operations at run time.
  71258. *
  71259. * This is simply done by scaling back the SH with Ylm constants parameter.
  71260. * The trigonometric part being applied by the shader at run time.
  71261. */
  71262. preScaleForRendering(): void;
  71263. /**
  71264. * Constructs a spherical harmonics from an array.
  71265. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  71266. * @returns the spherical harmonics
  71267. */
  71268. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  71269. /**
  71270. * Gets the spherical harmonics from polynomial
  71271. * @param polynomial the spherical polynomial
  71272. * @returns the spherical harmonics
  71273. */
  71274. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  71275. }
  71276. /**
  71277. * Class representing spherical polynomial coefficients to the 3rd degree
  71278. */
  71279. export class SphericalPolynomial {
  71280. private _harmonics;
  71281. /**
  71282. * The spherical harmonics used to create the polynomials.
  71283. */
  71284. readonly preScaledHarmonics: SphericalHarmonics;
  71285. /**
  71286. * The x coefficients of the spherical polynomial
  71287. */
  71288. x: Vector3;
  71289. /**
  71290. * The y coefficients of the spherical polynomial
  71291. */
  71292. y: Vector3;
  71293. /**
  71294. * The z coefficients of the spherical polynomial
  71295. */
  71296. z: Vector3;
  71297. /**
  71298. * The xx coefficients of the spherical polynomial
  71299. */
  71300. xx: Vector3;
  71301. /**
  71302. * The yy coefficients of the spherical polynomial
  71303. */
  71304. yy: Vector3;
  71305. /**
  71306. * The zz coefficients of the spherical polynomial
  71307. */
  71308. zz: Vector3;
  71309. /**
  71310. * The xy coefficients of the spherical polynomial
  71311. */
  71312. xy: Vector3;
  71313. /**
  71314. * The yz coefficients of the spherical polynomial
  71315. */
  71316. yz: Vector3;
  71317. /**
  71318. * The zx coefficients of the spherical polynomial
  71319. */
  71320. zx: Vector3;
  71321. /**
  71322. * Adds an ambient color to the spherical polynomial
  71323. * @param color the color to add
  71324. */
  71325. addAmbient(color: Color3): void;
  71326. /**
  71327. * Scales the spherical polynomial by the given amount
  71328. * @param scale the amount to scale
  71329. */
  71330. scaleInPlace(scale: number): void;
  71331. /**
  71332. * Gets the spherical polynomial from harmonics
  71333. * @param harmonics the spherical harmonics
  71334. * @returns the spherical polynomial
  71335. */
  71336. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71337. /**
  71338. * Constructs a spherical polynomial from an array.
  71339. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71340. * @returns the spherical polynomial
  71341. */
  71342. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71343. }
  71344. }
  71345. declare module BABYLON {
  71346. /**
  71347. * Define options used to create a render target texture
  71348. */
  71349. export class RenderTargetCreationOptions {
  71350. /**
  71351. * Specifies is mipmaps must be generated
  71352. */
  71353. generateMipMaps?: boolean;
  71354. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71355. generateDepthBuffer?: boolean;
  71356. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71357. generateStencilBuffer?: boolean;
  71358. /** Defines texture type (int by default) */
  71359. type?: number;
  71360. /** Defines sampling mode (trilinear by default) */
  71361. samplingMode?: number;
  71362. /** Defines format (RGBA by default) */
  71363. format?: number;
  71364. }
  71365. }
  71366. declare module BABYLON {
  71367. /**
  71368. * @hidden
  71369. **/
  71370. export class _AlphaState {
  71371. private _isAlphaBlendDirty;
  71372. private _isBlendFunctionParametersDirty;
  71373. private _isBlendEquationParametersDirty;
  71374. private _isBlendConstantsDirty;
  71375. private _alphaBlend;
  71376. private _blendFunctionParameters;
  71377. private _blendEquationParameters;
  71378. private _blendConstants;
  71379. /**
  71380. * Initializes the state.
  71381. */
  71382. constructor();
  71383. readonly isDirty: boolean;
  71384. alphaBlend: boolean;
  71385. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  71386. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  71387. setAlphaEquationParameters(rgb: number, alpha: number): void;
  71388. reset(): void;
  71389. apply(gl: WebGLRenderingContext): void;
  71390. }
  71391. }
  71392. declare module BABYLON {
  71393. /**
  71394. * @hidden
  71395. **/
  71396. export class _DepthCullingState {
  71397. private _isDepthTestDirty;
  71398. private _isDepthMaskDirty;
  71399. private _isDepthFuncDirty;
  71400. private _isCullFaceDirty;
  71401. private _isCullDirty;
  71402. private _isZOffsetDirty;
  71403. private _isFrontFaceDirty;
  71404. private _depthTest;
  71405. private _depthMask;
  71406. private _depthFunc;
  71407. private _cull;
  71408. private _cullFace;
  71409. private _zOffset;
  71410. private _frontFace;
  71411. /**
  71412. * Initializes the state.
  71413. */
  71414. constructor();
  71415. readonly isDirty: boolean;
  71416. zOffset: number;
  71417. cullFace: Nullable<number>;
  71418. cull: Nullable<boolean>;
  71419. depthFunc: Nullable<number>;
  71420. depthMask: boolean;
  71421. depthTest: boolean;
  71422. frontFace: Nullable<number>;
  71423. reset(): void;
  71424. apply(gl: WebGLRenderingContext): void;
  71425. }
  71426. }
  71427. declare module BABYLON {
  71428. /**
  71429. * @hidden
  71430. **/
  71431. export class _StencilState {
  71432. /** 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 */
  71433. static readonly ALWAYS: number;
  71434. /** Passed to stencilOperation to specify that stencil value must be kept */
  71435. static readonly KEEP: number;
  71436. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71437. static readonly REPLACE: number;
  71438. private _isStencilTestDirty;
  71439. private _isStencilMaskDirty;
  71440. private _isStencilFuncDirty;
  71441. private _isStencilOpDirty;
  71442. private _stencilTest;
  71443. private _stencilMask;
  71444. private _stencilFunc;
  71445. private _stencilFuncRef;
  71446. private _stencilFuncMask;
  71447. private _stencilOpStencilFail;
  71448. private _stencilOpDepthFail;
  71449. private _stencilOpStencilDepthPass;
  71450. readonly isDirty: boolean;
  71451. stencilFunc: number;
  71452. stencilFuncRef: number;
  71453. stencilFuncMask: number;
  71454. stencilOpStencilFail: number;
  71455. stencilOpDepthFail: number;
  71456. stencilOpStencilDepthPass: number;
  71457. stencilMask: number;
  71458. stencilTest: boolean;
  71459. constructor();
  71460. reset(): void;
  71461. apply(gl: WebGLRenderingContext): void;
  71462. }
  71463. }
  71464. declare module BABYLON {
  71465. /**
  71466. * @hidden
  71467. **/
  71468. export class _TimeToken {
  71469. _startTimeQuery: Nullable<WebGLQuery>;
  71470. _endTimeQuery: Nullable<WebGLQuery>;
  71471. _timeElapsedQuery: Nullable<WebGLQuery>;
  71472. _timeElapsedQueryEnded: boolean;
  71473. }
  71474. }
  71475. declare module BABYLON {
  71476. /**
  71477. * Class used to evalaute queries containing `and` and `or` operators
  71478. */
  71479. export class AndOrNotEvaluator {
  71480. /**
  71481. * Evaluate a query
  71482. * @param query defines the query to evaluate
  71483. * @param evaluateCallback defines the callback used to filter result
  71484. * @returns true if the query matches
  71485. */
  71486. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71487. private static _HandleParenthesisContent;
  71488. private static _SimplifyNegation;
  71489. }
  71490. }
  71491. declare module BABYLON {
  71492. /**
  71493. * Class used to store custom tags
  71494. */
  71495. export class Tags {
  71496. /**
  71497. * Adds support for tags on the given object
  71498. * @param obj defines the object to use
  71499. */
  71500. static EnableFor(obj: any): void;
  71501. /**
  71502. * Removes tags support
  71503. * @param obj defines the object to use
  71504. */
  71505. static DisableFor(obj: any): void;
  71506. /**
  71507. * Gets a boolean indicating if the given object has tags
  71508. * @param obj defines the object to use
  71509. * @returns a boolean
  71510. */
  71511. static HasTags(obj: any): boolean;
  71512. /**
  71513. * Gets the tags available on a given object
  71514. * @param obj defines the object to use
  71515. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71516. * @returns the tags
  71517. */
  71518. static GetTags(obj: any, asString?: boolean): any;
  71519. /**
  71520. * Adds tags to an object
  71521. * @param obj defines the object to use
  71522. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71523. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71524. */
  71525. static AddTagsTo(obj: any, tagsString: string): void;
  71526. /**
  71527. * @hidden
  71528. */
  71529. static _AddTagTo(obj: any, tag: string): void;
  71530. /**
  71531. * Removes specific tags from a specific object
  71532. * @param obj defines the object to use
  71533. * @param tagsString defines the tags to remove
  71534. */
  71535. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71536. /**
  71537. * @hidden
  71538. */
  71539. static _RemoveTagFrom(obj: any, tag: string): void;
  71540. /**
  71541. * Defines if tags hosted on an object match a given query
  71542. * @param obj defines the object to use
  71543. * @param tagsQuery defines the tag query
  71544. * @returns a boolean
  71545. */
  71546. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71547. }
  71548. }
  71549. declare module BABYLON {
  71550. /**
  71551. * Defines potential orientation for back face culling
  71552. */
  71553. export enum Orientation {
  71554. /**
  71555. * Clockwise
  71556. */
  71557. CW = 0,
  71558. /** Counter clockwise */
  71559. CCW = 1
  71560. }
  71561. /** Class used to represent a Bezier curve */
  71562. export class BezierCurve {
  71563. /**
  71564. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71565. * @param t defines the time
  71566. * @param x1 defines the left coordinate on X axis
  71567. * @param y1 defines the left coordinate on Y axis
  71568. * @param x2 defines the right coordinate on X axis
  71569. * @param y2 defines the right coordinate on Y axis
  71570. * @returns the interpolated value
  71571. */
  71572. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71573. }
  71574. /**
  71575. * Defines angle representation
  71576. */
  71577. export class Angle {
  71578. private _radians;
  71579. /**
  71580. * Creates an Angle object of "radians" radians (float).
  71581. * @param radians the angle in radians
  71582. */
  71583. constructor(radians: number);
  71584. /**
  71585. * Get value in degrees
  71586. * @returns the Angle value in degrees (float)
  71587. */
  71588. degrees(): number;
  71589. /**
  71590. * Get value in radians
  71591. * @returns the Angle value in radians (float)
  71592. */
  71593. radians(): number;
  71594. /**
  71595. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71596. * @param a defines first vector
  71597. * @param b defines second vector
  71598. * @returns a new Angle
  71599. */
  71600. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71601. /**
  71602. * Gets a new Angle object from the given float in radians
  71603. * @param radians defines the angle value in radians
  71604. * @returns a new Angle
  71605. */
  71606. static FromRadians(radians: number): Angle;
  71607. /**
  71608. * Gets a new Angle object from the given float in degrees
  71609. * @param degrees defines the angle value in degrees
  71610. * @returns a new Angle
  71611. */
  71612. static FromDegrees(degrees: number): Angle;
  71613. }
  71614. /**
  71615. * This represents an arc in a 2d space.
  71616. */
  71617. export class Arc2 {
  71618. /** Defines the start point of the arc */
  71619. startPoint: Vector2;
  71620. /** Defines the mid point of the arc */
  71621. midPoint: Vector2;
  71622. /** Defines the end point of the arc */
  71623. endPoint: Vector2;
  71624. /**
  71625. * Defines the center point of the arc.
  71626. */
  71627. centerPoint: Vector2;
  71628. /**
  71629. * Defines the radius of the arc.
  71630. */
  71631. radius: number;
  71632. /**
  71633. * Defines the angle of the arc (from mid point to end point).
  71634. */
  71635. angle: Angle;
  71636. /**
  71637. * Defines the start angle of the arc (from start point to middle point).
  71638. */
  71639. startAngle: Angle;
  71640. /**
  71641. * Defines the orientation of the arc (clock wise/counter clock wise).
  71642. */
  71643. orientation: Orientation;
  71644. /**
  71645. * Creates an Arc object from the three given points : start, middle and end.
  71646. * @param startPoint Defines the start point of the arc
  71647. * @param midPoint Defines the midlle point of the arc
  71648. * @param endPoint Defines the end point of the arc
  71649. */
  71650. constructor(
  71651. /** Defines the start point of the arc */
  71652. startPoint: Vector2,
  71653. /** Defines the mid point of the arc */
  71654. midPoint: Vector2,
  71655. /** Defines the end point of the arc */
  71656. endPoint: Vector2);
  71657. }
  71658. /**
  71659. * Represents a 2D path made up of multiple 2D points
  71660. */
  71661. export class Path2 {
  71662. private _points;
  71663. private _length;
  71664. /**
  71665. * If the path start and end point are the same
  71666. */
  71667. closed: boolean;
  71668. /**
  71669. * Creates a Path2 object from the starting 2D coordinates x and y.
  71670. * @param x the starting points x value
  71671. * @param y the starting points y value
  71672. */
  71673. constructor(x: number, y: number);
  71674. /**
  71675. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71676. * @param x the added points x value
  71677. * @param y the added points y value
  71678. * @returns the updated Path2.
  71679. */
  71680. addLineTo(x: number, y: number): Path2;
  71681. /**
  71682. * 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.
  71683. * @param midX middle point x value
  71684. * @param midY middle point y value
  71685. * @param endX end point x value
  71686. * @param endY end point y value
  71687. * @param numberOfSegments (default: 36)
  71688. * @returns the updated Path2.
  71689. */
  71690. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71691. /**
  71692. * Closes the Path2.
  71693. * @returns the Path2.
  71694. */
  71695. close(): Path2;
  71696. /**
  71697. * Gets the sum of the distance between each sequential point in the path
  71698. * @returns the Path2 total length (float).
  71699. */
  71700. length(): number;
  71701. /**
  71702. * Gets the points which construct the path
  71703. * @returns the Path2 internal array of points.
  71704. */
  71705. getPoints(): Vector2[];
  71706. /**
  71707. * Retreives the point at the distance aways from the starting point
  71708. * @param normalizedLengthPosition the length along the path to retreive the point from
  71709. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71710. */
  71711. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71712. /**
  71713. * Creates a new path starting from an x and y position
  71714. * @param x starting x value
  71715. * @param y starting y value
  71716. * @returns a new Path2 starting at the coordinates (x, y).
  71717. */
  71718. static StartingAt(x: number, y: number): Path2;
  71719. }
  71720. /**
  71721. * Represents a 3D path made up of multiple 3D points
  71722. */
  71723. export class Path3D {
  71724. /**
  71725. * an array of Vector3, the curve axis of the Path3D
  71726. */
  71727. path: Vector3[];
  71728. private _curve;
  71729. private _distances;
  71730. private _tangents;
  71731. private _normals;
  71732. private _binormals;
  71733. private _raw;
  71734. /**
  71735. * new Path3D(path, normal, raw)
  71736. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71737. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71738. * @param path an array of Vector3, the curve axis of the Path3D
  71739. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71740. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71741. */
  71742. constructor(
  71743. /**
  71744. * an array of Vector3, the curve axis of the Path3D
  71745. */
  71746. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71747. /**
  71748. * Returns the Path3D array of successive Vector3 designing its curve.
  71749. * @returns the Path3D array of successive Vector3 designing its curve.
  71750. */
  71751. getCurve(): Vector3[];
  71752. /**
  71753. * Returns an array populated with tangent vectors on each Path3D curve point.
  71754. * @returns an array populated with tangent vectors on each Path3D curve point.
  71755. */
  71756. getTangents(): Vector3[];
  71757. /**
  71758. * Returns an array populated with normal vectors on each Path3D curve point.
  71759. * @returns an array populated with normal vectors on each Path3D curve point.
  71760. */
  71761. getNormals(): Vector3[];
  71762. /**
  71763. * Returns an array populated with binormal vectors on each Path3D curve point.
  71764. * @returns an array populated with binormal vectors on each Path3D curve point.
  71765. */
  71766. getBinormals(): Vector3[];
  71767. /**
  71768. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71769. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71770. */
  71771. getDistances(): number[];
  71772. /**
  71773. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71774. * @param path path which all values are copied into the curves points
  71775. * @param firstNormal which should be projected onto the curve
  71776. * @returns the same object updated.
  71777. */
  71778. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71779. private _compute;
  71780. private _getFirstNonNullVector;
  71781. private _getLastNonNullVector;
  71782. private _normalVector;
  71783. }
  71784. /**
  71785. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71786. * A Curve3 is designed from a series of successive Vector3.
  71787. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71788. */
  71789. export class Curve3 {
  71790. private _points;
  71791. private _length;
  71792. /**
  71793. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71794. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71795. * @param v1 (Vector3) the control point
  71796. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71797. * @param nbPoints (integer) the wanted number of points in the curve
  71798. * @returns the created Curve3
  71799. */
  71800. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71801. /**
  71802. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71803. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71804. * @param v1 (Vector3) the first control point
  71805. * @param v2 (Vector3) the second control point
  71806. * @param v3 (Vector3) the end point of the Cubic Bezier
  71807. * @param nbPoints (integer) the wanted number of points in the curve
  71808. * @returns the created Curve3
  71809. */
  71810. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71811. /**
  71812. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71813. * @param p1 (Vector3) the origin point of the Hermite Spline
  71814. * @param t1 (Vector3) the tangent vector at the origin point
  71815. * @param p2 (Vector3) the end point of the Hermite Spline
  71816. * @param t2 (Vector3) the tangent vector at the end point
  71817. * @param nbPoints (integer) the wanted number of points in the curve
  71818. * @returns the created Curve3
  71819. */
  71820. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71821. /**
  71822. * Returns a Curve3 object along a CatmullRom Spline curve :
  71823. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71824. * @param nbPoints (integer) the wanted number of points between each curve control points
  71825. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71826. * @returns the created Curve3
  71827. */
  71828. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71829. /**
  71830. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71831. * A Curve3 is designed from a series of successive Vector3.
  71832. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71833. * @param points points which make up the curve
  71834. */
  71835. constructor(points: Vector3[]);
  71836. /**
  71837. * @returns the Curve3 stored array of successive Vector3
  71838. */
  71839. getPoints(): Vector3[];
  71840. /**
  71841. * @returns the computed length (float) of the curve.
  71842. */
  71843. length(): number;
  71844. /**
  71845. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71846. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71847. * curveA and curveB keep unchanged.
  71848. * @param curve the curve to continue from this curve
  71849. * @returns the newly constructed curve
  71850. */
  71851. continue(curve: DeepImmutable<Curve3>): Curve3;
  71852. private _computeLength;
  71853. }
  71854. }
  71855. declare module BABYLON {
  71856. /**
  71857. * This represents the main contract an easing function should follow.
  71858. * Easing functions are used throughout the animation system.
  71859. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71860. */
  71861. export interface IEasingFunction {
  71862. /**
  71863. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71864. * of the easing function.
  71865. * The link below provides some of the most common examples of easing functions.
  71866. * @see https://easings.net/
  71867. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71868. * @returns the corresponding value on the curve defined by the easing function
  71869. */
  71870. ease(gradient: number): number;
  71871. }
  71872. /**
  71873. * Base class used for every default easing function.
  71874. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71875. */
  71876. export class EasingFunction implements IEasingFunction {
  71877. /**
  71878. * Interpolation follows the mathematical formula associated with the easing function.
  71879. */
  71880. static readonly EASINGMODE_EASEIN: number;
  71881. /**
  71882. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71883. */
  71884. static readonly EASINGMODE_EASEOUT: number;
  71885. /**
  71886. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71887. */
  71888. static readonly EASINGMODE_EASEINOUT: number;
  71889. private _easingMode;
  71890. /**
  71891. * Sets the easing mode of the current function.
  71892. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71893. */
  71894. setEasingMode(easingMode: number): void;
  71895. /**
  71896. * Gets the current easing mode.
  71897. * @returns the easing mode
  71898. */
  71899. getEasingMode(): number;
  71900. /**
  71901. * @hidden
  71902. */
  71903. easeInCore(gradient: number): number;
  71904. /**
  71905. * Given an input gradient between 0 and 1, this returns the corresponding value
  71906. * of the easing function.
  71907. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71908. * @returns the corresponding value on the curve defined by the easing function
  71909. */
  71910. ease(gradient: number): number;
  71911. }
  71912. /**
  71913. * Easing function with a circle shape (see link below).
  71914. * @see https://easings.net/#easeInCirc
  71915. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71916. */
  71917. export class CircleEase extends EasingFunction implements IEasingFunction {
  71918. /** @hidden */
  71919. easeInCore(gradient: number): number;
  71920. }
  71921. /**
  71922. * Easing function with a ease back shape (see link below).
  71923. * @see https://easings.net/#easeInBack
  71924. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71925. */
  71926. export class BackEase extends EasingFunction implements IEasingFunction {
  71927. /** Defines the amplitude of the function */
  71928. amplitude: number;
  71929. /**
  71930. * Instantiates a back ease easing
  71931. * @see https://easings.net/#easeInBack
  71932. * @param amplitude Defines the amplitude of the function
  71933. */
  71934. constructor(
  71935. /** Defines the amplitude of the function */
  71936. amplitude?: number);
  71937. /** @hidden */
  71938. easeInCore(gradient: number): number;
  71939. }
  71940. /**
  71941. * Easing function with a bouncing shape (see link below).
  71942. * @see https://easings.net/#easeInBounce
  71943. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71944. */
  71945. export class BounceEase extends EasingFunction implements IEasingFunction {
  71946. /** Defines the number of bounces */
  71947. bounces: number;
  71948. /** Defines the amplitude of the bounce */
  71949. bounciness: number;
  71950. /**
  71951. * Instantiates a bounce easing
  71952. * @see https://easings.net/#easeInBounce
  71953. * @param bounces Defines the number of bounces
  71954. * @param bounciness Defines the amplitude of the bounce
  71955. */
  71956. constructor(
  71957. /** Defines the number of bounces */
  71958. bounces?: number,
  71959. /** Defines the amplitude of the bounce */
  71960. bounciness?: number);
  71961. /** @hidden */
  71962. easeInCore(gradient: number): number;
  71963. }
  71964. /**
  71965. * Easing function with a power of 3 shape (see link below).
  71966. * @see https://easings.net/#easeInCubic
  71967. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71968. */
  71969. export class CubicEase extends EasingFunction implements IEasingFunction {
  71970. /** @hidden */
  71971. easeInCore(gradient: number): number;
  71972. }
  71973. /**
  71974. * Easing function with an elastic shape (see link below).
  71975. * @see https://easings.net/#easeInElastic
  71976. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71977. */
  71978. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71979. /** Defines the number of oscillations*/
  71980. oscillations: number;
  71981. /** Defines the amplitude of the oscillations*/
  71982. springiness: number;
  71983. /**
  71984. * Instantiates an elastic easing function
  71985. * @see https://easings.net/#easeInElastic
  71986. * @param oscillations Defines the number of oscillations
  71987. * @param springiness Defines the amplitude of the oscillations
  71988. */
  71989. constructor(
  71990. /** Defines the number of oscillations*/
  71991. oscillations?: number,
  71992. /** Defines the amplitude of the oscillations*/
  71993. springiness?: number);
  71994. /** @hidden */
  71995. easeInCore(gradient: number): number;
  71996. }
  71997. /**
  71998. * Easing function with an exponential shape (see link below).
  71999. * @see https://easings.net/#easeInExpo
  72000. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72001. */
  72002. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72003. /** Defines the exponent of the function */
  72004. exponent: number;
  72005. /**
  72006. * Instantiates an exponential easing function
  72007. * @see https://easings.net/#easeInExpo
  72008. * @param exponent Defines the exponent of the function
  72009. */
  72010. constructor(
  72011. /** Defines the exponent of the function */
  72012. exponent?: number);
  72013. /** @hidden */
  72014. easeInCore(gradient: number): number;
  72015. }
  72016. /**
  72017. * Easing function with a power shape (see link below).
  72018. * @see https://easings.net/#easeInQuad
  72019. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72020. */
  72021. export class PowerEase extends EasingFunction implements IEasingFunction {
  72022. /** Defines the power of the function */
  72023. power: number;
  72024. /**
  72025. * Instantiates an power base easing function
  72026. * @see https://easings.net/#easeInQuad
  72027. * @param power Defines the power of the function
  72028. */
  72029. constructor(
  72030. /** Defines the power of the function */
  72031. power?: number);
  72032. /** @hidden */
  72033. easeInCore(gradient: number): number;
  72034. }
  72035. /**
  72036. * Easing function with a power of 2 shape (see link below).
  72037. * @see https://easings.net/#easeInQuad
  72038. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72039. */
  72040. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72041. /** @hidden */
  72042. easeInCore(gradient: number): number;
  72043. }
  72044. /**
  72045. * Easing function with a power of 4 shape (see link below).
  72046. * @see https://easings.net/#easeInQuart
  72047. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72048. */
  72049. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72050. /** @hidden */
  72051. easeInCore(gradient: number): number;
  72052. }
  72053. /**
  72054. * Easing function with a power of 5 shape (see link below).
  72055. * @see https://easings.net/#easeInQuint
  72056. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72057. */
  72058. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72059. /** @hidden */
  72060. easeInCore(gradient: number): number;
  72061. }
  72062. /**
  72063. * Easing function with a sin shape (see link below).
  72064. * @see https://easings.net/#easeInSine
  72065. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72066. */
  72067. export class SineEase extends EasingFunction implements IEasingFunction {
  72068. /** @hidden */
  72069. easeInCore(gradient: number): number;
  72070. }
  72071. /**
  72072. * Easing function with a bezier shape (see link below).
  72073. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72074. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72075. */
  72076. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72077. /** Defines the x component of the start tangent in the bezier curve */
  72078. x1: number;
  72079. /** Defines the y component of the start tangent in the bezier curve */
  72080. y1: number;
  72081. /** Defines the x component of the end tangent in the bezier curve */
  72082. x2: number;
  72083. /** Defines the y component of the end tangent in the bezier curve */
  72084. y2: number;
  72085. /**
  72086. * Instantiates a bezier function
  72087. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72088. * @param x1 Defines the x component of the start tangent in the bezier curve
  72089. * @param y1 Defines the y component of the start tangent in the bezier curve
  72090. * @param x2 Defines the x component of the end tangent in the bezier curve
  72091. * @param y2 Defines the y component of the end tangent in the bezier curve
  72092. */
  72093. constructor(
  72094. /** Defines the x component of the start tangent in the bezier curve */
  72095. x1?: number,
  72096. /** Defines the y component of the start tangent in the bezier curve */
  72097. y1?: number,
  72098. /** Defines the x component of the end tangent in the bezier curve */
  72099. x2?: number,
  72100. /** Defines the y component of the end tangent in the bezier curve */
  72101. y2?: number);
  72102. /** @hidden */
  72103. easeInCore(gradient: number): number;
  72104. }
  72105. }
  72106. declare module BABYLON {
  72107. /**
  72108. * Defines an interface which represents an animation key frame
  72109. */
  72110. export interface IAnimationKey {
  72111. /**
  72112. * Frame of the key frame
  72113. */
  72114. frame: number;
  72115. /**
  72116. * Value at the specifies key frame
  72117. */
  72118. value: any;
  72119. /**
  72120. * The input tangent for the cubic hermite spline
  72121. */
  72122. inTangent?: any;
  72123. /**
  72124. * The output tangent for the cubic hermite spline
  72125. */
  72126. outTangent?: any;
  72127. /**
  72128. * The animation interpolation type
  72129. */
  72130. interpolation?: AnimationKeyInterpolation;
  72131. }
  72132. /**
  72133. * Enum for the animation key frame interpolation type
  72134. */
  72135. export enum AnimationKeyInterpolation {
  72136. /**
  72137. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72138. */
  72139. STEP = 1
  72140. }
  72141. }
  72142. declare module BABYLON {
  72143. /**
  72144. * Represents the range of an animation
  72145. */
  72146. export class AnimationRange {
  72147. /**The name of the animation range**/
  72148. name: string;
  72149. /**The starting frame of the animation */
  72150. from: number;
  72151. /**The ending frame of the animation*/
  72152. to: number;
  72153. /**
  72154. * Initializes the range of an animation
  72155. * @param name The name of the animation range
  72156. * @param from The starting frame of the animation
  72157. * @param to The ending frame of the animation
  72158. */
  72159. constructor(
  72160. /**The name of the animation range**/
  72161. name: string,
  72162. /**The starting frame of the animation */
  72163. from: number,
  72164. /**The ending frame of the animation*/
  72165. to: number);
  72166. /**
  72167. * Makes a copy of the animation range
  72168. * @returns A copy of the animation range
  72169. */
  72170. clone(): AnimationRange;
  72171. }
  72172. }
  72173. declare module BABYLON {
  72174. /**
  72175. * Composed of a frame, and an action function
  72176. */
  72177. export class AnimationEvent {
  72178. /** The frame for which the event is triggered **/
  72179. frame: number;
  72180. /** The event to perform when triggered **/
  72181. action: (currentFrame: number) => void;
  72182. /** Specifies if the event should be triggered only once**/
  72183. onlyOnce?: boolean | undefined;
  72184. /**
  72185. * Specifies if the animation event is done
  72186. */
  72187. isDone: boolean;
  72188. /**
  72189. * Initializes the animation event
  72190. * @param frame The frame for which the event is triggered
  72191. * @param action The event to perform when triggered
  72192. * @param onlyOnce Specifies if the event should be triggered only once
  72193. */
  72194. constructor(
  72195. /** The frame for which the event is triggered **/
  72196. frame: number,
  72197. /** The event to perform when triggered **/
  72198. action: (currentFrame: number) => void,
  72199. /** Specifies if the event should be triggered only once**/
  72200. onlyOnce?: boolean | undefined);
  72201. /** @hidden */
  72202. _clone(): AnimationEvent;
  72203. }
  72204. }
  72205. declare module BABYLON {
  72206. /**
  72207. * Interface used to define a behavior
  72208. */
  72209. export interface Behavior<T> {
  72210. /** gets or sets behavior's name */
  72211. name: string;
  72212. /**
  72213. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72214. */
  72215. init(): void;
  72216. /**
  72217. * Called when the behavior is attached to a target
  72218. * @param target defines the target where the behavior is attached to
  72219. */
  72220. attach(target: T): void;
  72221. /**
  72222. * Called when the behavior is detached from its target
  72223. */
  72224. detach(): void;
  72225. }
  72226. /**
  72227. * Interface implemented by classes supporting behaviors
  72228. */
  72229. export interface IBehaviorAware<T> {
  72230. /**
  72231. * Attach a behavior
  72232. * @param behavior defines the behavior to attach
  72233. * @returns the current host
  72234. */
  72235. addBehavior(behavior: Behavior<T>): T;
  72236. /**
  72237. * Remove a behavior from the current object
  72238. * @param behavior defines the behavior to detach
  72239. * @returns the current host
  72240. */
  72241. removeBehavior(behavior: Behavior<T>): T;
  72242. /**
  72243. * Gets a behavior using its name to search
  72244. * @param name defines the name to search
  72245. * @returns the behavior or null if not found
  72246. */
  72247. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72248. }
  72249. }
  72250. declare module BABYLON {
  72251. /**
  72252. * Defines an array and its length.
  72253. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72254. */
  72255. export interface ISmartArrayLike<T> {
  72256. /**
  72257. * The data of the array.
  72258. */
  72259. data: Array<T>;
  72260. /**
  72261. * The active length of the array.
  72262. */
  72263. length: number;
  72264. }
  72265. /**
  72266. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72267. */
  72268. export class SmartArray<T> implements ISmartArrayLike<T> {
  72269. /**
  72270. * The full set of data from the array.
  72271. */
  72272. data: Array<T>;
  72273. /**
  72274. * The active length of the array.
  72275. */
  72276. length: number;
  72277. protected _id: number;
  72278. /**
  72279. * Instantiates a Smart Array.
  72280. * @param capacity defines the default capacity of the array.
  72281. */
  72282. constructor(capacity: number);
  72283. /**
  72284. * Pushes a value at the end of the active data.
  72285. * @param value defines the object to push in the array.
  72286. */
  72287. push(value: T): void;
  72288. /**
  72289. * Iterates over the active data and apply the lambda to them.
  72290. * @param func defines the action to apply on each value.
  72291. */
  72292. forEach(func: (content: T) => void): void;
  72293. /**
  72294. * Sorts the full sets of data.
  72295. * @param compareFn defines the comparison function to apply.
  72296. */
  72297. sort(compareFn: (a: T, b: T) => number): void;
  72298. /**
  72299. * Resets the active data to an empty array.
  72300. */
  72301. reset(): void;
  72302. /**
  72303. * Releases all the data from the array as well as the array.
  72304. */
  72305. dispose(): void;
  72306. /**
  72307. * Concats the active data with a given array.
  72308. * @param array defines the data to concatenate with.
  72309. */
  72310. concat(array: any): void;
  72311. /**
  72312. * Returns the position of a value in the active data.
  72313. * @param value defines the value to find the index for
  72314. * @returns the index if found in the active data otherwise -1
  72315. */
  72316. indexOf(value: T): number;
  72317. /**
  72318. * Returns whether an element is part of the active data.
  72319. * @param value defines the value to look for
  72320. * @returns true if found in the active data otherwise false
  72321. */
  72322. contains(value: T): boolean;
  72323. private static _GlobalId;
  72324. }
  72325. /**
  72326. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72327. * The data in this array can only be present once
  72328. */
  72329. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72330. private _duplicateId;
  72331. /**
  72332. * Pushes a value at the end of the active data.
  72333. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72334. * @param value defines the object to push in the array.
  72335. */
  72336. push(value: T): void;
  72337. /**
  72338. * Pushes a value at the end of the active data.
  72339. * If the data is already present, it won t be added again
  72340. * @param value defines the object to push in the array.
  72341. * @returns true if added false if it was already present
  72342. */
  72343. pushNoDuplicate(value: T): boolean;
  72344. /**
  72345. * Resets the active data to an empty array.
  72346. */
  72347. reset(): void;
  72348. /**
  72349. * Concats the active data with a given array.
  72350. * This ensures no dupplicate will be present in the result.
  72351. * @param array defines the data to concatenate with.
  72352. */
  72353. concatWithNoDuplicate(array: any): void;
  72354. }
  72355. }
  72356. declare module BABYLON {
  72357. /**
  72358. * @ignore
  72359. * This is a list of all the different input types that are available in the application.
  72360. * Fo instance: ArcRotateCameraGamepadInput...
  72361. */
  72362. export var CameraInputTypes: {};
  72363. /**
  72364. * This is the contract to implement in order to create a new input class.
  72365. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72366. */
  72367. export interface ICameraInput<TCamera extends Camera> {
  72368. /**
  72369. * Defines the camera the input is attached to.
  72370. */
  72371. camera: Nullable<TCamera>;
  72372. /**
  72373. * Gets the class name of the current intput.
  72374. * @returns the class name
  72375. */
  72376. getClassName(): string;
  72377. /**
  72378. * Get the friendly name associated with the input class.
  72379. * @returns the input friendly name
  72380. */
  72381. getSimpleName(): string;
  72382. /**
  72383. * Attach the input controls to a specific dom element to get the input from.
  72384. * @param element Defines the element the controls should be listened from
  72385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72386. */
  72387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72388. /**
  72389. * Detach the current controls from the specified dom element.
  72390. * @param element Defines the element to stop listening the inputs from
  72391. */
  72392. detachControl(element: Nullable<HTMLElement>): void;
  72393. /**
  72394. * Update the current camera state depending on the inputs that have been used this frame.
  72395. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72396. */
  72397. checkInputs?: () => void;
  72398. }
  72399. /**
  72400. * Represents a map of input types to input instance or input index to input instance.
  72401. */
  72402. export interface CameraInputsMap<TCamera extends Camera> {
  72403. /**
  72404. * Accessor to the input by input type.
  72405. */
  72406. [name: string]: ICameraInput<TCamera>;
  72407. /**
  72408. * Accessor to the input by input index.
  72409. */
  72410. [idx: number]: ICameraInput<TCamera>;
  72411. }
  72412. /**
  72413. * This represents the input manager used within a camera.
  72414. * It helps dealing with all the different kind of input attached to a camera.
  72415. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72416. */
  72417. export class CameraInputsManager<TCamera extends Camera> {
  72418. /**
  72419. * Defines the list of inputs attahed to the camera.
  72420. */
  72421. attached: CameraInputsMap<TCamera>;
  72422. /**
  72423. * Defines the dom element the camera is collecting inputs from.
  72424. * This is null if the controls have not been attached.
  72425. */
  72426. attachedElement: Nullable<HTMLElement>;
  72427. /**
  72428. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72429. */
  72430. noPreventDefault: boolean;
  72431. /**
  72432. * Defined the camera the input manager belongs to.
  72433. */
  72434. camera: TCamera;
  72435. /**
  72436. * Update the current camera state depending on the inputs that have been used this frame.
  72437. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72438. */
  72439. checkInputs: () => void;
  72440. /**
  72441. * Instantiate a new Camera Input Manager.
  72442. * @param camera Defines the camera the input manager blongs to
  72443. */
  72444. constructor(camera: TCamera);
  72445. /**
  72446. * Add an input method to a camera
  72447. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72448. * @param input camera input method
  72449. */
  72450. add(input: ICameraInput<TCamera>): void;
  72451. /**
  72452. * Remove a specific input method from a camera
  72453. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72454. * @param inputToRemove camera input method
  72455. */
  72456. remove(inputToRemove: ICameraInput<TCamera>): void;
  72457. /**
  72458. * Remove a specific input type from a camera
  72459. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72460. * @param inputType the type of the input to remove
  72461. */
  72462. removeByType(inputType: string): void;
  72463. private _addCheckInputs;
  72464. /**
  72465. * Attach the input controls to the currently attached dom element to listen the events from.
  72466. * @param input Defines the input to attach
  72467. */
  72468. attachInput(input: ICameraInput<TCamera>): void;
  72469. /**
  72470. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72471. * @param element Defines the dom element to collect the events from
  72472. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72473. */
  72474. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72475. /**
  72476. * Detach the current manager inputs controls from a specific dom element.
  72477. * @param element Defines the dom element to collect the events from
  72478. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72479. */
  72480. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72481. /**
  72482. * Rebuild the dynamic inputCheck function from the current list of
  72483. * defined inputs in the manager.
  72484. */
  72485. rebuildInputCheck(): void;
  72486. /**
  72487. * Remove all attached input methods from a camera
  72488. */
  72489. clear(): void;
  72490. /**
  72491. * Serialize the current input manager attached to a camera.
  72492. * This ensures than once parsed,
  72493. * the input associated to the camera will be identical to the current ones
  72494. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72495. */
  72496. serialize(serializedCamera: any): void;
  72497. /**
  72498. * Parses an input manager serialized JSON to restore the previous list of inputs
  72499. * and states associated to a camera.
  72500. * @param parsedCamera Defines the JSON to parse
  72501. */
  72502. parse(parsedCamera: any): void;
  72503. }
  72504. }
  72505. declare module BABYLON {
  72506. /**
  72507. * @hidden
  72508. */
  72509. export class IntersectionInfo {
  72510. bu: Nullable<number>;
  72511. bv: Nullable<number>;
  72512. distance: number;
  72513. faceId: number;
  72514. subMeshId: number;
  72515. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72516. }
  72517. }
  72518. declare module BABYLON {
  72519. /**
  72520. * Represens a plane by the equation ax + by + cz + d = 0
  72521. */
  72522. export class Plane {
  72523. private static _TmpMatrix;
  72524. /**
  72525. * Normal of the plane (a,b,c)
  72526. */
  72527. normal: Vector3;
  72528. /**
  72529. * d component of the plane
  72530. */
  72531. d: number;
  72532. /**
  72533. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72534. * @param a a component of the plane
  72535. * @param b b component of the plane
  72536. * @param c c component of the plane
  72537. * @param d d component of the plane
  72538. */
  72539. constructor(a: number, b: number, c: number, d: number);
  72540. /**
  72541. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72542. */
  72543. asArray(): number[];
  72544. /**
  72545. * @returns a new plane copied from the current Plane.
  72546. */
  72547. clone(): Plane;
  72548. /**
  72549. * @returns the string "Plane".
  72550. */
  72551. getClassName(): string;
  72552. /**
  72553. * @returns the Plane hash code.
  72554. */
  72555. getHashCode(): number;
  72556. /**
  72557. * Normalize the current Plane in place.
  72558. * @returns the updated Plane.
  72559. */
  72560. normalize(): Plane;
  72561. /**
  72562. * Applies a transformation the plane and returns the result
  72563. * @param transformation the transformation matrix to be applied to the plane
  72564. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72565. */
  72566. transform(transformation: DeepImmutable<Matrix>): Plane;
  72567. /**
  72568. * Calcualtte the dot product between the point and the plane normal
  72569. * @param point point to calculate the dot product with
  72570. * @returns the dot product (float) of the point coordinates and the plane normal.
  72571. */
  72572. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72573. /**
  72574. * Updates the current Plane from the plane defined by the three given points.
  72575. * @param point1 one of the points used to contruct the plane
  72576. * @param point2 one of the points used to contruct the plane
  72577. * @param point3 one of the points used to contruct the plane
  72578. * @returns the updated Plane.
  72579. */
  72580. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72581. /**
  72582. * Checks if the plane is facing a given direction
  72583. * @param direction the direction to check if the plane is facing
  72584. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72585. * @returns True is the vector "direction" is the same side than the plane normal.
  72586. */
  72587. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72588. /**
  72589. * Calculates the distance to a point
  72590. * @param point point to calculate distance to
  72591. * @returns the signed distance (float) from the given point to the Plane.
  72592. */
  72593. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  72594. /**
  72595. * Creates a plane from an array
  72596. * @param array the array to create a plane from
  72597. * @returns a new Plane from the given array.
  72598. */
  72599. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  72600. /**
  72601. * Creates a plane from three points
  72602. * @param point1 point used to create the plane
  72603. * @param point2 point used to create the plane
  72604. * @param point3 point used to create the plane
  72605. * @returns a new Plane defined by the three given points.
  72606. */
  72607. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72608. /**
  72609. * Creates a plane from an origin point and a normal
  72610. * @param origin origin of the plane to be constructed
  72611. * @param normal normal of the plane to be constructed
  72612. * @returns a new Plane the normal vector to this plane at the given origin point.
  72613. * Note : the vector "normal" is updated because normalized.
  72614. */
  72615. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  72616. /**
  72617. * Calculates the distance from a plane and a point
  72618. * @param origin origin of the plane to be constructed
  72619. * @param normal normal of the plane to be constructed
  72620. * @param point point to calculate distance to
  72621. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72622. */
  72623. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  72624. }
  72625. }
  72626. declare module BABYLON {
  72627. /**
  72628. * Class used to store bounding sphere information
  72629. */
  72630. export class BoundingSphere {
  72631. /**
  72632. * Gets the center of the bounding sphere in local space
  72633. */
  72634. readonly center: Vector3;
  72635. /**
  72636. * Radius of the bounding sphere in local space
  72637. */
  72638. radius: number;
  72639. /**
  72640. * Gets the center of the bounding sphere in world space
  72641. */
  72642. readonly centerWorld: Vector3;
  72643. /**
  72644. * Radius of the bounding sphere in world space
  72645. */
  72646. radiusWorld: number;
  72647. /**
  72648. * Gets the minimum vector in local space
  72649. */
  72650. readonly minimum: Vector3;
  72651. /**
  72652. * Gets the maximum vector in local space
  72653. */
  72654. readonly maximum: Vector3;
  72655. private _worldMatrix;
  72656. private static readonly TmpVector3;
  72657. /**
  72658. * Creates a new bounding sphere
  72659. * @param min defines the minimum vector (in local space)
  72660. * @param max defines the maximum vector (in local space)
  72661. * @param worldMatrix defines the new world matrix
  72662. */
  72663. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72664. /**
  72665. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  72666. * @param min defines the new minimum vector (in local space)
  72667. * @param max defines the new maximum vector (in local space)
  72668. * @param worldMatrix defines the new world matrix
  72669. */
  72670. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72671. /**
  72672. * Scale the current bounding sphere by applying a scale factor
  72673. * @param factor defines the scale factor to apply
  72674. * @returns the current bounding box
  72675. */
  72676. scale(factor: number): BoundingSphere;
  72677. /**
  72678. * Gets the world matrix of the bounding box
  72679. * @returns a matrix
  72680. */
  72681. getWorldMatrix(): DeepImmutable<Matrix>;
  72682. /** @hidden */
  72683. _update(worldMatrix: DeepImmutable<Matrix>): void;
  72684. /**
  72685. * Tests if the bounding sphere is intersecting the frustum planes
  72686. * @param frustumPlanes defines the frustum planes to test
  72687. * @returns true if there is an intersection
  72688. */
  72689. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72690. /**
  72691. * Tests if the bounding sphere center is in between the frustum planes.
  72692. * Used for optimistic fast inclusion.
  72693. * @param frustumPlanes defines the frustum planes to test
  72694. * @returns true if the sphere center is in between the frustum planes
  72695. */
  72696. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72697. /**
  72698. * Tests if a point is inside the bounding sphere
  72699. * @param point defines the point to test
  72700. * @returns true if the point is inside the bounding sphere
  72701. */
  72702. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72703. /**
  72704. * Checks if two sphere intersct
  72705. * @param sphere0 sphere 0
  72706. * @param sphere1 sphere 1
  72707. * @returns true if the speres intersect
  72708. */
  72709. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  72710. }
  72711. }
  72712. declare module BABYLON {
  72713. /**
  72714. * Class used to store bounding box information
  72715. */
  72716. export class BoundingBox implements ICullable {
  72717. /**
  72718. * Gets the 8 vectors representing the bounding box in local space
  72719. */
  72720. readonly vectors: Vector3[];
  72721. /**
  72722. * Gets the center of the bounding box in local space
  72723. */
  72724. readonly center: Vector3;
  72725. /**
  72726. * Gets the center of the bounding box in world space
  72727. */
  72728. readonly centerWorld: Vector3;
  72729. /**
  72730. * Gets the extend size in local space
  72731. */
  72732. readonly extendSize: Vector3;
  72733. /**
  72734. * Gets the extend size in world space
  72735. */
  72736. readonly extendSizeWorld: Vector3;
  72737. /**
  72738. * Gets the OBB (object bounding box) directions
  72739. */
  72740. readonly directions: Vector3[];
  72741. /**
  72742. * Gets the 8 vectors representing the bounding box in world space
  72743. */
  72744. readonly vectorsWorld: Vector3[];
  72745. /**
  72746. * Gets the minimum vector in world space
  72747. */
  72748. readonly minimumWorld: Vector3;
  72749. /**
  72750. * Gets the maximum vector in world space
  72751. */
  72752. readonly maximumWorld: Vector3;
  72753. /**
  72754. * Gets the minimum vector in local space
  72755. */
  72756. readonly minimum: Vector3;
  72757. /**
  72758. * Gets the maximum vector in local space
  72759. */
  72760. readonly maximum: Vector3;
  72761. private _worldMatrix;
  72762. private static readonly TmpVector3;
  72763. /**
  72764. * @hidden
  72765. */
  72766. _tag: number;
  72767. /**
  72768. * Creates a new bounding box
  72769. * @param min defines the minimum vector (in local space)
  72770. * @param max defines the maximum vector (in local space)
  72771. * @param worldMatrix defines the new world matrix
  72772. */
  72773. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72774. /**
  72775. * Recreates the entire bounding box from scratch as if we call the constructor in place
  72776. * @param min defines the new minimum vector (in local space)
  72777. * @param max defines the new maximum vector (in local space)
  72778. * @param worldMatrix defines the new world matrix
  72779. */
  72780. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72781. /**
  72782. * Scale the current bounding box by applying a scale factor
  72783. * @param factor defines the scale factor to apply
  72784. * @returns the current bounding box
  72785. */
  72786. scale(factor: number): BoundingBox;
  72787. /**
  72788. * Gets the world matrix of the bounding box
  72789. * @returns a matrix
  72790. */
  72791. getWorldMatrix(): DeepImmutable<Matrix>;
  72792. /** @hidden */
  72793. _update(world: DeepImmutable<Matrix>): void;
  72794. /**
  72795. * Tests if the bounding box is intersecting the frustum planes
  72796. * @param frustumPlanes defines the frustum planes to test
  72797. * @returns true if there is an intersection
  72798. */
  72799. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72800. /**
  72801. * Tests if the bounding box is entirely inside the frustum planes
  72802. * @param frustumPlanes defines the frustum planes to test
  72803. * @returns true if there is an inclusion
  72804. */
  72805. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72806. /**
  72807. * Tests if a point is inside the bounding box
  72808. * @param point defines the point to test
  72809. * @returns true if the point is inside the bounding box
  72810. */
  72811. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72812. /**
  72813. * Tests if the bounding box intersects with a bounding sphere
  72814. * @param sphere defines the sphere to test
  72815. * @returns true if there is an intersection
  72816. */
  72817. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  72818. /**
  72819. * Tests if the bounding box intersects with a box defined by a min and max vectors
  72820. * @param min defines the min vector to use
  72821. * @param max defines the max vector to use
  72822. * @returns true if there is an intersection
  72823. */
  72824. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  72825. /**
  72826. * Tests if two bounding boxes are intersections
  72827. * @param box0 defines the first box to test
  72828. * @param box1 defines the second box to test
  72829. * @returns true if there is an intersection
  72830. */
  72831. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  72832. /**
  72833. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  72834. * @param minPoint defines the minimum vector of the bounding box
  72835. * @param maxPoint defines the maximum vector of the bounding box
  72836. * @param sphereCenter defines the sphere center
  72837. * @param sphereRadius defines the sphere radius
  72838. * @returns true if there is an intersection
  72839. */
  72840. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  72841. /**
  72842. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  72843. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72844. * @param frustumPlanes defines the frustum planes to test
  72845. * @return true if there is an inclusion
  72846. */
  72847. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72848. /**
  72849. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  72850. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72851. * @param frustumPlanes defines the frustum planes to test
  72852. * @return true if there is an intersection
  72853. */
  72854. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72855. }
  72856. }
  72857. declare module BABYLON {
  72858. /** @hidden */
  72859. export class Collider {
  72860. /** Define if a collision was found */
  72861. collisionFound: boolean;
  72862. /**
  72863. * Define last intersection point in local space
  72864. */
  72865. intersectionPoint: Vector3;
  72866. /**
  72867. * Define last collided mesh
  72868. */
  72869. collidedMesh: Nullable<AbstractMesh>;
  72870. private _collisionPoint;
  72871. private _planeIntersectionPoint;
  72872. private _tempVector;
  72873. private _tempVector2;
  72874. private _tempVector3;
  72875. private _tempVector4;
  72876. private _edge;
  72877. private _baseToVertex;
  72878. private _destinationPoint;
  72879. private _slidePlaneNormal;
  72880. private _displacementVector;
  72881. /** @hidden */
  72882. _radius: Vector3;
  72883. /** @hidden */
  72884. _retry: number;
  72885. private _velocity;
  72886. private _basePoint;
  72887. private _epsilon;
  72888. /** @hidden */
  72889. _velocityWorldLength: number;
  72890. /** @hidden */
  72891. _basePointWorld: Vector3;
  72892. private _velocityWorld;
  72893. private _normalizedVelocity;
  72894. /** @hidden */
  72895. _initialVelocity: Vector3;
  72896. /** @hidden */
  72897. _initialPosition: Vector3;
  72898. private _nearestDistance;
  72899. private _collisionMask;
  72900. collisionMask: number;
  72901. /**
  72902. * Gets the plane normal used to compute the sliding response (in local space)
  72903. */
  72904. readonly slidePlaneNormal: Vector3;
  72905. /** @hidden */
  72906. _initialize(source: Vector3, dir: Vector3, e: number): void;
  72907. /** @hidden */
  72908. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  72909. /** @hidden */
  72910. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  72911. /** @hidden */
  72912. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72913. /** @hidden */
  72914. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72915. /** @hidden */
  72916. _getResponse(pos: Vector3, vel: Vector3): void;
  72917. }
  72918. }
  72919. declare module BABYLON {
  72920. /**
  72921. * Interface for cullable objects
  72922. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  72923. */
  72924. export interface ICullable {
  72925. /**
  72926. * Checks if the object or part of the object is in the frustum
  72927. * @param frustumPlanes Camera near/planes
  72928. * @returns true if the object is in frustum otherwise false
  72929. */
  72930. isInFrustum(frustumPlanes: Plane[]): boolean;
  72931. /**
  72932. * Checks if a cullable object (mesh...) is in the camera frustum
  72933. * Unlike isInFrustum this cheks the full bounding box
  72934. * @param frustumPlanes Camera near/planes
  72935. * @returns true if the object is in frustum otherwise false
  72936. */
  72937. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  72938. }
  72939. /**
  72940. * Info for a bounding data of a mesh
  72941. */
  72942. export class BoundingInfo implements ICullable {
  72943. /**
  72944. * Bounding box for the mesh
  72945. */
  72946. readonly boundingBox: BoundingBox;
  72947. /**
  72948. * Bounding sphere for the mesh
  72949. */
  72950. readonly boundingSphere: BoundingSphere;
  72951. private _isLocked;
  72952. private static readonly TmpVector3;
  72953. /**
  72954. * Constructs bounding info
  72955. * @param minimum min vector of the bounding box/sphere
  72956. * @param maximum max vector of the bounding box/sphere
  72957. * @param worldMatrix defines the new world matrix
  72958. */
  72959. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72960. /**
  72961. * Recreates the entire bounding info from scratch as if we call the constructor in place
  72962. * @param min defines the new minimum vector (in local space)
  72963. * @param max defines the new maximum vector (in local space)
  72964. * @param worldMatrix defines the new world matrix
  72965. */
  72966. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72967. /**
  72968. * min vector of the bounding box/sphere
  72969. */
  72970. readonly minimum: Vector3;
  72971. /**
  72972. * max vector of the bounding box/sphere
  72973. */
  72974. readonly maximum: Vector3;
  72975. /**
  72976. * If the info is locked and won't be updated to avoid perf overhead
  72977. */
  72978. isLocked: boolean;
  72979. /**
  72980. * Updates the bounding sphere and box
  72981. * @param world world matrix to be used to update
  72982. */
  72983. update(world: DeepImmutable<Matrix>): void;
  72984. /**
  72985. * Recreate the bounding info to be centered around a specific point given a specific extend.
  72986. * @param center New center of the bounding info
  72987. * @param extend New extend of the bounding info
  72988. * @returns the current bounding info
  72989. */
  72990. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  72991. /**
  72992. * Scale the current bounding info by applying a scale factor
  72993. * @param factor defines the scale factor to apply
  72994. * @returns the current bounding info
  72995. */
  72996. scale(factor: number): BoundingInfo;
  72997. /**
  72998. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  72999. * @param frustumPlanes defines the frustum to test
  73000. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73001. * @returns true if the bounding info is in the frustum planes
  73002. */
  73003. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73004. /**
  73005. * Gets the world distance between the min and max points of the bounding box
  73006. */
  73007. readonly diagonalLength: number;
  73008. /**
  73009. * Checks if a cullable object (mesh...) is in the camera frustum
  73010. * Unlike isInFrustum this cheks the full bounding box
  73011. * @param frustumPlanes Camera near/planes
  73012. * @returns true if the object is in frustum otherwise false
  73013. */
  73014. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73015. /** @hidden */
  73016. _checkCollision(collider: Collider): boolean;
  73017. /**
  73018. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73019. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73020. * @param point the point to check intersection with
  73021. * @returns if the point intersects
  73022. */
  73023. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73024. /**
  73025. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73026. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73027. * @param boundingInfo the bounding info to check intersection with
  73028. * @param precise if the intersection should be done using OBB
  73029. * @returns if the bounding info intersects
  73030. */
  73031. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73032. }
  73033. }
  73034. declare module BABYLON {
  73035. /**
  73036. * Extracts minimum and maximum values from a list of indexed positions
  73037. * @param positions defines the positions to use
  73038. * @param indices defines the indices to the positions
  73039. * @param indexStart defines the start index
  73040. * @param indexCount defines the end index
  73041. * @param bias defines bias value to add to the result
  73042. * @return minimum and maximum values
  73043. */
  73044. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73045. minimum: Vector3;
  73046. maximum: Vector3;
  73047. };
  73048. /**
  73049. * Extracts minimum and maximum values from a list of positions
  73050. * @param positions defines the positions to use
  73051. * @param start defines the start index in the positions array
  73052. * @param count defines the number of positions to handle
  73053. * @param bias defines bias value to add to the result
  73054. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73055. * @return minimum and maximum values
  73056. */
  73057. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73058. minimum: Vector3;
  73059. maximum: Vector3;
  73060. };
  73061. }
  73062. declare module BABYLON {
  73063. /**
  73064. * Enum that determines the text-wrapping mode to use.
  73065. */
  73066. export enum InspectableType {
  73067. /**
  73068. * Checkbox for booleans
  73069. */
  73070. Checkbox = 0,
  73071. /**
  73072. * Sliders for numbers
  73073. */
  73074. Slider = 1,
  73075. /**
  73076. * Vector3
  73077. */
  73078. Vector3 = 2,
  73079. /**
  73080. * Quaternions
  73081. */
  73082. Quaternion = 3,
  73083. /**
  73084. * Color3
  73085. */
  73086. Color3 = 4,
  73087. /**
  73088. * String
  73089. */
  73090. String = 5
  73091. }
  73092. /**
  73093. * Interface used to define custom inspectable properties.
  73094. * This interface is used by the inspector to display custom property grids
  73095. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73096. */
  73097. export interface IInspectable {
  73098. /**
  73099. * Gets the label to display
  73100. */
  73101. label: string;
  73102. /**
  73103. * Gets the name of the property to edit
  73104. */
  73105. propertyName: string;
  73106. /**
  73107. * Gets the type of the editor to use
  73108. */
  73109. type: InspectableType;
  73110. /**
  73111. * Gets the minimum value of the property when using in "slider" mode
  73112. */
  73113. min?: number;
  73114. /**
  73115. * Gets the maximum value of the property when using in "slider" mode
  73116. */
  73117. max?: number;
  73118. /**
  73119. * Gets the setp to use when using in "slider" mode
  73120. */
  73121. step?: number;
  73122. }
  73123. }
  73124. declare module BABYLON {
  73125. /**
  73126. * Class used to provide helper for timing
  73127. */
  73128. export class TimingTools {
  73129. /**
  73130. * Polyfill for setImmediate
  73131. * @param action defines the action to execute after the current execution block
  73132. */
  73133. static SetImmediate(action: () => void): void;
  73134. }
  73135. }
  73136. declare module BABYLON {
  73137. /**
  73138. * Class used to enable instatition of objects by class name
  73139. */
  73140. export class InstantiationTools {
  73141. /**
  73142. * Use this object to register external classes like custom textures or material
  73143. * to allow the laoders to instantiate them
  73144. */
  73145. static RegisteredExternalClasses: {
  73146. [key: string]: Object;
  73147. };
  73148. /**
  73149. * Tries to instantiate a new object from a given class name
  73150. * @param className defines the class name to instantiate
  73151. * @returns the new object or null if the system was not able to do the instantiation
  73152. */
  73153. static Instantiate(className: string): any;
  73154. }
  73155. }
  73156. declare module BABYLON {
  73157. /**
  73158. * This represents the required contract to create a new type of texture loader.
  73159. */
  73160. export interface IInternalTextureLoader {
  73161. /**
  73162. * Defines wether the loader supports cascade loading the different faces.
  73163. */
  73164. supportCascades: boolean;
  73165. /**
  73166. * This returns if the loader support the current file information.
  73167. * @param extension defines the file extension of the file being loaded
  73168. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73169. * @param fallback defines the fallback internal texture if any
  73170. * @param isBase64 defines whether the texture is encoded as a base64
  73171. * @param isBuffer defines whether the texture data are stored as a buffer
  73172. * @returns true if the loader can load the specified file
  73173. */
  73174. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73175. /**
  73176. * Transform the url before loading if required.
  73177. * @param rootUrl the url of the texture
  73178. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73179. * @returns the transformed texture
  73180. */
  73181. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73182. /**
  73183. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73184. * @param rootUrl the url of the texture
  73185. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73186. * @returns the fallback texture
  73187. */
  73188. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73189. /**
  73190. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73191. * @param data contains the texture data
  73192. * @param texture defines the BabylonJS internal texture
  73193. * @param createPolynomials will be true if polynomials have been requested
  73194. * @param onLoad defines the callback to trigger once the texture is ready
  73195. * @param onError defines the callback to trigger in case of error
  73196. */
  73197. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73198. /**
  73199. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73200. * @param data contains the texture data
  73201. * @param texture defines the BabylonJS internal texture
  73202. * @param callback defines the method to call once ready to upload
  73203. */
  73204. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73205. }
  73206. }
  73207. declare module BABYLON {
  73208. interface Engine {
  73209. /**
  73210. * Creates a depth stencil cube texture.
  73211. * This is only available in WebGL 2.
  73212. * @param size The size of face edge in the cube texture.
  73213. * @param options The options defining the cube texture.
  73214. * @returns The cube texture
  73215. */
  73216. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  73217. /**
  73218. * Creates a cube texture
  73219. * @param rootUrl defines the url where the files to load is located
  73220. * @param scene defines the current scene
  73221. * @param files defines the list of files to load (1 per face)
  73222. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73223. * @param onLoad defines an optional callback raised when the texture is loaded
  73224. * @param onError defines an optional callback raised if there is an issue to load the texture
  73225. * @param format defines the format of the data
  73226. * @param forcedExtension defines the extension to use to pick the right loader
  73227. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73228. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73229. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73230. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  73231. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  73232. * @returns the cube texture as an InternalTexture
  73233. */
  73234. 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;
  73235. /**
  73236. * Creates a cube texture
  73237. * @param rootUrl defines the url where the files to load is located
  73238. * @param scene defines the current scene
  73239. * @param files defines the list of files to load (1 per face)
  73240. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73241. * @param onLoad defines an optional callback raised when the texture is loaded
  73242. * @param onError defines an optional callback raised if there is an issue to load the texture
  73243. * @param format defines the format of the data
  73244. * @param forcedExtension defines the extension to use to pick the right loader
  73245. * @returns the cube texture as an InternalTexture
  73246. */
  73247. 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;
  73248. /**
  73249. * Creates a cube texture
  73250. * @param rootUrl defines the url where the files to load is located
  73251. * @param scene defines the current scene
  73252. * @param files defines the list of files to load (1 per face)
  73253. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73254. * @param onLoad defines an optional callback raised when the texture is loaded
  73255. * @param onError defines an optional callback raised if there is an issue to load the texture
  73256. * @param format defines the format of the data
  73257. * @param forcedExtension defines the extension to use to pick the right loader
  73258. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73259. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73260. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73261. * @returns the cube texture as an InternalTexture
  73262. */
  73263. 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;
  73264. /** @hidden */
  73265. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73266. /** @hidden */
  73267. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73268. /** @hidden */
  73269. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73270. /** @hidden */
  73271. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73272. }
  73273. }
  73274. declare module BABYLON {
  73275. /**
  73276. * Class for creating a cube texture
  73277. */
  73278. export class CubeTexture extends BaseTexture {
  73279. private _delayedOnLoad;
  73280. /**
  73281. * The url of the texture
  73282. */
  73283. url: string;
  73284. /**
  73285. * Gets or sets the center of the bounding box associated with the cube texture.
  73286. * It must define where the camera used to render the texture was set
  73287. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73288. */
  73289. boundingBoxPosition: Vector3;
  73290. private _boundingBoxSize;
  73291. /**
  73292. * Gets or sets the size of the bounding box associated with the cube texture
  73293. * When defined, the cubemap will switch to local mode
  73294. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73295. * @example https://www.babylonjs-playground.com/#RNASML
  73296. */
  73297. /**
  73298. * Returns the bounding box size
  73299. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73300. */
  73301. boundingBoxSize: Vector3;
  73302. protected _rotationY: number;
  73303. /**
  73304. * Sets texture matrix rotation angle around Y axis in radians.
  73305. */
  73306. /**
  73307. * Gets texture matrix rotation angle around Y axis radians.
  73308. */
  73309. rotationY: number;
  73310. /**
  73311. * Are mip maps generated for this texture or not.
  73312. */
  73313. readonly noMipmap: boolean;
  73314. private _noMipmap;
  73315. private _files;
  73316. private _extensions;
  73317. private _textureMatrix;
  73318. private _format;
  73319. private _createPolynomials;
  73320. /** @hidden */
  73321. _prefiltered: boolean;
  73322. /**
  73323. * Creates a cube texture from an array of image urls
  73324. * @param files defines an array of image urls
  73325. * @param scene defines the hosting scene
  73326. * @param noMipmap specifies if mip maps are not used
  73327. * @returns a cube texture
  73328. */
  73329. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  73330. /**
  73331. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  73332. * @param url defines the url of the prefiltered texture
  73333. * @param scene defines the scene the texture is attached to
  73334. * @param forcedExtension defines the extension of the file if different from the url
  73335. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73336. * @return the prefiltered texture
  73337. */
  73338. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  73339. /**
  73340. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  73341. * as prefiltered data.
  73342. * @param rootUrl defines the url of the texture or the root name of the six images
  73343. * @param scene defines the scene the texture is attached to
  73344. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  73345. * @param noMipmap defines if mipmaps should be created or not
  73346. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  73347. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  73348. * @param onError defines a callback triggered in case of error during load
  73349. * @param format defines the internal format to use for the texture once loaded
  73350. * @param prefiltered defines whether or not the texture is created from prefiltered data
  73351. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  73352. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73353. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73354. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73355. * @return the cube texture
  73356. */
  73357. 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);
  73358. /**
  73359. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  73360. */
  73361. readonly isPrefiltered: boolean;
  73362. /**
  73363. * Get the current class name of the texture useful for serialization or dynamic coding.
  73364. * @returns "CubeTexture"
  73365. */
  73366. getClassName(): string;
  73367. /**
  73368. * Update the url (and optional buffer) of this texture if url was null during construction.
  73369. * @param url the url of the texture
  73370. * @param forcedExtension defines the extension to use
  73371. * @param onLoad callback called when the texture is loaded (defaults to null)
  73372. */
  73373. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  73374. /**
  73375. * Delays loading of the cube texture
  73376. * @param forcedExtension defines the extension to use
  73377. */
  73378. delayLoad(forcedExtension?: string): void;
  73379. /**
  73380. * Returns the reflection texture matrix
  73381. * @returns the reflection texture matrix
  73382. */
  73383. getReflectionTextureMatrix(): Matrix;
  73384. /**
  73385. * Sets the reflection texture matrix
  73386. * @param value Reflection texture matrix
  73387. */
  73388. setReflectionTextureMatrix(value: Matrix): void;
  73389. /**
  73390. * Parses text to create a cube texture
  73391. * @param parsedTexture define the serialized text to read from
  73392. * @param scene defines the hosting scene
  73393. * @param rootUrl defines the root url of the cube texture
  73394. * @returns a cube texture
  73395. */
  73396. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  73397. /**
  73398. * Makes a clone, or deep copy, of the cube texture
  73399. * @returns a new cube texture
  73400. */
  73401. clone(): CubeTexture;
  73402. }
  73403. }
  73404. declare module BABYLON {
  73405. /**
  73406. * Manages the defines for the Material
  73407. */
  73408. export class MaterialDefines {
  73409. /** @hidden */
  73410. protected _keys: string[];
  73411. private _isDirty;
  73412. /** @hidden */
  73413. _renderId: number;
  73414. /** @hidden */
  73415. _areLightsDirty: boolean;
  73416. /** @hidden */
  73417. _areLightsDisposed: boolean;
  73418. /** @hidden */
  73419. _areAttributesDirty: boolean;
  73420. /** @hidden */
  73421. _areTexturesDirty: boolean;
  73422. /** @hidden */
  73423. _areFresnelDirty: boolean;
  73424. /** @hidden */
  73425. _areMiscDirty: boolean;
  73426. /** @hidden */
  73427. _areImageProcessingDirty: boolean;
  73428. /** @hidden */
  73429. _normals: boolean;
  73430. /** @hidden */
  73431. _uvs: boolean;
  73432. /** @hidden */
  73433. _needNormals: boolean;
  73434. /** @hidden */
  73435. _needUVs: boolean;
  73436. [id: string]: any;
  73437. /**
  73438. * Specifies if the material needs to be re-calculated
  73439. */
  73440. readonly isDirty: boolean;
  73441. /**
  73442. * Marks the material to indicate that it has been re-calculated
  73443. */
  73444. markAsProcessed(): void;
  73445. /**
  73446. * Marks the material to indicate that it needs to be re-calculated
  73447. */
  73448. markAsUnprocessed(): void;
  73449. /**
  73450. * Marks the material to indicate all of its defines need to be re-calculated
  73451. */
  73452. markAllAsDirty(): void;
  73453. /**
  73454. * Marks the material to indicate that image processing needs to be re-calculated
  73455. */
  73456. markAsImageProcessingDirty(): void;
  73457. /**
  73458. * Marks the material to indicate the lights need to be re-calculated
  73459. * @param disposed Defines whether the light is dirty due to dispose or not
  73460. */
  73461. markAsLightDirty(disposed?: boolean): void;
  73462. /**
  73463. * Marks the attribute state as changed
  73464. */
  73465. markAsAttributesDirty(): void;
  73466. /**
  73467. * Marks the texture state as changed
  73468. */
  73469. markAsTexturesDirty(): void;
  73470. /**
  73471. * Marks the fresnel state as changed
  73472. */
  73473. markAsFresnelDirty(): void;
  73474. /**
  73475. * Marks the misc state as changed
  73476. */
  73477. markAsMiscDirty(): void;
  73478. /**
  73479. * Rebuilds the material defines
  73480. */
  73481. rebuild(): void;
  73482. /**
  73483. * Specifies if two material defines are equal
  73484. * @param other - A material define instance to compare to
  73485. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  73486. */
  73487. isEqual(other: MaterialDefines): boolean;
  73488. /**
  73489. * Clones this instance's defines to another instance
  73490. * @param other - material defines to clone values to
  73491. */
  73492. cloneTo(other: MaterialDefines): void;
  73493. /**
  73494. * Resets the material define values
  73495. */
  73496. reset(): void;
  73497. /**
  73498. * Converts the material define values to a string
  73499. * @returns - String of material define information
  73500. */
  73501. toString(): string;
  73502. }
  73503. }
  73504. declare module BABYLON {
  73505. /**
  73506. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  73507. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  73508. * 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;
  73509. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  73510. */
  73511. export class ColorCurves {
  73512. private _dirty;
  73513. private _tempColor;
  73514. private _globalCurve;
  73515. private _highlightsCurve;
  73516. private _midtonesCurve;
  73517. private _shadowsCurve;
  73518. private _positiveCurve;
  73519. private _negativeCurve;
  73520. private _globalHue;
  73521. private _globalDensity;
  73522. private _globalSaturation;
  73523. private _globalExposure;
  73524. /**
  73525. * Gets the global Hue value.
  73526. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  73527. */
  73528. /**
  73529. * Sets the global Hue value.
  73530. * 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).
  73531. */
  73532. globalHue: number;
  73533. /**
  73534. * Gets the global Density value.
  73535. * 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.
  73536. * Values less than zero provide a filter of opposite hue.
  73537. */
  73538. /**
  73539. * Sets the global Density value.
  73540. * 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.
  73541. * Values less than zero provide a filter of opposite hue.
  73542. */
  73543. globalDensity: number;
  73544. /**
  73545. * Gets the global Saturation value.
  73546. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  73547. */
  73548. /**
  73549. * Sets the global Saturation value.
  73550. * 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.
  73551. */
  73552. globalSaturation: number;
  73553. /**
  73554. * Gets the global Exposure value.
  73555. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  73556. */
  73557. /**
  73558. * Sets the global Exposure value.
  73559. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  73560. */
  73561. globalExposure: number;
  73562. private _highlightsHue;
  73563. private _highlightsDensity;
  73564. private _highlightsSaturation;
  73565. private _highlightsExposure;
  73566. /**
  73567. * Gets the highlights Hue value.
  73568. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  73569. */
  73570. /**
  73571. * Sets the highlights Hue value.
  73572. * 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).
  73573. */
  73574. highlightsHue: number;
  73575. /**
  73576. * Gets the highlights Density value.
  73577. * 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.
  73578. * Values less than zero provide a filter of opposite hue.
  73579. */
  73580. /**
  73581. * Sets the highlights Density value.
  73582. * 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.
  73583. * Values less than zero provide a filter of opposite hue.
  73584. */
  73585. highlightsDensity: number;
  73586. /**
  73587. * Gets the highlights Saturation value.
  73588. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  73589. */
  73590. /**
  73591. * Sets the highlights Saturation value.
  73592. * 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.
  73593. */
  73594. highlightsSaturation: number;
  73595. /**
  73596. * Gets the highlights Exposure value.
  73597. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  73598. */
  73599. /**
  73600. * Sets the highlights Exposure value.
  73601. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  73602. */
  73603. highlightsExposure: number;
  73604. private _midtonesHue;
  73605. private _midtonesDensity;
  73606. private _midtonesSaturation;
  73607. private _midtonesExposure;
  73608. /**
  73609. * Gets the midtones Hue value.
  73610. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  73611. */
  73612. /**
  73613. * Sets the midtones Hue value.
  73614. * 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).
  73615. */
  73616. midtonesHue: number;
  73617. /**
  73618. * Gets the midtones Density value.
  73619. * 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.
  73620. * Values less than zero provide a filter of opposite hue.
  73621. */
  73622. /**
  73623. * Sets the midtones Density value.
  73624. * 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.
  73625. * Values less than zero provide a filter of opposite hue.
  73626. */
  73627. midtonesDensity: number;
  73628. /**
  73629. * Gets the midtones Saturation value.
  73630. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  73631. */
  73632. /**
  73633. * Sets the midtones Saturation value.
  73634. * 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.
  73635. */
  73636. midtonesSaturation: number;
  73637. /**
  73638. * Gets the midtones Exposure value.
  73639. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  73640. */
  73641. /**
  73642. * Sets the midtones Exposure value.
  73643. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  73644. */
  73645. midtonesExposure: number;
  73646. private _shadowsHue;
  73647. private _shadowsDensity;
  73648. private _shadowsSaturation;
  73649. private _shadowsExposure;
  73650. /**
  73651. * Gets the shadows Hue value.
  73652. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  73653. */
  73654. /**
  73655. * Sets the shadows Hue value.
  73656. * 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).
  73657. */
  73658. shadowsHue: number;
  73659. /**
  73660. * Gets the shadows Density value.
  73661. * 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.
  73662. * Values less than zero provide a filter of opposite hue.
  73663. */
  73664. /**
  73665. * Sets the shadows Density value.
  73666. * 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.
  73667. * Values less than zero provide a filter of opposite hue.
  73668. */
  73669. shadowsDensity: number;
  73670. /**
  73671. * Gets the shadows Saturation value.
  73672. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  73673. */
  73674. /**
  73675. * Sets the shadows Saturation value.
  73676. * 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.
  73677. */
  73678. shadowsSaturation: number;
  73679. /**
  73680. * Gets the shadows Exposure value.
  73681. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  73682. */
  73683. /**
  73684. * Sets the shadows Exposure value.
  73685. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  73686. */
  73687. shadowsExposure: number;
  73688. /**
  73689. * Returns the class name
  73690. * @returns The class name
  73691. */
  73692. getClassName(): string;
  73693. /**
  73694. * Binds the color curves to the shader.
  73695. * @param colorCurves The color curve to bind
  73696. * @param effect The effect to bind to
  73697. * @param positiveUniform The positive uniform shader parameter
  73698. * @param neutralUniform The neutral uniform shader parameter
  73699. * @param negativeUniform The negative uniform shader parameter
  73700. */
  73701. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  73702. /**
  73703. * Prepare the list of uniforms associated with the ColorCurves effects.
  73704. * @param uniformsList The list of uniforms used in the effect
  73705. */
  73706. static PrepareUniforms(uniformsList: string[]): void;
  73707. /**
  73708. * Returns color grading data based on a hue, density, saturation and exposure value.
  73709. * @param filterHue The hue of the color filter.
  73710. * @param filterDensity The density of the color filter.
  73711. * @param saturation The saturation.
  73712. * @param exposure The exposure.
  73713. * @param result The result data container.
  73714. */
  73715. private getColorGradingDataToRef;
  73716. /**
  73717. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  73718. * @param value The input slider value in range [-100,100].
  73719. * @returns Adjusted value.
  73720. */
  73721. private static applyColorGradingSliderNonlinear;
  73722. /**
  73723. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  73724. * @param hue The hue (H) input.
  73725. * @param saturation The saturation (S) input.
  73726. * @param brightness The brightness (B) input.
  73727. * @result An RGBA color represented as Vector4.
  73728. */
  73729. private static fromHSBToRef;
  73730. /**
  73731. * Returns a value clamped between min and max
  73732. * @param value The value to clamp
  73733. * @param min The minimum of value
  73734. * @param max The maximum of value
  73735. * @returns The clamped value.
  73736. */
  73737. private static clamp;
  73738. /**
  73739. * Clones the current color curve instance.
  73740. * @return The cloned curves
  73741. */
  73742. clone(): ColorCurves;
  73743. /**
  73744. * Serializes the current color curve instance to a json representation.
  73745. * @return a JSON representation
  73746. */
  73747. serialize(): any;
  73748. /**
  73749. * Parses the color curve from a json representation.
  73750. * @param source the JSON source to parse
  73751. * @return The parsed curves
  73752. */
  73753. static Parse(source: any): ColorCurves;
  73754. }
  73755. }
  73756. declare module BABYLON {
  73757. /**
  73758. * Interface to follow in your material defines to integrate easily the
  73759. * Image proccessing functions.
  73760. * @hidden
  73761. */
  73762. export interface IImageProcessingConfigurationDefines {
  73763. IMAGEPROCESSING: boolean;
  73764. VIGNETTE: boolean;
  73765. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73766. VIGNETTEBLENDMODEOPAQUE: boolean;
  73767. TONEMAPPING: boolean;
  73768. TONEMAPPING_ACES: boolean;
  73769. CONTRAST: boolean;
  73770. EXPOSURE: boolean;
  73771. COLORCURVES: boolean;
  73772. COLORGRADING: boolean;
  73773. COLORGRADING3D: boolean;
  73774. SAMPLER3DGREENDEPTH: boolean;
  73775. SAMPLER3DBGRMAP: boolean;
  73776. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73777. }
  73778. /**
  73779. * @hidden
  73780. */
  73781. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  73782. IMAGEPROCESSING: boolean;
  73783. VIGNETTE: boolean;
  73784. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73785. VIGNETTEBLENDMODEOPAQUE: boolean;
  73786. TONEMAPPING: boolean;
  73787. TONEMAPPING_ACES: boolean;
  73788. CONTRAST: boolean;
  73789. COLORCURVES: boolean;
  73790. COLORGRADING: boolean;
  73791. COLORGRADING3D: boolean;
  73792. SAMPLER3DGREENDEPTH: boolean;
  73793. SAMPLER3DBGRMAP: boolean;
  73794. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73795. EXPOSURE: boolean;
  73796. constructor();
  73797. }
  73798. /**
  73799. * This groups together the common properties used for image processing either in direct forward pass
  73800. * or through post processing effect depending on the use of the image processing pipeline in your scene
  73801. * or not.
  73802. */
  73803. export class ImageProcessingConfiguration {
  73804. /**
  73805. * Default tone mapping applied in BabylonJS.
  73806. */
  73807. static readonly TONEMAPPING_STANDARD: number;
  73808. /**
  73809. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  73810. * to other engines rendering to increase portability.
  73811. */
  73812. static readonly TONEMAPPING_ACES: number;
  73813. /**
  73814. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73815. */
  73816. colorCurves: Nullable<ColorCurves>;
  73817. private _colorCurvesEnabled;
  73818. /**
  73819. * Gets wether the color curves effect is enabled.
  73820. */
  73821. /**
  73822. * Sets wether the color curves effect is enabled.
  73823. */
  73824. colorCurvesEnabled: boolean;
  73825. private _colorGradingTexture;
  73826. /**
  73827. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73828. */
  73829. /**
  73830. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73831. */
  73832. colorGradingTexture: Nullable<BaseTexture>;
  73833. private _colorGradingEnabled;
  73834. /**
  73835. * Gets wether the color grading effect is enabled.
  73836. */
  73837. /**
  73838. * Sets wether the color grading effect is enabled.
  73839. */
  73840. colorGradingEnabled: boolean;
  73841. private _colorGradingWithGreenDepth;
  73842. /**
  73843. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73844. */
  73845. /**
  73846. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73847. */
  73848. colorGradingWithGreenDepth: boolean;
  73849. private _colorGradingBGR;
  73850. /**
  73851. * Gets wether the color grading texture contains BGR values.
  73852. */
  73853. /**
  73854. * Sets wether the color grading texture contains BGR values.
  73855. */
  73856. colorGradingBGR: boolean;
  73857. /** @hidden */
  73858. _exposure: number;
  73859. /**
  73860. * Gets the Exposure used in the effect.
  73861. */
  73862. /**
  73863. * Sets the Exposure used in the effect.
  73864. */
  73865. exposure: number;
  73866. private _toneMappingEnabled;
  73867. /**
  73868. * Gets wether the tone mapping effect is enabled.
  73869. */
  73870. /**
  73871. * Sets wether the tone mapping effect is enabled.
  73872. */
  73873. toneMappingEnabled: boolean;
  73874. private _toneMappingType;
  73875. /**
  73876. * Gets the type of tone mapping effect.
  73877. */
  73878. /**
  73879. * Sets the type of tone mapping effect used in BabylonJS.
  73880. */
  73881. toneMappingType: number;
  73882. protected _contrast: number;
  73883. /**
  73884. * Gets the contrast used in the effect.
  73885. */
  73886. /**
  73887. * Sets the contrast used in the effect.
  73888. */
  73889. contrast: number;
  73890. /**
  73891. * Vignette stretch size.
  73892. */
  73893. vignetteStretch: number;
  73894. /**
  73895. * Vignette centre X Offset.
  73896. */
  73897. vignetteCentreX: number;
  73898. /**
  73899. * Vignette centre Y Offset.
  73900. */
  73901. vignetteCentreY: number;
  73902. /**
  73903. * Vignette weight or intensity of the vignette effect.
  73904. */
  73905. vignetteWeight: number;
  73906. /**
  73907. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  73908. * if vignetteEnabled is set to true.
  73909. */
  73910. vignetteColor: Color4;
  73911. /**
  73912. * Camera field of view used by the Vignette effect.
  73913. */
  73914. vignetteCameraFov: number;
  73915. private _vignetteBlendMode;
  73916. /**
  73917. * Gets the vignette blend mode allowing different kind of effect.
  73918. */
  73919. /**
  73920. * Sets the vignette blend mode allowing different kind of effect.
  73921. */
  73922. vignetteBlendMode: number;
  73923. private _vignetteEnabled;
  73924. /**
  73925. * Gets wether the vignette effect is enabled.
  73926. */
  73927. /**
  73928. * Sets wether the vignette effect is enabled.
  73929. */
  73930. vignetteEnabled: boolean;
  73931. private _applyByPostProcess;
  73932. /**
  73933. * Gets wether the image processing is applied through a post process or not.
  73934. */
  73935. /**
  73936. * Sets wether the image processing is applied through a post process or not.
  73937. */
  73938. applyByPostProcess: boolean;
  73939. private _isEnabled;
  73940. /**
  73941. * Gets wether the image processing is enabled or not.
  73942. */
  73943. /**
  73944. * Sets wether the image processing is enabled or not.
  73945. */
  73946. isEnabled: boolean;
  73947. /**
  73948. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  73949. */
  73950. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  73951. /**
  73952. * Method called each time the image processing information changes requires to recompile the effect.
  73953. */
  73954. protected _updateParameters(): void;
  73955. /**
  73956. * Gets the current class name.
  73957. * @return "ImageProcessingConfiguration"
  73958. */
  73959. getClassName(): string;
  73960. /**
  73961. * Prepare the list of uniforms associated with the Image Processing effects.
  73962. * @param uniforms The list of uniforms used in the effect
  73963. * @param defines the list of defines currently in use
  73964. */
  73965. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  73966. /**
  73967. * Prepare the list of samplers associated with the Image Processing effects.
  73968. * @param samplersList The list of uniforms used in the effect
  73969. * @param defines the list of defines currently in use
  73970. */
  73971. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  73972. /**
  73973. * Prepare the list of defines associated to the shader.
  73974. * @param defines the list of defines to complete
  73975. * @param forPostProcess Define if we are currently in post process mode or not
  73976. */
  73977. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  73978. /**
  73979. * Returns true if all the image processing information are ready.
  73980. * @returns True if ready, otherwise, false
  73981. */
  73982. isReady(): boolean;
  73983. /**
  73984. * Binds the image processing to the shader.
  73985. * @param effect The effect to bind to
  73986. * @param aspectRatio Define the current aspect ratio of the effect
  73987. */
  73988. bind(effect: Effect, aspectRatio?: number): void;
  73989. /**
  73990. * Clones the current image processing instance.
  73991. * @return The cloned image processing
  73992. */
  73993. clone(): ImageProcessingConfiguration;
  73994. /**
  73995. * Serializes the current image processing instance to a json representation.
  73996. * @return a JSON representation
  73997. */
  73998. serialize(): any;
  73999. /**
  74000. * Parses the image processing from a json representation.
  74001. * @param source the JSON source to parse
  74002. * @return The parsed image processing
  74003. */
  74004. static Parse(source: any): ImageProcessingConfiguration;
  74005. private static _VIGNETTEMODE_MULTIPLY;
  74006. private static _VIGNETTEMODE_OPAQUE;
  74007. /**
  74008. * Used to apply the vignette as a mix with the pixel color.
  74009. */
  74010. static readonly VIGNETTEMODE_MULTIPLY: number;
  74011. /**
  74012. * Used to apply the vignette as a replacement of the pixel color.
  74013. */
  74014. static readonly VIGNETTEMODE_OPAQUE: number;
  74015. }
  74016. }
  74017. declare module BABYLON {
  74018. /** @hidden */
  74019. export var postprocessVertexShader: {
  74020. name: string;
  74021. shader: string;
  74022. };
  74023. }
  74024. declare module BABYLON {
  74025. /** Defines supported spaces */
  74026. export enum Space {
  74027. /** Local (object) space */
  74028. LOCAL = 0,
  74029. /** World space */
  74030. WORLD = 1,
  74031. /** Bone space */
  74032. BONE = 2
  74033. }
  74034. /** Defines the 3 main axes */
  74035. export class Axis {
  74036. /** X axis */
  74037. static X: Vector3;
  74038. /** Y axis */
  74039. static Y: Vector3;
  74040. /** Z axis */
  74041. static Z: Vector3;
  74042. }
  74043. }
  74044. declare module BABYLON {
  74045. /**
  74046. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  74047. * This is the base of the follow, arc rotate cameras and Free camera
  74048. * @see http://doc.babylonjs.com/features/cameras
  74049. */
  74050. export class TargetCamera extends Camera {
  74051. private static _RigCamTransformMatrix;
  74052. private static _TargetTransformMatrix;
  74053. private static _TargetFocalPoint;
  74054. /**
  74055. * Define the current direction the camera is moving to
  74056. */
  74057. cameraDirection: Vector3;
  74058. /**
  74059. * Define the current rotation the camera is rotating to
  74060. */
  74061. cameraRotation: Vector2;
  74062. /**
  74063. * When set, the up vector of the camera will be updated by the rotation of the camera
  74064. */
  74065. updateUpVectorFromRotation: boolean;
  74066. private _tmpQuaternion;
  74067. /**
  74068. * Define the current rotation of the camera
  74069. */
  74070. rotation: Vector3;
  74071. /**
  74072. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  74073. */
  74074. rotationQuaternion: Quaternion;
  74075. /**
  74076. * Define the current speed of the camera
  74077. */
  74078. speed: number;
  74079. /**
  74080. * Add cconstraint to the camera to prevent it to move freely in all directions and
  74081. * around all axis.
  74082. */
  74083. noRotationConstraint: boolean;
  74084. /**
  74085. * Define the current target of the camera as an object or a position.
  74086. */
  74087. lockedTarget: any;
  74088. /** @hidden */
  74089. _currentTarget: Vector3;
  74090. /** @hidden */
  74091. _initialFocalDistance: number;
  74092. /** @hidden */
  74093. _viewMatrix: Matrix;
  74094. /** @hidden */
  74095. _camMatrix: Matrix;
  74096. /** @hidden */
  74097. _cameraTransformMatrix: Matrix;
  74098. /** @hidden */
  74099. _cameraRotationMatrix: Matrix;
  74100. /** @hidden */
  74101. _referencePoint: Vector3;
  74102. /** @hidden */
  74103. _transformedReferencePoint: Vector3;
  74104. protected _globalCurrentTarget: Vector3;
  74105. protected _globalCurrentUpVector: Vector3;
  74106. /** @hidden */
  74107. _reset: () => void;
  74108. private _defaultUp;
  74109. /**
  74110. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  74111. * This is the base of the follow, arc rotate cameras and Free camera
  74112. * @see http://doc.babylonjs.com/features/cameras
  74113. * @param name Defines the name of the camera in the scene
  74114. * @param position Defines the start position of the camera in the scene
  74115. * @param scene Defines the scene the camera belongs to
  74116. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74117. */
  74118. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74119. /**
  74120. * Gets the position in front of the camera at a given distance.
  74121. * @param distance The distance from the camera we want the position to be
  74122. * @returns the position
  74123. */
  74124. getFrontPosition(distance: number): Vector3;
  74125. /** @hidden */
  74126. _getLockedTargetPosition(): Nullable<Vector3>;
  74127. private _storedPosition;
  74128. private _storedRotation;
  74129. private _storedRotationQuaternion;
  74130. /**
  74131. * Store current camera state of the camera (fov, position, rotation, etc..)
  74132. * @returns the camera
  74133. */
  74134. storeState(): Camera;
  74135. /**
  74136. * Restored camera state. You must call storeState() first
  74137. * @returns whether it was successful or not
  74138. * @hidden
  74139. */
  74140. _restoreStateValues(): boolean;
  74141. /** @hidden */
  74142. _initCache(): void;
  74143. /** @hidden */
  74144. _updateCache(ignoreParentClass?: boolean): void;
  74145. /** @hidden */
  74146. _isSynchronizedViewMatrix(): boolean;
  74147. /** @hidden */
  74148. _computeLocalCameraSpeed(): number;
  74149. /**
  74150. * Defines the target the camera should look at.
  74151. * @param target Defines the new target as a Vector or a mesh
  74152. */
  74153. setTarget(target: Vector3): void;
  74154. /**
  74155. * Return the current target position of the camera. This value is expressed in local space.
  74156. * @returns the target position
  74157. */
  74158. getTarget(): Vector3;
  74159. /** @hidden */
  74160. _decideIfNeedsToMove(): boolean;
  74161. /** @hidden */
  74162. _updatePosition(): void;
  74163. /** @hidden */
  74164. _checkInputs(): void;
  74165. protected _updateCameraRotationMatrix(): void;
  74166. /**
  74167. * 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)
  74168. * @returns the current camera
  74169. */
  74170. private _rotateUpVectorWithCameraRotationMatrix;
  74171. private _cachedRotationZ;
  74172. private _cachedQuaternionRotationZ;
  74173. /** @hidden */
  74174. _getViewMatrix(): Matrix;
  74175. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  74176. /**
  74177. * @hidden
  74178. */
  74179. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  74180. /**
  74181. * @hidden
  74182. */
  74183. _updateRigCameras(): void;
  74184. private _getRigCamPositionAndTarget;
  74185. /**
  74186. * Gets the current object class name.
  74187. * @return the class name
  74188. */
  74189. getClassName(): string;
  74190. }
  74191. }
  74192. declare module BABYLON {
  74193. /**
  74194. * Gather the list of keyboard event types as constants.
  74195. */
  74196. export class KeyboardEventTypes {
  74197. /**
  74198. * The keydown event is fired when a key becomes active (pressed).
  74199. */
  74200. static readonly KEYDOWN: number;
  74201. /**
  74202. * The keyup event is fired when a key has been released.
  74203. */
  74204. static readonly KEYUP: number;
  74205. }
  74206. /**
  74207. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74208. */
  74209. export class KeyboardInfo {
  74210. /**
  74211. * Defines the type of event (KeyboardEventTypes)
  74212. */
  74213. type: number;
  74214. /**
  74215. * Defines the related dom event
  74216. */
  74217. event: KeyboardEvent;
  74218. /**
  74219. * Instantiates a new keyboard info.
  74220. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74221. * @param type Defines the type of event (KeyboardEventTypes)
  74222. * @param event Defines the related dom event
  74223. */
  74224. constructor(
  74225. /**
  74226. * Defines the type of event (KeyboardEventTypes)
  74227. */
  74228. type: number,
  74229. /**
  74230. * Defines the related dom event
  74231. */
  74232. event: KeyboardEvent);
  74233. }
  74234. /**
  74235. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74236. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  74237. */
  74238. export class KeyboardInfoPre extends KeyboardInfo {
  74239. /**
  74240. * Defines the type of event (KeyboardEventTypes)
  74241. */
  74242. type: number;
  74243. /**
  74244. * Defines the related dom event
  74245. */
  74246. event: KeyboardEvent;
  74247. /**
  74248. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  74249. */
  74250. skipOnPointerObservable: boolean;
  74251. /**
  74252. * Instantiates a new keyboard pre info.
  74253. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74254. * @param type Defines the type of event (KeyboardEventTypes)
  74255. * @param event Defines the related dom event
  74256. */
  74257. constructor(
  74258. /**
  74259. * Defines the type of event (KeyboardEventTypes)
  74260. */
  74261. type: number,
  74262. /**
  74263. * Defines the related dom event
  74264. */
  74265. event: KeyboardEvent);
  74266. }
  74267. }
  74268. declare module BABYLON {
  74269. /**
  74270. * Manage the keyboard inputs to control the movement of a free camera.
  74271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74272. */
  74273. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  74274. /**
  74275. * Defines the camera the input is attached to.
  74276. */
  74277. camera: FreeCamera;
  74278. /**
  74279. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74280. */
  74281. keysUp: number[];
  74282. /**
  74283. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74284. */
  74285. keysDown: number[];
  74286. /**
  74287. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74288. */
  74289. keysLeft: number[];
  74290. /**
  74291. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74292. */
  74293. keysRight: number[];
  74294. private _keys;
  74295. private _onCanvasBlurObserver;
  74296. private _onKeyboardObserver;
  74297. private _engine;
  74298. private _scene;
  74299. /**
  74300. * Attach the input controls to a specific dom element to get the input from.
  74301. * @param element Defines the element the controls should be listened from
  74302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74303. */
  74304. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74305. /**
  74306. * Detach the current controls from the specified dom element.
  74307. * @param element Defines the element to stop listening the inputs from
  74308. */
  74309. detachControl(element: Nullable<HTMLElement>): void;
  74310. /**
  74311. * Update the current camera state depending on the inputs that have been used this frame.
  74312. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74313. */
  74314. checkInputs(): void;
  74315. /**
  74316. * Gets the class name of the current intput.
  74317. * @returns the class name
  74318. */
  74319. getClassName(): string;
  74320. /** @hidden */
  74321. _onLostFocus(): void;
  74322. /**
  74323. * Get the friendly name associated with the input class.
  74324. * @returns the input friendly name
  74325. */
  74326. getSimpleName(): string;
  74327. }
  74328. }
  74329. declare module BABYLON {
  74330. /**
  74331. * Interface describing all the common properties and methods a shadow light needs to implement.
  74332. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  74333. * as well as binding the different shadow properties to the effects.
  74334. */
  74335. export interface IShadowLight extends Light {
  74336. /**
  74337. * The light id in the scene (used in scene.findLighById for instance)
  74338. */
  74339. id: string;
  74340. /**
  74341. * The position the shdow will be casted from.
  74342. */
  74343. position: Vector3;
  74344. /**
  74345. * In 2d mode (needCube being false), the direction used to cast the shadow.
  74346. */
  74347. direction: Vector3;
  74348. /**
  74349. * The transformed position. Position of the light in world space taking parenting in account.
  74350. */
  74351. transformedPosition: Vector3;
  74352. /**
  74353. * The transformed direction. Direction of the light in world space taking parenting in account.
  74354. */
  74355. transformedDirection: Vector3;
  74356. /**
  74357. * The friendly name of the light in the scene.
  74358. */
  74359. name: string;
  74360. /**
  74361. * Defines the shadow projection clipping minimum z value.
  74362. */
  74363. shadowMinZ: number;
  74364. /**
  74365. * Defines the shadow projection clipping maximum z value.
  74366. */
  74367. shadowMaxZ: number;
  74368. /**
  74369. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74370. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74371. */
  74372. computeTransformedInformation(): boolean;
  74373. /**
  74374. * Gets the scene the light belongs to.
  74375. * @returns The scene
  74376. */
  74377. getScene(): Scene;
  74378. /**
  74379. * Callback defining a custom Projection Matrix Builder.
  74380. * This can be used to override the default projection matrix computation.
  74381. */
  74382. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74383. /**
  74384. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74385. * @param matrix The materix to updated with the projection information
  74386. * @param viewMatrix The transform matrix of the light
  74387. * @param renderList The list of mesh to render in the map
  74388. * @returns The current light
  74389. */
  74390. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74391. /**
  74392. * Gets the current depth scale used in ESM.
  74393. * @returns The scale
  74394. */
  74395. getDepthScale(): number;
  74396. /**
  74397. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74398. * @returns true if a cube texture needs to be use
  74399. */
  74400. needCube(): boolean;
  74401. /**
  74402. * Detects if the projection matrix requires to be recomputed this frame.
  74403. * @returns true if it requires to be recomputed otherwise, false.
  74404. */
  74405. needProjectionMatrixCompute(): boolean;
  74406. /**
  74407. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74408. */
  74409. forceProjectionMatrixCompute(): void;
  74410. /**
  74411. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74412. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74413. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74414. */
  74415. getShadowDirection(faceIndex?: number): Vector3;
  74416. /**
  74417. * Gets the minZ used for shadow according to both the scene and the light.
  74418. * @param activeCamera The camera we are returning the min for
  74419. * @returns the depth min z
  74420. */
  74421. getDepthMinZ(activeCamera: Camera): number;
  74422. /**
  74423. * Gets the maxZ used for shadow according to both the scene and the light.
  74424. * @param activeCamera The camera we are returning the max for
  74425. * @returns the depth max z
  74426. */
  74427. getDepthMaxZ(activeCamera: Camera): number;
  74428. }
  74429. /**
  74430. * Base implementation IShadowLight
  74431. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  74432. */
  74433. export abstract class ShadowLight extends Light implements IShadowLight {
  74434. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  74435. protected _position: Vector3;
  74436. protected _setPosition(value: Vector3): void;
  74437. /**
  74438. * Sets the position the shadow will be casted from. Also use as the light position for both
  74439. * point and spot lights.
  74440. */
  74441. /**
  74442. * Sets the position the shadow will be casted from. Also use as the light position for both
  74443. * point and spot lights.
  74444. */
  74445. position: Vector3;
  74446. protected _direction: Vector3;
  74447. protected _setDirection(value: Vector3): void;
  74448. /**
  74449. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  74450. * Also use as the light direction on spot and directional lights.
  74451. */
  74452. /**
  74453. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  74454. * Also use as the light direction on spot and directional lights.
  74455. */
  74456. direction: Vector3;
  74457. private _shadowMinZ;
  74458. /**
  74459. * Gets the shadow projection clipping minimum z value.
  74460. */
  74461. /**
  74462. * Sets the shadow projection clipping minimum z value.
  74463. */
  74464. shadowMinZ: number;
  74465. private _shadowMaxZ;
  74466. /**
  74467. * Sets the shadow projection clipping maximum z value.
  74468. */
  74469. /**
  74470. * Gets the shadow projection clipping maximum z value.
  74471. */
  74472. shadowMaxZ: number;
  74473. /**
  74474. * Callback defining a custom Projection Matrix Builder.
  74475. * This can be used to override the default projection matrix computation.
  74476. */
  74477. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74478. /**
  74479. * The transformed position. Position of the light in world space taking parenting in account.
  74480. */
  74481. transformedPosition: Vector3;
  74482. /**
  74483. * The transformed direction. Direction of the light in world space taking parenting in account.
  74484. */
  74485. transformedDirection: Vector3;
  74486. private _needProjectionMatrixCompute;
  74487. /**
  74488. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74489. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74490. */
  74491. computeTransformedInformation(): boolean;
  74492. /**
  74493. * Return the depth scale used for the shadow map.
  74494. * @returns the depth scale.
  74495. */
  74496. getDepthScale(): number;
  74497. /**
  74498. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74499. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74500. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74501. */
  74502. getShadowDirection(faceIndex?: number): Vector3;
  74503. /**
  74504. * Returns the ShadowLight absolute position in the World.
  74505. * @returns the position vector in world space
  74506. */
  74507. getAbsolutePosition(): Vector3;
  74508. /**
  74509. * Sets the ShadowLight direction toward the passed target.
  74510. * @param target The point to target in local space
  74511. * @returns the updated ShadowLight direction
  74512. */
  74513. setDirectionToTarget(target: Vector3): Vector3;
  74514. /**
  74515. * Returns the light rotation in euler definition.
  74516. * @returns the x y z rotation in local space.
  74517. */
  74518. getRotation(): Vector3;
  74519. /**
  74520. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74521. * @returns true if a cube texture needs to be use
  74522. */
  74523. needCube(): boolean;
  74524. /**
  74525. * Detects if the projection matrix requires to be recomputed this frame.
  74526. * @returns true if it requires to be recomputed otherwise, false.
  74527. */
  74528. needProjectionMatrixCompute(): boolean;
  74529. /**
  74530. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74531. */
  74532. forceProjectionMatrixCompute(): void;
  74533. /** @hidden */
  74534. _initCache(): void;
  74535. /** @hidden */
  74536. _isSynchronized(): boolean;
  74537. /**
  74538. * Computes the world matrix of the node
  74539. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  74540. * @returns the world matrix
  74541. */
  74542. computeWorldMatrix(force?: boolean): Matrix;
  74543. /**
  74544. * Gets the minZ used for shadow according to both the scene and the light.
  74545. * @param activeCamera The camera we are returning the min for
  74546. * @returns the depth min z
  74547. */
  74548. getDepthMinZ(activeCamera: Camera): number;
  74549. /**
  74550. * Gets the maxZ used for shadow according to both the scene and the light.
  74551. * @param activeCamera The camera we are returning the max for
  74552. * @returns the depth max z
  74553. */
  74554. getDepthMaxZ(activeCamera: Camera): number;
  74555. /**
  74556. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74557. * @param matrix The materix to updated with the projection information
  74558. * @param viewMatrix The transform matrix of the light
  74559. * @param renderList The list of mesh to render in the map
  74560. * @returns The current light
  74561. */
  74562. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74563. }
  74564. }
  74565. declare module BABYLON {
  74566. /**
  74567. * "Static Class" containing the most commonly used helper while dealing with material for
  74568. * rendering purpose.
  74569. *
  74570. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  74571. *
  74572. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  74573. */
  74574. export class MaterialHelper {
  74575. /**
  74576. * Bind the current view position to an effect.
  74577. * @param effect The effect to be bound
  74578. * @param scene The scene the eyes position is used from
  74579. */
  74580. static BindEyePosition(effect: Effect, scene: Scene): void;
  74581. /**
  74582. * Helps preparing the defines values about the UVs in used in the effect.
  74583. * UVs are shared as much as we can accross channels in the shaders.
  74584. * @param texture The texture we are preparing the UVs for
  74585. * @param defines The defines to update
  74586. * @param key The channel key "diffuse", "specular"... used in the shader
  74587. */
  74588. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  74589. /**
  74590. * Binds a texture matrix value to its corrsponding uniform
  74591. * @param texture The texture to bind the matrix for
  74592. * @param uniformBuffer The uniform buffer receivin the data
  74593. * @param key The channel key "diffuse", "specular"... used in the shader
  74594. */
  74595. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  74596. /**
  74597. * Gets the current status of the fog (should it be enabled?)
  74598. * @param mesh defines the mesh to evaluate for fog support
  74599. * @param scene defines the hosting scene
  74600. * @returns true if fog must be enabled
  74601. */
  74602. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  74603. /**
  74604. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  74605. * @param mesh defines the current mesh
  74606. * @param scene defines the current scene
  74607. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  74608. * @param pointsCloud defines if point cloud rendering has to be turned on
  74609. * @param fogEnabled defines if fog has to be turned on
  74610. * @param alphaTest defines if alpha testing has to be turned on
  74611. * @param defines defines the current list of defines
  74612. */
  74613. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  74614. /**
  74615. * Helper used to prepare the list of defines associated with frame values for shader compilation
  74616. * @param scene defines the current scene
  74617. * @param engine defines the current engine
  74618. * @param defines specifies the list of active defines
  74619. * @param useInstances defines if instances have to be turned on
  74620. * @param useClipPlane defines if clip plane have to be turned on
  74621. */
  74622. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  74623. /**
  74624. * Prepares the defines for bones
  74625. * @param mesh The mesh containing the geometry data we will draw
  74626. * @param defines The defines to update
  74627. */
  74628. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  74629. /**
  74630. * Prepares the defines for morph targets
  74631. * @param mesh The mesh containing the geometry data we will draw
  74632. * @param defines The defines to update
  74633. */
  74634. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  74635. /**
  74636. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  74637. * @param mesh The mesh containing the geometry data we will draw
  74638. * @param defines The defines to update
  74639. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  74640. * @param useBones Precise whether bones should be used or not (override mesh info)
  74641. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  74642. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  74643. * @returns false if defines are considered not dirty and have not been checked
  74644. */
  74645. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  74646. /**
  74647. * Prepares the defines related to multiview
  74648. * @param scene The scene we are intending to draw
  74649. * @param defines The defines to update
  74650. */
  74651. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  74652. /**
  74653. * Prepares the defines related to the light information passed in parameter
  74654. * @param scene The scene we are intending to draw
  74655. * @param mesh The mesh the effect is compiling for
  74656. * @param light The light the effect is compiling for
  74657. * @param lightIndex The index of the light
  74658. * @param defines The defines to update
  74659. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74660. * @param state Defines the current state regarding what is needed (normals, etc...)
  74661. */
  74662. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  74663. needNormals: boolean;
  74664. needRebuild: boolean;
  74665. shadowEnabled: boolean;
  74666. specularEnabled: boolean;
  74667. lightmapMode: boolean;
  74668. }): void;
  74669. /**
  74670. * Prepares the defines related to the light information passed in parameter
  74671. * @param scene The scene we are intending to draw
  74672. * @param mesh The mesh the effect is compiling for
  74673. * @param defines The defines to update
  74674. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74675. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  74676. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  74677. * @returns true if normals will be required for the rest of the effect
  74678. */
  74679. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  74680. /**
  74681. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  74682. * @param lightIndex defines the light index
  74683. * @param uniformsList The uniform list
  74684. * @param samplersList The sampler list
  74685. * @param projectedLightTexture defines if projected texture must be used
  74686. * @param uniformBuffersList defines an optional list of uniform buffers
  74687. */
  74688. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  74689. /**
  74690. * Prepares the uniforms and samplers list to be used in the effect
  74691. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  74692. * @param samplersList The sampler list
  74693. * @param defines The defines helping in the list generation
  74694. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  74695. */
  74696. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  74697. /**
  74698. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  74699. * @param defines The defines to update while falling back
  74700. * @param fallbacks The authorized effect fallbacks
  74701. * @param maxSimultaneousLights The maximum number of lights allowed
  74702. * @param rank the current rank of the Effect
  74703. * @returns The newly affected rank
  74704. */
  74705. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  74706. private static _TmpMorphInfluencers;
  74707. /**
  74708. * Prepares the list of attributes required for morph targets according to the effect defines.
  74709. * @param attribs The current list of supported attribs
  74710. * @param mesh The mesh to prepare the morph targets attributes for
  74711. * @param influencers The number of influencers
  74712. */
  74713. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  74714. /**
  74715. * Prepares the list of attributes required for morph targets according to the effect defines.
  74716. * @param attribs The current list of supported attribs
  74717. * @param mesh The mesh to prepare the morph targets attributes for
  74718. * @param defines The current Defines of the effect
  74719. */
  74720. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  74721. /**
  74722. * Prepares the list of attributes required for bones according to the effect defines.
  74723. * @param attribs The current list of supported attribs
  74724. * @param mesh The mesh to prepare the bones attributes for
  74725. * @param defines The current Defines of the effect
  74726. * @param fallbacks The current efffect fallback strategy
  74727. */
  74728. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  74729. /**
  74730. * Check and prepare the list of attributes required for instances according to the effect defines.
  74731. * @param attribs The current list of supported attribs
  74732. * @param defines The current MaterialDefines of the effect
  74733. */
  74734. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  74735. /**
  74736. * Add the list of attributes required for instances to the attribs array.
  74737. * @param attribs The current list of supported attribs
  74738. */
  74739. static PushAttributesForInstances(attribs: string[]): void;
  74740. /**
  74741. * Binds the light shadow information to the effect for the given mesh.
  74742. * @param light The light containing the generator
  74743. * @param scene The scene the lights belongs to
  74744. * @param mesh The mesh we are binding the information to render
  74745. * @param lightIndex The light index in the effect used to render the mesh
  74746. * @param effect The effect we are binding the data to
  74747. */
  74748. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74749. /**
  74750. * Binds the light information to the effect.
  74751. * @param light The light containing the generator
  74752. * @param effect The effect we are binding the data to
  74753. * @param lightIndex The light index in the effect used to render
  74754. */
  74755. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74756. /**
  74757. * Binds the lights information from the scene to the effect for the given mesh.
  74758. * @param light Light to bind
  74759. * @param lightIndex Light index
  74760. * @param scene The scene where the light belongs to
  74761. * @param mesh The mesh we are binding the information to render
  74762. * @param effect The effect we are binding the data to
  74763. * @param useSpecular Defines if specular is supported
  74764. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74765. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74766. */
  74767. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74768. /**
  74769. * Binds the lights information from the scene to the effect for the given mesh.
  74770. * @param scene The scene the lights belongs to
  74771. * @param mesh The mesh we are binding the information to render
  74772. * @param effect The effect we are binding the data to
  74773. * @param defines The generated defines for the effect
  74774. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74775. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74776. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74777. */
  74778. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74779. private static _tempFogColor;
  74780. /**
  74781. * Binds the fog information from the scene to the effect for the given mesh.
  74782. * @param scene The scene the lights belongs to
  74783. * @param mesh The mesh we are binding the information to render
  74784. * @param effect The effect we are binding the data to
  74785. * @param linearSpace Defines if the fog effect is applied in linear space
  74786. */
  74787. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74788. /**
  74789. * Binds the bones information from the mesh to the effect.
  74790. * @param mesh The mesh we are binding the information to render
  74791. * @param effect The effect we are binding the data to
  74792. */
  74793. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74794. /**
  74795. * Binds the morph targets information from the mesh to the effect.
  74796. * @param abstractMesh The mesh we are binding the information to render
  74797. * @param effect The effect we are binding the data to
  74798. */
  74799. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74800. /**
  74801. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74802. * @param defines The generated defines used in the effect
  74803. * @param effect The effect we are binding the data to
  74804. * @param scene The scene we are willing to render with logarithmic scale for
  74805. */
  74806. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74807. /**
  74808. * Binds the clip plane information from the scene to the effect.
  74809. * @param scene The scene the clip plane information are extracted from
  74810. * @param effect The effect we are binding the data to
  74811. */
  74812. static BindClipPlane(effect: Effect, scene: Scene): void;
  74813. }
  74814. }
  74815. declare module BABYLON {
  74816. /** @hidden */
  74817. export var packingFunctions: {
  74818. name: string;
  74819. shader: string;
  74820. };
  74821. }
  74822. declare module BABYLON {
  74823. /** @hidden */
  74824. export var shadowMapPixelShader: {
  74825. name: string;
  74826. shader: string;
  74827. };
  74828. }
  74829. declare module BABYLON {
  74830. /** @hidden */
  74831. export var bonesDeclaration: {
  74832. name: string;
  74833. shader: string;
  74834. };
  74835. }
  74836. declare module BABYLON {
  74837. /** @hidden */
  74838. export var morphTargetsVertexGlobalDeclaration: {
  74839. name: string;
  74840. shader: string;
  74841. };
  74842. }
  74843. declare module BABYLON {
  74844. /** @hidden */
  74845. export var morphTargetsVertexDeclaration: {
  74846. name: string;
  74847. shader: string;
  74848. };
  74849. }
  74850. declare module BABYLON {
  74851. /** @hidden */
  74852. export var instancesDeclaration: {
  74853. name: string;
  74854. shader: string;
  74855. };
  74856. }
  74857. declare module BABYLON {
  74858. /** @hidden */
  74859. export var helperFunctions: {
  74860. name: string;
  74861. shader: string;
  74862. };
  74863. }
  74864. declare module BABYLON {
  74865. /** @hidden */
  74866. export var morphTargetsVertex: {
  74867. name: string;
  74868. shader: string;
  74869. };
  74870. }
  74871. declare module BABYLON {
  74872. /** @hidden */
  74873. export var instancesVertex: {
  74874. name: string;
  74875. shader: string;
  74876. };
  74877. }
  74878. declare module BABYLON {
  74879. /** @hidden */
  74880. export var bonesVertex: {
  74881. name: string;
  74882. shader: string;
  74883. };
  74884. }
  74885. declare module BABYLON {
  74886. /** @hidden */
  74887. export var shadowMapVertexShader: {
  74888. name: string;
  74889. shader: string;
  74890. };
  74891. }
  74892. declare module BABYLON {
  74893. /** @hidden */
  74894. export var depthBoxBlurPixelShader: {
  74895. name: string;
  74896. shader: string;
  74897. };
  74898. }
  74899. declare module BABYLON {
  74900. /**
  74901. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74902. */
  74903. export interface ICustomShaderOptions {
  74904. /**
  74905. * Gets or sets the custom shader name to use
  74906. */
  74907. shaderName: string;
  74908. /**
  74909. * The list of attribute names used in the shader
  74910. */
  74911. attributes?: string[];
  74912. /**
  74913. * The list of unifrom names used in the shader
  74914. */
  74915. uniforms?: string[];
  74916. /**
  74917. * The list of sampler names used in the shader
  74918. */
  74919. samplers?: string[];
  74920. /**
  74921. * The list of defines used in the shader
  74922. */
  74923. defines?: string[];
  74924. }
  74925. /**
  74926. * Interface to implement to create a shadow generator compatible with BJS.
  74927. */
  74928. export interface IShadowGenerator {
  74929. /**
  74930. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74931. * @returns The render target texture if present otherwise, null
  74932. */
  74933. getShadowMap(): Nullable<RenderTargetTexture>;
  74934. /**
  74935. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74936. * @returns The render target texture if the shadow map is present otherwise, null
  74937. */
  74938. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74939. /**
  74940. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74941. * @param subMesh The submesh we want to render in the shadow map
  74942. * @param useInstances Defines wether will draw in the map using instances
  74943. * @returns true if ready otherwise, false
  74944. */
  74945. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74946. /**
  74947. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74948. * @param defines Defines of the material we want to update
  74949. * @param lightIndex Index of the light in the enabled light list of the material
  74950. */
  74951. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74952. /**
  74953. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74954. * defined in the generator but impacting the effect).
  74955. * It implies the unifroms available on the materials are the standard BJS ones.
  74956. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74957. * @param effect The effect we are binfing the information for
  74958. */
  74959. bindShadowLight(lightIndex: string, effect: Effect): void;
  74960. /**
  74961. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74962. * (eq to shadow prjection matrix * light transform matrix)
  74963. * @returns The transform matrix used to create the shadow map
  74964. */
  74965. getTransformMatrix(): Matrix;
  74966. /**
  74967. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74968. * Cube and 2D textures for instance.
  74969. */
  74970. recreateShadowMap(): void;
  74971. /**
  74972. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74973. * @param onCompiled Callback triggered at the and of the effects compilation
  74974. * @param options Sets of optional options forcing the compilation with different modes
  74975. */
  74976. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74977. useInstances: boolean;
  74978. }>): void;
  74979. /**
  74980. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74981. * @param options Sets of optional options forcing the compilation with different modes
  74982. * @returns A promise that resolves when the compilation completes
  74983. */
  74984. forceCompilationAsync(options?: Partial<{
  74985. useInstances: boolean;
  74986. }>): Promise<void>;
  74987. /**
  74988. * Serializes the shadow generator setup to a json object.
  74989. * @returns The serialized JSON object
  74990. */
  74991. serialize(): any;
  74992. /**
  74993. * Disposes the Shadow map and related Textures and effects.
  74994. */
  74995. dispose(): void;
  74996. }
  74997. /**
  74998. * Default implementation IShadowGenerator.
  74999. * This is the main object responsible of generating shadows in the framework.
  75000. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  75001. */
  75002. export class ShadowGenerator implements IShadowGenerator {
  75003. /**
  75004. * Shadow generator mode None: no filtering applied.
  75005. */
  75006. static readonly FILTER_NONE: number;
  75007. /**
  75008. * Shadow generator mode ESM: Exponential Shadow Mapping.
  75009. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75010. */
  75011. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  75012. /**
  75013. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  75014. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  75015. */
  75016. static readonly FILTER_POISSONSAMPLING: number;
  75017. /**
  75018. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  75019. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75020. */
  75021. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  75022. /**
  75023. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  75024. * edge artifacts on steep falloff.
  75025. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75026. */
  75027. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  75028. /**
  75029. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  75030. * edge artifacts on steep falloff.
  75031. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75032. */
  75033. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  75034. /**
  75035. * Shadow generator mode PCF: Percentage Closer Filtering
  75036. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75037. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  75038. */
  75039. static readonly FILTER_PCF: number;
  75040. /**
  75041. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  75042. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75043. * Contact Hardening
  75044. */
  75045. static readonly FILTER_PCSS: number;
  75046. /**
  75047. * Reserved for PCF and PCSS
  75048. * Highest Quality.
  75049. *
  75050. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  75051. *
  75052. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  75053. */
  75054. static readonly QUALITY_HIGH: number;
  75055. /**
  75056. * Reserved for PCF and PCSS
  75057. * Good tradeoff for quality/perf cross devices
  75058. *
  75059. * Execute PCF on a 3*3 kernel.
  75060. *
  75061. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  75062. */
  75063. static readonly QUALITY_MEDIUM: number;
  75064. /**
  75065. * Reserved for PCF and PCSS
  75066. * The lowest quality but the fastest.
  75067. *
  75068. * Execute PCF on a 1*1 kernel.
  75069. *
  75070. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  75071. */
  75072. static readonly QUALITY_LOW: number;
  75073. /** Gets or sets the custom shader name to use */
  75074. customShaderOptions: ICustomShaderOptions;
  75075. /**
  75076. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  75077. */
  75078. onBeforeShadowMapRenderObservable: Observable<Effect>;
  75079. /**
  75080. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  75081. */
  75082. onAfterShadowMapRenderObservable: Observable<Effect>;
  75083. /**
  75084. * Observable triggered before a mesh is rendered in the shadow map.
  75085. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  75086. */
  75087. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  75088. /**
  75089. * Observable triggered after a mesh is rendered in the shadow map.
  75090. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  75091. */
  75092. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  75093. private _bias;
  75094. /**
  75095. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  75096. */
  75097. /**
  75098. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  75099. */
  75100. bias: number;
  75101. private _normalBias;
  75102. /**
  75103. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75104. */
  75105. /**
  75106. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75107. */
  75108. normalBias: number;
  75109. private _blurBoxOffset;
  75110. /**
  75111. * Gets the blur box offset: offset applied during the blur pass.
  75112. * Only useful if useKernelBlur = false
  75113. */
  75114. /**
  75115. * Sets the blur box offset: offset applied during the blur pass.
  75116. * Only useful if useKernelBlur = false
  75117. */
  75118. blurBoxOffset: number;
  75119. private _blurScale;
  75120. /**
  75121. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  75122. * 2 means half of the size.
  75123. */
  75124. /**
  75125. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  75126. * 2 means half of the size.
  75127. */
  75128. blurScale: number;
  75129. private _blurKernel;
  75130. /**
  75131. * Gets the blur kernel: kernel size of the blur pass.
  75132. * Only useful if useKernelBlur = true
  75133. */
  75134. /**
  75135. * Sets the blur kernel: kernel size of the blur pass.
  75136. * Only useful if useKernelBlur = true
  75137. */
  75138. blurKernel: number;
  75139. private _useKernelBlur;
  75140. /**
  75141. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  75142. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75143. */
  75144. /**
  75145. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  75146. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75147. */
  75148. useKernelBlur: boolean;
  75149. private _depthScale;
  75150. /**
  75151. * Gets the depth scale used in ESM mode.
  75152. */
  75153. /**
  75154. * Sets the depth scale used in ESM mode.
  75155. * This can override the scale stored on the light.
  75156. */
  75157. depthScale: number;
  75158. private _filter;
  75159. /**
  75160. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  75161. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75162. */
  75163. /**
  75164. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  75165. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75166. */
  75167. filter: number;
  75168. /**
  75169. * Gets if the current filter is set to Poisson Sampling.
  75170. */
  75171. /**
  75172. * Sets the current filter to Poisson Sampling.
  75173. */
  75174. usePoissonSampling: boolean;
  75175. /**
  75176. * Gets if the current filter is set to ESM.
  75177. */
  75178. /**
  75179. * Sets the current filter is to ESM.
  75180. */
  75181. useExponentialShadowMap: boolean;
  75182. /**
  75183. * Gets if the current filter is set to filtered ESM.
  75184. */
  75185. /**
  75186. * Gets if the current filter is set to filtered ESM.
  75187. */
  75188. useBlurExponentialShadowMap: boolean;
  75189. /**
  75190. * Gets if the current filter is set to "close ESM" (using the inverse of the
  75191. * exponential to prevent steep falloff artifacts).
  75192. */
  75193. /**
  75194. * Sets the current filter to "close ESM" (using the inverse of the
  75195. * exponential to prevent steep falloff artifacts).
  75196. */
  75197. useCloseExponentialShadowMap: boolean;
  75198. /**
  75199. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  75200. * exponential to prevent steep falloff artifacts).
  75201. */
  75202. /**
  75203. * Sets the current filter to filtered "close ESM" (using the inverse of the
  75204. * exponential to prevent steep falloff artifacts).
  75205. */
  75206. useBlurCloseExponentialShadowMap: boolean;
  75207. /**
  75208. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  75209. */
  75210. /**
  75211. * Sets the current filter to "PCF" (percentage closer filtering).
  75212. */
  75213. usePercentageCloserFiltering: boolean;
  75214. private _filteringQuality;
  75215. /**
  75216. * Gets the PCF or PCSS Quality.
  75217. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75218. */
  75219. /**
  75220. * Sets the PCF or PCSS Quality.
  75221. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75222. */
  75223. filteringQuality: number;
  75224. /**
  75225. * Gets if the current filter is set to "PCSS" (contact hardening).
  75226. */
  75227. /**
  75228. * Sets the current filter to "PCSS" (contact hardening).
  75229. */
  75230. useContactHardeningShadow: boolean;
  75231. private _contactHardeningLightSizeUVRatio;
  75232. /**
  75233. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75234. * Using a ratio helps keeping shape stability independently of the map size.
  75235. *
  75236. * It does not account for the light projection as it was having too much
  75237. * instability during the light setup or during light position changes.
  75238. *
  75239. * Only valid if useContactHardeningShadow is true.
  75240. */
  75241. /**
  75242. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75243. * Using a ratio helps keeping shape stability independently of the map size.
  75244. *
  75245. * It does not account for the light projection as it was having too much
  75246. * instability during the light setup or during light position changes.
  75247. *
  75248. * Only valid if useContactHardeningShadow is true.
  75249. */
  75250. contactHardeningLightSizeUVRatio: number;
  75251. private _darkness;
  75252. /** Gets or sets the actual darkness of a shadow */
  75253. darkness: number;
  75254. /**
  75255. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  75256. * 0 means strongest and 1 would means no shadow.
  75257. * @returns the darkness.
  75258. */
  75259. getDarkness(): number;
  75260. /**
  75261. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  75262. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  75263. * @returns the shadow generator allowing fluent coding.
  75264. */
  75265. setDarkness(darkness: number): ShadowGenerator;
  75266. private _transparencyShadow;
  75267. /** Gets or sets the ability to have transparent shadow */
  75268. transparencyShadow: boolean;
  75269. /**
  75270. * Sets the ability to have transparent shadow (boolean).
  75271. * @param transparent True if transparent else False
  75272. * @returns the shadow generator allowing fluent coding
  75273. */
  75274. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  75275. private _shadowMap;
  75276. private _shadowMap2;
  75277. /**
  75278. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75279. * @returns The render target texture if present otherwise, null
  75280. */
  75281. getShadowMap(): Nullable<RenderTargetTexture>;
  75282. /**
  75283. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75284. * @returns The render target texture if the shadow map is present otherwise, null
  75285. */
  75286. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75287. /**
  75288. * Gets the class name of that object
  75289. * @returns "ShadowGenerator"
  75290. */
  75291. getClassName(): string;
  75292. /**
  75293. * Helper function to add a mesh and its descendants to the list of shadow casters.
  75294. * @param mesh Mesh to add
  75295. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  75296. * @returns the Shadow Generator itself
  75297. */
  75298. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75299. /**
  75300. * Helper function to remove a mesh and its descendants from the list of shadow casters
  75301. * @param mesh Mesh to remove
  75302. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  75303. * @returns the Shadow Generator itself
  75304. */
  75305. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75306. /**
  75307. * Controls the extent to which the shadows fade out at the edge of the frustum
  75308. * Used only by directionals and spots
  75309. */
  75310. frustumEdgeFalloff: number;
  75311. private _light;
  75312. /**
  75313. * Returns the associated light object.
  75314. * @returns the light generating the shadow
  75315. */
  75316. getLight(): IShadowLight;
  75317. /**
  75318. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  75319. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  75320. * It might on the other hand introduce peter panning.
  75321. */
  75322. forceBackFacesOnly: boolean;
  75323. private _scene;
  75324. private _lightDirection;
  75325. private _effect;
  75326. private _viewMatrix;
  75327. private _projectionMatrix;
  75328. private _transformMatrix;
  75329. private _cachedPosition;
  75330. private _cachedDirection;
  75331. private _cachedDefines;
  75332. private _currentRenderID;
  75333. private _boxBlurPostprocess;
  75334. private _kernelBlurXPostprocess;
  75335. private _kernelBlurYPostprocess;
  75336. private _blurPostProcesses;
  75337. private _mapSize;
  75338. private _currentFaceIndex;
  75339. private _currentFaceIndexCache;
  75340. private _textureType;
  75341. private _defaultTextureMatrix;
  75342. /** @hidden */
  75343. static _SceneComponentInitialization: (scene: Scene) => void;
  75344. /**
  75345. * Creates a ShadowGenerator object.
  75346. * A ShadowGenerator is the required tool to use the shadows.
  75347. * Each light casting shadows needs to use its own ShadowGenerator.
  75348. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  75349. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  75350. * @param light The light object generating the shadows.
  75351. * @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.
  75352. */
  75353. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  75354. private _initializeGenerator;
  75355. private _initializeShadowMap;
  75356. private _initializeBlurRTTAndPostProcesses;
  75357. private _renderForShadowMap;
  75358. private _renderSubMeshForShadowMap;
  75359. private _applyFilterValues;
  75360. /**
  75361. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75362. * @param onCompiled Callback triggered at the and of the effects compilation
  75363. * @param options Sets of optional options forcing the compilation with different modes
  75364. */
  75365. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75366. useInstances: boolean;
  75367. }>): void;
  75368. /**
  75369. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75370. * @param options Sets of optional options forcing the compilation with different modes
  75371. * @returns A promise that resolves when the compilation completes
  75372. */
  75373. forceCompilationAsync(options?: Partial<{
  75374. useInstances: boolean;
  75375. }>): Promise<void>;
  75376. /**
  75377. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75378. * @param subMesh The submesh we want to render in the shadow map
  75379. * @param useInstances Defines wether will draw in the map using instances
  75380. * @returns true if ready otherwise, false
  75381. */
  75382. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75383. /**
  75384. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75385. * @param defines Defines of the material we want to update
  75386. * @param lightIndex Index of the light in the enabled light list of the material
  75387. */
  75388. prepareDefines(defines: any, lightIndex: number): void;
  75389. /**
  75390. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75391. * defined in the generator but impacting the effect).
  75392. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75393. * @param effect The effect we are binfing the information for
  75394. */
  75395. bindShadowLight(lightIndex: string, effect: Effect): void;
  75396. /**
  75397. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75398. * (eq to shadow prjection matrix * light transform matrix)
  75399. * @returns The transform matrix used to create the shadow map
  75400. */
  75401. getTransformMatrix(): Matrix;
  75402. /**
  75403. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75404. * Cube and 2D textures for instance.
  75405. */
  75406. recreateShadowMap(): void;
  75407. private _disposeBlurPostProcesses;
  75408. private _disposeRTTandPostProcesses;
  75409. /**
  75410. * Disposes the ShadowGenerator.
  75411. * Returns nothing.
  75412. */
  75413. dispose(): void;
  75414. /**
  75415. * Serializes the shadow generator setup to a json object.
  75416. * @returns The serialized JSON object
  75417. */
  75418. serialize(): any;
  75419. /**
  75420. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  75421. * @param parsedShadowGenerator The JSON object to parse
  75422. * @param scene The scene to create the shadow map for
  75423. * @returns The parsed shadow generator
  75424. */
  75425. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  75426. }
  75427. }
  75428. declare module BABYLON {
  75429. /**
  75430. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  75431. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  75432. * 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.
  75433. */
  75434. export abstract class Light extends Node {
  75435. /**
  75436. * Falloff Default: light is falling off following the material specification:
  75437. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  75438. */
  75439. static readonly FALLOFF_DEFAULT: number;
  75440. /**
  75441. * Falloff Physical: light is falling off following the inverse squared distance law.
  75442. */
  75443. static readonly FALLOFF_PHYSICAL: number;
  75444. /**
  75445. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  75446. * to enhance interoperability with other engines.
  75447. */
  75448. static readonly FALLOFF_GLTF: number;
  75449. /**
  75450. * Falloff Standard: light is falling off like in the standard material
  75451. * to enhance interoperability with other materials.
  75452. */
  75453. static readonly FALLOFF_STANDARD: number;
  75454. /**
  75455. * If every light affecting the material is in this lightmapMode,
  75456. * material.lightmapTexture adds or multiplies
  75457. * (depends on material.useLightmapAsShadowmap)
  75458. * after every other light calculations.
  75459. */
  75460. static readonly LIGHTMAP_DEFAULT: number;
  75461. /**
  75462. * material.lightmapTexture as only diffuse lighting from this light
  75463. * adds only specular lighting from this light
  75464. * adds dynamic shadows
  75465. */
  75466. static readonly LIGHTMAP_SPECULAR: number;
  75467. /**
  75468. * material.lightmapTexture as only lighting
  75469. * no light calculation from this light
  75470. * only adds dynamic shadows from this light
  75471. */
  75472. static readonly LIGHTMAP_SHADOWSONLY: number;
  75473. /**
  75474. * Each light type uses the default quantity according to its type:
  75475. * point/spot lights use luminous intensity
  75476. * directional lights use illuminance
  75477. */
  75478. static readonly INTENSITYMODE_AUTOMATIC: number;
  75479. /**
  75480. * lumen (lm)
  75481. */
  75482. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  75483. /**
  75484. * candela (lm/sr)
  75485. */
  75486. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  75487. /**
  75488. * lux (lm/m^2)
  75489. */
  75490. static readonly INTENSITYMODE_ILLUMINANCE: number;
  75491. /**
  75492. * nit (cd/m^2)
  75493. */
  75494. static readonly INTENSITYMODE_LUMINANCE: number;
  75495. /**
  75496. * Light type const id of the point light.
  75497. */
  75498. static readonly LIGHTTYPEID_POINTLIGHT: number;
  75499. /**
  75500. * Light type const id of the directional light.
  75501. */
  75502. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  75503. /**
  75504. * Light type const id of the spot light.
  75505. */
  75506. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  75507. /**
  75508. * Light type const id of the hemispheric light.
  75509. */
  75510. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  75511. /**
  75512. * Diffuse gives the basic color to an object.
  75513. */
  75514. diffuse: Color3;
  75515. /**
  75516. * Specular produces a highlight color on an object.
  75517. * Note: This is note affecting PBR materials.
  75518. */
  75519. specular: Color3;
  75520. /**
  75521. * Defines the falloff type for this light. This lets overrriding how punctual light are
  75522. * falling off base on range or angle.
  75523. * This can be set to any values in Light.FALLOFF_x.
  75524. *
  75525. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  75526. * other types of materials.
  75527. */
  75528. falloffType: number;
  75529. /**
  75530. * Strength of the light.
  75531. * Note: By default it is define in the framework own unit.
  75532. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  75533. */
  75534. intensity: number;
  75535. private _range;
  75536. protected _inverseSquaredRange: number;
  75537. /**
  75538. * Defines how far from the source the light is impacting in scene units.
  75539. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75540. */
  75541. /**
  75542. * Defines how far from the source the light is impacting in scene units.
  75543. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75544. */
  75545. range: number;
  75546. /**
  75547. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  75548. * of light.
  75549. */
  75550. private _photometricScale;
  75551. private _intensityMode;
  75552. /**
  75553. * Gets the photometric scale used to interpret the intensity.
  75554. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75555. */
  75556. /**
  75557. * Sets the photometric scale used to interpret the intensity.
  75558. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75559. */
  75560. intensityMode: number;
  75561. private _radius;
  75562. /**
  75563. * Gets the light radius used by PBR Materials to simulate soft area lights.
  75564. */
  75565. /**
  75566. * sets the light radius used by PBR Materials to simulate soft area lights.
  75567. */
  75568. radius: number;
  75569. private _renderPriority;
  75570. /**
  75571. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  75572. * exceeding the number allowed of the materials.
  75573. */
  75574. renderPriority: number;
  75575. private _shadowEnabled;
  75576. /**
  75577. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75578. * the current shadow generator.
  75579. */
  75580. /**
  75581. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75582. * the current shadow generator.
  75583. */
  75584. shadowEnabled: boolean;
  75585. private _includedOnlyMeshes;
  75586. /**
  75587. * Gets the only meshes impacted by this light.
  75588. */
  75589. /**
  75590. * Sets the only meshes impacted by this light.
  75591. */
  75592. includedOnlyMeshes: AbstractMesh[];
  75593. private _excludedMeshes;
  75594. /**
  75595. * Gets the meshes not impacted by this light.
  75596. */
  75597. /**
  75598. * Sets the meshes not impacted by this light.
  75599. */
  75600. excludedMeshes: AbstractMesh[];
  75601. private _excludeWithLayerMask;
  75602. /**
  75603. * Gets the layer id use to find what meshes are not impacted by the light.
  75604. * Inactive if 0
  75605. */
  75606. /**
  75607. * Sets the layer id use to find what meshes are not impacted by the light.
  75608. * Inactive if 0
  75609. */
  75610. excludeWithLayerMask: number;
  75611. private _includeOnlyWithLayerMask;
  75612. /**
  75613. * Gets the layer id use to find what meshes are impacted by the light.
  75614. * Inactive if 0
  75615. */
  75616. /**
  75617. * Sets the layer id use to find what meshes are impacted by the light.
  75618. * Inactive if 0
  75619. */
  75620. includeOnlyWithLayerMask: number;
  75621. private _lightmapMode;
  75622. /**
  75623. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75624. */
  75625. /**
  75626. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75627. */
  75628. lightmapMode: number;
  75629. /**
  75630. * Shadow generator associted to the light.
  75631. * @hidden Internal use only.
  75632. */
  75633. _shadowGenerator: Nullable<IShadowGenerator>;
  75634. /**
  75635. * @hidden Internal use only.
  75636. */
  75637. _excludedMeshesIds: string[];
  75638. /**
  75639. * @hidden Internal use only.
  75640. */
  75641. _includedOnlyMeshesIds: string[];
  75642. /**
  75643. * The current light unifom buffer.
  75644. * @hidden Internal use only.
  75645. */
  75646. _uniformBuffer: UniformBuffer;
  75647. /**
  75648. * Creates a Light object in the scene.
  75649. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75650. * @param name The firendly name of the light
  75651. * @param scene The scene the light belongs too
  75652. */
  75653. constructor(name: string, scene: Scene);
  75654. protected abstract _buildUniformLayout(): void;
  75655. /**
  75656. * Sets the passed Effect "effect" with the Light information.
  75657. * @param effect The effect to update
  75658. * @param lightIndex The index of the light in the effect to update
  75659. * @returns The light
  75660. */
  75661. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  75662. /**
  75663. * Sets the passed Effect "effect" with the Light information.
  75664. * @param effect The effect to update
  75665. * @param lightDataUniformName The uniform used to store light data (position or direction)
  75666. * @returns The light
  75667. */
  75668. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  75669. /**
  75670. * Returns the string "Light".
  75671. * @returns the class name
  75672. */
  75673. getClassName(): string;
  75674. /** @hidden */
  75675. readonly _isLight: boolean;
  75676. /**
  75677. * Converts the light information to a readable string for debug purpose.
  75678. * @param fullDetails Supports for multiple levels of logging within scene loading
  75679. * @returns the human readable light info
  75680. */
  75681. toString(fullDetails?: boolean): string;
  75682. /** @hidden */
  75683. protected _syncParentEnabledState(): void;
  75684. /**
  75685. * Set the enabled state of this node.
  75686. * @param value - the new enabled state
  75687. */
  75688. setEnabled(value: boolean): void;
  75689. /**
  75690. * Returns the Light associated shadow generator if any.
  75691. * @return the associated shadow generator.
  75692. */
  75693. getShadowGenerator(): Nullable<IShadowGenerator>;
  75694. /**
  75695. * Returns a Vector3, the absolute light position in the World.
  75696. * @returns the world space position of the light
  75697. */
  75698. getAbsolutePosition(): Vector3;
  75699. /**
  75700. * Specifies if the light will affect the passed mesh.
  75701. * @param mesh The mesh to test against the light
  75702. * @return true the mesh is affected otherwise, false.
  75703. */
  75704. canAffectMesh(mesh: AbstractMesh): boolean;
  75705. /**
  75706. * Sort function to order lights for rendering.
  75707. * @param a First Light object to compare to second.
  75708. * @param b Second Light object to compare first.
  75709. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  75710. */
  75711. static CompareLightsPriority(a: Light, b: Light): number;
  75712. /**
  75713. * Releases resources associated with this node.
  75714. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75715. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75716. */
  75717. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75718. /**
  75719. * Returns the light type ID (integer).
  75720. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75721. */
  75722. getTypeID(): number;
  75723. /**
  75724. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  75725. * @returns the scaled intensity in intensity mode unit
  75726. */
  75727. getScaledIntensity(): number;
  75728. /**
  75729. * Returns a new Light object, named "name", from the current one.
  75730. * @param name The name of the cloned light
  75731. * @returns the new created light
  75732. */
  75733. clone(name: string): Nullable<Light>;
  75734. /**
  75735. * Serializes the current light into a Serialization object.
  75736. * @returns the serialized object.
  75737. */
  75738. serialize(): any;
  75739. /**
  75740. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  75741. * This new light is named "name" and added to the passed scene.
  75742. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75743. * @param name The friendly name of the light
  75744. * @param scene The scene the new light will belong to
  75745. * @returns the constructor function
  75746. */
  75747. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75748. /**
  75749. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75750. * @param parsedLight The JSON representation of the light
  75751. * @param scene The scene to create the parsed light in
  75752. * @returns the created light after parsing
  75753. */
  75754. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75755. private _hookArrayForExcluded;
  75756. private _hookArrayForIncludedOnly;
  75757. private _resyncMeshes;
  75758. /**
  75759. * Forces the meshes to update their light related information in their rendering used effects
  75760. * @hidden Internal Use Only
  75761. */
  75762. _markMeshesAsLightDirty(): void;
  75763. /**
  75764. * Recomputes the cached photometric scale if needed.
  75765. */
  75766. private _computePhotometricScale;
  75767. /**
  75768. * Returns the Photometric Scale according to the light type and intensity mode.
  75769. */
  75770. private _getPhotometricScale;
  75771. /**
  75772. * Reorder the light in the scene according to their defined priority.
  75773. * @hidden Internal Use Only
  75774. */
  75775. _reorderLightsInScene(): void;
  75776. /**
  75777. * Prepares the list of defines specific to the light type.
  75778. * @param defines the list of defines
  75779. * @param lightIndex defines the index of the light for the effect
  75780. */
  75781. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75782. }
  75783. }
  75784. declare module BABYLON {
  75785. /**
  75786. * Interface used to define Action
  75787. */
  75788. export interface IAction {
  75789. /**
  75790. * Trigger for the action
  75791. */
  75792. trigger: number;
  75793. /** Options of the trigger */
  75794. triggerOptions: any;
  75795. /**
  75796. * Gets the trigger parameters
  75797. * @returns the trigger parameters
  75798. */
  75799. getTriggerParameter(): any;
  75800. /**
  75801. * Internal only - executes current action event
  75802. * @hidden
  75803. */
  75804. _executeCurrent(evt?: ActionEvent): void;
  75805. /**
  75806. * Serialize placeholder for child classes
  75807. * @param parent of child
  75808. * @returns the serialized object
  75809. */
  75810. serialize(parent: any): any;
  75811. /**
  75812. * Internal only
  75813. * @hidden
  75814. */
  75815. _prepare(): void;
  75816. /**
  75817. * Internal only - manager for action
  75818. * @hidden
  75819. */
  75820. _actionManager: AbstractActionManager;
  75821. /**
  75822. * Adds action to chain of actions, may be a DoNothingAction
  75823. * @param action defines the next action to execute
  75824. * @returns The action passed in
  75825. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75826. */
  75827. then(action: IAction): IAction;
  75828. }
  75829. /**
  75830. * The action to be carried out following a trigger
  75831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75832. */
  75833. export class Action implements IAction {
  75834. /** the trigger, with or without parameters, for the action */
  75835. triggerOptions: any;
  75836. /**
  75837. * Trigger for the action
  75838. */
  75839. trigger: number;
  75840. /**
  75841. * Internal only - manager for action
  75842. * @hidden
  75843. */
  75844. _actionManager: ActionManager;
  75845. private _nextActiveAction;
  75846. private _child;
  75847. private _condition?;
  75848. private _triggerParameter;
  75849. /**
  75850. * An event triggered prior to action being executed.
  75851. */
  75852. onBeforeExecuteObservable: Observable<Action>;
  75853. /**
  75854. * Creates a new Action
  75855. * @param triggerOptions the trigger, with or without parameters, for the action
  75856. * @param condition an optional determinant of action
  75857. */
  75858. constructor(
  75859. /** the trigger, with or without parameters, for the action */
  75860. triggerOptions: any, condition?: Condition);
  75861. /**
  75862. * Internal only
  75863. * @hidden
  75864. */
  75865. _prepare(): void;
  75866. /**
  75867. * Gets the trigger parameters
  75868. * @returns the trigger parameters
  75869. */
  75870. getTriggerParameter(): any;
  75871. /**
  75872. * Internal only - executes current action event
  75873. * @hidden
  75874. */
  75875. _executeCurrent(evt?: ActionEvent): void;
  75876. /**
  75877. * Execute placeholder for child classes
  75878. * @param evt optional action event
  75879. */
  75880. execute(evt?: ActionEvent): void;
  75881. /**
  75882. * Skips to next active action
  75883. */
  75884. skipToNextActiveAction(): void;
  75885. /**
  75886. * Adds action to chain of actions, may be a DoNothingAction
  75887. * @param action defines the next action to execute
  75888. * @returns The action passed in
  75889. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75890. */
  75891. then(action: Action): Action;
  75892. /**
  75893. * Internal only
  75894. * @hidden
  75895. */
  75896. _getProperty(propertyPath: string): string;
  75897. /**
  75898. * Internal only
  75899. * @hidden
  75900. */
  75901. _getEffectiveTarget(target: any, propertyPath: string): any;
  75902. /**
  75903. * Serialize placeholder for child classes
  75904. * @param parent of child
  75905. * @returns the serialized object
  75906. */
  75907. serialize(parent: any): any;
  75908. /**
  75909. * Internal only called by serialize
  75910. * @hidden
  75911. */
  75912. protected _serialize(serializedAction: any, parent?: any): any;
  75913. /**
  75914. * Internal only
  75915. * @hidden
  75916. */
  75917. static _SerializeValueAsString: (value: any) => string;
  75918. /**
  75919. * Internal only
  75920. * @hidden
  75921. */
  75922. static _GetTargetProperty: (target: Node | Scene) => {
  75923. name: string;
  75924. targetType: string;
  75925. value: string;
  75926. };
  75927. }
  75928. }
  75929. declare module BABYLON {
  75930. /**
  75931. * A Condition applied to an Action
  75932. */
  75933. export class Condition {
  75934. /**
  75935. * Internal only - manager for action
  75936. * @hidden
  75937. */
  75938. _actionManager: ActionManager;
  75939. /**
  75940. * Internal only
  75941. * @hidden
  75942. */
  75943. _evaluationId: number;
  75944. /**
  75945. * Internal only
  75946. * @hidden
  75947. */
  75948. _currentResult: boolean;
  75949. /**
  75950. * Creates a new Condition
  75951. * @param actionManager the manager of the action the condition is applied to
  75952. */
  75953. constructor(actionManager: ActionManager);
  75954. /**
  75955. * Check if the current condition is valid
  75956. * @returns a boolean
  75957. */
  75958. isValid(): boolean;
  75959. /**
  75960. * Internal only
  75961. * @hidden
  75962. */
  75963. _getProperty(propertyPath: string): string;
  75964. /**
  75965. * Internal only
  75966. * @hidden
  75967. */
  75968. _getEffectiveTarget(target: any, propertyPath: string): any;
  75969. /**
  75970. * Serialize placeholder for child classes
  75971. * @returns the serialized object
  75972. */
  75973. serialize(): any;
  75974. /**
  75975. * Internal only
  75976. * @hidden
  75977. */
  75978. protected _serialize(serializedCondition: any): any;
  75979. }
  75980. /**
  75981. * Defines specific conditional operators as extensions of Condition
  75982. */
  75983. export class ValueCondition extends Condition {
  75984. /** path to specify the property of the target the conditional operator uses */
  75985. propertyPath: string;
  75986. /** the value compared by the conditional operator against the current value of the property */
  75987. value: any;
  75988. /** the conditional operator, default ValueCondition.IsEqual */
  75989. operator: number;
  75990. /**
  75991. * Internal only
  75992. * @hidden
  75993. */
  75994. private static _IsEqual;
  75995. /**
  75996. * Internal only
  75997. * @hidden
  75998. */
  75999. private static _IsDifferent;
  76000. /**
  76001. * Internal only
  76002. * @hidden
  76003. */
  76004. private static _IsGreater;
  76005. /**
  76006. * Internal only
  76007. * @hidden
  76008. */
  76009. private static _IsLesser;
  76010. /**
  76011. * returns the number for IsEqual
  76012. */
  76013. static readonly IsEqual: number;
  76014. /**
  76015. * Returns the number for IsDifferent
  76016. */
  76017. static readonly IsDifferent: number;
  76018. /**
  76019. * Returns the number for IsGreater
  76020. */
  76021. static readonly IsGreater: number;
  76022. /**
  76023. * Returns the number for IsLesser
  76024. */
  76025. static readonly IsLesser: number;
  76026. /**
  76027. * Internal only The action manager for the condition
  76028. * @hidden
  76029. */
  76030. _actionManager: ActionManager;
  76031. /**
  76032. * Internal only
  76033. * @hidden
  76034. */
  76035. private _target;
  76036. /**
  76037. * Internal only
  76038. * @hidden
  76039. */
  76040. private _effectiveTarget;
  76041. /**
  76042. * Internal only
  76043. * @hidden
  76044. */
  76045. private _property;
  76046. /**
  76047. * Creates a new ValueCondition
  76048. * @param actionManager manager for the action the condition applies to
  76049. * @param target for the action
  76050. * @param propertyPath path to specify the property of the target the conditional operator uses
  76051. * @param value the value compared by the conditional operator against the current value of the property
  76052. * @param operator the conditional operator, default ValueCondition.IsEqual
  76053. */
  76054. constructor(actionManager: ActionManager, target: any,
  76055. /** path to specify the property of the target the conditional operator uses */
  76056. propertyPath: string,
  76057. /** the value compared by the conditional operator against the current value of the property */
  76058. value: any,
  76059. /** the conditional operator, default ValueCondition.IsEqual */
  76060. operator?: number);
  76061. /**
  76062. * Compares the given value with the property value for the specified conditional operator
  76063. * @returns the result of the comparison
  76064. */
  76065. isValid(): boolean;
  76066. /**
  76067. * Serialize the ValueCondition into a JSON compatible object
  76068. * @returns serialization object
  76069. */
  76070. serialize(): any;
  76071. /**
  76072. * Gets the name of the conditional operator for the ValueCondition
  76073. * @param operator the conditional operator
  76074. * @returns the name
  76075. */
  76076. static GetOperatorName(operator: number): string;
  76077. }
  76078. /**
  76079. * Defines a predicate condition as an extension of Condition
  76080. */
  76081. export class PredicateCondition extends Condition {
  76082. /** defines the predicate function used to validate the condition */
  76083. predicate: () => boolean;
  76084. /**
  76085. * Internal only - manager for action
  76086. * @hidden
  76087. */
  76088. _actionManager: ActionManager;
  76089. /**
  76090. * Creates a new PredicateCondition
  76091. * @param actionManager manager for the action the condition applies to
  76092. * @param predicate defines the predicate function used to validate the condition
  76093. */
  76094. constructor(actionManager: ActionManager,
  76095. /** defines the predicate function used to validate the condition */
  76096. predicate: () => boolean);
  76097. /**
  76098. * @returns the validity of the predicate condition
  76099. */
  76100. isValid(): boolean;
  76101. }
  76102. /**
  76103. * Defines a state condition as an extension of Condition
  76104. */
  76105. export class StateCondition extends Condition {
  76106. /** Value to compare with target state */
  76107. value: string;
  76108. /**
  76109. * Internal only - manager for action
  76110. * @hidden
  76111. */
  76112. _actionManager: ActionManager;
  76113. /**
  76114. * Internal only
  76115. * @hidden
  76116. */
  76117. private _target;
  76118. /**
  76119. * Creates a new StateCondition
  76120. * @param actionManager manager for the action the condition applies to
  76121. * @param target of the condition
  76122. * @param value to compare with target state
  76123. */
  76124. constructor(actionManager: ActionManager, target: any,
  76125. /** Value to compare with target state */
  76126. value: string);
  76127. /**
  76128. * Gets a boolean indicating if the current condition is met
  76129. * @returns the validity of the state
  76130. */
  76131. isValid(): boolean;
  76132. /**
  76133. * Serialize the StateCondition into a JSON compatible object
  76134. * @returns serialization object
  76135. */
  76136. serialize(): any;
  76137. }
  76138. }
  76139. declare module BABYLON {
  76140. /**
  76141. * This defines an action responsible to toggle a boolean once triggered.
  76142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76143. */
  76144. export class SwitchBooleanAction extends Action {
  76145. /**
  76146. * The path to the boolean property in the target object
  76147. */
  76148. propertyPath: string;
  76149. private _target;
  76150. private _effectiveTarget;
  76151. private _property;
  76152. /**
  76153. * Instantiate the action
  76154. * @param triggerOptions defines the trigger options
  76155. * @param target defines the object containing the boolean
  76156. * @param propertyPath defines the path to the boolean property in the target object
  76157. * @param condition defines the trigger related conditions
  76158. */
  76159. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76160. /** @hidden */
  76161. _prepare(): void;
  76162. /**
  76163. * Execute the action toggle the boolean value.
  76164. */
  76165. execute(): void;
  76166. /**
  76167. * Serializes the actions and its related information.
  76168. * @param parent defines the object to serialize in
  76169. * @returns the serialized object
  76170. */
  76171. serialize(parent: any): any;
  76172. }
  76173. /**
  76174. * This defines an action responsible to set a the state field of the target
  76175. * to a desired value once triggered.
  76176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76177. */
  76178. export class SetStateAction extends Action {
  76179. /**
  76180. * The value to store in the state field.
  76181. */
  76182. value: string;
  76183. private _target;
  76184. /**
  76185. * Instantiate the action
  76186. * @param triggerOptions defines the trigger options
  76187. * @param target defines the object containing the state property
  76188. * @param value defines the value to store in the state field
  76189. * @param condition defines the trigger related conditions
  76190. */
  76191. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76192. /**
  76193. * Execute the action and store the value on the target state property.
  76194. */
  76195. execute(): void;
  76196. /**
  76197. * Serializes the actions and its related information.
  76198. * @param parent defines the object to serialize in
  76199. * @returns the serialized object
  76200. */
  76201. serialize(parent: any): any;
  76202. }
  76203. /**
  76204. * This defines an action responsible to set a property of the target
  76205. * to a desired value once triggered.
  76206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76207. */
  76208. export class SetValueAction extends Action {
  76209. /**
  76210. * The path of the property to set in the target.
  76211. */
  76212. propertyPath: string;
  76213. /**
  76214. * The value to set in the property
  76215. */
  76216. value: any;
  76217. private _target;
  76218. private _effectiveTarget;
  76219. private _property;
  76220. /**
  76221. * Instantiate the action
  76222. * @param triggerOptions defines the trigger options
  76223. * @param target defines the object containing the property
  76224. * @param propertyPath defines the path of the property to set in the target
  76225. * @param value defines the value to set in the property
  76226. * @param condition defines the trigger related conditions
  76227. */
  76228. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76229. /** @hidden */
  76230. _prepare(): void;
  76231. /**
  76232. * Execute the action and set the targetted property to the desired value.
  76233. */
  76234. execute(): void;
  76235. /**
  76236. * Serializes the actions and its related information.
  76237. * @param parent defines the object to serialize in
  76238. * @returns the serialized object
  76239. */
  76240. serialize(parent: any): any;
  76241. }
  76242. /**
  76243. * This defines an action responsible to increment the target value
  76244. * to a desired value once triggered.
  76245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76246. */
  76247. export class IncrementValueAction extends Action {
  76248. /**
  76249. * The path of the property to increment in the target.
  76250. */
  76251. propertyPath: string;
  76252. /**
  76253. * The value we should increment the property by.
  76254. */
  76255. value: any;
  76256. private _target;
  76257. private _effectiveTarget;
  76258. private _property;
  76259. /**
  76260. * Instantiate the action
  76261. * @param triggerOptions defines the trigger options
  76262. * @param target defines the object containing the property
  76263. * @param propertyPath defines the path of the property to increment in the target
  76264. * @param value defines the value value we should increment the property by
  76265. * @param condition defines the trigger related conditions
  76266. */
  76267. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76268. /** @hidden */
  76269. _prepare(): void;
  76270. /**
  76271. * Execute the action and increment the target of the value amount.
  76272. */
  76273. execute(): void;
  76274. /**
  76275. * Serializes the actions and its related information.
  76276. * @param parent defines the object to serialize in
  76277. * @returns the serialized object
  76278. */
  76279. serialize(parent: any): any;
  76280. }
  76281. /**
  76282. * This defines an action responsible to start an animation once triggered.
  76283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76284. */
  76285. export class PlayAnimationAction extends Action {
  76286. /**
  76287. * Where the animation should start (animation frame)
  76288. */
  76289. from: number;
  76290. /**
  76291. * Where the animation should stop (animation frame)
  76292. */
  76293. to: number;
  76294. /**
  76295. * Define if the animation should loop or stop after the first play.
  76296. */
  76297. loop?: boolean;
  76298. private _target;
  76299. /**
  76300. * Instantiate the action
  76301. * @param triggerOptions defines the trigger options
  76302. * @param target defines the target animation or animation name
  76303. * @param from defines from where the animation should start (animation frame)
  76304. * @param end defines where the animation should stop (animation frame)
  76305. * @param loop defines if the animation should loop or stop after the first play
  76306. * @param condition defines the trigger related conditions
  76307. */
  76308. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  76309. /** @hidden */
  76310. _prepare(): void;
  76311. /**
  76312. * Execute the action and play the animation.
  76313. */
  76314. execute(): void;
  76315. /**
  76316. * Serializes the actions and its related information.
  76317. * @param parent defines the object to serialize in
  76318. * @returns the serialized object
  76319. */
  76320. serialize(parent: any): any;
  76321. }
  76322. /**
  76323. * This defines an action responsible to stop an animation once triggered.
  76324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76325. */
  76326. export class StopAnimationAction extends Action {
  76327. private _target;
  76328. /**
  76329. * Instantiate the action
  76330. * @param triggerOptions defines the trigger options
  76331. * @param target defines the target animation or animation name
  76332. * @param condition defines the trigger related conditions
  76333. */
  76334. constructor(triggerOptions: any, target: any, condition?: Condition);
  76335. /** @hidden */
  76336. _prepare(): void;
  76337. /**
  76338. * Execute the action and stop the animation.
  76339. */
  76340. execute(): void;
  76341. /**
  76342. * Serializes the actions and its related information.
  76343. * @param parent defines the object to serialize in
  76344. * @returns the serialized object
  76345. */
  76346. serialize(parent: any): any;
  76347. }
  76348. /**
  76349. * This defines an action responsible that does nothing once triggered.
  76350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76351. */
  76352. export class DoNothingAction extends Action {
  76353. /**
  76354. * Instantiate the action
  76355. * @param triggerOptions defines the trigger options
  76356. * @param condition defines the trigger related conditions
  76357. */
  76358. constructor(triggerOptions?: any, condition?: Condition);
  76359. /**
  76360. * Execute the action and do nothing.
  76361. */
  76362. execute(): void;
  76363. /**
  76364. * Serializes the actions and its related information.
  76365. * @param parent defines the object to serialize in
  76366. * @returns the serialized object
  76367. */
  76368. serialize(parent: any): any;
  76369. }
  76370. /**
  76371. * This defines an action responsible to trigger several actions once triggered.
  76372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76373. */
  76374. export class CombineAction extends Action {
  76375. /**
  76376. * The list of aggregated animations to run.
  76377. */
  76378. children: Action[];
  76379. /**
  76380. * Instantiate the action
  76381. * @param triggerOptions defines the trigger options
  76382. * @param children defines the list of aggregated animations to run
  76383. * @param condition defines the trigger related conditions
  76384. */
  76385. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76386. /** @hidden */
  76387. _prepare(): void;
  76388. /**
  76389. * Execute the action and executes all the aggregated actions.
  76390. */
  76391. execute(evt: ActionEvent): void;
  76392. /**
  76393. * Serializes the actions and its related information.
  76394. * @param parent defines the object to serialize in
  76395. * @returns the serialized object
  76396. */
  76397. serialize(parent: any): any;
  76398. }
  76399. /**
  76400. * This defines an action responsible to run code (external event) once triggered.
  76401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76402. */
  76403. export class ExecuteCodeAction extends Action {
  76404. /**
  76405. * The callback function to run.
  76406. */
  76407. func: (evt: ActionEvent) => void;
  76408. /**
  76409. * Instantiate the action
  76410. * @param triggerOptions defines the trigger options
  76411. * @param func defines the callback function to run
  76412. * @param condition defines the trigger related conditions
  76413. */
  76414. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76415. /**
  76416. * Execute the action and run the attached code.
  76417. */
  76418. execute(evt: ActionEvent): void;
  76419. }
  76420. /**
  76421. * This defines an action responsible to set the parent property of the target once triggered.
  76422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76423. */
  76424. export class SetParentAction extends Action {
  76425. private _parent;
  76426. private _target;
  76427. /**
  76428. * Instantiate the action
  76429. * @param triggerOptions defines the trigger options
  76430. * @param target defines the target containing the parent property
  76431. * @param parent defines from where the animation should start (animation frame)
  76432. * @param condition defines the trigger related conditions
  76433. */
  76434. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76435. /** @hidden */
  76436. _prepare(): void;
  76437. /**
  76438. * Execute the action and set the parent property.
  76439. */
  76440. execute(): void;
  76441. /**
  76442. * Serializes the actions and its related information.
  76443. * @param parent defines the object to serialize in
  76444. * @returns the serialized object
  76445. */
  76446. serialize(parent: any): any;
  76447. }
  76448. }
  76449. declare module BABYLON {
  76450. /**
  76451. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76452. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76454. */
  76455. export class ActionManager extends AbstractActionManager {
  76456. /**
  76457. * Nothing
  76458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76459. */
  76460. static readonly NothingTrigger: number;
  76461. /**
  76462. * On pick
  76463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76464. */
  76465. static readonly OnPickTrigger: number;
  76466. /**
  76467. * On left pick
  76468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76469. */
  76470. static readonly OnLeftPickTrigger: number;
  76471. /**
  76472. * On right pick
  76473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76474. */
  76475. static readonly OnRightPickTrigger: number;
  76476. /**
  76477. * On center pick
  76478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76479. */
  76480. static readonly OnCenterPickTrigger: number;
  76481. /**
  76482. * On pick down
  76483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76484. */
  76485. static readonly OnPickDownTrigger: number;
  76486. /**
  76487. * On double pick
  76488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76489. */
  76490. static readonly OnDoublePickTrigger: number;
  76491. /**
  76492. * On pick up
  76493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76494. */
  76495. static readonly OnPickUpTrigger: number;
  76496. /**
  76497. * On pick out.
  76498. * This trigger will only be raised if you also declared a OnPickDown
  76499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76500. */
  76501. static readonly OnPickOutTrigger: number;
  76502. /**
  76503. * On long press
  76504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76505. */
  76506. static readonly OnLongPressTrigger: number;
  76507. /**
  76508. * On pointer over
  76509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76510. */
  76511. static readonly OnPointerOverTrigger: number;
  76512. /**
  76513. * On pointer out
  76514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76515. */
  76516. static readonly OnPointerOutTrigger: number;
  76517. /**
  76518. * On every frame
  76519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76520. */
  76521. static readonly OnEveryFrameTrigger: number;
  76522. /**
  76523. * On intersection enter
  76524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76525. */
  76526. static readonly OnIntersectionEnterTrigger: number;
  76527. /**
  76528. * On intersection exit
  76529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76530. */
  76531. static readonly OnIntersectionExitTrigger: number;
  76532. /**
  76533. * On key down
  76534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76535. */
  76536. static readonly OnKeyDownTrigger: number;
  76537. /**
  76538. * On key up
  76539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76540. */
  76541. static readonly OnKeyUpTrigger: number;
  76542. private _scene;
  76543. /**
  76544. * Creates a new action manager
  76545. * @param scene defines the hosting scene
  76546. */
  76547. constructor(scene: Scene);
  76548. /**
  76549. * Releases all associated resources
  76550. */
  76551. dispose(): void;
  76552. /**
  76553. * Gets hosting scene
  76554. * @returns the hosting scene
  76555. */
  76556. getScene(): Scene;
  76557. /**
  76558. * Does this action manager handles actions of any of the given triggers
  76559. * @param triggers defines the triggers to be tested
  76560. * @return a boolean indicating whether one (or more) of the triggers is handled
  76561. */
  76562. hasSpecificTriggers(triggers: number[]): boolean;
  76563. /**
  76564. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76565. * speed.
  76566. * @param triggerA defines the trigger to be tested
  76567. * @param triggerB defines the trigger to be tested
  76568. * @return a boolean indicating whether one (or more) of the triggers is handled
  76569. */
  76570. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76571. /**
  76572. * Does this action manager handles actions of a given trigger
  76573. * @param trigger defines the trigger to be tested
  76574. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76575. * @return whether the trigger is handled
  76576. */
  76577. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76578. /**
  76579. * Does this action manager has pointer triggers
  76580. */
  76581. readonly hasPointerTriggers: boolean;
  76582. /**
  76583. * Does this action manager has pick triggers
  76584. */
  76585. readonly hasPickTriggers: boolean;
  76586. /**
  76587. * Registers an action to this action manager
  76588. * @param action defines the action to be registered
  76589. * @return the action amended (prepared) after registration
  76590. */
  76591. registerAction(action: IAction): Nullable<IAction>;
  76592. /**
  76593. * Unregisters an action to this action manager
  76594. * @param action defines the action to be unregistered
  76595. * @return a boolean indicating whether the action has been unregistered
  76596. */
  76597. unregisterAction(action: IAction): Boolean;
  76598. /**
  76599. * Process a specific trigger
  76600. * @param trigger defines the trigger to process
  76601. * @param evt defines the event details to be processed
  76602. */
  76603. processTrigger(trigger: number, evt?: IActionEvent): void;
  76604. /** @hidden */
  76605. _getEffectiveTarget(target: any, propertyPath: string): any;
  76606. /** @hidden */
  76607. _getProperty(propertyPath: string): string;
  76608. /**
  76609. * Serialize this manager to a JSON object
  76610. * @param name defines the property name to store this manager
  76611. * @returns a JSON representation of this manager
  76612. */
  76613. serialize(name: string): any;
  76614. /**
  76615. * Creates a new ActionManager from a JSON data
  76616. * @param parsedActions defines the JSON data to read from
  76617. * @param object defines the hosting mesh
  76618. * @param scene defines the hosting scene
  76619. */
  76620. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  76621. /**
  76622. * Get a trigger name by index
  76623. * @param trigger defines the trigger index
  76624. * @returns a trigger name
  76625. */
  76626. static GetTriggerName(trigger: number): string;
  76627. }
  76628. }
  76629. declare module BABYLON {
  76630. /**
  76631. * Class representing a ray with position and direction
  76632. */
  76633. export class Ray {
  76634. /** origin point */
  76635. origin: Vector3;
  76636. /** direction */
  76637. direction: Vector3;
  76638. /** length of the ray */
  76639. length: number;
  76640. private static readonly TmpVector3;
  76641. private _tmpRay;
  76642. /**
  76643. * Creates a new ray
  76644. * @param origin origin point
  76645. * @param direction direction
  76646. * @param length length of the ray
  76647. */
  76648. constructor(
  76649. /** origin point */
  76650. origin: Vector3,
  76651. /** direction */
  76652. direction: Vector3,
  76653. /** length of the ray */
  76654. length?: number);
  76655. /**
  76656. * Checks if the ray intersects a box
  76657. * @param minimum bound of the box
  76658. * @param maximum bound of the box
  76659. * @param intersectionTreshold extra extend to be added to the box in all direction
  76660. * @returns if the box was hit
  76661. */
  76662. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  76663. /**
  76664. * Checks if the ray intersects a box
  76665. * @param box the bounding box to check
  76666. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  76667. * @returns if the box was hit
  76668. */
  76669. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  76670. /**
  76671. * If the ray hits a sphere
  76672. * @param sphere the bounding sphere to check
  76673. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  76674. * @returns true if it hits the sphere
  76675. */
  76676. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  76677. /**
  76678. * If the ray hits a triange
  76679. * @param vertex0 triangle vertex
  76680. * @param vertex1 triangle vertex
  76681. * @param vertex2 triangle vertex
  76682. * @returns intersection information if hit
  76683. */
  76684. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  76685. /**
  76686. * Checks if ray intersects a plane
  76687. * @param plane the plane to check
  76688. * @returns the distance away it was hit
  76689. */
  76690. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  76691. /**
  76692. * Calculate the intercept of a ray on a given axis
  76693. * @param axis to check 'x' | 'y' | 'z'
  76694. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  76695. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  76696. */
  76697. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  76698. /**
  76699. * Checks if ray intersects a mesh
  76700. * @param mesh the mesh to check
  76701. * @param fastCheck if only the bounding box should checked
  76702. * @returns picking info of the intersecton
  76703. */
  76704. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  76705. /**
  76706. * Checks if ray intersects a mesh
  76707. * @param meshes the meshes to check
  76708. * @param fastCheck if only the bounding box should checked
  76709. * @param results array to store result in
  76710. * @returns Array of picking infos
  76711. */
  76712. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  76713. private _comparePickingInfo;
  76714. private static smallnum;
  76715. private static rayl;
  76716. /**
  76717. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  76718. * @param sega the first point of the segment to test the intersection against
  76719. * @param segb the second point of the segment to test the intersection against
  76720. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  76721. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  76722. */
  76723. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  76724. /**
  76725. * Update the ray from viewport position
  76726. * @param x position
  76727. * @param y y position
  76728. * @param viewportWidth viewport width
  76729. * @param viewportHeight viewport height
  76730. * @param world world matrix
  76731. * @param view view matrix
  76732. * @param projection projection matrix
  76733. * @returns this ray updated
  76734. */
  76735. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76736. /**
  76737. * Creates a ray with origin and direction of 0,0,0
  76738. * @returns the new ray
  76739. */
  76740. static Zero(): Ray;
  76741. /**
  76742. * Creates a new ray from screen space and viewport
  76743. * @param x position
  76744. * @param y y position
  76745. * @param viewportWidth viewport width
  76746. * @param viewportHeight viewport height
  76747. * @param world world matrix
  76748. * @param view view matrix
  76749. * @param projection projection matrix
  76750. * @returns new ray
  76751. */
  76752. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76753. /**
  76754. * 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
  76755. * transformed to the given world matrix.
  76756. * @param origin The origin point
  76757. * @param end The end point
  76758. * @param world a matrix to transform the ray to. Default is the identity matrix.
  76759. * @returns the new ray
  76760. */
  76761. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  76762. /**
  76763. * Transforms a ray by a matrix
  76764. * @param ray ray to transform
  76765. * @param matrix matrix to apply
  76766. * @returns the resulting new ray
  76767. */
  76768. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  76769. /**
  76770. * Transforms a ray by a matrix
  76771. * @param ray ray to transform
  76772. * @param matrix matrix to apply
  76773. * @param result ray to store result in
  76774. */
  76775. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  76776. /**
  76777. * Unproject a ray from screen space to object space
  76778. * @param sourceX defines the screen space x coordinate to use
  76779. * @param sourceY defines the screen space y coordinate to use
  76780. * @param viewportWidth defines the current width of the viewport
  76781. * @param viewportHeight defines the current height of the viewport
  76782. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76783. * @param view defines the view matrix to use
  76784. * @param projection defines the projection matrix to use
  76785. */
  76786. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  76787. }
  76788. /**
  76789. * Type used to define predicate used to select faces when a mesh intersection is detected
  76790. */
  76791. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  76792. interface Scene {
  76793. /** @hidden */
  76794. _tempPickingRay: Nullable<Ray>;
  76795. /** @hidden */
  76796. _cachedRayForTransform: Ray;
  76797. /** @hidden */
  76798. _pickWithRayInverseMatrix: Matrix;
  76799. /** @hidden */
  76800. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  76801. /** @hidden */
  76802. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  76803. }
  76804. }
  76805. declare module BABYLON {
  76806. /**
  76807. * Groups all the scene component constants in one place to ease maintenance.
  76808. * @hidden
  76809. */
  76810. export class SceneComponentConstants {
  76811. static readonly NAME_EFFECTLAYER: string;
  76812. static readonly NAME_LAYER: string;
  76813. static readonly NAME_LENSFLARESYSTEM: string;
  76814. static readonly NAME_BOUNDINGBOXRENDERER: string;
  76815. static readonly NAME_PARTICLESYSTEM: string;
  76816. static readonly NAME_GAMEPAD: string;
  76817. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  76818. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  76819. static readonly NAME_DEPTHRENDERER: string;
  76820. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  76821. static readonly NAME_SPRITE: string;
  76822. static readonly NAME_OUTLINERENDERER: string;
  76823. static readonly NAME_PROCEDURALTEXTURE: string;
  76824. static readonly NAME_SHADOWGENERATOR: string;
  76825. static readonly NAME_OCTREE: string;
  76826. static readonly NAME_PHYSICSENGINE: string;
  76827. static readonly NAME_AUDIO: string;
  76828. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  76829. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76830. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  76831. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76832. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  76833. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  76834. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  76835. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  76836. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  76837. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  76838. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  76839. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  76840. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  76841. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  76842. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  76843. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  76844. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  76845. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  76846. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  76847. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  76848. static readonly STEP_AFTERRENDER_AUDIO: number;
  76849. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  76850. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  76851. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  76852. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  76853. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  76854. static readonly STEP_POINTERMOVE_SPRITE: number;
  76855. static readonly STEP_POINTERDOWN_SPRITE: number;
  76856. static readonly STEP_POINTERUP_SPRITE: number;
  76857. }
  76858. /**
  76859. * This represents a scene component.
  76860. *
  76861. * This is used to decouple the dependency the scene is having on the different workloads like
  76862. * layers, post processes...
  76863. */
  76864. export interface ISceneComponent {
  76865. /**
  76866. * The name of the component. Each component must have a unique name.
  76867. */
  76868. name: string;
  76869. /**
  76870. * The scene the component belongs to.
  76871. */
  76872. scene: Scene;
  76873. /**
  76874. * Register the component to one instance of a scene.
  76875. */
  76876. register(): void;
  76877. /**
  76878. * Rebuilds the elements related to this component in case of
  76879. * context lost for instance.
  76880. */
  76881. rebuild(): void;
  76882. /**
  76883. * Disposes the component and the associated ressources.
  76884. */
  76885. dispose(): void;
  76886. }
  76887. /**
  76888. * This represents a SERIALIZABLE scene component.
  76889. *
  76890. * This extends Scene Component to add Serialization methods on top.
  76891. */
  76892. export interface ISceneSerializableComponent extends ISceneComponent {
  76893. /**
  76894. * Adds all the elements from the container to the scene
  76895. * @param container the container holding the elements
  76896. */
  76897. addFromContainer(container: AbstractScene): void;
  76898. /**
  76899. * Removes all the elements in the container from the scene
  76900. * @param container contains the elements to remove
  76901. * @param dispose if the removed element should be disposed (default: false)
  76902. */
  76903. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76904. /**
  76905. * Serializes the component data to the specified json object
  76906. * @param serializationObject The object to serialize to
  76907. */
  76908. serialize(serializationObject: any): void;
  76909. }
  76910. /**
  76911. * Strong typing of a Mesh related stage step action
  76912. */
  76913. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  76914. /**
  76915. * Strong typing of a Evaluate Sub Mesh related stage step action
  76916. */
  76917. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  76918. /**
  76919. * Strong typing of a Active Mesh related stage step action
  76920. */
  76921. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  76922. /**
  76923. * Strong typing of a Camera related stage step action
  76924. */
  76925. export type CameraStageAction = (camera: Camera) => void;
  76926. /**
  76927. * Strong typing of a Camera Frame buffer related stage step action
  76928. */
  76929. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  76930. /**
  76931. * Strong typing of a Render Target related stage step action
  76932. */
  76933. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  76934. /**
  76935. * Strong typing of a RenderingGroup related stage step action
  76936. */
  76937. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  76938. /**
  76939. * Strong typing of a Mesh Render related stage step action
  76940. */
  76941. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  76942. /**
  76943. * Strong typing of a simple stage step action
  76944. */
  76945. export type SimpleStageAction = () => void;
  76946. /**
  76947. * Strong typing of a render target action.
  76948. */
  76949. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  76950. /**
  76951. * Strong typing of a pointer move action.
  76952. */
  76953. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  76954. /**
  76955. * Strong typing of a pointer up/down action.
  76956. */
  76957. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  76958. /**
  76959. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  76960. * @hidden
  76961. */
  76962. export class Stage<T extends Function> extends Array<{
  76963. index: number;
  76964. component: ISceneComponent;
  76965. action: T;
  76966. }> {
  76967. /**
  76968. * Hide ctor from the rest of the world.
  76969. * @param items The items to add.
  76970. */
  76971. private constructor();
  76972. /**
  76973. * Creates a new Stage.
  76974. * @returns A new instance of a Stage
  76975. */
  76976. static Create<T extends Function>(): Stage<T>;
  76977. /**
  76978. * Registers a step in an ordered way in the targeted stage.
  76979. * @param index Defines the position to register the step in
  76980. * @param component Defines the component attached to the step
  76981. * @param action Defines the action to launch during the step
  76982. */
  76983. registerStep(index: number, component: ISceneComponent, action: T): void;
  76984. /**
  76985. * Clears all the steps from the stage.
  76986. */
  76987. clear(): void;
  76988. }
  76989. }
  76990. declare module BABYLON {
  76991. interface Scene {
  76992. /** @hidden */
  76993. _pointerOverSprite: Nullable<Sprite>;
  76994. /** @hidden */
  76995. _pickedDownSprite: Nullable<Sprite>;
  76996. /** @hidden */
  76997. _tempSpritePickingRay: Nullable<Ray>;
  76998. /**
  76999. * All of the sprite managers added to this scene
  77000. * @see http://doc.babylonjs.com/babylon101/sprites
  77001. */
  77002. spriteManagers: Array<ISpriteManager>;
  77003. /**
  77004. * An event triggered when sprites rendering is about to start
  77005. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77006. */
  77007. onBeforeSpritesRenderingObservable: Observable<Scene>;
  77008. /**
  77009. * An event triggered when sprites rendering is done
  77010. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77011. */
  77012. onAfterSpritesRenderingObservable: Observable<Scene>;
  77013. /** @hidden */
  77014. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77015. /** Launch a ray to try to pick a sprite in the scene
  77016. * @param x position on screen
  77017. * @param y position on screen
  77018. * @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
  77019. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77020. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77021. * @returns a PickingInfo
  77022. */
  77023. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77024. /** Use the given ray to pick a sprite in the scene
  77025. * @param ray The ray (in world space) to use to pick meshes
  77026. * @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
  77027. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77028. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77029. * @returns a PickingInfo
  77030. */
  77031. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77032. /** @hidden */
  77033. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77034. /** Launch a ray to try to pick sprites in the scene
  77035. * @param x position on screen
  77036. * @param y position on screen
  77037. * @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
  77038. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77039. * @returns a PickingInfo array
  77040. */
  77041. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77042. /** Use the given ray to pick sprites in the scene
  77043. * @param ray The ray (in world space) to use to pick meshes
  77044. * @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
  77045. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77046. * @returns a PickingInfo array
  77047. */
  77048. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77049. /**
  77050. * Force the sprite under the pointer
  77051. * @param sprite defines the sprite to use
  77052. */
  77053. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  77054. /**
  77055. * Gets the sprite under the pointer
  77056. * @returns a Sprite or null if no sprite is under the pointer
  77057. */
  77058. getPointerOverSprite(): Nullable<Sprite>;
  77059. }
  77060. /**
  77061. * Defines the sprite scene component responsible to manage sprites
  77062. * in a given scene.
  77063. */
  77064. export class SpriteSceneComponent implements ISceneComponent {
  77065. /**
  77066. * The component name helpfull to identify the component in the list of scene components.
  77067. */
  77068. readonly name: string;
  77069. /**
  77070. * The scene the component belongs to.
  77071. */
  77072. scene: Scene;
  77073. /** @hidden */
  77074. private _spritePredicate;
  77075. /**
  77076. * Creates a new instance of the component for the given scene
  77077. * @param scene Defines the scene to register the component in
  77078. */
  77079. constructor(scene: Scene);
  77080. /**
  77081. * Registers the component in a given scene
  77082. */
  77083. register(): void;
  77084. /**
  77085. * Rebuilds the elements related to this component in case of
  77086. * context lost for instance.
  77087. */
  77088. rebuild(): void;
  77089. /**
  77090. * Disposes the component and the associated ressources.
  77091. */
  77092. dispose(): void;
  77093. private _pickSpriteButKeepRay;
  77094. private _pointerMove;
  77095. private _pointerDown;
  77096. private _pointerUp;
  77097. }
  77098. }
  77099. declare module BABYLON {
  77100. /** @hidden */
  77101. export var fogFragmentDeclaration: {
  77102. name: string;
  77103. shader: string;
  77104. };
  77105. }
  77106. declare module BABYLON {
  77107. /** @hidden */
  77108. export var fogFragment: {
  77109. name: string;
  77110. shader: string;
  77111. };
  77112. }
  77113. declare module BABYLON {
  77114. /** @hidden */
  77115. export var spritesPixelShader: {
  77116. name: string;
  77117. shader: string;
  77118. };
  77119. }
  77120. declare module BABYLON {
  77121. /** @hidden */
  77122. export var fogVertexDeclaration: {
  77123. name: string;
  77124. shader: string;
  77125. };
  77126. }
  77127. declare module BABYLON {
  77128. /** @hidden */
  77129. export var spritesVertexShader: {
  77130. name: string;
  77131. shader: string;
  77132. };
  77133. }
  77134. declare module BABYLON {
  77135. /**
  77136. * Defines the minimum interface to fullfil in order to be a sprite manager.
  77137. */
  77138. export interface ISpriteManager extends IDisposable {
  77139. /**
  77140. * Restricts the camera to viewing objects with the same layerMask.
  77141. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  77142. */
  77143. layerMask: number;
  77144. /**
  77145. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  77146. */
  77147. isPickable: boolean;
  77148. /**
  77149. * Specifies the rendering group id for this mesh (0 by default)
  77150. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  77151. */
  77152. renderingGroupId: number;
  77153. /**
  77154. * Defines the list of sprites managed by the manager.
  77155. */
  77156. sprites: Array<Sprite>;
  77157. /**
  77158. * Tests the intersection of a sprite with a specific ray.
  77159. * @param ray The ray we are sending to test the collision
  77160. * @param camera The camera space we are sending rays in
  77161. * @param predicate A predicate allowing excluding sprites from the list of object to test
  77162. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  77163. * @returns picking info or null.
  77164. */
  77165. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77166. /**
  77167. * Intersects the sprites with a ray
  77168. * @param ray defines the ray to intersect with
  77169. * @param camera defines the current active camera
  77170. * @param predicate defines a predicate used to select candidate sprites
  77171. * @returns null if no hit or a PickingInfo array
  77172. */
  77173. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77174. /**
  77175. * Renders the list of sprites on screen.
  77176. */
  77177. render(): void;
  77178. }
  77179. /**
  77180. * Class used to manage multiple sprites on the same spritesheet
  77181. * @see http://doc.babylonjs.com/babylon101/sprites
  77182. */
  77183. export class SpriteManager implements ISpriteManager {
  77184. /** defines the manager's name */
  77185. name: string;
  77186. /** Gets the list of sprites */
  77187. sprites: Sprite[];
  77188. /** Gets or sets the rendering group id (0 by default) */
  77189. renderingGroupId: number;
  77190. /** Gets or sets camera layer mask */
  77191. layerMask: number;
  77192. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  77193. fogEnabled: boolean;
  77194. /** Gets or sets a boolean indicating if the sprites are pickable */
  77195. isPickable: boolean;
  77196. /** Defines the default width of a cell in the spritesheet */
  77197. cellWidth: number;
  77198. /** Defines the default height of a cell in the spritesheet */
  77199. cellHeight: number;
  77200. /** Associative array from JSON sprite data file */
  77201. private _cellData;
  77202. /** Array of sprite names from JSON sprite data file */
  77203. private _spriteMap;
  77204. /** True when packed cell data from JSON file is ready*/
  77205. private _packedAndReady;
  77206. /**
  77207. * An event triggered when the manager is disposed.
  77208. */
  77209. onDisposeObservable: Observable<SpriteManager>;
  77210. private _onDisposeObserver;
  77211. /**
  77212. * Callback called when the manager is disposed
  77213. */
  77214. onDispose: () => void;
  77215. private _capacity;
  77216. private _fromPacked;
  77217. private _spriteTexture;
  77218. private _epsilon;
  77219. private _scene;
  77220. private _vertexData;
  77221. private _buffer;
  77222. private _vertexBuffers;
  77223. private _indexBuffer;
  77224. private _effectBase;
  77225. private _effectFog;
  77226. /**
  77227. * Gets or sets the spritesheet texture
  77228. */
  77229. texture: Texture;
  77230. /**
  77231. * Creates a new sprite manager
  77232. * @param name defines the manager's name
  77233. * @param imgUrl defines the sprite sheet url
  77234. * @param capacity defines the maximum allowed number of sprites
  77235. * @param cellSize defines the size of a sprite cell
  77236. * @param scene defines the hosting scene
  77237. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77238. * @param samplingMode defines the smapling mode to use with spritesheet
  77239. * @param fromPacked set to false; do not alter
  77240. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  77241. */
  77242. constructor(
  77243. /** defines the manager's name */
  77244. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  77245. private _makePacked;
  77246. private _appendSpriteVertex;
  77247. /**
  77248. * Intersects the sprites with a ray
  77249. * @param ray defines the ray to intersect with
  77250. * @param camera defines the current active camera
  77251. * @param predicate defines a predicate used to select candidate sprites
  77252. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  77253. * @returns null if no hit or a PickingInfo
  77254. */
  77255. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77256. /**
  77257. * Intersects the sprites with a ray
  77258. * @param ray defines the ray to intersect with
  77259. * @param camera defines the current active camera
  77260. * @param predicate defines a predicate used to select candidate sprites
  77261. * @returns null if no hit or a PickingInfo array
  77262. */
  77263. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77264. /**
  77265. * Render all child sprites
  77266. */
  77267. render(): void;
  77268. /**
  77269. * Release associated resources
  77270. */
  77271. dispose(): void;
  77272. }
  77273. }
  77274. declare module BABYLON {
  77275. /**
  77276. * Class used to represent a sprite
  77277. * @see http://doc.babylonjs.com/babylon101/sprites
  77278. */
  77279. export class Sprite {
  77280. /** defines the name */
  77281. name: string;
  77282. /** Gets or sets the current world position */
  77283. position: Vector3;
  77284. /** Gets or sets the main color */
  77285. color: Color4;
  77286. /** Gets or sets the width */
  77287. width: number;
  77288. /** Gets or sets the height */
  77289. height: number;
  77290. /** Gets or sets rotation angle */
  77291. angle: number;
  77292. /** Gets or sets the cell index in the sprite sheet */
  77293. cellIndex: number;
  77294. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  77295. cellRef: string;
  77296. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  77297. invertU: number;
  77298. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  77299. invertV: number;
  77300. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  77301. disposeWhenFinishedAnimating: boolean;
  77302. /** Gets the list of attached animations */
  77303. animations: Animation[];
  77304. /** Gets or sets a boolean indicating if the sprite can be picked */
  77305. isPickable: boolean;
  77306. /**
  77307. * Gets or sets the associated action manager
  77308. */
  77309. actionManager: Nullable<ActionManager>;
  77310. private _animationStarted;
  77311. private _loopAnimation;
  77312. private _fromIndex;
  77313. private _toIndex;
  77314. private _delay;
  77315. private _direction;
  77316. private _manager;
  77317. private _time;
  77318. private _onAnimationEnd;
  77319. /**
  77320. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  77321. */
  77322. isVisible: boolean;
  77323. /**
  77324. * Gets or sets the sprite size
  77325. */
  77326. size: number;
  77327. /**
  77328. * Creates a new Sprite
  77329. * @param name defines the name
  77330. * @param manager defines the manager
  77331. */
  77332. constructor(
  77333. /** defines the name */
  77334. name: string, manager: ISpriteManager);
  77335. /**
  77336. * Starts an animation
  77337. * @param from defines the initial key
  77338. * @param to defines the end key
  77339. * @param loop defines if the animation must loop
  77340. * @param delay defines the start delay (in ms)
  77341. * @param onAnimationEnd defines a callback to call when animation ends
  77342. */
  77343. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  77344. /** Stops current animation (if any) */
  77345. stopAnimation(): void;
  77346. /** @hidden */
  77347. _animate(deltaTime: number): void;
  77348. /** Release associated resources */
  77349. dispose(): void;
  77350. }
  77351. }
  77352. declare module BABYLON {
  77353. /**
  77354. * Information about the result of picking within a scene
  77355. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  77356. */
  77357. export class PickingInfo {
  77358. /** @hidden */
  77359. _pickingUnavailable: boolean;
  77360. /**
  77361. * If the pick collided with an object
  77362. */
  77363. hit: boolean;
  77364. /**
  77365. * Distance away where the pick collided
  77366. */
  77367. distance: number;
  77368. /**
  77369. * The location of pick collision
  77370. */
  77371. pickedPoint: Nullable<Vector3>;
  77372. /**
  77373. * The mesh corresponding the the pick collision
  77374. */
  77375. pickedMesh: Nullable<AbstractMesh>;
  77376. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  77377. bu: number;
  77378. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  77379. bv: number;
  77380. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  77381. faceId: number;
  77382. /** Id of the the submesh that was picked */
  77383. subMeshId: number;
  77384. /** If a sprite was picked, this will be the sprite the pick collided with */
  77385. pickedSprite: Nullable<Sprite>;
  77386. /**
  77387. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  77388. */
  77389. originMesh: Nullable<AbstractMesh>;
  77390. /**
  77391. * The ray that was used to perform the picking.
  77392. */
  77393. ray: Nullable<Ray>;
  77394. /**
  77395. * Gets the normal correspodning to the face the pick collided with
  77396. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  77397. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  77398. * @returns The normal correspodning to the face the pick collided with
  77399. */
  77400. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  77401. /**
  77402. * Gets the texture coordinates of where the pick occured
  77403. * @returns the vector containing the coordnates of the texture
  77404. */
  77405. getTextureCoordinates(): Nullable<Vector2>;
  77406. }
  77407. }
  77408. declare module BABYLON {
  77409. /**
  77410. * Gather the list of pointer event types as constants.
  77411. */
  77412. export class PointerEventTypes {
  77413. /**
  77414. * 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.
  77415. */
  77416. static readonly POINTERDOWN: number;
  77417. /**
  77418. * The pointerup event is fired when a pointer is no longer active.
  77419. */
  77420. static readonly POINTERUP: number;
  77421. /**
  77422. * The pointermove event is fired when a pointer changes coordinates.
  77423. */
  77424. static readonly POINTERMOVE: number;
  77425. /**
  77426. * The pointerwheel event is fired when a mouse wheel has been rotated.
  77427. */
  77428. static readonly POINTERWHEEL: number;
  77429. /**
  77430. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  77431. */
  77432. static readonly POINTERPICK: number;
  77433. /**
  77434. * The pointertap event is fired when a the object has been touched and released without drag.
  77435. */
  77436. static readonly POINTERTAP: number;
  77437. /**
  77438. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  77439. */
  77440. static readonly POINTERDOUBLETAP: number;
  77441. }
  77442. /**
  77443. * Base class of pointer info types.
  77444. */
  77445. export class PointerInfoBase {
  77446. /**
  77447. * Defines the type of event (PointerEventTypes)
  77448. */
  77449. type: number;
  77450. /**
  77451. * Defines the related dom event
  77452. */
  77453. event: PointerEvent | MouseWheelEvent;
  77454. /**
  77455. * Instantiates the base class of pointers info.
  77456. * @param type Defines the type of event (PointerEventTypes)
  77457. * @param event Defines the related dom event
  77458. */
  77459. constructor(
  77460. /**
  77461. * Defines the type of event (PointerEventTypes)
  77462. */
  77463. type: number,
  77464. /**
  77465. * Defines the related dom event
  77466. */
  77467. event: PointerEvent | MouseWheelEvent);
  77468. }
  77469. /**
  77470. * This class is used to store pointer related info for the onPrePointerObservable event.
  77471. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  77472. */
  77473. export class PointerInfoPre extends PointerInfoBase {
  77474. /**
  77475. * Ray from a pointer if availible (eg. 6dof controller)
  77476. */
  77477. ray: Nullable<Ray>;
  77478. /**
  77479. * Defines the local position of the pointer on the canvas.
  77480. */
  77481. localPosition: Vector2;
  77482. /**
  77483. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  77484. */
  77485. skipOnPointerObservable: boolean;
  77486. /**
  77487. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  77488. * @param type Defines the type of event (PointerEventTypes)
  77489. * @param event Defines the related dom event
  77490. * @param localX Defines the local x coordinates of the pointer when the event occured
  77491. * @param localY Defines the local y coordinates of the pointer when the event occured
  77492. */
  77493. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  77494. }
  77495. /**
  77496. * This type contains all the data related to a pointer event in Babylon.js.
  77497. * 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.
  77498. */
  77499. export class PointerInfo extends PointerInfoBase {
  77500. /**
  77501. * Defines the picking info associated to the info (if any)\
  77502. */
  77503. pickInfo: Nullable<PickingInfo>;
  77504. /**
  77505. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  77506. * @param type Defines the type of event (PointerEventTypes)
  77507. * @param event Defines the related dom event
  77508. * @param pickInfo Defines the picking info associated to the info (if any)\
  77509. */
  77510. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  77511. /**
  77512. * Defines the picking info associated to the info (if any)\
  77513. */
  77514. pickInfo: Nullable<PickingInfo>);
  77515. }
  77516. /**
  77517. * Data relating to a touch event on the screen.
  77518. */
  77519. export interface PointerTouch {
  77520. /**
  77521. * X coordinate of touch.
  77522. */
  77523. x: number;
  77524. /**
  77525. * Y coordinate of touch.
  77526. */
  77527. y: number;
  77528. /**
  77529. * Id of touch. Unique for each finger.
  77530. */
  77531. pointerId: number;
  77532. /**
  77533. * Event type passed from DOM.
  77534. */
  77535. type: any;
  77536. }
  77537. }
  77538. declare module BABYLON {
  77539. /**
  77540. * Manage the mouse inputs to control the movement of a free camera.
  77541. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77542. */
  77543. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  77544. /**
  77545. * Define if touch is enabled in the mouse input
  77546. */
  77547. touchEnabled: boolean;
  77548. /**
  77549. * Defines the camera the input is attached to.
  77550. */
  77551. camera: FreeCamera;
  77552. /**
  77553. * Defines the buttons associated with the input to handle camera move.
  77554. */
  77555. buttons: number[];
  77556. /**
  77557. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  77558. */
  77559. angularSensibility: number;
  77560. private _pointerInput;
  77561. private _onMouseMove;
  77562. private _observer;
  77563. private previousPosition;
  77564. /**
  77565. * Observable for when a pointer move event occurs containing the move offset
  77566. */
  77567. onPointerMovedObservable: Observable<{
  77568. offsetX: number;
  77569. offsetY: number;
  77570. }>;
  77571. /**
  77572. * @hidden
  77573. * If the camera should be rotated automatically based on pointer movement
  77574. */
  77575. _allowCameraRotation: boolean;
  77576. /**
  77577. * Manage the mouse inputs to control the movement of a free camera.
  77578. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77579. * @param touchEnabled Defines if touch is enabled or not
  77580. */
  77581. constructor(
  77582. /**
  77583. * Define if touch is enabled in the mouse input
  77584. */
  77585. touchEnabled?: boolean);
  77586. /**
  77587. * Attach the input controls to a specific dom element to get the input from.
  77588. * @param element Defines the element the controls should be listened from
  77589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77590. */
  77591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77592. /**
  77593. * Called on JS contextmenu event.
  77594. * Override this method to provide functionality.
  77595. */
  77596. protected onContextMenu(evt: PointerEvent): void;
  77597. /**
  77598. * Detach the current controls from the specified dom element.
  77599. * @param element Defines the element to stop listening the inputs from
  77600. */
  77601. detachControl(element: Nullable<HTMLElement>): void;
  77602. /**
  77603. * Gets the class name of the current intput.
  77604. * @returns the class name
  77605. */
  77606. getClassName(): string;
  77607. /**
  77608. * Get the friendly name associated with the input class.
  77609. * @returns the input friendly name
  77610. */
  77611. getSimpleName(): string;
  77612. }
  77613. }
  77614. declare module BABYLON {
  77615. /**
  77616. * Manage the touch inputs to control the movement of a free camera.
  77617. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77618. */
  77619. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  77620. /**
  77621. * Defines the camera the input is attached to.
  77622. */
  77623. camera: FreeCamera;
  77624. /**
  77625. * Defines the touch sensibility for rotation.
  77626. * The higher the faster.
  77627. */
  77628. touchAngularSensibility: number;
  77629. /**
  77630. * Defines the touch sensibility for move.
  77631. * The higher the faster.
  77632. */
  77633. touchMoveSensibility: number;
  77634. private _offsetX;
  77635. private _offsetY;
  77636. private _pointerPressed;
  77637. private _pointerInput;
  77638. private _observer;
  77639. private _onLostFocus;
  77640. /**
  77641. * Attach the input controls to a specific dom element to get the input from.
  77642. * @param element Defines the element the controls should be listened from
  77643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77644. */
  77645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77646. /**
  77647. * Detach the current controls from the specified dom element.
  77648. * @param element Defines the element to stop listening the inputs from
  77649. */
  77650. detachControl(element: Nullable<HTMLElement>): void;
  77651. /**
  77652. * Update the current camera state depending on the inputs that have been used this frame.
  77653. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77654. */
  77655. checkInputs(): void;
  77656. /**
  77657. * Gets the class name of the current intput.
  77658. * @returns the class name
  77659. */
  77660. getClassName(): string;
  77661. /**
  77662. * Get the friendly name associated with the input class.
  77663. * @returns the input friendly name
  77664. */
  77665. getSimpleName(): string;
  77666. }
  77667. }
  77668. declare module BABYLON {
  77669. /**
  77670. * Default Inputs manager for the FreeCamera.
  77671. * It groups all the default supported inputs for ease of use.
  77672. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77673. */
  77674. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  77675. /**
  77676. * @hidden
  77677. */
  77678. _mouseInput: Nullable<FreeCameraMouseInput>;
  77679. /**
  77680. * Instantiates a new FreeCameraInputsManager.
  77681. * @param camera Defines the camera the inputs belong to
  77682. */
  77683. constructor(camera: FreeCamera);
  77684. /**
  77685. * Add keyboard input support to the input manager.
  77686. * @returns the current input manager
  77687. */
  77688. addKeyboard(): FreeCameraInputsManager;
  77689. /**
  77690. * Add mouse input support to the input manager.
  77691. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  77692. * @returns the current input manager
  77693. */
  77694. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  77695. /**
  77696. * Removes the mouse input support from the manager
  77697. * @returns the current input manager
  77698. */
  77699. removeMouse(): FreeCameraInputsManager;
  77700. /**
  77701. * Add touch input support to the input manager.
  77702. * @returns the current input manager
  77703. */
  77704. addTouch(): FreeCameraInputsManager;
  77705. /**
  77706. * Remove all attached input methods from a camera
  77707. */
  77708. clear(): void;
  77709. }
  77710. }
  77711. declare module BABYLON {
  77712. /**
  77713. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77714. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  77715. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77716. */
  77717. export class FreeCamera extends TargetCamera {
  77718. /**
  77719. * Define the collision ellipsoid of the camera.
  77720. * This is helpful to simulate a camera body like the player body around the camera
  77721. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  77722. */
  77723. ellipsoid: Vector3;
  77724. /**
  77725. * Define an offset for the position of the ellipsoid around the camera.
  77726. * This can be helpful to determine the center of the body near the gravity center of the body
  77727. * instead of its head.
  77728. */
  77729. ellipsoidOffset: Vector3;
  77730. /**
  77731. * Enable or disable collisions of the camera with the rest of the scene objects.
  77732. */
  77733. checkCollisions: boolean;
  77734. /**
  77735. * Enable or disable gravity on the camera.
  77736. */
  77737. applyGravity: boolean;
  77738. /**
  77739. * Define the input manager associated to the camera.
  77740. */
  77741. inputs: FreeCameraInputsManager;
  77742. /**
  77743. * Gets the input sensibility for a mouse input. (default is 2000.0)
  77744. * Higher values reduce sensitivity.
  77745. */
  77746. /**
  77747. * Sets the input sensibility for a mouse input. (default is 2000.0)
  77748. * Higher values reduce sensitivity.
  77749. */
  77750. angularSensibility: number;
  77751. /**
  77752. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77753. */
  77754. keysUp: number[];
  77755. /**
  77756. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77757. */
  77758. keysDown: number[];
  77759. /**
  77760. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77761. */
  77762. keysLeft: number[];
  77763. /**
  77764. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77765. */
  77766. keysRight: number[];
  77767. /**
  77768. * Event raised when the camera collide with a mesh in the scene.
  77769. */
  77770. onCollide: (collidedMesh: AbstractMesh) => void;
  77771. private _collider;
  77772. private _needMoveForGravity;
  77773. private _oldPosition;
  77774. private _diffPosition;
  77775. private _newPosition;
  77776. /** @hidden */
  77777. _localDirection: Vector3;
  77778. /** @hidden */
  77779. _transformedDirection: Vector3;
  77780. /**
  77781. * Instantiates a Free Camera.
  77782. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77783. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  77784. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77785. * @param name Define the name of the camera in the scene
  77786. * @param position Define the start position of the camera in the scene
  77787. * @param scene Define the scene the camera belongs to
  77788. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77789. */
  77790. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77791. /**
  77792. * Attached controls to the current camera.
  77793. * @param element Defines the element the controls should be listened from
  77794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77795. */
  77796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77797. /**
  77798. * Detach the current controls from the camera.
  77799. * The camera will stop reacting to inputs.
  77800. * @param element Defines the element to stop listening the inputs from
  77801. */
  77802. detachControl(element: HTMLElement): void;
  77803. private _collisionMask;
  77804. /**
  77805. * Define a collision mask to limit the list of object the camera can collide with
  77806. */
  77807. collisionMask: number;
  77808. /** @hidden */
  77809. _collideWithWorld(displacement: Vector3): void;
  77810. private _onCollisionPositionChange;
  77811. /** @hidden */
  77812. _checkInputs(): void;
  77813. /** @hidden */
  77814. _decideIfNeedsToMove(): boolean;
  77815. /** @hidden */
  77816. _updatePosition(): void;
  77817. /**
  77818. * Destroy the camera and release the current resources hold by it.
  77819. */
  77820. dispose(): void;
  77821. /**
  77822. * Gets the current object class name.
  77823. * @return the class name
  77824. */
  77825. getClassName(): string;
  77826. }
  77827. }
  77828. declare module BABYLON {
  77829. /**
  77830. * Represents a gamepad control stick position
  77831. */
  77832. export class StickValues {
  77833. /**
  77834. * The x component of the control stick
  77835. */
  77836. x: number;
  77837. /**
  77838. * The y component of the control stick
  77839. */
  77840. y: number;
  77841. /**
  77842. * Initializes the gamepad x and y control stick values
  77843. * @param x The x component of the gamepad control stick value
  77844. * @param y The y component of the gamepad control stick value
  77845. */
  77846. constructor(
  77847. /**
  77848. * The x component of the control stick
  77849. */
  77850. x: number,
  77851. /**
  77852. * The y component of the control stick
  77853. */
  77854. y: number);
  77855. }
  77856. /**
  77857. * An interface which manages callbacks for gamepad button changes
  77858. */
  77859. export interface GamepadButtonChanges {
  77860. /**
  77861. * Called when a gamepad has been changed
  77862. */
  77863. changed: boolean;
  77864. /**
  77865. * Called when a gamepad press event has been triggered
  77866. */
  77867. pressChanged: boolean;
  77868. /**
  77869. * Called when a touch event has been triggered
  77870. */
  77871. touchChanged: boolean;
  77872. /**
  77873. * Called when a value has changed
  77874. */
  77875. valueChanged: boolean;
  77876. }
  77877. /**
  77878. * Represents a gamepad
  77879. */
  77880. export class Gamepad {
  77881. /**
  77882. * The id of the gamepad
  77883. */
  77884. id: string;
  77885. /**
  77886. * The index of the gamepad
  77887. */
  77888. index: number;
  77889. /**
  77890. * The browser gamepad
  77891. */
  77892. browserGamepad: any;
  77893. /**
  77894. * Specifies what type of gamepad this represents
  77895. */
  77896. type: number;
  77897. private _leftStick;
  77898. private _rightStick;
  77899. /** @hidden */
  77900. _isConnected: boolean;
  77901. private _leftStickAxisX;
  77902. private _leftStickAxisY;
  77903. private _rightStickAxisX;
  77904. private _rightStickAxisY;
  77905. /**
  77906. * Triggered when the left control stick has been changed
  77907. */
  77908. private _onleftstickchanged;
  77909. /**
  77910. * Triggered when the right control stick has been changed
  77911. */
  77912. private _onrightstickchanged;
  77913. /**
  77914. * Represents a gamepad controller
  77915. */
  77916. static GAMEPAD: number;
  77917. /**
  77918. * Represents a generic controller
  77919. */
  77920. static GENERIC: number;
  77921. /**
  77922. * Represents an XBox controller
  77923. */
  77924. static XBOX: number;
  77925. /**
  77926. * Represents a pose-enabled controller
  77927. */
  77928. static POSE_ENABLED: number;
  77929. /**
  77930. * Represents an Dual Shock controller
  77931. */
  77932. static DUALSHOCK: number;
  77933. /**
  77934. * Specifies whether the left control stick should be Y-inverted
  77935. */
  77936. protected _invertLeftStickY: boolean;
  77937. /**
  77938. * Specifies if the gamepad has been connected
  77939. */
  77940. readonly isConnected: boolean;
  77941. /**
  77942. * Initializes the gamepad
  77943. * @param id The id of the gamepad
  77944. * @param index The index of the gamepad
  77945. * @param browserGamepad The browser gamepad
  77946. * @param leftStickX The x component of the left joystick
  77947. * @param leftStickY The y component of the left joystick
  77948. * @param rightStickX The x component of the right joystick
  77949. * @param rightStickY The y component of the right joystick
  77950. */
  77951. constructor(
  77952. /**
  77953. * The id of the gamepad
  77954. */
  77955. id: string,
  77956. /**
  77957. * The index of the gamepad
  77958. */
  77959. index: number,
  77960. /**
  77961. * The browser gamepad
  77962. */
  77963. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  77964. /**
  77965. * Callback triggered when the left joystick has changed
  77966. * @param callback
  77967. */
  77968. onleftstickchanged(callback: (values: StickValues) => void): void;
  77969. /**
  77970. * Callback triggered when the right joystick has changed
  77971. * @param callback
  77972. */
  77973. onrightstickchanged(callback: (values: StickValues) => void): void;
  77974. /**
  77975. * Gets the left joystick
  77976. */
  77977. /**
  77978. * Sets the left joystick values
  77979. */
  77980. leftStick: StickValues;
  77981. /**
  77982. * Gets the right joystick
  77983. */
  77984. /**
  77985. * Sets the right joystick value
  77986. */
  77987. rightStick: StickValues;
  77988. /**
  77989. * Updates the gamepad joystick positions
  77990. */
  77991. update(): void;
  77992. /**
  77993. * Disposes the gamepad
  77994. */
  77995. dispose(): void;
  77996. }
  77997. /**
  77998. * Represents a generic gamepad
  77999. */
  78000. export class GenericPad extends Gamepad {
  78001. private _buttons;
  78002. private _onbuttondown;
  78003. private _onbuttonup;
  78004. /**
  78005. * Observable triggered when a button has been pressed
  78006. */
  78007. onButtonDownObservable: Observable<number>;
  78008. /**
  78009. * Observable triggered when a button has been released
  78010. */
  78011. onButtonUpObservable: Observable<number>;
  78012. /**
  78013. * Callback triggered when a button has been pressed
  78014. * @param callback Called when a button has been pressed
  78015. */
  78016. onbuttondown(callback: (buttonPressed: number) => void): void;
  78017. /**
  78018. * Callback triggered when a button has been released
  78019. * @param callback Called when a button has been released
  78020. */
  78021. onbuttonup(callback: (buttonReleased: number) => void): void;
  78022. /**
  78023. * Initializes the generic gamepad
  78024. * @param id The id of the generic gamepad
  78025. * @param index The index of the generic gamepad
  78026. * @param browserGamepad The browser gamepad
  78027. */
  78028. constructor(id: string, index: number, browserGamepad: any);
  78029. private _setButtonValue;
  78030. /**
  78031. * Updates the generic gamepad
  78032. */
  78033. update(): void;
  78034. /**
  78035. * Disposes the generic gamepad
  78036. */
  78037. dispose(): void;
  78038. }
  78039. }
  78040. declare module BABYLON {
  78041. interface Engine {
  78042. /**
  78043. * Creates a raw texture
  78044. * @param data defines the data to store in the texture
  78045. * @param width defines the width of the texture
  78046. * @param height defines the height of the texture
  78047. * @param format defines the format of the data
  78048. * @param generateMipMaps defines if the engine should generate the mip levels
  78049. * @param invertY defines if data must be stored with Y axis inverted
  78050. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78051. * @param compression defines the compression used (null by default)
  78052. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78053. * @returns the raw texture inside an InternalTexture
  78054. */
  78055. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78056. /**
  78057. * Update a raw texture
  78058. * @param texture defines the texture to update
  78059. * @param data defines the data to store in the texture
  78060. * @param format defines the format of the data
  78061. * @param invertY defines if data must be stored with Y axis inverted
  78062. */
  78063. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78064. /**
  78065. * Update a raw texture
  78066. * @param texture defines the texture to update
  78067. * @param data defines the data to store in the texture
  78068. * @param format defines the format of the data
  78069. * @param invertY defines if data must be stored with Y axis inverted
  78070. * @param compression defines the compression used (null by default)
  78071. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78072. */
  78073. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78074. /**
  78075. * Creates a new raw cube texture
  78076. * @param data defines the array of data to use to create each face
  78077. * @param size defines the size of the textures
  78078. * @param format defines the format of the data
  78079. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78080. * @param generateMipMaps defines if the engine should generate the mip levels
  78081. * @param invertY defines if data must be stored with Y axis inverted
  78082. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78083. * @param compression defines the compression used (null by default)
  78084. * @returns the cube texture as an InternalTexture
  78085. */
  78086. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78087. /**
  78088. * Update a raw cube texture
  78089. * @param texture defines the texture to udpdate
  78090. * @param data defines the data to store
  78091. * @param format defines the data format
  78092. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78093. * @param invertY defines if data must be stored with Y axis inverted
  78094. */
  78095. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78096. /**
  78097. * Update a raw cube texture
  78098. * @param texture defines the texture to udpdate
  78099. * @param data defines the data to store
  78100. * @param format defines the data format
  78101. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78102. * @param invertY defines if data must be stored with Y axis inverted
  78103. * @param compression defines the compression used (null by default)
  78104. */
  78105. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78106. /**
  78107. * Update a raw cube texture
  78108. * @param texture defines the texture to udpdate
  78109. * @param data defines the data to store
  78110. * @param format defines the data format
  78111. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78112. * @param invertY defines if data must be stored with Y axis inverted
  78113. * @param compression defines the compression used (null by default)
  78114. * @param level defines which level of the texture to update
  78115. */
  78116. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78117. /**
  78118. * Creates a new raw cube texture from a specified url
  78119. * @param url defines the url where the data is located
  78120. * @param scene defines the current scene
  78121. * @param size defines the size of the textures
  78122. * @param format defines the format of the data
  78123. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78124. * @param noMipmap defines if the engine should avoid generating the mip levels
  78125. * @param callback defines a callback used to extract texture data from loaded data
  78126. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78127. * @param onLoad defines a callback called when texture is loaded
  78128. * @param onError defines a callback called if there is an error
  78129. * @returns the cube texture as an InternalTexture
  78130. */
  78131. 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;
  78132. /**
  78133. * Creates a new raw cube texture from a specified url
  78134. * @param url defines the url where the data is located
  78135. * @param scene defines the current scene
  78136. * @param size defines the size of the textures
  78137. * @param format defines the format of the data
  78138. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78139. * @param noMipmap defines if the engine should avoid generating the mip levels
  78140. * @param callback defines a callback used to extract texture data from loaded data
  78141. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78142. * @param onLoad defines a callback called when texture is loaded
  78143. * @param onError defines a callback called if there is an error
  78144. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78145. * @param invertY defines if data must be stored with Y axis inverted
  78146. * @returns the cube texture as an InternalTexture
  78147. */
  78148. 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;
  78149. /**
  78150. * Creates a new raw 3D texture
  78151. * @param data defines the data used to create the texture
  78152. * @param width defines the width of the texture
  78153. * @param height defines the height of the texture
  78154. * @param depth defines the depth of the texture
  78155. * @param format defines the format of the texture
  78156. * @param generateMipMaps defines if the engine must generate mip levels
  78157. * @param invertY defines if data must be stored with Y axis inverted
  78158. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78159. * @param compression defines the compressed used (can be null)
  78160. * @param textureType defines the compressed used (can be null)
  78161. * @returns a new raw 3D texture (stored in an InternalTexture)
  78162. */
  78163. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78164. /**
  78165. * Update a raw 3D texture
  78166. * @param texture defines the texture to update
  78167. * @param data defines the data to store
  78168. * @param format defines the data format
  78169. * @param invertY defines if data must be stored with Y axis inverted
  78170. */
  78171. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78172. /**
  78173. * Update a raw 3D texture
  78174. * @param texture defines the texture to update
  78175. * @param data defines the data to store
  78176. * @param format defines the data format
  78177. * @param invertY defines if data must be stored with Y axis inverted
  78178. * @param compression defines the used compression (can be null)
  78179. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78180. */
  78181. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78182. }
  78183. }
  78184. declare module BABYLON {
  78185. /**
  78186. * Raw texture can help creating a texture directly from an array of data.
  78187. * This can be super useful if you either get the data from an uncompressed source or
  78188. * if you wish to create your texture pixel by pixel.
  78189. */
  78190. export class RawTexture extends Texture {
  78191. /**
  78192. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78193. */
  78194. format: number;
  78195. private _engine;
  78196. /**
  78197. * Instantiates a new RawTexture.
  78198. * Raw texture can help creating a texture directly from an array of data.
  78199. * This can be super useful if you either get the data from an uncompressed source or
  78200. * if you wish to create your texture pixel by pixel.
  78201. * @param data define the array of data to use to create the texture
  78202. * @param width define the width of the texture
  78203. * @param height define the height of the texture
  78204. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78205. * @param scene define the scene the texture belongs to
  78206. * @param generateMipMaps define whether mip maps should be generated or not
  78207. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78208. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78209. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78210. */
  78211. constructor(data: ArrayBufferView, width: number, height: number,
  78212. /**
  78213. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78214. */
  78215. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78216. /**
  78217. * Updates the texture underlying data.
  78218. * @param data Define the new data of the texture
  78219. */
  78220. update(data: ArrayBufferView): void;
  78221. /**
  78222. * Creates a luminance texture from some data.
  78223. * @param data Define the texture data
  78224. * @param width Define the width of the texture
  78225. * @param height Define the height of the texture
  78226. * @param scene Define the scene the texture belongs to
  78227. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78228. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78229. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78230. * @returns the luminance texture
  78231. */
  78232. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78233. /**
  78234. * Creates a luminance alpha texture from some data.
  78235. * @param data Define the texture data
  78236. * @param width Define the width of the texture
  78237. * @param height Define the height of the texture
  78238. * @param scene Define the scene the texture belongs to
  78239. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78240. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78241. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78242. * @returns the luminance alpha texture
  78243. */
  78244. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78245. /**
  78246. * Creates an alpha texture from some data.
  78247. * @param data Define the texture data
  78248. * @param width Define the width of the texture
  78249. * @param height Define the height of the texture
  78250. * @param scene Define the scene the texture belongs to
  78251. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78252. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78253. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78254. * @returns the alpha texture
  78255. */
  78256. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78257. /**
  78258. * Creates a RGB texture from some data.
  78259. * @param data Define the texture data
  78260. * @param width Define the width of the texture
  78261. * @param height Define the height of the texture
  78262. * @param scene Define the scene the texture belongs to
  78263. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78264. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78265. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78266. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78267. * @returns the RGB alpha texture
  78268. */
  78269. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78270. /**
  78271. * Creates a RGBA texture from some data.
  78272. * @param data Define the texture data
  78273. * @param width Define the width of the texture
  78274. * @param height Define the height of the texture
  78275. * @param scene Define the scene the texture belongs to
  78276. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78277. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78278. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78279. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78280. * @returns the RGBA texture
  78281. */
  78282. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78283. /**
  78284. * Creates a R texture from some data.
  78285. * @param data Define the texture data
  78286. * @param width Define the width of the texture
  78287. * @param height Define the height of the texture
  78288. * @param scene Define the scene the texture belongs to
  78289. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78290. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78291. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78292. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78293. * @returns the R texture
  78294. */
  78295. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78296. }
  78297. }
  78298. declare module BABYLON {
  78299. /**
  78300. * Interface for the size containing width and height
  78301. */
  78302. export interface ISize {
  78303. /**
  78304. * Width
  78305. */
  78306. width: number;
  78307. /**
  78308. * Heighht
  78309. */
  78310. height: number;
  78311. }
  78312. /**
  78313. * Size containing widht and height
  78314. */
  78315. export class Size implements ISize {
  78316. /**
  78317. * Width
  78318. */
  78319. width: number;
  78320. /**
  78321. * Height
  78322. */
  78323. height: number;
  78324. /**
  78325. * Creates a Size object from the given width and height (floats).
  78326. * @param width width of the new size
  78327. * @param height height of the new size
  78328. */
  78329. constructor(width: number, height: number);
  78330. /**
  78331. * Returns a string with the Size width and height
  78332. * @returns a string with the Size width and height
  78333. */
  78334. toString(): string;
  78335. /**
  78336. * "Size"
  78337. * @returns the string "Size"
  78338. */
  78339. getClassName(): string;
  78340. /**
  78341. * Returns the Size hash code.
  78342. * @returns a hash code for a unique width and height
  78343. */
  78344. getHashCode(): number;
  78345. /**
  78346. * Updates the current size from the given one.
  78347. * @param src the given size
  78348. */
  78349. copyFrom(src: Size): void;
  78350. /**
  78351. * Updates in place the current Size from the given floats.
  78352. * @param width width of the new size
  78353. * @param height height of the new size
  78354. * @returns the updated Size.
  78355. */
  78356. copyFromFloats(width: number, height: number): Size;
  78357. /**
  78358. * Updates in place the current Size from the given floats.
  78359. * @param width width to set
  78360. * @param height height to set
  78361. * @returns the updated Size.
  78362. */
  78363. set(width: number, height: number): Size;
  78364. /**
  78365. * Multiplies the width and height by numbers
  78366. * @param w factor to multiple the width by
  78367. * @param h factor to multiple the height by
  78368. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  78369. */
  78370. multiplyByFloats(w: number, h: number): Size;
  78371. /**
  78372. * Clones the size
  78373. * @returns a new Size copied from the given one.
  78374. */
  78375. clone(): Size;
  78376. /**
  78377. * True if the current Size and the given one width and height are strictly equal.
  78378. * @param other the other size to compare against
  78379. * @returns True if the current Size and the given one width and height are strictly equal.
  78380. */
  78381. equals(other: Size): boolean;
  78382. /**
  78383. * The surface of the Size : width * height (float).
  78384. */
  78385. readonly surface: number;
  78386. /**
  78387. * Create a new size of zero
  78388. * @returns a new Size set to (0.0, 0.0)
  78389. */
  78390. static Zero(): Size;
  78391. /**
  78392. * Sums the width and height of two sizes
  78393. * @param otherSize size to add to this size
  78394. * @returns a new Size set as the addition result of the current Size and the given one.
  78395. */
  78396. add(otherSize: Size): Size;
  78397. /**
  78398. * Subtracts the width and height of two
  78399. * @param otherSize size to subtract to this size
  78400. * @returns a new Size set as the subtraction result of the given one from the current Size.
  78401. */
  78402. subtract(otherSize: Size): Size;
  78403. /**
  78404. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  78405. * @param start starting size to lerp between
  78406. * @param end end size to lerp between
  78407. * @param amount amount to lerp between the start and end values
  78408. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  78409. */
  78410. static Lerp(start: Size, end: Size, amount: number): Size;
  78411. }
  78412. }
  78413. declare module BABYLON {
  78414. /**
  78415. * Defines a runtime animation
  78416. */
  78417. export class RuntimeAnimation {
  78418. private _events;
  78419. /**
  78420. * The current frame of the runtime animation
  78421. */
  78422. private _currentFrame;
  78423. /**
  78424. * The animation used by the runtime animation
  78425. */
  78426. private _animation;
  78427. /**
  78428. * The target of the runtime animation
  78429. */
  78430. private _target;
  78431. /**
  78432. * The initiating animatable
  78433. */
  78434. private _host;
  78435. /**
  78436. * The original value of the runtime animation
  78437. */
  78438. private _originalValue;
  78439. /**
  78440. * The original blend value of the runtime animation
  78441. */
  78442. private _originalBlendValue;
  78443. /**
  78444. * The offsets cache of the runtime animation
  78445. */
  78446. private _offsetsCache;
  78447. /**
  78448. * The high limits cache of the runtime animation
  78449. */
  78450. private _highLimitsCache;
  78451. /**
  78452. * Specifies if the runtime animation has been stopped
  78453. */
  78454. private _stopped;
  78455. /**
  78456. * The blending factor of the runtime animation
  78457. */
  78458. private _blendingFactor;
  78459. /**
  78460. * The BabylonJS scene
  78461. */
  78462. private _scene;
  78463. /**
  78464. * The current value of the runtime animation
  78465. */
  78466. private _currentValue;
  78467. /** @hidden */
  78468. _animationState: _IAnimationState;
  78469. /**
  78470. * The active target of the runtime animation
  78471. */
  78472. private _activeTargets;
  78473. private _currentActiveTarget;
  78474. private _directTarget;
  78475. /**
  78476. * The target path of the runtime animation
  78477. */
  78478. private _targetPath;
  78479. /**
  78480. * The weight of the runtime animation
  78481. */
  78482. private _weight;
  78483. /**
  78484. * The ratio offset of the runtime animation
  78485. */
  78486. private _ratioOffset;
  78487. /**
  78488. * The previous delay of the runtime animation
  78489. */
  78490. private _previousDelay;
  78491. /**
  78492. * The previous ratio of the runtime animation
  78493. */
  78494. private _previousRatio;
  78495. private _enableBlending;
  78496. private _keys;
  78497. private _minFrame;
  78498. private _maxFrame;
  78499. private _minValue;
  78500. private _maxValue;
  78501. private _targetIsArray;
  78502. /**
  78503. * Gets the current frame of the runtime animation
  78504. */
  78505. readonly currentFrame: number;
  78506. /**
  78507. * Gets the weight of the runtime animation
  78508. */
  78509. readonly weight: number;
  78510. /**
  78511. * Gets the current value of the runtime animation
  78512. */
  78513. readonly currentValue: any;
  78514. /**
  78515. * Gets the target path of the runtime animation
  78516. */
  78517. readonly targetPath: string;
  78518. /**
  78519. * Gets the actual target of the runtime animation
  78520. */
  78521. readonly target: any;
  78522. /** @hidden */
  78523. _onLoop: () => void;
  78524. /**
  78525. * Create a new RuntimeAnimation object
  78526. * @param target defines the target of the animation
  78527. * @param animation defines the source animation object
  78528. * @param scene defines the hosting scene
  78529. * @param host defines the initiating Animatable
  78530. */
  78531. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78532. private _preparePath;
  78533. /**
  78534. * Gets the animation from the runtime animation
  78535. */
  78536. readonly animation: Animation;
  78537. /**
  78538. * Resets the runtime animation to the beginning
  78539. * @param restoreOriginal defines whether to restore the target property to the original value
  78540. */
  78541. reset(restoreOriginal?: boolean): void;
  78542. /**
  78543. * Specifies if the runtime animation is stopped
  78544. * @returns Boolean specifying if the runtime animation is stopped
  78545. */
  78546. isStopped(): boolean;
  78547. /**
  78548. * Disposes of the runtime animation
  78549. */
  78550. dispose(): void;
  78551. /**
  78552. * Apply the interpolated value to the target
  78553. * @param currentValue defines the value computed by the animation
  78554. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78555. */
  78556. setValue(currentValue: any, weight: number): void;
  78557. private _getOriginalValues;
  78558. private _setValue;
  78559. /**
  78560. * Gets the loop pmode of the runtime animation
  78561. * @returns Loop Mode
  78562. */
  78563. private _getCorrectLoopMode;
  78564. /**
  78565. * Move the current animation to a given frame
  78566. * @param frame defines the frame to move to
  78567. */
  78568. goToFrame(frame: number): void;
  78569. /**
  78570. * @hidden Internal use only
  78571. */
  78572. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78573. /**
  78574. * Execute the current animation
  78575. * @param delay defines the delay to add to the current frame
  78576. * @param from defines the lower bound of the animation range
  78577. * @param to defines the upper bound of the animation range
  78578. * @param loop defines if the current animation must loop
  78579. * @param speedRatio defines the current speed ratio
  78580. * @param weight defines the weight of the animation (default is -1 so no weight)
  78581. * @param onLoop optional callback called when animation loops
  78582. * @returns a boolean indicating if the animation is running
  78583. */
  78584. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78585. }
  78586. }
  78587. declare module BABYLON {
  78588. /**
  78589. * Class used to store an actual running animation
  78590. */
  78591. export class Animatable {
  78592. /** defines the target object */
  78593. target: any;
  78594. /** defines the starting frame number (default is 0) */
  78595. fromFrame: number;
  78596. /** defines the ending frame number (default is 100) */
  78597. toFrame: number;
  78598. /** defines if the animation must loop (default is false) */
  78599. loopAnimation: boolean;
  78600. /** defines a callback to call when animation ends if it is not looping */
  78601. onAnimationEnd?: (() => void) | null | undefined;
  78602. /** defines a callback to call when animation loops */
  78603. onAnimationLoop?: (() => void) | null | undefined;
  78604. private _localDelayOffset;
  78605. private _pausedDelay;
  78606. private _runtimeAnimations;
  78607. private _paused;
  78608. private _scene;
  78609. private _speedRatio;
  78610. private _weight;
  78611. private _syncRoot;
  78612. /**
  78613. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78614. * This will only apply for non looping animation (default is true)
  78615. */
  78616. disposeOnEnd: boolean;
  78617. /**
  78618. * Gets a boolean indicating if the animation has started
  78619. */
  78620. animationStarted: boolean;
  78621. /**
  78622. * Observer raised when the animation ends
  78623. */
  78624. onAnimationEndObservable: Observable<Animatable>;
  78625. /**
  78626. * Observer raised when the animation loops
  78627. */
  78628. onAnimationLoopObservable: Observable<Animatable>;
  78629. /**
  78630. * Gets the root Animatable used to synchronize and normalize animations
  78631. */
  78632. readonly syncRoot: Nullable<Animatable>;
  78633. /**
  78634. * Gets the current frame of the first RuntimeAnimation
  78635. * Used to synchronize Animatables
  78636. */
  78637. readonly masterFrame: number;
  78638. /**
  78639. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78640. */
  78641. weight: number;
  78642. /**
  78643. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78644. */
  78645. speedRatio: number;
  78646. /**
  78647. * Creates a new Animatable
  78648. * @param scene defines the hosting scene
  78649. * @param target defines the target object
  78650. * @param fromFrame defines the starting frame number (default is 0)
  78651. * @param toFrame defines the ending frame number (default is 100)
  78652. * @param loopAnimation defines if the animation must loop (default is false)
  78653. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78654. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78655. * @param animations defines a group of animation to add to the new Animatable
  78656. * @param onAnimationLoop defines a callback to call when animation loops
  78657. */
  78658. constructor(scene: Scene,
  78659. /** defines the target object */
  78660. target: any,
  78661. /** defines the starting frame number (default is 0) */
  78662. fromFrame?: number,
  78663. /** defines the ending frame number (default is 100) */
  78664. toFrame?: number,
  78665. /** defines if the animation must loop (default is false) */
  78666. loopAnimation?: boolean, speedRatio?: number,
  78667. /** defines a callback to call when animation ends if it is not looping */
  78668. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78669. /** defines a callback to call when animation loops */
  78670. onAnimationLoop?: (() => void) | null | undefined);
  78671. /**
  78672. * Synchronize and normalize current Animatable with a source Animatable
  78673. * This is useful when using animation weights and when animations are not of the same length
  78674. * @param root defines the root Animatable to synchronize with
  78675. * @returns the current Animatable
  78676. */
  78677. syncWith(root: Animatable): Animatable;
  78678. /**
  78679. * Gets the list of runtime animations
  78680. * @returns an array of RuntimeAnimation
  78681. */
  78682. getAnimations(): RuntimeAnimation[];
  78683. /**
  78684. * Adds more animations to the current animatable
  78685. * @param target defines the target of the animations
  78686. * @param animations defines the new animations to add
  78687. */
  78688. appendAnimations(target: any, animations: Animation[]): void;
  78689. /**
  78690. * Gets the source animation for a specific property
  78691. * @param property defines the propertyu to look for
  78692. * @returns null or the source animation for the given property
  78693. */
  78694. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78695. /**
  78696. * Gets the runtime animation for a specific property
  78697. * @param property defines the propertyu to look for
  78698. * @returns null or the runtime animation for the given property
  78699. */
  78700. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78701. /**
  78702. * Resets the animatable to its original state
  78703. */
  78704. reset(): void;
  78705. /**
  78706. * Allows the animatable to blend with current running animations
  78707. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78708. * @param blendingSpeed defines the blending speed to use
  78709. */
  78710. enableBlending(blendingSpeed: number): void;
  78711. /**
  78712. * Disable animation blending
  78713. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78714. */
  78715. disableBlending(): void;
  78716. /**
  78717. * Jump directly to a given frame
  78718. * @param frame defines the frame to jump to
  78719. */
  78720. goToFrame(frame: number): void;
  78721. /**
  78722. * Pause the animation
  78723. */
  78724. pause(): void;
  78725. /**
  78726. * Restart the animation
  78727. */
  78728. restart(): void;
  78729. private _raiseOnAnimationEnd;
  78730. /**
  78731. * Stop and delete the current animation
  78732. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78733. * @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)
  78734. */
  78735. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78736. /**
  78737. * Wait asynchronously for the animation to end
  78738. * @returns a promise which will be fullfilled when the animation ends
  78739. */
  78740. waitAsync(): Promise<Animatable>;
  78741. /** @hidden */
  78742. _animate(delay: number): boolean;
  78743. }
  78744. interface Scene {
  78745. /** @hidden */
  78746. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78747. /** @hidden */
  78748. _processLateAnimationBindingsForMatrices(holder: {
  78749. totalWeight: number;
  78750. animations: RuntimeAnimation[];
  78751. originalValue: Matrix;
  78752. }): any;
  78753. /** @hidden */
  78754. _processLateAnimationBindingsForQuaternions(holder: {
  78755. totalWeight: number;
  78756. animations: RuntimeAnimation[];
  78757. originalValue: Quaternion;
  78758. }, refQuaternion: Quaternion): Quaternion;
  78759. /** @hidden */
  78760. _processLateAnimationBindings(): void;
  78761. /**
  78762. * Will start the animation sequence of a given target
  78763. * @param target defines the target
  78764. * @param from defines from which frame should animation start
  78765. * @param to defines until which frame should animation run.
  78766. * @param weight defines the weight to apply to the animation (1.0 by default)
  78767. * @param loop defines if the animation loops
  78768. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78769. * @param onAnimationEnd defines the function to be executed when the animation ends
  78770. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78771. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78772. * @param onAnimationLoop defines the callback to call when an animation loops
  78773. * @returns the animatable object created for this animation
  78774. */
  78775. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78776. /**
  78777. * Will start the animation sequence of a given target
  78778. * @param target defines the target
  78779. * @param from defines from which frame should animation start
  78780. * @param to defines until which frame should animation run.
  78781. * @param loop defines if the animation loops
  78782. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78783. * @param onAnimationEnd defines the function to be executed when the animation ends
  78784. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78785. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78786. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78787. * @param onAnimationLoop defines the callback to call when an animation loops
  78788. * @returns the animatable object created for this animation
  78789. */
  78790. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78791. /**
  78792. * Will start the animation sequence of a given target and its hierarchy
  78793. * @param target defines the target
  78794. * @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.
  78795. * @param from defines from which frame should animation start
  78796. * @param to defines until which frame should animation run.
  78797. * @param loop defines if the animation loops
  78798. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78799. * @param onAnimationEnd defines the function to be executed when the animation ends
  78800. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78801. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78802. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78803. * @param onAnimationLoop defines the callback to call when an animation loops
  78804. * @returns the list of created animatables
  78805. */
  78806. 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[];
  78807. /**
  78808. * Begin a new animation on a given node
  78809. * @param target defines the target where the animation will take place
  78810. * @param animations defines the list of animations to start
  78811. * @param from defines the initial value
  78812. * @param to defines the final value
  78813. * @param loop defines if you want animation to loop (off by default)
  78814. * @param speedRatio defines the speed ratio to apply to all animations
  78815. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78816. * @param onAnimationLoop defines the callback to call when an animation loops
  78817. * @returns the list of created animatables
  78818. */
  78819. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78820. /**
  78821. * Begin a new animation on a given node and its hierarchy
  78822. * @param target defines the root node where the animation will take place
  78823. * @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.
  78824. * @param animations defines the list of animations to start
  78825. * @param from defines the initial value
  78826. * @param to defines the final value
  78827. * @param loop defines if you want animation to loop (off by default)
  78828. * @param speedRatio defines the speed ratio to apply to all animations
  78829. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78830. * @param onAnimationLoop defines the callback to call when an animation loops
  78831. * @returns the list of animatables created for all nodes
  78832. */
  78833. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78834. /**
  78835. * Gets the animatable associated with a specific target
  78836. * @param target defines the target of the animatable
  78837. * @returns the required animatable if found
  78838. */
  78839. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78840. /**
  78841. * Gets all animatables associated with a given target
  78842. * @param target defines the target to look animatables for
  78843. * @returns an array of Animatables
  78844. */
  78845. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78846. /**
  78847. * Stops and removes all animations that have been applied to the scene
  78848. */
  78849. stopAllAnimations(): void;
  78850. }
  78851. interface Bone {
  78852. /**
  78853. * Copy an animation range from another bone
  78854. * @param source defines the source bone
  78855. * @param rangeName defines the range name to copy
  78856. * @param frameOffset defines the frame offset
  78857. * @param rescaleAsRequired defines if rescaling must be applied if required
  78858. * @param skelDimensionsRatio defines the scaling ratio
  78859. * @returns true if operation was successful
  78860. */
  78861. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78862. }
  78863. }
  78864. declare module BABYLON {
  78865. /**
  78866. * Class used to override all child animations of a given target
  78867. */
  78868. export class AnimationPropertiesOverride {
  78869. /**
  78870. * Gets or sets a value indicating if animation blending must be used
  78871. */
  78872. enableBlending: boolean;
  78873. /**
  78874. * Gets or sets the blending speed to use when enableBlending is true
  78875. */
  78876. blendingSpeed: number;
  78877. /**
  78878. * Gets or sets the default loop mode to use
  78879. */
  78880. loopMode: number;
  78881. }
  78882. }
  78883. declare module BABYLON {
  78884. /**
  78885. * Class used to handle skinning animations
  78886. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78887. */
  78888. export class Skeleton implements IAnimatable {
  78889. /** defines the skeleton name */
  78890. name: string;
  78891. /** defines the skeleton Id */
  78892. id: string;
  78893. /**
  78894. * Defines the list of child bones
  78895. */
  78896. bones: Bone[];
  78897. /**
  78898. * Defines an estimate of the dimension of the skeleton at rest
  78899. */
  78900. dimensionsAtRest: Vector3;
  78901. /**
  78902. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78903. */
  78904. needInitialSkinMatrix: boolean;
  78905. /**
  78906. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78907. */
  78908. overrideMesh: Nullable<AbstractMesh>;
  78909. /**
  78910. * Gets the list of animations attached to this skeleton
  78911. */
  78912. animations: Array<Animation>;
  78913. private _scene;
  78914. private _isDirty;
  78915. private _transformMatrices;
  78916. private _transformMatrixTexture;
  78917. private _meshesWithPoseMatrix;
  78918. private _animatables;
  78919. private _identity;
  78920. private _synchronizedWithMesh;
  78921. private _ranges;
  78922. private _lastAbsoluteTransformsUpdateId;
  78923. private _canUseTextureForBones;
  78924. private _uniqueId;
  78925. /** @hidden */
  78926. _numBonesWithLinkedTransformNode: number;
  78927. /** @hidden */
  78928. _hasWaitingData: Nullable<boolean>;
  78929. /**
  78930. * Specifies if the skeleton should be serialized
  78931. */
  78932. doNotSerialize: boolean;
  78933. private _useTextureToStoreBoneMatrices;
  78934. /**
  78935. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78936. * Please note that this option is not available if the hardware does not support it
  78937. */
  78938. useTextureToStoreBoneMatrices: boolean;
  78939. private _animationPropertiesOverride;
  78940. /**
  78941. * Gets or sets the animation properties override
  78942. */
  78943. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78944. /**
  78945. * List of inspectable custom properties (used by the Inspector)
  78946. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78947. */
  78948. inspectableCustomProperties: IInspectable[];
  78949. /**
  78950. * An observable triggered before computing the skeleton's matrices
  78951. */
  78952. onBeforeComputeObservable: Observable<Skeleton>;
  78953. /**
  78954. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78955. */
  78956. readonly isUsingTextureForMatrices: boolean;
  78957. /**
  78958. * Gets the unique ID of this skeleton
  78959. */
  78960. readonly uniqueId: number;
  78961. /**
  78962. * Creates a new skeleton
  78963. * @param name defines the skeleton name
  78964. * @param id defines the skeleton Id
  78965. * @param scene defines the hosting scene
  78966. */
  78967. constructor(
  78968. /** defines the skeleton name */
  78969. name: string,
  78970. /** defines the skeleton Id */
  78971. id: string, scene: Scene);
  78972. /**
  78973. * Gets the current object class name.
  78974. * @return the class name
  78975. */
  78976. getClassName(): string;
  78977. /**
  78978. * Returns an array containing the root bones
  78979. * @returns an array containing the root bones
  78980. */
  78981. getChildren(): Array<Bone>;
  78982. /**
  78983. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78984. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78985. * @returns a Float32Array containing matrices data
  78986. */
  78987. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78988. /**
  78989. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78990. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78991. * @returns a raw texture containing the data
  78992. */
  78993. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  78994. /**
  78995. * Gets the current hosting scene
  78996. * @returns a scene object
  78997. */
  78998. getScene(): Scene;
  78999. /**
  79000. * Gets a string representing the current skeleton data
  79001. * @param fullDetails defines a boolean indicating if we want a verbose version
  79002. * @returns a string representing the current skeleton data
  79003. */
  79004. toString(fullDetails?: boolean): string;
  79005. /**
  79006. * Get bone's index searching by name
  79007. * @param name defines bone's name to search for
  79008. * @return the indice of the bone. Returns -1 if not found
  79009. */
  79010. getBoneIndexByName(name: string): number;
  79011. /**
  79012. * Creater a new animation range
  79013. * @param name defines the name of the range
  79014. * @param from defines the start key
  79015. * @param to defines the end key
  79016. */
  79017. createAnimationRange(name: string, from: number, to: number): void;
  79018. /**
  79019. * Delete a specific animation range
  79020. * @param name defines the name of the range
  79021. * @param deleteFrames defines if frames must be removed as well
  79022. */
  79023. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79024. /**
  79025. * Gets a specific animation range
  79026. * @param name defines the name of the range to look for
  79027. * @returns the requested animation range or null if not found
  79028. */
  79029. getAnimationRange(name: string): Nullable<AnimationRange>;
  79030. /**
  79031. * Gets the list of all animation ranges defined on this skeleton
  79032. * @returns an array
  79033. */
  79034. getAnimationRanges(): Nullable<AnimationRange>[];
  79035. /**
  79036. * Copy animation range from a source skeleton.
  79037. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79038. * @param source defines the source skeleton
  79039. * @param name defines the name of the range to copy
  79040. * @param rescaleAsRequired defines if rescaling must be applied if required
  79041. * @returns true if operation was successful
  79042. */
  79043. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79044. /**
  79045. * Forces the skeleton to go to rest pose
  79046. */
  79047. returnToRest(): void;
  79048. private _getHighestAnimationFrame;
  79049. /**
  79050. * Begin a specific animation range
  79051. * @param name defines the name of the range to start
  79052. * @param loop defines if looping must be turned on (false by default)
  79053. * @param speedRatio defines the speed ratio to apply (1 by default)
  79054. * @param onAnimationEnd defines a callback which will be called when animation will end
  79055. * @returns a new animatable
  79056. */
  79057. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79058. /** @hidden */
  79059. _markAsDirty(): void;
  79060. /** @hidden */
  79061. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79062. /** @hidden */
  79063. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79064. private _computeTransformMatrices;
  79065. /**
  79066. * Build all resources required to render a skeleton
  79067. */
  79068. prepare(): void;
  79069. /**
  79070. * Gets the list of animatables currently running for this skeleton
  79071. * @returns an array of animatables
  79072. */
  79073. getAnimatables(): IAnimatable[];
  79074. /**
  79075. * Clone the current skeleton
  79076. * @param name defines the name of the new skeleton
  79077. * @param id defines the id of the new skeleton
  79078. * @returns the new skeleton
  79079. */
  79080. clone(name: string, id: string): Skeleton;
  79081. /**
  79082. * Enable animation blending for this skeleton
  79083. * @param blendingSpeed defines the blending speed to apply
  79084. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79085. */
  79086. enableBlending(blendingSpeed?: number): void;
  79087. /**
  79088. * Releases all resources associated with the current skeleton
  79089. */
  79090. dispose(): void;
  79091. /**
  79092. * Serialize the skeleton in a JSON object
  79093. * @returns a JSON object
  79094. */
  79095. serialize(): any;
  79096. /**
  79097. * Creates a new skeleton from serialized data
  79098. * @param parsedSkeleton defines the serialized data
  79099. * @param scene defines the hosting scene
  79100. * @returns a new skeleton
  79101. */
  79102. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79103. /**
  79104. * Compute all node absolute transforms
  79105. * @param forceUpdate defines if computation must be done even if cache is up to date
  79106. */
  79107. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79108. /**
  79109. * Gets the root pose matrix
  79110. * @returns a matrix
  79111. */
  79112. getPoseMatrix(): Nullable<Matrix>;
  79113. /**
  79114. * Sorts bones per internal index
  79115. */
  79116. sortBones(): void;
  79117. private _sortBones;
  79118. }
  79119. }
  79120. declare module BABYLON {
  79121. /**
  79122. * Class used to store bone information
  79123. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79124. */
  79125. export class Bone extends Node {
  79126. /**
  79127. * defines the bone name
  79128. */
  79129. name: string;
  79130. private static _tmpVecs;
  79131. private static _tmpQuat;
  79132. private static _tmpMats;
  79133. /**
  79134. * Gets the list of child bones
  79135. */
  79136. children: Bone[];
  79137. /** Gets the animations associated with this bone */
  79138. animations: Animation[];
  79139. /**
  79140. * Gets or sets bone length
  79141. */
  79142. length: number;
  79143. /**
  79144. * @hidden Internal only
  79145. * Set this value to map this bone to a different index in the transform matrices
  79146. * Set this value to -1 to exclude the bone from the transform matrices
  79147. */
  79148. _index: Nullable<number>;
  79149. private _skeleton;
  79150. private _localMatrix;
  79151. private _restPose;
  79152. private _baseMatrix;
  79153. private _absoluteTransform;
  79154. private _invertedAbsoluteTransform;
  79155. private _parent;
  79156. private _scalingDeterminant;
  79157. private _worldTransform;
  79158. private _localScaling;
  79159. private _localRotation;
  79160. private _localPosition;
  79161. private _needToDecompose;
  79162. private _needToCompose;
  79163. /** @hidden */
  79164. _linkedTransformNode: Nullable<TransformNode>;
  79165. /** @hidden */
  79166. _waitingTransformNodeId: Nullable<string>;
  79167. /** @hidden */
  79168. /** @hidden */
  79169. _matrix: Matrix;
  79170. /**
  79171. * Create a new bone
  79172. * @param name defines the bone name
  79173. * @param skeleton defines the parent skeleton
  79174. * @param parentBone defines the parent (can be null if the bone is the root)
  79175. * @param localMatrix defines the local matrix
  79176. * @param restPose defines the rest pose matrix
  79177. * @param baseMatrix defines the base matrix
  79178. * @param index defines index of the bone in the hiearchy
  79179. */
  79180. constructor(
  79181. /**
  79182. * defines the bone name
  79183. */
  79184. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79185. /**
  79186. * Gets the current object class name.
  79187. * @return the class name
  79188. */
  79189. getClassName(): string;
  79190. /**
  79191. * Gets the parent skeleton
  79192. * @returns a skeleton
  79193. */
  79194. getSkeleton(): Skeleton;
  79195. /**
  79196. * Gets parent bone
  79197. * @returns a bone or null if the bone is the root of the bone hierarchy
  79198. */
  79199. getParent(): Nullable<Bone>;
  79200. /**
  79201. * Returns an array containing the root bones
  79202. * @returns an array containing the root bones
  79203. */
  79204. getChildren(): Array<Bone>;
  79205. /**
  79206. * Sets the parent bone
  79207. * @param parent defines the parent (can be null if the bone is the root)
  79208. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79209. */
  79210. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79211. /**
  79212. * Gets the local matrix
  79213. * @returns a matrix
  79214. */
  79215. getLocalMatrix(): Matrix;
  79216. /**
  79217. * Gets the base matrix (initial matrix which remains unchanged)
  79218. * @returns a matrix
  79219. */
  79220. getBaseMatrix(): Matrix;
  79221. /**
  79222. * Gets the rest pose matrix
  79223. * @returns a matrix
  79224. */
  79225. getRestPose(): Matrix;
  79226. /**
  79227. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79228. */
  79229. getWorldMatrix(): Matrix;
  79230. /**
  79231. * Sets the local matrix to rest pose matrix
  79232. */
  79233. returnToRest(): void;
  79234. /**
  79235. * Gets the inverse of the absolute transform matrix.
  79236. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79237. * @returns a matrix
  79238. */
  79239. getInvertedAbsoluteTransform(): Matrix;
  79240. /**
  79241. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79242. * @returns a matrix
  79243. */
  79244. getAbsoluteTransform(): Matrix;
  79245. /**
  79246. * Links with the given transform node.
  79247. * The local matrix of this bone is copied from the transform node every frame.
  79248. * @param transformNode defines the transform node to link to
  79249. */
  79250. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79251. /**
  79252. * Gets the node used to drive the bone's transformation
  79253. * @returns a transform node or null
  79254. */
  79255. getTransformNode(): Nullable<TransformNode>;
  79256. /** Gets or sets current position (in local space) */
  79257. position: Vector3;
  79258. /** Gets or sets current rotation (in local space) */
  79259. rotation: Vector3;
  79260. /** Gets or sets current rotation quaternion (in local space) */
  79261. rotationQuaternion: Quaternion;
  79262. /** Gets or sets current scaling (in local space) */
  79263. scaling: Vector3;
  79264. /**
  79265. * Gets the animation properties override
  79266. */
  79267. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79268. private _decompose;
  79269. private _compose;
  79270. /**
  79271. * Update the base and local matrices
  79272. * @param matrix defines the new base or local matrix
  79273. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79274. * @param updateLocalMatrix defines if the local matrix should be updated
  79275. */
  79276. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  79277. /** @hidden */
  79278. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  79279. /**
  79280. * Flag the bone as dirty (Forcing it to update everything)
  79281. */
  79282. markAsDirty(): void;
  79283. /** @hidden */
  79284. _markAsDirtyAndCompose(): void;
  79285. private _markAsDirtyAndDecompose;
  79286. /**
  79287. * Translate the bone in local or world space
  79288. * @param vec The amount to translate the bone
  79289. * @param space The space that the translation is in
  79290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79291. */
  79292. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79293. /**
  79294. * Set the postion of the bone in local or world space
  79295. * @param position The position to set the bone
  79296. * @param space The space that the position is in
  79297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79298. */
  79299. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79300. /**
  79301. * Set the absolute position of the bone (world space)
  79302. * @param position The position to set the bone
  79303. * @param mesh The mesh that this bone is attached to
  79304. */
  79305. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  79306. /**
  79307. * Scale the bone on the x, y and z axes (in local space)
  79308. * @param x The amount to scale the bone on the x axis
  79309. * @param y The amount to scale the bone on the y axis
  79310. * @param z The amount to scale the bone on the z axis
  79311. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  79312. */
  79313. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  79314. /**
  79315. * Set the bone scaling in local space
  79316. * @param scale defines the scaling vector
  79317. */
  79318. setScale(scale: Vector3): void;
  79319. /**
  79320. * Gets the current scaling in local space
  79321. * @returns the current scaling vector
  79322. */
  79323. getScale(): Vector3;
  79324. /**
  79325. * Gets the current scaling in local space and stores it in a target vector
  79326. * @param result defines the target vector
  79327. */
  79328. getScaleToRef(result: Vector3): void;
  79329. /**
  79330. * Set the yaw, pitch, and roll of the bone in local or world space
  79331. * @param yaw The rotation of the bone on the y axis
  79332. * @param pitch The rotation of the bone on the x axis
  79333. * @param roll The rotation of the bone on the z axis
  79334. * @param space The space that the axes of rotation are in
  79335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79336. */
  79337. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  79338. /**
  79339. * Add a rotation to the bone on an axis in local or world space
  79340. * @param axis The axis to rotate the bone on
  79341. * @param amount The amount to rotate the bone
  79342. * @param space The space that the axis is in
  79343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79344. */
  79345. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  79346. /**
  79347. * Set the rotation of the bone to a particular axis angle in local or world space
  79348. * @param axis The axis to rotate the bone on
  79349. * @param angle The angle that the bone should be rotated to
  79350. * @param space The space that the axis is in
  79351. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79352. */
  79353. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  79354. /**
  79355. * Set the euler rotation of the bone in local of world space
  79356. * @param rotation The euler rotation that the bone should be set to
  79357. * @param space The space that the rotation is in
  79358. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79359. */
  79360. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79361. /**
  79362. * Set the quaternion rotation of the bone in local of world space
  79363. * @param quat The quaternion rotation that the bone should be set to
  79364. * @param space The space that the rotation is in
  79365. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79366. */
  79367. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  79368. /**
  79369. * Set the rotation matrix of the bone in local of world space
  79370. * @param rotMat The rotation matrix that the bone should be set to
  79371. * @param space The space that the rotation is in
  79372. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79373. */
  79374. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  79375. private _rotateWithMatrix;
  79376. private _getNegativeRotationToRef;
  79377. /**
  79378. * Get the position of the bone in local or world space
  79379. * @param space The space that the returned position is in
  79380. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79381. * @returns The position of the bone
  79382. */
  79383. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79384. /**
  79385. * Copy the position of the bone to a vector3 in local or world space
  79386. * @param space The space that the returned position is in
  79387. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79388. * @param result The vector3 to copy the position to
  79389. */
  79390. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  79391. /**
  79392. * Get the absolute position of the bone (world space)
  79393. * @param mesh The mesh that this bone is attached to
  79394. * @returns The absolute position of the bone
  79395. */
  79396. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  79397. /**
  79398. * Copy the absolute position of the bone (world space) to the result param
  79399. * @param mesh The mesh that this bone is attached to
  79400. * @param result The vector3 to copy the absolute position to
  79401. */
  79402. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  79403. /**
  79404. * Compute the absolute transforms of this bone and its children
  79405. */
  79406. computeAbsoluteTransforms(): void;
  79407. /**
  79408. * Get the world direction from an axis that is in the local space of the bone
  79409. * @param localAxis The local direction that is used to compute the world direction
  79410. * @param mesh The mesh that this bone is attached to
  79411. * @returns The world direction
  79412. */
  79413. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79414. /**
  79415. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  79416. * @param localAxis The local direction that is used to compute the world direction
  79417. * @param mesh The mesh that this bone is attached to
  79418. * @param result The vector3 that the world direction will be copied to
  79419. */
  79420. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79421. /**
  79422. * Get the euler rotation of the bone in local or world space
  79423. * @param space The space that the rotation should be in
  79424. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79425. * @returns The euler rotation
  79426. */
  79427. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79428. /**
  79429. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  79430. * @param space The space that the rotation should be in
  79431. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79432. * @param result The vector3 that the rotation should be copied to
  79433. */
  79434. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79435. /**
  79436. * Get the quaternion rotation of the bone in either local or world space
  79437. * @param space The space that the rotation should be in
  79438. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79439. * @returns The quaternion rotation
  79440. */
  79441. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  79442. /**
  79443. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  79444. * @param space The space that the rotation should be in
  79445. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79446. * @param result The quaternion that the rotation should be copied to
  79447. */
  79448. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  79449. /**
  79450. * Get the rotation matrix of the bone in local or world space
  79451. * @param space The space that the rotation should be in
  79452. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79453. * @returns The rotation matrix
  79454. */
  79455. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  79456. /**
  79457. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  79458. * @param space The space that the rotation should be in
  79459. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79460. * @param result The quaternion that the rotation should be copied to
  79461. */
  79462. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  79463. /**
  79464. * Get the world position of a point that is in the local space of the bone
  79465. * @param position The local position
  79466. * @param mesh The mesh that this bone is attached to
  79467. * @returns The world position
  79468. */
  79469. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79470. /**
  79471. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  79472. * @param position The local position
  79473. * @param mesh The mesh that this bone is attached to
  79474. * @param result The vector3 that the world position should be copied to
  79475. */
  79476. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79477. /**
  79478. * Get the local position of a point that is in world space
  79479. * @param position The world position
  79480. * @param mesh The mesh that this bone is attached to
  79481. * @returns The local position
  79482. */
  79483. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79484. /**
  79485. * Get the local position of a point that is in world space and copy it to the result param
  79486. * @param position The world position
  79487. * @param mesh The mesh that this bone is attached to
  79488. * @param result The vector3 that the local position should be copied to
  79489. */
  79490. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79491. }
  79492. }
  79493. declare module BABYLON {
  79494. /**
  79495. * 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.
  79496. * @see https://doc.babylonjs.com/how_to/transformnode
  79497. */
  79498. export class TransformNode extends Node {
  79499. /**
  79500. * Object will not rotate to face the camera
  79501. */
  79502. static BILLBOARDMODE_NONE: number;
  79503. /**
  79504. * Object will rotate to face the camera but only on the x axis
  79505. */
  79506. static BILLBOARDMODE_X: number;
  79507. /**
  79508. * Object will rotate to face the camera but only on the y axis
  79509. */
  79510. static BILLBOARDMODE_Y: number;
  79511. /**
  79512. * Object will rotate to face the camera but only on the z axis
  79513. */
  79514. static BILLBOARDMODE_Z: number;
  79515. /**
  79516. * Object will rotate to face the camera
  79517. */
  79518. static BILLBOARDMODE_ALL: number;
  79519. /**
  79520. * Object will rotate to face the camera's position instead of orientation
  79521. */
  79522. static BILLBOARDMODE_USE_POSITION: number;
  79523. private _forward;
  79524. private _forwardInverted;
  79525. private _up;
  79526. private _right;
  79527. private _rightInverted;
  79528. private _position;
  79529. private _rotation;
  79530. private _rotationQuaternion;
  79531. protected _scaling: Vector3;
  79532. protected _isDirty: boolean;
  79533. private _transformToBoneReferal;
  79534. private _isAbsoluteSynced;
  79535. private _billboardMode;
  79536. /**
  79537. * Gets or sets the billboard mode. Default is 0.
  79538. *
  79539. * | Value | Type | Description |
  79540. * | --- | --- | --- |
  79541. * | 0 | BILLBOARDMODE_NONE | |
  79542. * | 1 | BILLBOARDMODE_X | |
  79543. * | 2 | BILLBOARDMODE_Y | |
  79544. * | 4 | BILLBOARDMODE_Z | |
  79545. * | 7 | BILLBOARDMODE_ALL | |
  79546. *
  79547. */
  79548. billboardMode: number;
  79549. private _preserveParentRotationForBillboard;
  79550. /**
  79551. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  79552. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  79553. */
  79554. preserveParentRotationForBillboard: boolean;
  79555. /**
  79556. * 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
  79557. */
  79558. scalingDeterminant: number;
  79559. private _infiniteDistance;
  79560. /**
  79561. * Gets or sets the distance of the object to max, often used by skybox
  79562. */
  79563. infiniteDistance: boolean;
  79564. /**
  79565. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  79566. * By default the system will update normals to compensate
  79567. */
  79568. ignoreNonUniformScaling: boolean;
  79569. /**
  79570. * 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
  79571. */
  79572. reIntegrateRotationIntoRotationQuaternion: boolean;
  79573. /** @hidden */
  79574. _poseMatrix: Nullable<Matrix>;
  79575. /** @hidden */
  79576. _localMatrix: Matrix;
  79577. private _usePivotMatrix;
  79578. private _absolutePosition;
  79579. private _absoluteScaling;
  79580. private _absoluteRotationQuaternion;
  79581. private _pivotMatrix;
  79582. private _pivotMatrixInverse;
  79583. protected _postMultiplyPivotMatrix: boolean;
  79584. protected _isWorldMatrixFrozen: boolean;
  79585. /** @hidden */
  79586. _indexInSceneTransformNodesArray: number;
  79587. /**
  79588. * An event triggered after the world matrix is updated
  79589. */
  79590. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  79591. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  79592. /**
  79593. * Gets a string identifying the name of the class
  79594. * @returns "TransformNode" string
  79595. */
  79596. getClassName(): string;
  79597. /**
  79598. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  79599. */
  79600. position: Vector3;
  79601. /**
  79602. * 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)).
  79603. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  79604. */
  79605. rotation: Vector3;
  79606. /**
  79607. * 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)).
  79608. */
  79609. scaling: Vector3;
  79610. /**
  79611. * 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).
  79612. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  79613. */
  79614. rotationQuaternion: Nullable<Quaternion>;
  79615. /**
  79616. * The forward direction of that transform in world space.
  79617. */
  79618. readonly forward: Vector3;
  79619. /**
  79620. * The up direction of that transform in world space.
  79621. */
  79622. readonly up: Vector3;
  79623. /**
  79624. * The right direction of that transform in world space.
  79625. */
  79626. readonly right: Vector3;
  79627. /**
  79628. * Copies the parameter passed Matrix into the mesh Pose matrix.
  79629. * @param matrix the matrix to copy the pose from
  79630. * @returns this TransformNode.
  79631. */
  79632. updatePoseMatrix(matrix: Matrix): TransformNode;
  79633. /**
  79634. * Returns the mesh Pose matrix.
  79635. * @returns the pose matrix
  79636. */
  79637. getPoseMatrix(): Matrix;
  79638. /** @hidden */
  79639. _isSynchronized(): boolean;
  79640. /** @hidden */
  79641. _initCache(): void;
  79642. /**
  79643. * Flag the transform node as dirty (Forcing it to update everything)
  79644. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  79645. * @returns this transform node
  79646. */
  79647. markAsDirty(property: string): TransformNode;
  79648. /**
  79649. * Returns the current mesh absolute position.
  79650. * Returns a Vector3.
  79651. */
  79652. readonly absolutePosition: Vector3;
  79653. /**
  79654. * Returns the current mesh absolute scaling.
  79655. * Returns a Vector3.
  79656. */
  79657. readonly absoluteScaling: Vector3;
  79658. /**
  79659. * Returns the current mesh absolute rotation.
  79660. * Returns a Quaternion.
  79661. */
  79662. readonly absoluteRotationQuaternion: Quaternion;
  79663. /**
  79664. * Sets a new matrix to apply before all other transformation
  79665. * @param matrix defines the transform matrix
  79666. * @returns the current TransformNode
  79667. */
  79668. setPreTransformMatrix(matrix: Matrix): TransformNode;
  79669. /**
  79670. * Sets a new pivot matrix to the current node
  79671. * @param matrix defines the new pivot matrix to use
  79672. * @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
  79673. * @returns the current TransformNode
  79674. */
  79675. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  79676. /**
  79677. * Returns the mesh pivot matrix.
  79678. * Default : Identity.
  79679. * @returns the matrix
  79680. */
  79681. getPivotMatrix(): Matrix;
  79682. /**
  79683. * Instantiate (when possible) or clone that node with its hierarchy
  79684. * @param newParent defines the new parent to use for the instance (or clone)
  79685. * @returns an instance (or a clone) of the current node with its hiearchy
  79686. */
  79687. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  79688. /**
  79689. * Prevents the World matrix to be computed any longer
  79690. * @param newWorldMatrix defines an optional matrix to use as world matrix
  79691. * @returns the TransformNode.
  79692. */
  79693. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  79694. /**
  79695. * Allows back the World matrix computation.
  79696. * @returns the TransformNode.
  79697. */
  79698. unfreezeWorldMatrix(): this;
  79699. /**
  79700. * True if the World matrix has been frozen.
  79701. */
  79702. readonly isWorldMatrixFrozen: boolean;
  79703. /**
  79704. * Retuns the mesh absolute position in the World.
  79705. * @returns a Vector3.
  79706. */
  79707. getAbsolutePosition(): Vector3;
  79708. /**
  79709. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  79710. * @param absolutePosition the absolute position to set
  79711. * @returns the TransformNode.
  79712. */
  79713. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79714. /**
  79715. * Sets the mesh position in its local space.
  79716. * @param vector3 the position to set in localspace
  79717. * @returns the TransformNode.
  79718. */
  79719. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  79720. /**
  79721. * Returns the mesh position in the local space from the current World matrix values.
  79722. * @returns a new Vector3.
  79723. */
  79724. getPositionExpressedInLocalSpace(): Vector3;
  79725. /**
  79726. * Translates the mesh along the passed Vector3 in its local space.
  79727. * @param vector3 the distance to translate in localspace
  79728. * @returns the TransformNode.
  79729. */
  79730. locallyTranslate(vector3: Vector3): TransformNode;
  79731. private static _lookAtVectorCache;
  79732. /**
  79733. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  79734. * @param targetPoint the position (must be in same space as current mesh) to look at
  79735. * @param yawCor optional yaw (y-axis) correction in radians
  79736. * @param pitchCor optional pitch (x-axis) correction in radians
  79737. * @param rollCor optional roll (z-axis) correction in radians
  79738. * @param space the choosen space of the target
  79739. * @returns the TransformNode.
  79740. */
  79741. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  79742. /**
  79743. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79744. * This Vector3 is expressed in the World space.
  79745. * @param localAxis axis to rotate
  79746. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79747. */
  79748. getDirection(localAxis: Vector3): Vector3;
  79749. /**
  79750. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  79751. * localAxis is expressed in the mesh local space.
  79752. * result is computed in the Wordl space from the mesh World matrix.
  79753. * @param localAxis axis to rotate
  79754. * @param result the resulting transformnode
  79755. * @returns this TransformNode.
  79756. */
  79757. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  79758. /**
  79759. * Sets this transform node rotation to the given local axis.
  79760. * @param localAxis the axis in local space
  79761. * @param yawCor optional yaw (y-axis) correction in radians
  79762. * @param pitchCor optional pitch (x-axis) correction in radians
  79763. * @param rollCor optional roll (z-axis) correction in radians
  79764. * @returns this TransformNode
  79765. */
  79766. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  79767. /**
  79768. * Sets a new pivot point to the current node
  79769. * @param point defines the new pivot point to use
  79770. * @param space defines if the point is in world or local space (local by default)
  79771. * @returns the current TransformNode
  79772. */
  79773. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  79774. /**
  79775. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  79776. * @returns the pivot point
  79777. */
  79778. getPivotPoint(): Vector3;
  79779. /**
  79780. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  79781. * @param result the vector3 to store the result
  79782. * @returns this TransformNode.
  79783. */
  79784. getPivotPointToRef(result: Vector3): TransformNode;
  79785. /**
  79786. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  79787. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  79788. */
  79789. getAbsolutePivotPoint(): Vector3;
  79790. /**
  79791. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  79792. * @param result vector3 to store the result
  79793. * @returns this TransformNode.
  79794. */
  79795. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  79796. /**
  79797. * Defines the passed node as the parent of the current node.
  79798. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  79799. * @see https://doc.babylonjs.com/how_to/parenting
  79800. * @param node the node ot set as the parent
  79801. * @returns this TransformNode.
  79802. */
  79803. setParent(node: Nullable<Node>): TransformNode;
  79804. private _nonUniformScaling;
  79805. /**
  79806. * True if the scaling property of this object is non uniform eg. (1,2,1)
  79807. */
  79808. readonly nonUniformScaling: boolean;
  79809. /** @hidden */
  79810. _updateNonUniformScalingState(value: boolean): boolean;
  79811. /**
  79812. * Attach the current TransformNode to another TransformNode associated with a bone
  79813. * @param bone Bone affecting the TransformNode
  79814. * @param affectedTransformNode TransformNode associated with the bone
  79815. * @returns this object
  79816. */
  79817. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  79818. /**
  79819. * Detach the transform node if its associated with a bone
  79820. * @returns this object
  79821. */
  79822. detachFromBone(): TransformNode;
  79823. private static _rotationAxisCache;
  79824. /**
  79825. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  79826. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79827. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79828. * The passed axis is also normalized.
  79829. * @param axis the axis to rotate around
  79830. * @param amount the amount to rotate in radians
  79831. * @param space Space to rotate in (Default: local)
  79832. * @returns the TransformNode.
  79833. */
  79834. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79835. /**
  79836. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  79837. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79838. * The passed axis is also normalized. .
  79839. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  79840. * @param point the point to rotate around
  79841. * @param axis the axis to rotate around
  79842. * @param amount the amount to rotate in radians
  79843. * @returns the TransformNode
  79844. */
  79845. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  79846. /**
  79847. * Translates the mesh along the axis vector for the passed distance in the given space.
  79848. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79849. * @param axis the axis to translate in
  79850. * @param distance the distance to translate
  79851. * @param space Space to rotate in (Default: local)
  79852. * @returns the TransformNode.
  79853. */
  79854. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79855. /**
  79856. * Adds a rotation step to the mesh current rotation.
  79857. * x, y, z are Euler angles expressed in radians.
  79858. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  79859. * This means this rotation is made in the mesh local space only.
  79860. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  79861. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  79862. * ```javascript
  79863. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  79864. * ```
  79865. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  79866. * 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.
  79867. * @param x Rotation to add
  79868. * @param y Rotation to add
  79869. * @param z Rotation to add
  79870. * @returns the TransformNode.
  79871. */
  79872. addRotation(x: number, y: number, z: number): TransformNode;
  79873. /**
  79874. * @hidden
  79875. */
  79876. protected _getEffectiveParent(): Nullable<Node>;
  79877. /**
  79878. * Computes the world matrix of the node
  79879. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79880. * @returns the world matrix
  79881. */
  79882. computeWorldMatrix(force?: boolean): Matrix;
  79883. protected _afterComputeWorldMatrix(): void;
  79884. /**
  79885. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  79886. * @param func callback function to add
  79887. *
  79888. * @returns the TransformNode.
  79889. */
  79890. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79891. /**
  79892. * Removes a registered callback function.
  79893. * @param func callback function to remove
  79894. * @returns the TransformNode.
  79895. */
  79896. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79897. /**
  79898. * Gets the position of the current mesh in camera space
  79899. * @param camera defines the camera to use
  79900. * @returns a position
  79901. */
  79902. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  79903. /**
  79904. * Returns the distance from the mesh to the active camera
  79905. * @param camera defines the camera to use
  79906. * @returns the distance
  79907. */
  79908. getDistanceToCamera(camera?: Nullable<Camera>): number;
  79909. /**
  79910. * Clone the current transform node
  79911. * @param name Name of the new clone
  79912. * @param newParent New parent for the clone
  79913. * @param doNotCloneChildren Do not clone children hierarchy
  79914. * @returns the new transform node
  79915. */
  79916. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  79917. /**
  79918. * Serializes the objects information.
  79919. * @param currentSerializationObject defines the object to serialize in
  79920. * @returns the serialized object
  79921. */
  79922. serialize(currentSerializationObject?: any): any;
  79923. /**
  79924. * Returns a new TransformNode object parsed from the source provided.
  79925. * @param parsedTransformNode is the source.
  79926. * @param scene the scne the object belongs to
  79927. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  79928. * @returns a new TransformNode object parsed from the source provided.
  79929. */
  79930. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  79931. /**
  79932. * Get all child-transformNodes of this node
  79933. * @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
  79934. * @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
  79935. * @returns an array of TransformNode
  79936. */
  79937. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  79938. /**
  79939. * Releases resources associated with this transform node.
  79940. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79941. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79942. */
  79943. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79944. /**
  79945. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79946. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  79947. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  79948. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  79949. * @returns the current mesh
  79950. */
  79951. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  79952. private _syncAbsoluteScalingAndRotation;
  79953. }
  79954. }
  79955. declare module BABYLON {
  79956. /**
  79957. * Defines the types of pose enabled controllers that are supported
  79958. */
  79959. export enum PoseEnabledControllerType {
  79960. /**
  79961. * HTC Vive
  79962. */
  79963. VIVE = 0,
  79964. /**
  79965. * Oculus Rift
  79966. */
  79967. OCULUS = 1,
  79968. /**
  79969. * Windows mixed reality
  79970. */
  79971. WINDOWS = 2,
  79972. /**
  79973. * Samsung gear VR
  79974. */
  79975. GEAR_VR = 3,
  79976. /**
  79977. * Google Daydream
  79978. */
  79979. DAYDREAM = 4,
  79980. /**
  79981. * Generic
  79982. */
  79983. GENERIC = 5
  79984. }
  79985. /**
  79986. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79987. */
  79988. export interface MutableGamepadButton {
  79989. /**
  79990. * Value of the button/trigger
  79991. */
  79992. value: number;
  79993. /**
  79994. * If the button/trigger is currently touched
  79995. */
  79996. touched: boolean;
  79997. /**
  79998. * If the button/trigger is currently pressed
  79999. */
  80000. pressed: boolean;
  80001. }
  80002. /**
  80003. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80004. * @hidden
  80005. */
  80006. export interface ExtendedGamepadButton extends GamepadButton {
  80007. /**
  80008. * If the button/trigger is currently pressed
  80009. */
  80010. readonly pressed: boolean;
  80011. /**
  80012. * If the button/trigger is currently touched
  80013. */
  80014. readonly touched: boolean;
  80015. /**
  80016. * Value of the button/trigger
  80017. */
  80018. readonly value: number;
  80019. }
  80020. /** @hidden */
  80021. export interface _GamePadFactory {
  80022. /**
  80023. * Returns wether or not the current gamepad can be created for this type of controller.
  80024. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80025. * @returns true if it can be created, otherwise false
  80026. */
  80027. canCreate(gamepadInfo: any): boolean;
  80028. /**
  80029. * Creates a new instance of the Gamepad.
  80030. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80031. * @returns the new gamepad instance
  80032. */
  80033. create(gamepadInfo: any): Gamepad;
  80034. }
  80035. /**
  80036. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80037. */
  80038. export class PoseEnabledControllerHelper {
  80039. /** @hidden */
  80040. static _ControllerFactories: _GamePadFactory[];
  80041. /** @hidden */
  80042. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80043. /**
  80044. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80045. * @param vrGamepad the gamepad to initialized
  80046. * @returns a vr controller of the type the gamepad identified as
  80047. */
  80048. static InitiateController(vrGamepad: any): Gamepad;
  80049. }
  80050. /**
  80051. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80052. */
  80053. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80054. /**
  80055. * If the controller is used in a webXR session
  80056. */
  80057. isXR: boolean;
  80058. private _deviceRoomPosition;
  80059. private _deviceRoomRotationQuaternion;
  80060. /**
  80061. * The device position in babylon space
  80062. */
  80063. devicePosition: Vector3;
  80064. /**
  80065. * The device rotation in babylon space
  80066. */
  80067. deviceRotationQuaternion: Quaternion;
  80068. /**
  80069. * The scale factor of the device in babylon space
  80070. */
  80071. deviceScaleFactor: number;
  80072. /**
  80073. * (Likely devicePosition should be used instead) The device position in its room space
  80074. */
  80075. position: Vector3;
  80076. /**
  80077. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80078. */
  80079. rotationQuaternion: Quaternion;
  80080. /**
  80081. * The type of controller (Eg. Windows mixed reality)
  80082. */
  80083. controllerType: PoseEnabledControllerType;
  80084. protected _calculatedPosition: Vector3;
  80085. private _calculatedRotation;
  80086. /**
  80087. * The raw pose from the device
  80088. */
  80089. rawPose: DevicePose;
  80090. private _trackPosition;
  80091. private _maxRotationDistFromHeadset;
  80092. private _draggedRoomRotation;
  80093. /**
  80094. * @hidden
  80095. */
  80096. _disableTrackPosition(fixedPosition: Vector3): void;
  80097. /**
  80098. * Internal, the mesh attached to the controller
  80099. * @hidden
  80100. */
  80101. _mesh: Nullable<AbstractMesh>;
  80102. private _poseControlledCamera;
  80103. private _leftHandSystemQuaternion;
  80104. /**
  80105. * Internal, matrix used to convert room space to babylon space
  80106. * @hidden
  80107. */
  80108. _deviceToWorld: Matrix;
  80109. /**
  80110. * Node to be used when casting a ray from the controller
  80111. * @hidden
  80112. */
  80113. _pointingPoseNode: Nullable<TransformNode>;
  80114. /**
  80115. * Name of the child mesh that can be used to cast a ray from the controller
  80116. */
  80117. static readonly POINTING_POSE: string;
  80118. /**
  80119. * Creates a new PoseEnabledController from a gamepad
  80120. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80121. */
  80122. constructor(browserGamepad: any);
  80123. private _workingMatrix;
  80124. /**
  80125. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80126. */
  80127. update(): void;
  80128. /**
  80129. * Updates only the pose device and mesh without doing any button event checking
  80130. */
  80131. protected _updatePoseAndMesh(): void;
  80132. /**
  80133. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80134. * @param poseData raw pose fromthe device
  80135. */
  80136. updateFromDevice(poseData: DevicePose): void;
  80137. /**
  80138. * @hidden
  80139. */
  80140. _meshAttachedObservable: Observable<AbstractMesh>;
  80141. /**
  80142. * Attaches a mesh to the controller
  80143. * @param mesh the mesh to be attached
  80144. */
  80145. attachToMesh(mesh: AbstractMesh): void;
  80146. /**
  80147. * Attaches the controllers mesh to a camera
  80148. * @param camera the camera the mesh should be attached to
  80149. */
  80150. attachToPoseControlledCamera(camera: TargetCamera): void;
  80151. /**
  80152. * Disposes of the controller
  80153. */
  80154. dispose(): void;
  80155. /**
  80156. * The mesh that is attached to the controller
  80157. */
  80158. readonly mesh: Nullable<AbstractMesh>;
  80159. /**
  80160. * Gets the ray of the controller in the direction the controller is pointing
  80161. * @param length the length the resulting ray should be
  80162. * @returns a ray in the direction the controller is pointing
  80163. */
  80164. getForwardRay(length?: number): Ray;
  80165. }
  80166. }
  80167. declare module BABYLON {
  80168. /**
  80169. * Defines the WebVRController object that represents controllers tracked in 3D space
  80170. */
  80171. export abstract class WebVRController extends PoseEnabledController {
  80172. /**
  80173. * Internal, the default controller model for the controller
  80174. */
  80175. protected _defaultModel: AbstractMesh;
  80176. /**
  80177. * Fired when the trigger state has changed
  80178. */
  80179. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80180. /**
  80181. * Fired when the main button state has changed
  80182. */
  80183. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80184. /**
  80185. * Fired when the secondary button state has changed
  80186. */
  80187. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80188. /**
  80189. * Fired when the pad state has changed
  80190. */
  80191. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80192. /**
  80193. * Fired when controllers stick values have changed
  80194. */
  80195. onPadValuesChangedObservable: Observable<StickValues>;
  80196. /**
  80197. * Array of button availible on the controller
  80198. */
  80199. protected _buttons: Array<MutableGamepadButton>;
  80200. private _onButtonStateChange;
  80201. /**
  80202. * Fired when a controller button's state has changed
  80203. * @param callback the callback containing the button that was modified
  80204. */
  80205. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80206. /**
  80207. * X and Y axis corresponding to the controllers joystick
  80208. */
  80209. pad: StickValues;
  80210. /**
  80211. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80212. */
  80213. hand: string;
  80214. /**
  80215. * The default controller model for the controller
  80216. */
  80217. readonly defaultModel: AbstractMesh;
  80218. /**
  80219. * Creates a new WebVRController from a gamepad
  80220. * @param vrGamepad the gamepad that the WebVRController should be created from
  80221. */
  80222. constructor(vrGamepad: any);
  80223. /**
  80224. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80225. */
  80226. update(): void;
  80227. /**
  80228. * Function to be called when a button is modified
  80229. */
  80230. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80231. /**
  80232. * Loads a mesh and attaches it to the controller
  80233. * @param scene the scene the mesh should be added to
  80234. * @param meshLoaded callback for when the mesh has been loaded
  80235. */
  80236. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80237. private _setButtonValue;
  80238. private _changes;
  80239. private _checkChanges;
  80240. /**
  80241. * Disposes of th webVRCOntroller
  80242. */
  80243. dispose(): void;
  80244. }
  80245. }
  80246. declare module BABYLON {
  80247. /**
  80248. * The HemisphericLight simulates the ambient environment light,
  80249. * so the passed direction is the light reflection direction, not the incoming direction.
  80250. */
  80251. export class HemisphericLight extends Light {
  80252. /**
  80253. * The groundColor is the light in the opposite direction to the one specified during creation.
  80254. * 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.
  80255. */
  80256. groundColor: Color3;
  80257. /**
  80258. * The light reflection direction, not the incoming direction.
  80259. */
  80260. direction: Vector3;
  80261. /**
  80262. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80263. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80264. * The HemisphericLight can't cast shadows.
  80265. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80266. * @param name The friendly name of the light
  80267. * @param direction The direction of the light reflection
  80268. * @param scene The scene the light belongs to
  80269. */
  80270. constructor(name: string, direction: Vector3, scene: Scene);
  80271. protected _buildUniformLayout(): void;
  80272. /**
  80273. * Returns the string "HemisphericLight".
  80274. * @return The class name
  80275. */
  80276. getClassName(): string;
  80277. /**
  80278. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80279. * Returns the updated direction.
  80280. * @param target The target the direction should point to
  80281. * @return The computed direction
  80282. */
  80283. setDirectionToTarget(target: Vector3): Vector3;
  80284. /**
  80285. * Returns the shadow generator associated to the light.
  80286. * @returns Always null for hemispheric lights because it does not support shadows.
  80287. */
  80288. getShadowGenerator(): Nullable<IShadowGenerator>;
  80289. /**
  80290. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80291. * @param effect The effect to update
  80292. * @param lightIndex The index of the light in the effect to update
  80293. * @returns The hemispheric light
  80294. */
  80295. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80296. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  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. * @param useWasUpdatedFlag defines a reserved property
  80301. * @returns the world matrix
  80302. */
  80303. computeWorldMatrix(): Matrix;
  80304. /**
  80305. * Returns the integer 3.
  80306. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80307. */
  80308. getTypeID(): number;
  80309. /**
  80310. * Prepares the list of defines specific to the light type.
  80311. * @param defines the list of defines
  80312. * @param lightIndex defines the index of the light for the effect
  80313. */
  80314. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80315. }
  80316. }
  80317. declare module BABYLON {
  80318. /** @hidden */
  80319. export var vrMultiviewToSingleviewPixelShader: {
  80320. name: string;
  80321. shader: string;
  80322. };
  80323. }
  80324. declare module BABYLON {
  80325. /**
  80326. * Renders to multiple views with a single draw call
  80327. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80328. */
  80329. export class MultiviewRenderTarget extends RenderTargetTexture {
  80330. /**
  80331. * Creates a multiview render target
  80332. * @param scene scene used with the render target
  80333. * @param size the size of the render target (used for each view)
  80334. */
  80335. constructor(scene: Scene, size?: number | {
  80336. width: number;
  80337. height: number;
  80338. } | {
  80339. ratio: number;
  80340. });
  80341. /**
  80342. * @hidden
  80343. * @param faceIndex the face index, if its a cube texture
  80344. */
  80345. _bindFrameBuffer(faceIndex?: number): void;
  80346. /**
  80347. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80348. * @returns the view count
  80349. */
  80350. getViewCount(): number;
  80351. }
  80352. }
  80353. declare module BABYLON {
  80354. /**
  80355. * Represents a camera frustum
  80356. */
  80357. export class Frustum {
  80358. /**
  80359. * Gets the planes representing the frustum
  80360. * @param transform matrix to be applied to the returned planes
  80361. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  80362. */
  80363. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  80364. /**
  80365. * Gets the near frustum plane transformed by the transform matrix
  80366. * @param transform transformation matrix to be applied to the resulting frustum plane
  80367. * @param frustumPlane the resuling frustum plane
  80368. */
  80369. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80370. /**
  80371. * Gets the far frustum plane transformed by the transform matrix
  80372. * @param transform transformation matrix to be applied to the resulting frustum plane
  80373. * @param frustumPlane the resuling frustum plane
  80374. */
  80375. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80376. /**
  80377. * Gets the left frustum plane transformed by the transform matrix
  80378. * @param transform transformation matrix to be applied to the resulting frustum plane
  80379. * @param frustumPlane the resuling frustum plane
  80380. */
  80381. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80382. /**
  80383. * Gets the right frustum plane transformed by the transform matrix
  80384. * @param transform transformation matrix to be applied to the resulting frustum plane
  80385. * @param frustumPlane the resuling frustum plane
  80386. */
  80387. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80388. /**
  80389. * Gets the top frustum plane transformed by the transform matrix
  80390. * @param transform transformation matrix to be applied to the resulting frustum plane
  80391. * @param frustumPlane the resuling frustum plane
  80392. */
  80393. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80394. /**
  80395. * Gets the bottom frustum plane transformed by the transform matrix
  80396. * @param transform transformation matrix to be applied to the resulting frustum plane
  80397. * @param frustumPlane the resuling frustum plane
  80398. */
  80399. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80400. /**
  80401. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  80402. * @param transform transformation matrix to be applied to the resulting frustum planes
  80403. * @param frustumPlanes the resuling frustum planes
  80404. */
  80405. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  80406. }
  80407. }
  80408. declare module BABYLON {
  80409. interface Engine {
  80410. /**
  80411. * Creates a new multiview render target
  80412. * @param width defines the width of the texture
  80413. * @param height defines the height of the texture
  80414. * @returns the created multiview texture
  80415. */
  80416. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80417. /**
  80418. * Binds a multiview framebuffer to be drawn to
  80419. * @param multiviewTexture texture to bind
  80420. */
  80421. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80422. }
  80423. interface Camera {
  80424. /**
  80425. * @hidden
  80426. * 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)
  80427. */
  80428. _useMultiviewToSingleView: boolean;
  80429. /**
  80430. * @hidden
  80431. * 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)
  80432. */
  80433. _multiviewTexture: Nullable<RenderTargetTexture>;
  80434. /**
  80435. * @hidden
  80436. * ensures the multiview texture of the camera exists and has the specified width/height
  80437. * @param width height to set on the multiview texture
  80438. * @param height width to set on the multiview texture
  80439. */
  80440. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80441. }
  80442. interface Scene {
  80443. /** @hidden */
  80444. _transformMatrixR: Matrix;
  80445. /** @hidden */
  80446. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80447. /** @hidden */
  80448. _createMultiviewUbo(): void;
  80449. /** @hidden */
  80450. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80451. /** @hidden */
  80452. _renderMultiviewToSingleView(camera: Camera): void;
  80453. }
  80454. }
  80455. declare module BABYLON {
  80456. /**
  80457. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80458. * This will not be used for webXR as it supports displaying texture arrays directly
  80459. */
  80460. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80461. /**
  80462. * Initializes a VRMultiviewToSingleview
  80463. * @param name name of the post process
  80464. * @param camera camera to be applied to
  80465. * @param scaleFactor scaling factor to the size of the output texture
  80466. */
  80467. constructor(name: string, camera: Camera, scaleFactor: number);
  80468. }
  80469. }
  80470. declare module BABYLON {
  80471. interface Engine {
  80472. /** @hidden */
  80473. _vrDisplay: any;
  80474. /** @hidden */
  80475. _vrSupported: boolean;
  80476. /** @hidden */
  80477. _oldSize: Size;
  80478. /** @hidden */
  80479. _oldHardwareScaleFactor: number;
  80480. /** @hidden */
  80481. _vrExclusivePointerMode: boolean;
  80482. /** @hidden */
  80483. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80484. /** @hidden */
  80485. _onVRDisplayPointerRestricted: () => void;
  80486. /** @hidden */
  80487. _onVRDisplayPointerUnrestricted: () => void;
  80488. /** @hidden */
  80489. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80490. /** @hidden */
  80491. _onVrDisplayDisconnect: Nullable<() => void>;
  80492. /** @hidden */
  80493. _onVrDisplayPresentChange: Nullable<() => void>;
  80494. /**
  80495. * Observable signaled when VR display mode changes
  80496. */
  80497. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80498. /**
  80499. * Observable signaled when VR request present is complete
  80500. */
  80501. onVRRequestPresentComplete: Observable<boolean>;
  80502. /**
  80503. * Observable signaled when VR request present starts
  80504. */
  80505. onVRRequestPresentStart: Observable<Engine>;
  80506. /**
  80507. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80508. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80509. */
  80510. isInVRExclusivePointerMode: boolean;
  80511. /**
  80512. * Gets a boolean indicating if a webVR device was detected
  80513. * @returns true if a webVR device was detected
  80514. */
  80515. isVRDevicePresent(): boolean;
  80516. /**
  80517. * Gets the current webVR device
  80518. * @returns the current webVR device (or null)
  80519. */
  80520. getVRDevice(): any;
  80521. /**
  80522. * Initializes a webVR display and starts listening to display change events
  80523. * The onVRDisplayChangedObservable will be notified upon these changes
  80524. * @returns A promise containing a VRDisplay and if vr is supported
  80525. */
  80526. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80527. /** @hidden */
  80528. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80529. /**
  80530. * Call this function to switch to webVR mode
  80531. * Will do nothing if webVR is not supported or if there is no webVR device
  80532. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80533. */
  80534. enableVR(): void;
  80535. /** @hidden */
  80536. _onVRFullScreenTriggered(): void;
  80537. }
  80538. }
  80539. declare module BABYLON {
  80540. /**
  80541. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80542. * IMPORTANT!! The data is right-hand data.
  80543. * @export
  80544. * @interface DevicePose
  80545. */
  80546. export interface DevicePose {
  80547. /**
  80548. * The position of the device, values in array are [x,y,z].
  80549. */
  80550. readonly position: Nullable<Float32Array>;
  80551. /**
  80552. * The linearVelocity of the device, values in array are [x,y,z].
  80553. */
  80554. readonly linearVelocity: Nullable<Float32Array>;
  80555. /**
  80556. * The linearAcceleration of the device, values in array are [x,y,z].
  80557. */
  80558. readonly linearAcceleration: Nullable<Float32Array>;
  80559. /**
  80560. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80561. */
  80562. readonly orientation: Nullable<Float32Array>;
  80563. /**
  80564. * The angularVelocity of the device, values in array are [x,y,z].
  80565. */
  80566. readonly angularVelocity: Nullable<Float32Array>;
  80567. /**
  80568. * The angularAcceleration of the device, values in array are [x,y,z].
  80569. */
  80570. readonly angularAcceleration: Nullable<Float32Array>;
  80571. }
  80572. /**
  80573. * Interface representing a pose controlled object in Babylon.
  80574. * A pose controlled object has both regular pose values as well as pose values
  80575. * from an external device such as a VR head mounted display
  80576. */
  80577. export interface PoseControlled {
  80578. /**
  80579. * The position of the object in babylon space.
  80580. */
  80581. position: Vector3;
  80582. /**
  80583. * The rotation quaternion of the object in babylon space.
  80584. */
  80585. rotationQuaternion: Quaternion;
  80586. /**
  80587. * The position of the device in babylon space.
  80588. */
  80589. devicePosition?: Vector3;
  80590. /**
  80591. * The rotation quaternion of the device in babylon space.
  80592. */
  80593. deviceRotationQuaternion: Quaternion;
  80594. /**
  80595. * The raw pose coming from the device.
  80596. */
  80597. rawPose: Nullable<DevicePose>;
  80598. /**
  80599. * The scale of the device to be used when translating from device space to babylon space.
  80600. */
  80601. deviceScaleFactor: number;
  80602. /**
  80603. * Updates the poseControlled values based on the input device pose.
  80604. * @param poseData the pose data to update the object with
  80605. */
  80606. updateFromDevice(poseData: DevicePose): void;
  80607. }
  80608. /**
  80609. * Set of options to customize the webVRCamera
  80610. */
  80611. export interface WebVROptions {
  80612. /**
  80613. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80614. */
  80615. trackPosition?: boolean;
  80616. /**
  80617. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80618. */
  80619. positionScale?: number;
  80620. /**
  80621. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80622. */
  80623. displayName?: string;
  80624. /**
  80625. * Should the native controller meshes be initialized. (default: true)
  80626. */
  80627. controllerMeshes?: boolean;
  80628. /**
  80629. * Creating a default HemiLight only on controllers. (default: true)
  80630. */
  80631. defaultLightingOnControllers?: boolean;
  80632. /**
  80633. * If you don't want to use the default VR button of the helper. (default: false)
  80634. */
  80635. useCustomVRButton?: boolean;
  80636. /**
  80637. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80638. */
  80639. customVRButton?: HTMLButtonElement;
  80640. /**
  80641. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80642. */
  80643. rayLength?: number;
  80644. /**
  80645. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80646. */
  80647. defaultHeight?: number;
  80648. /**
  80649. * If multiview should be used if availible (default: false)
  80650. */
  80651. useMultiview?: boolean;
  80652. }
  80653. /**
  80654. * This represents a WebVR camera.
  80655. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80656. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80657. */
  80658. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80659. private webVROptions;
  80660. /**
  80661. * @hidden
  80662. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80663. */
  80664. _vrDevice: any;
  80665. /**
  80666. * The rawPose of the vrDevice.
  80667. */
  80668. rawPose: Nullable<DevicePose>;
  80669. private _onVREnabled;
  80670. private _specsVersion;
  80671. private _attached;
  80672. private _frameData;
  80673. protected _descendants: Array<Node>;
  80674. private _deviceRoomPosition;
  80675. /** @hidden */
  80676. _deviceRoomRotationQuaternion: Quaternion;
  80677. private _standingMatrix;
  80678. /**
  80679. * Represents device position in babylon space.
  80680. */
  80681. devicePosition: Vector3;
  80682. /**
  80683. * Represents device rotation in babylon space.
  80684. */
  80685. deviceRotationQuaternion: Quaternion;
  80686. /**
  80687. * The scale of the device to be used when translating from device space to babylon space.
  80688. */
  80689. deviceScaleFactor: number;
  80690. private _deviceToWorld;
  80691. private _worldToDevice;
  80692. /**
  80693. * References to the webVR controllers for the vrDevice.
  80694. */
  80695. controllers: Array<WebVRController>;
  80696. /**
  80697. * Emits an event when a controller is attached.
  80698. */
  80699. onControllersAttachedObservable: Observable<WebVRController[]>;
  80700. /**
  80701. * Emits an event when a controller's mesh has been loaded;
  80702. */
  80703. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80704. /**
  80705. * Emits an event when the HMD's pose has been updated.
  80706. */
  80707. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80708. private _poseSet;
  80709. /**
  80710. * If the rig cameras be used as parent instead of this camera.
  80711. */
  80712. rigParenting: boolean;
  80713. private _lightOnControllers;
  80714. private _defaultHeight?;
  80715. /**
  80716. * Instantiates a WebVRFreeCamera.
  80717. * @param name The name of the WebVRFreeCamera
  80718. * @param position The starting anchor position for the camera
  80719. * @param scene The scene the camera belongs to
  80720. * @param webVROptions a set of customizable options for the webVRCamera
  80721. */
  80722. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80723. /**
  80724. * Gets the device distance from the ground in meters.
  80725. * @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.
  80726. */
  80727. deviceDistanceToRoomGround(): number;
  80728. /**
  80729. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80730. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80731. */
  80732. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80733. /**
  80734. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80735. * @returns A promise with a boolean set to if the standing matrix is supported.
  80736. */
  80737. useStandingMatrixAsync(): Promise<boolean>;
  80738. /**
  80739. * Disposes the camera
  80740. */
  80741. dispose(): void;
  80742. /**
  80743. * Gets a vrController by name.
  80744. * @param name The name of the controller to retreive
  80745. * @returns the controller matching the name specified or null if not found
  80746. */
  80747. getControllerByName(name: string): Nullable<WebVRController>;
  80748. private _leftController;
  80749. /**
  80750. * The controller corresponding to the users left hand.
  80751. */
  80752. readonly leftController: Nullable<WebVRController>;
  80753. private _rightController;
  80754. /**
  80755. * The controller corresponding to the users right hand.
  80756. */
  80757. readonly rightController: Nullable<WebVRController>;
  80758. /**
  80759. * Casts a ray forward from the vrCamera's gaze.
  80760. * @param length Length of the ray (default: 100)
  80761. * @returns the ray corresponding to the gaze
  80762. */
  80763. getForwardRay(length?: number): Ray;
  80764. /**
  80765. * @hidden
  80766. * Updates the camera based on device's frame data
  80767. */
  80768. _checkInputs(): void;
  80769. /**
  80770. * Updates the poseControlled values based on the input device pose.
  80771. * @param poseData Pose coming from the device
  80772. */
  80773. updateFromDevice(poseData: DevicePose): void;
  80774. private _htmlElementAttached;
  80775. private _detachIfAttached;
  80776. /**
  80777. * WebVR's attach control will start broadcasting frames to the device.
  80778. * Note that in certain browsers (chrome for example) this function must be called
  80779. * within a user-interaction callback. Example:
  80780. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80781. *
  80782. * @param element html element to attach the vrDevice to
  80783. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80784. */
  80785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80786. /**
  80787. * Detaches the camera from the html element and disables VR
  80788. *
  80789. * @param element html element to detach from
  80790. */
  80791. detachControl(element: HTMLElement): void;
  80792. /**
  80793. * @returns the name of this class
  80794. */
  80795. getClassName(): string;
  80796. /**
  80797. * Calls resetPose on the vrDisplay
  80798. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80799. */
  80800. resetToCurrentRotation(): void;
  80801. /**
  80802. * @hidden
  80803. * Updates the rig cameras (left and right eye)
  80804. */
  80805. _updateRigCameras(): void;
  80806. private _workingVector;
  80807. private _oneVector;
  80808. private _workingMatrix;
  80809. private updateCacheCalled;
  80810. private _correctPositionIfNotTrackPosition;
  80811. /**
  80812. * @hidden
  80813. * Updates the cached values of the camera
  80814. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80815. */
  80816. _updateCache(ignoreParentClass?: boolean): void;
  80817. /**
  80818. * @hidden
  80819. * Get current device position in babylon world
  80820. */
  80821. _computeDevicePosition(): void;
  80822. /**
  80823. * Updates the current device position and rotation in the babylon world
  80824. */
  80825. update(): void;
  80826. /**
  80827. * @hidden
  80828. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80829. * @returns an identity matrix
  80830. */
  80831. _getViewMatrix(): Matrix;
  80832. private _tmpMatrix;
  80833. /**
  80834. * This function is called by the two RIG cameras.
  80835. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80836. * @hidden
  80837. */
  80838. _getWebVRViewMatrix(): Matrix;
  80839. /** @hidden */
  80840. _getWebVRProjectionMatrix(): Matrix;
  80841. private _onGamepadConnectedObserver;
  80842. private _onGamepadDisconnectedObserver;
  80843. private _updateCacheWhenTrackingDisabledObserver;
  80844. /**
  80845. * Initializes the controllers and their meshes
  80846. */
  80847. initControllers(): void;
  80848. }
  80849. }
  80850. declare module BABYLON {
  80851. /**
  80852. * Size options for a post process
  80853. */
  80854. export type PostProcessOptions = {
  80855. width: number;
  80856. height: number;
  80857. };
  80858. /**
  80859. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80860. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80861. */
  80862. export class PostProcess {
  80863. /** Name of the PostProcess. */
  80864. name: string;
  80865. /**
  80866. * Gets or sets the unique id of the post process
  80867. */
  80868. uniqueId: number;
  80869. /**
  80870. * Width of the texture to apply the post process on
  80871. */
  80872. width: number;
  80873. /**
  80874. * Height of the texture to apply the post process on
  80875. */
  80876. height: number;
  80877. /**
  80878. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80879. * @hidden
  80880. */
  80881. _outputTexture: Nullable<InternalTexture>;
  80882. /**
  80883. * Sampling mode used by the shader
  80884. * See https://doc.babylonjs.com/classes/3.1/texture
  80885. */
  80886. renderTargetSamplingMode: number;
  80887. /**
  80888. * Clear color to use when screen clearing
  80889. */
  80890. clearColor: Color4;
  80891. /**
  80892. * If the buffer needs to be cleared before applying the post process. (default: true)
  80893. * Should be set to false if shader will overwrite all previous pixels.
  80894. */
  80895. autoClear: boolean;
  80896. /**
  80897. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80898. */
  80899. alphaMode: number;
  80900. /**
  80901. * Sets the setAlphaBlendConstants of the babylon engine
  80902. */
  80903. alphaConstants: Color4;
  80904. /**
  80905. * Animations to be used for the post processing
  80906. */
  80907. animations: Animation[];
  80908. /**
  80909. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80910. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80911. */
  80912. enablePixelPerfectMode: boolean;
  80913. /**
  80914. * Force the postprocess to be applied without taking in account viewport
  80915. */
  80916. forceFullscreenViewport: boolean;
  80917. /**
  80918. * List of inspectable custom properties (used by the Inspector)
  80919. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80920. */
  80921. inspectableCustomProperties: IInspectable[];
  80922. /**
  80923. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80924. *
  80925. * | Value | Type | Description |
  80926. * | ----- | ----------------------------------- | ----------- |
  80927. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80928. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80929. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80930. *
  80931. */
  80932. scaleMode: number;
  80933. /**
  80934. * Force textures to be a power of two (default: false)
  80935. */
  80936. alwaysForcePOT: boolean;
  80937. private _samples;
  80938. /**
  80939. * Number of sample textures (default: 1)
  80940. */
  80941. samples: number;
  80942. /**
  80943. * Modify the scale of the post process to be the same as the viewport (default: false)
  80944. */
  80945. adaptScaleToCurrentViewport: boolean;
  80946. private _camera;
  80947. private _scene;
  80948. private _engine;
  80949. private _options;
  80950. private _reusable;
  80951. private _textureType;
  80952. /**
  80953. * Smart array of input and output textures for the post process.
  80954. * @hidden
  80955. */
  80956. _textures: SmartArray<InternalTexture>;
  80957. /**
  80958. * The index in _textures that corresponds to the output texture.
  80959. * @hidden
  80960. */
  80961. _currentRenderTextureInd: number;
  80962. private _effect;
  80963. private _samplers;
  80964. private _fragmentUrl;
  80965. private _vertexUrl;
  80966. private _parameters;
  80967. private _scaleRatio;
  80968. protected _indexParameters: any;
  80969. private _shareOutputWithPostProcess;
  80970. private _texelSize;
  80971. private _forcedOutputTexture;
  80972. /**
  80973. * Returns the fragment url or shader name used in the post process.
  80974. * @returns the fragment url or name in the shader store.
  80975. */
  80976. getEffectName(): string;
  80977. /**
  80978. * An event triggered when the postprocess is activated.
  80979. */
  80980. onActivateObservable: Observable<Camera>;
  80981. private _onActivateObserver;
  80982. /**
  80983. * A function that is added to the onActivateObservable
  80984. */
  80985. onActivate: Nullable<(camera: Camera) => void>;
  80986. /**
  80987. * An event triggered when the postprocess changes its size.
  80988. */
  80989. onSizeChangedObservable: Observable<PostProcess>;
  80990. private _onSizeChangedObserver;
  80991. /**
  80992. * A function that is added to the onSizeChangedObservable
  80993. */
  80994. onSizeChanged: (postProcess: PostProcess) => void;
  80995. /**
  80996. * An event triggered when the postprocess applies its effect.
  80997. */
  80998. onApplyObservable: Observable<Effect>;
  80999. private _onApplyObserver;
  81000. /**
  81001. * A function that is added to the onApplyObservable
  81002. */
  81003. onApply: (effect: Effect) => void;
  81004. /**
  81005. * An event triggered before rendering the postprocess
  81006. */
  81007. onBeforeRenderObservable: Observable<Effect>;
  81008. private _onBeforeRenderObserver;
  81009. /**
  81010. * A function that is added to the onBeforeRenderObservable
  81011. */
  81012. onBeforeRender: (effect: Effect) => void;
  81013. /**
  81014. * An event triggered after rendering the postprocess
  81015. */
  81016. onAfterRenderObservable: Observable<Effect>;
  81017. private _onAfterRenderObserver;
  81018. /**
  81019. * A function that is added to the onAfterRenderObservable
  81020. */
  81021. onAfterRender: (efect: Effect) => void;
  81022. /**
  81023. * 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
  81024. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81025. */
  81026. inputTexture: InternalTexture;
  81027. /**
  81028. * Gets the camera which post process is applied to.
  81029. * @returns The camera the post process is applied to.
  81030. */
  81031. getCamera(): Camera;
  81032. /**
  81033. * Gets the texel size of the postprocess.
  81034. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81035. */
  81036. readonly texelSize: Vector2;
  81037. /**
  81038. * Creates a new instance PostProcess
  81039. * @param name The name of the PostProcess.
  81040. * @param fragmentUrl The url of the fragment shader to be used.
  81041. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81042. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81043. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81044. * @param camera The camera to apply the render pass to.
  81045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81046. * @param engine The engine which the post process will be applied. (default: current engine)
  81047. * @param reusable If the post process can be reused on the same frame. (default: false)
  81048. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81049. * @param textureType Type of textures used when performing the post process. (default: 0)
  81050. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81051. * @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
  81052. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81053. */
  81054. constructor(
  81055. /** Name of the PostProcess. */
  81056. 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);
  81057. /**
  81058. * Gets a string idenfifying the name of the class
  81059. * @returns "PostProcess" string
  81060. */
  81061. getClassName(): string;
  81062. /**
  81063. * Gets the engine which this post process belongs to.
  81064. * @returns The engine the post process was enabled with.
  81065. */
  81066. getEngine(): Engine;
  81067. /**
  81068. * The effect that is created when initializing the post process.
  81069. * @returns The created effect corresponding the the postprocess.
  81070. */
  81071. getEffect(): Effect;
  81072. /**
  81073. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81074. * @param postProcess The post process to share the output with.
  81075. * @returns This post process.
  81076. */
  81077. shareOutputWith(postProcess: PostProcess): PostProcess;
  81078. /**
  81079. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81080. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81081. */
  81082. useOwnOutput(): void;
  81083. /**
  81084. * Updates the effect with the current post process compile time values and recompiles the shader.
  81085. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81086. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81087. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81088. * @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
  81089. * @param onCompiled Called when the shader has been compiled.
  81090. * @param onError Called if there is an error when compiling a shader.
  81091. */
  81092. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81093. /**
  81094. * The post process is reusable if it can be used multiple times within one frame.
  81095. * @returns If the post process is reusable
  81096. */
  81097. isReusable(): boolean;
  81098. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81099. markTextureDirty(): void;
  81100. /**
  81101. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81102. * 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.
  81103. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81104. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81105. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81106. * @returns The target texture that was bound to be written to.
  81107. */
  81108. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81109. /**
  81110. * If the post process is supported.
  81111. */
  81112. readonly isSupported: boolean;
  81113. /**
  81114. * The aspect ratio of the output texture.
  81115. */
  81116. readonly aspectRatio: number;
  81117. /**
  81118. * Get a value indicating if the post-process is ready to be used
  81119. * @returns true if the post-process is ready (shader is compiled)
  81120. */
  81121. isReady(): boolean;
  81122. /**
  81123. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81124. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81125. */
  81126. apply(): Nullable<Effect>;
  81127. private _disposeTextures;
  81128. /**
  81129. * Disposes the post process.
  81130. * @param camera The camera to dispose the post process on.
  81131. */
  81132. dispose(camera?: Camera): void;
  81133. }
  81134. }
  81135. declare module BABYLON {
  81136. /** @hidden */
  81137. export var kernelBlurVaryingDeclaration: {
  81138. name: string;
  81139. shader: string;
  81140. };
  81141. }
  81142. declare module BABYLON {
  81143. /** @hidden */
  81144. export var kernelBlurFragment: {
  81145. name: string;
  81146. shader: string;
  81147. };
  81148. }
  81149. declare module BABYLON {
  81150. /** @hidden */
  81151. export var kernelBlurFragment2: {
  81152. name: string;
  81153. shader: string;
  81154. };
  81155. }
  81156. declare module BABYLON {
  81157. /** @hidden */
  81158. export var kernelBlurPixelShader: {
  81159. name: string;
  81160. shader: string;
  81161. };
  81162. }
  81163. declare module BABYLON {
  81164. /** @hidden */
  81165. export var kernelBlurVertex: {
  81166. name: string;
  81167. shader: string;
  81168. };
  81169. }
  81170. declare module BABYLON {
  81171. /** @hidden */
  81172. export var kernelBlurVertexShader: {
  81173. name: string;
  81174. shader: string;
  81175. };
  81176. }
  81177. declare module BABYLON {
  81178. /**
  81179. * The Blur Post Process which blurs an image based on a kernel and direction.
  81180. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81181. */
  81182. export class BlurPostProcess extends PostProcess {
  81183. /** The direction in which to blur the image. */
  81184. direction: Vector2;
  81185. private blockCompilation;
  81186. protected _kernel: number;
  81187. protected _idealKernel: number;
  81188. protected _packedFloat: boolean;
  81189. private _staticDefines;
  81190. /**
  81191. * Sets the length in pixels of the blur sample region
  81192. */
  81193. /**
  81194. * Gets the length in pixels of the blur sample region
  81195. */
  81196. kernel: number;
  81197. /**
  81198. * Sets wether or not the blur needs to unpack/repack floats
  81199. */
  81200. /**
  81201. * Gets wether or not the blur is unpacking/repacking floats
  81202. */
  81203. packedFloat: boolean;
  81204. /**
  81205. * Creates a new instance BlurPostProcess
  81206. * @param name The name of the effect.
  81207. * @param direction The direction in which to blur the image.
  81208. * @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.
  81209. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81210. * @param camera The camera to apply the render pass to.
  81211. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81212. * @param engine The engine which the post process will be applied. (default: current engine)
  81213. * @param reusable If the post process can be reused on the same frame. (default: false)
  81214. * @param textureType Type of textures used when performing the post process. (default: 0)
  81215. * @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)
  81216. */
  81217. constructor(name: string,
  81218. /** The direction in which to blur the image. */
  81219. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81220. /**
  81221. * Updates the effect with the current post process compile time values and recompiles the shader.
  81222. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81223. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81224. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81225. * @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
  81226. * @param onCompiled Called when the shader has been compiled.
  81227. * @param onError Called if there is an error when compiling a shader.
  81228. */
  81229. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81230. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81231. /**
  81232. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81233. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81234. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81235. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81236. * The gaps between physical kernels are compensated for in the weighting of the samples
  81237. * @param idealKernel Ideal blur kernel.
  81238. * @return Nearest best kernel.
  81239. */
  81240. protected _nearestBestKernel(idealKernel: number): number;
  81241. /**
  81242. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81243. * @param x The point on the Gaussian distribution to sample.
  81244. * @return the value of the Gaussian function at x.
  81245. */
  81246. protected _gaussianWeight(x: number): number;
  81247. /**
  81248. * Generates a string that can be used as a floating point number in GLSL.
  81249. * @param x Value to print.
  81250. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81251. * @return GLSL float string.
  81252. */
  81253. protected _glslFloat(x: number, decimalFigures?: number): string;
  81254. }
  81255. }
  81256. declare module BABYLON {
  81257. /**
  81258. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81259. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81260. * You can then easily use it as a reflectionTexture on a flat surface.
  81261. * In case the surface is not a plane, please consider relying on reflection probes.
  81262. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81263. */
  81264. export class MirrorTexture extends RenderTargetTexture {
  81265. private scene;
  81266. /**
  81267. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81268. * 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.
  81269. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81270. */
  81271. mirrorPlane: Plane;
  81272. /**
  81273. * Define the blur ratio used to blur the reflection if needed.
  81274. */
  81275. blurRatio: number;
  81276. /**
  81277. * Define the adaptive blur kernel used to blur the reflection if needed.
  81278. * This will autocompute the closest best match for the `blurKernel`
  81279. */
  81280. adaptiveBlurKernel: number;
  81281. /**
  81282. * Define the blur kernel used to blur the reflection if needed.
  81283. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81284. */
  81285. blurKernel: number;
  81286. /**
  81287. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81288. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81289. */
  81290. blurKernelX: number;
  81291. /**
  81292. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81293. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81294. */
  81295. blurKernelY: number;
  81296. private _autoComputeBlurKernel;
  81297. protected _onRatioRescale(): void;
  81298. private _updateGammaSpace;
  81299. private _imageProcessingConfigChangeObserver;
  81300. private _transformMatrix;
  81301. private _mirrorMatrix;
  81302. private _savedViewMatrix;
  81303. private _blurX;
  81304. private _blurY;
  81305. private _adaptiveBlurKernel;
  81306. private _blurKernelX;
  81307. private _blurKernelY;
  81308. private _blurRatio;
  81309. /**
  81310. * Instantiates a Mirror Texture.
  81311. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81312. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81313. * You can then easily use it as a reflectionTexture on a flat surface.
  81314. * In case the surface is not a plane, please consider relying on reflection probes.
  81315. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81316. * @param name
  81317. * @param size
  81318. * @param scene
  81319. * @param generateMipMaps
  81320. * @param type
  81321. * @param samplingMode
  81322. * @param generateDepthBuffer
  81323. */
  81324. constructor(name: string, size: number | {
  81325. width: number;
  81326. height: number;
  81327. } | {
  81328. ratio: number;
  81329. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81330. private _preparePostProcesses;
  81331. /**
  81332. * Clone the mirror texture.
  81333. * @returns the cloned texture
  81334. */
  81335. clone(): MirrorTexture;
  81336. /**
  81337. * Serialize the texture to a JSON representation you could use in Parse later on
  81338. * @returns the serialized JSON representation
  81339. */
  81340. serialize(): any;
  81341. /**
  81342. * Dispose the texture and release its associated resources.
  81343. */
  81344. dispose(): void;
  81345. }
  81346. }
  81347. declare module BABYLON {
  81348. /**
  81349. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81350. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81351. */
  81352. export class Texture extends BaseTexture {
  81353. /**
  81354. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  81355. */
  81356. static SerializeBuffers: boolean;
  81357. /** @hidden */
  81358. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81359. /** @hidden */
  81360. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81361. /** @hidden */
  81362. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81363. /** nearest is mag = nearest and min = nearest and mip = linear */
  81364. static readonly NEAREST_SAMPLINGMODE: number;
  81365. /** nearest is mag = nearest and min = nearest and mip = linear */
  81366. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81367. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81368. static readonly BILINEAR_SAMPLINGMODE: number;
  81369. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81370. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81371. /** Trilinear is mag = linear and min = linear and mip = linear */
  81372. static readonly TRILINEAR_SAMPLINGMODE: number;
  81373. /** Trilinear is mag = linear and min = linear and mip = linear */
  81374. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81375. /** mag = nearest and min = nearest and mip = nearest */
  81376. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81377. /** mag = nearest and min = linear and mip = nearest */
  81378. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81379. /** mag = nearest and min = linear and mip = linear */
  81380. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81381. /** mag = nearest and min = linear and mip = none */
  81382. static readonly NEAREST_LINEAR: number;
  81383. /** mag = nearest and min = nearest and mip = none */
  81384. static readonly NEAREST_NEAREST: number;
  81385. /** mag = linear and min = nearest and mip = nearest */
  81386. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81387. /** mag = linear and min = nearest and mip = linear */
  81388. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81389. /** mag = linear and min = linear and mip = none */
  81390. static readonly LINEAR_LINEAR: number;
  81391. /** mag = linear and min = nearest and mip = none */
  81392. static readonly LINEAR_NEAREST: number;
  81393. /** Explicit coordinates mode */
  81394. static readonly EXPLICIT_MODE: number;
  81395. /** Spherical coordinates mode */
  81396. static readonly SPHERICAL_MODE: number;
  81397. /** Planar coordinates mode */
  81398. static readonly PLANAR_MODE: number;
  81399. /** Cubic coordinates mode */
  81400. static readonly CUBIC_MODE: number;
  81401. /** Projection coordinates mode */
  81402. static readonly PROJECTION_MODE: number;
  81403. /** Inverse Cubic coordinates mode */
  81404. static readonly SKYBOX_MODE: number;
  81405. /** Inverse Cubic coordinates mode */
  81406. static readonly INVCUBIC_MODE: number;
  81407. /** Equirectangular coordinates mode */
  81408. static readonly EQUIRECTANGULAR_MODE: number;
  81409. /** Equirectangular Fixed coordinates mode */
  81410. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81411. /** Equirectangular Fixed Mirrored coordinates mode */
  81412. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81413. /** Texture is not repeating outside of 0..1 UVs */
  81414. static readonly CLAMP_ADDRESSMODE: number;
  81415. /** Texture is repeating outside of 0..1 UVs */
  81416. static readonly WRAP_ADDRESSMODE: number;
  81417. /** Texture is repeating and mirrored */
  81418. static readonly MIRROR_ADDRESSMODE: number;
  81419. /**
  81420. * 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
  81421. */
  81422. static UseSerializedUrlIfAny: boolean;
  81423. /**
  81424. * Define the url of the texture.
  81425. */
  81426. url: Nullable<string>;
  81427. /**
  81428. * Define an offset on the texture to offset the u coordinates of the UVs
  81429. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81430. */
  81431. uOffset: number;
  81432. /**
  81433. * Define an offset on the texture to offset the v coordinates of the UVs
  81434. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81435. */
  81436. vOffset: number;
  81437. /**
  81438. * Define an offset on the texture to scale the u coordinates of the UVs
  81439. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81440. */
  81441. uScale: number;
  81442. /**
  81443. * Define an offset on the texture to scale the v coordinates of the UVs
  81444. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81445. */
  81446. vScale: number;
  81447. /**
  81448. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81449. * @see http://doc.babylonjs.com/how_to/more_materials
  81450. */
  81451. uAng: number;
  81452. /**
  81453. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81454. * @see http://doc.babylonjs.com/how_to/more_materials
  81455. */
  81456. vAng: number;
  81457. /**
  81458. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81459. * @see http://doc.babylonjs.com/how_to/more_materials
  81460. */
  81461. wAng: number;
  81462. /**
  81463. * Defines the center of rotation (U)
  81464. */
  81465. uRotationCenter: number;
  81466. /**
  81467. * Defines the center of rotation (V)
  81468. */
  81469. vRotationCenter: number;
  81470. /**
  81471. * Defines the center of rotation (W)
  81472. */
  81473. wRotationCenter: number;
  81474. /**
  81475. * Are mip maps generated for this texture or not.
  81476. */
  81477. readonly noMipmap: boolean;
  81478. /**
  81479. * List of inspectable custom properties (used by the Inspector)
  81480. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81481. */
  81482. inspectableCustomProperties: Nullable<IInspectable[]>;
  81483. private _noMipmap;
  81484. /** @hidden */
  81485. _invertY: boolean;
  81486. private _rowGenerationMatrix;
  81487. private _cachedTextureMatrix;
  81488. private _projectionModeMatrix;
  81489. private _t0;
  81490. private _t1;
  81491. private _t2;
  81492. private _cachedUOffset;
  81493. private _cachedVOffset;
  81494. private _cachedUScale;
  81495. private _cachedVScale;
  81496. private _cachedUAng;
  81497. private _cachedVAng;
  81498. private _cachedWAng;
  81499. private _cachedProjectionMatrixId;
  81500. private _cachedCoordinatesMode;
  81501. /** @hidden */
  81502. protected _initialSamplingMode: number;
  81503. /** @hidden */
  81504. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  81505. private _deleteBuffer;
  81506. protected _format: Nullable<number>;
  81507. private _delayedOnLoad;
  81508. private _delayedOnError;
  81509. /**
  81510. * Observable triggered once the texture has been loaded.
  81511. */
  81512. onLoadObservable: Observable<Texture>;
  81513. protected _isBlocking: boolean;
  81514. /**
  81515. * Is the texture preventing material to render while loading.
  81516. * If false, a default texture will be used instead of the loading one during the preparation step.
  81517. */
  81518. isBlocking: boolean;
  81519. /**
  81520. * Get the current sampling mode associated with the texture.
  81521. */
  81522. readonly samplingMode: number;
  81523. /**
  81524. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81525. */
  81526. readonly invertY: boolean;
  81527. /**
  81528. * Instantiates a new texture.
  81529. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81530. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81531. * @param url define the url of the picture to load as a texture
  81532. * @param scene define the scene or engine the texture will belong to
  81533. * @param noMipmap define if the texture will require mip maps or not
  81534. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81535. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81536. * @param onLoad define a callback triggered when the texture has been loaded
  81537. * @param onError define a callback triggered when an error occurred during the loading session
  81538. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81539. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81540. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81541. */
  81542. 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);
  81543. /**
  81544. * Update the url (and optional buffer) of this texture if url was null during construction.
  81545. * @param url the url of the texture
  81546. * @param buffer the buffer of the texture (defaults to null)
  81547. * @param onLoad callback called when the texture is loaded (defaults to null)
  81548. */
  81549. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81550. /**
  81551. * Finish the loading sequence of a texture flagged as delayed load.
  81552. * @hidden
  81553. */
  81554. delayLoad(): void;
  81555. private _prepareRowForTextureGeneration;
  81556. /**
  81557. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81558. * @returns the transform matrix of the texture.
  81559. */
  81560. getTextureMatrix(): Matrix;
  81561. /**
  81562. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81563. * @returns The reflection texture transform
  81564. */
  81565. getReflectionTextureMatrix(): Matrix;
  81566. /**
  81567. * Clones the texture.
  81568. * @returns the cloned texture
  81569. */
  81570. clone(): Texture;
  81571. /**
  81572. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81573. * @returns The JSON representation of the texture
  81574. */
  81575. serialize(): any;
  81576. /**
  81577. * Get the current class name of the texture useful for serialization or dynamic coding.
  81578. * @returns "Texture"
  81579. */
  81580. getClassName(): string;
  81581. /**
  81582. * Dispose the texture and release its associated resources.
  81583. */
  81584. dispose(): void;
  81585. /**
  81586. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81587. * @param parsedTexture Define the JSON representation of the texture
  81588. * @param scene Define the scene the parsed texture should be instantiated in
  81589. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81590. * @returns The parsed texture if successful
  81591. */
  81592. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81593. /**
  81594. * Creates a texture from its base 64 representation.
  81595. * @param data Define the base64 payload without the data: prefix
  81596. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81597. * @param scene Define the scene the texture should belong to
  81598. * @param noMipmap Forces the texture to not create mip map information if true
  81599. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81600. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81601. * @param onLoad define a callback triggered when the texture has been loaded
  81602. * @param onError define a callback triggered when an error occurred during the loading session
  81603. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81604. * @returns the created texture
  81605. */
  81606. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81607. /**
  81608. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81609. * @param data Define the base64 payload without the data: prefix
  81610. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81611. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81612. * @param scene Define the scene the texture should belong to
  81613. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81614. * @param noMipmap Forces the texture to not create mip map information if true
  81615. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81616. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81617. * @param onLoad define a callback triggered when the texture has been loaded
  81618. * @param onError define a callback triggered when an error occurred during the loading session
  81619. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81620. * @returns the created texture
  81621. */
  81622. 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;
  81623. }
  81624. }
  81625. declare module BABYLON {
  81626. /**
  81627. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81628. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81629. */
  81630. export class PostProcessManager {
  81631. private _scene;
  81632. private _indexBuffer;
  81633. private _vertexBuffers;
  81634. /**
  81635. * Creates a new instance PostProcess
  81636. * @param scene The scene that the post process is associated with.
  81637. */
  81638. constructor(scene: Scene);
  81639. private _prepareBuffers;
  81640. private _buildIndexBuffer;
  81641. /**
  81642. * Rebuilds the vertex buffers of the manager.
  81643. * @hidden
  81644. */
  81645. _rebuild(): void;
  81646. /**
  81647. * Prepares a frame to be run through a post process.
  81648. * @param sourceTexture The input texture to the post procesess. (default: null)
  81649. * @param postProcesses An array of post processes to be run. (default: null)
  81650. * @returns True if the post processes were able to be run.
  81651. * @hidden
  81652. */
  81653. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81654. /**
  81655. * Manually render a set of post processes to a texture.
  81656. * @param postProcesses An array of post processes to be run.
  81657. * @param targetTexture The target texture to render to.
  81658. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81659. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81660. * @param lodLevel defines which lod of the texture to render to
  81661. */
  81662. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81663. /**
  81664. * Finalize the result of the output of the postprocesses.
  81665. * @param doNotPresent If true the result will not be displayed to the screen.
  81666. * @param targetTexture The target texture to render to.
  81667. * @param faceIndex The index of the face to bind the target texture to.
  81668. * @param postProcesses The array of post processes to render.
  81669. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81670. * @hidden
  81671. */
  81672. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81673. /**
  81674. * Disposes of the post process manager.
  81675. */
  81676. dispose(): void;
  81677. }
  81678. }
  81679. declare module BABYLON {
  81680. /** Interface used by value gradients (color, factor, ...) */
  81681. export interface IValueGradient {
  81682. /**
  81683. * Gets or sets the gradient value (between 0 and 1)
  81684. */
  81685. gradient: number;
  81686. }
  81687. /** Class used to store color4 gradient */
  81688. export class ColorGradient implements IValueGradient {
  81689. /**
  81690. * Gets or sets the gradient value (between 0 and 1)
  81691. */
  81692. gradient: number;
  81693. /**
  81694. * Gets or sets first associated color
  81695. */
  81696. color1: Color4;
  81697. /**
  81698. * Gets or sets second associated color
  81699. */
  81700. color2?: Color4;
  81701. /**
  81702. * Will get a color picked randomly between color1 and color2.
  81703. * If color2 is undefined then color1 will be used
  81704. * @param result defines the target Color4 to store the result in
  81705. */
  81706. getColorToRef(result: Color4): void;
  81707. }
  81708. /** Class used to store color 3 gradient */
  81709. export class Color3Gradient implements IValueGradient {
  81710. /**
  81711. * Gets or sets the gradient value (between 0 and 1)
  81712. */
  81713. gradient: number;
  81714. /**
  81715. * Gets or sets the associated color
  81716. */
  81717. color: Color3;
  81718. }
  81719. /** Class used to store factor gradient */
  81720. export class FactorGradient implements IValueGradient {
  81721. /**
  81722. * Gets or sets the gradient value (between 0 and 1)
  81723. */
  81724. gradient: number;
  81725. /**
  81726. * Gets or sets first associated factor
  81727. */
  81728. factor1: number;
  81729. /**
  81730. * Gets or sets second associated factor
  81731. */
  81732. factor2?: number;
  81733. /**
  81734. * Will get a number picked randomly between factor1 and factor2.
  81735. * If factor2 is undefined then factor1 will be used
  81736. * @returns the picked number
  81737. */
  81738. getFactor(): number;
  81739. }
  81740. /**
  81741. * Helper used to simplify some generic gradient tasks
  81742. */
  81743. export class GradientHelper {
  81744. /**
  81745. * Gets the current gradient from an array of IValueGradient
  81746. * @param ratio defines the current ratio to get
  81747. * @param gradients defines the array of IValueGradient
  81748. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  81749. */
  81750. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  81751. }
  81752. }
  81753. declare module BABYLON {
  81754. /**
  81755. * A class extending Texture allowing drawing on a texture
  81756. * @see http://doc.babylonjs.com/how_to/dynamictexture
  81757. */
  81758. export class DynamicTexture extends Texture {
  81759. private _generateMipMaps;
  81760. private _canvas;
  81761. private _context;
  81762. private _engine;
  81763. /**
  81764. * Creates a DynamicTexture
  81765. * @param name defines the name of the texture
  81766. * @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
  81767. * @param scene defines the scene where you want the texture
  81768. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  81769. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81770. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  81771. */
  81772. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  81773. /**
  81774. * Get the current class name of the texture useful for serialization or dynamic coding.
  81775. * @returns "DynamicTexture"
  81776. */
  81777. getClassName(): string;
  81778. /**
  81779. * Gets the current state of canRescale
  81780. */
  81781. readonly canRescale: boolean;
  81782. private _recreate;
  81783. /**
  81784. * Scales the texture
  81785. * @param ratio the scale factor to apply to both width and height
  81786. */
  81787. scale(ratio: number): void;
  81788. /**
  81789. * Resizes the texture
  81790. * @param width the new width
  81791. * @param height the new height
  81792. */
  81793. scaleTo(width: number, height: number): void;
  81794. /**
  81795. * Gets the context of the canvas used by the texture
  81796. * @returns the canvas context of the dynamic texture
  81797. */
  81798. getContext(): CanvasRenderingContext2D;
  81799. /**
  81800. * Clears the texture
  81801. */
  81802. clear(): void;
  81803. /**
  81804. * Updates the texture
  81805. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81806. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  81807. */
  81808. update(invertY?: boolean, premulAlpha?: boolean): void;
  81809. /**
  81810. * Draws text onto the texture
  81811. * @param text defines the text to be drawn
  81812. * @param x defines the placement of the text from the left
  81813. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  81814. * @param font defines the font to be used with font-style, font-size, font-name
  81815. * @param color defines the color used for the text
  81816. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  81817. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81818. * @param update defines whether texture is immediately update (default is true)
  81819. */
  81820. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  81821. /**
  81822. * Clones the texture
  81823. * @returns the clone of the texture.
  81824. */
  81825. clone(): DynamicTexture;
  81826. /**
  81827. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  81828. * @returns a serialized dynamic texture object
  81829. */
  81830. serialize(): any;
  81831. /** @hidden */
  81832. _rebuild(): void;
  81833. }
  81834. }
  81835. declare module BABYLON {
  81836. interface AbstractScene {
  81837. /**
  81838. * The list of procedural textures added to the scene
  81839. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81840. */
  81841. proceduralTextures: Array<ProceduralTexture>;
  81842. }
  81843. /**
  81844. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81845. * in a given scene.
  81846. */
  81847. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81848. /**
  81849. * The component name helpfull to identify the component in the list of scene components.
  81850. */
  81851. readonly name: string;
  81852. /**
  81853. * The scene the component belongs to.
  81854. */
  81855. scene: Scene;
  81856. /**
  81857. * Creates a new instance of the component for the given scene
  81858. * @param scene Defines the scene to register the component in
  81859. */
  81860. constructor(scene: Scene);
  81861. /**
  81862. * Registers the component in a given scene
  81863. */
  81864. register(): void;
  81865. /**
  81866. * Rebuilds the elements related to this component in case of
  81867. * context lost for instance.
  81868. */
  81869. rebuild(): void;
  81870. /**
  81871. * Disposes the component and the associated ressources.
  81872. */
  81873. dispose(): void;
  81874. private _beforeClear;
  81875. }
  81876. }
  81877. declare module BABYLON {
  81878. interface Engine {
  81879. /**
  81880. * Creates a new render target cube texture
  81881. * @param size defines the size of the texture
  81882. * @param options defines the options used to create the texture
  81883. * @returns a new render target cube texture stored in an InternalTexture
  81884. */
  81885. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81886. }
  81887. }
  81888. declare module BABYLON {
  81889. /** @hidden */
  81890. export var proceduralVertexShader: {
  81891. name: string;
  81892. shader: string;
  81893. };
  81894. }
  81895. declare module BABYLON {
  81896. /**
  81897. * 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.
  81898. * This is the base class of any Procedural texture and contains most of the shareable code.
  81899. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81900. */
  81901. export class ProceduralTexture extends Texture {
  81902. isCube: boolean;
  81903. /**
  81904. * Define if the texture is enabled or not (disabled texture will not render)
  81905. */
  81906. isEnabled: boolean;
  81907. /**
  81908. * Define if the texture must be cleared before rendering (default is true)
  81909. */
  81910. autoClear: boolean;
  81911. /**
  81912. * Callback called when the texture is generated
  81913. */
  81914. onGenerated: () => void;
  81915. /**
  81916. * Event raised when the texture is generated
  81917. */
  81918. onGeneratedObservable: Observable<ProceduralTexture>;
  81919. /** @hidden */
  81920. _generateMipMaps: boolean;
  81921. /** @hidden **/
  81922. _effect: Effect;
  81923. /** @hidden */
  81924. _textures: {
  81925. [key: string]: Texture;
  81926. };
  81927. private _size;
  81928. private _currentRefreshId;
  81929. private _refreshRate;
  81930. private _vertexBuffers;
  81931. private _indexBuffer;
  81932. private _uniforms;
  81933. private _samplers;
  81934. private _fragment;
  81935. private _floats;
  81936. private _ints;
  81937. private _floatsArrays;
  81938. private _colors3;
  81939. private _colors4;
  81940. private _vectors2;
  81941. private _vectors3;
  81942. private _matrices;
  81943. private _fallbackTexture;
  81944. private _fallbackTextureUsed;
  81945. private _engine;
  81946. private _cachedDefines;
  81947. private _contentUpdateId;
  81948. private _contentData;
  81949. /**
  81950. * Instantiates a new procedural texture.
  81951. * 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.
  81952. * This is the base class of any Procedural texture and contains most of the shareable code.
  81953. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81954. * @param name Define the name of the texture
  81955. * @param size Define the size of the texture to create
  81956. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81957. * @param scene Define the scene the texture belongs to
  81958. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81959. * @param generateMipMaps Define if the texture should creates mip maps or not
  81960. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81961. */
  81962. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81963. /**
  81964. * The effect that is created when initializing the post process.
  81965. * @returns The created effect corresponding the the postprocess.
  81966. */
  81967. getEffect(): Effect;
  81968. /**
  81969. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81970. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81971. */
  81972. getContent(): Nullable<ArrayBufferView>;
  81973. private _createIndexBuffer;
  81974. /** @hidden */
  81975. _rebuild(): void;
  81976. /**
  81977. * Resets the texture in order to recreate its associated resources.
  81978. * This can be called in case of context loss
  81979. */
  81980. reset(): void;
  81981. protected _getDefines(): string;
  81982. /**
  81983. * Is the texture ready to be used ? (rendered at least once)
  81984. * @returns true if ready, otherwise, false.
  81985. */
  81986. isReady(): boolean;
  81987. /**
  81988. * Resets the refresh counter of the texture and start bak from scratch.
  81989. * Could be useful to regenerate the texture if it is setup to render only once.
  81990. */
  81991. resetRefreshCounter(): void;
  81992. /**
  81993. * Set the fragment shader to use in order to render the texture.
  81994. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81995. */
  81996. setFragment(fragment: any): void;
  81997. /**
  81998. * Define the refresh rate of the texture or the rendering frequency.
  81999. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  82000. */
  82001. refreshRate: number;
  82002. /** @hidden */
  82003. _shouldRender(): boolean;
  82004. /**
  82005. * Get the size the texture is rendering at.
  82006. * @returns the size (texture is always squared)
  82007. */
  82008. getRenderSize(): number;
  82009. /**
  82010. * Resize the texture to new value.
  82011. * @param size Define the new size the texture should have
  82012. * @param generateMipMaps Define whether the new texture should create mip maps
  82013. */
  82014. resize(size: number, generateMipMaps: boolean): void;
  82015. private _checkUniform;
  82016. /**
  82017. * Set a texture in the shader program used to render.
  82018. * @param name Define the name of the uniform samplers as defined in the shader
  82019. * @param texture Define the texture to bind to this sampler
  82020. * @return the texture itself allowing "fluent" like uniform updates
  82021. */
  82022. setTexture(name: string, texture: Texture): ProceduralTexture;
  82023. /**
  82024. * Set a float in the shader.
  82025. * @param name Define the name of the uniform as defined in the shader
  82026. * @param value Define the value to give to the uniform
  82027. * @return the texture itself allowing "fluent" like uniform updates
  82028. */
  82029. setFloat(name: string, value: number): ProceduralTexture;
  82030. /**
  82031. * Set a int in the shader.
  82032. * @param name Define the name of the uniform as defined in the shader
  82033. * @param value Define the value to give to the uniform
  82034. * @return the texture itself allowing "fluent" like uniform updates
  82035. */
  82036. setInt(name: string, value: number): ProceduralTexture;
  82037. /**
  82038. * Set an array of floats in the shader.
  82039. * @param name Define the name of the uniform as defined in the shader
  82040. * @param value Define the value to give to the uniform
  82041. * @return the texture itself allowing "fluent" like uniform updates
  82042. */
  82043. setFloats(name: string, value: number[]): ProceduralTexture;
  82044. /**
  82045. * Set a vec3 in the shader from a Color3.
  82046. * @param name Define the name of the uniform as defined in the shader
  82047. * @param value Define the value to give to the uniform
  82048. * @return the texture itself allowing "fluent" like uniform updates
  82049. */
  82050. setColor3(name: string, value: Color3): ProceduralTexture;
  82051. /**
  82052. * Set a vec4 in the shader from a Color4.
  82053. * @param name Define the name of the uniform as defined in the shader
  82054. * @param value Define the value to give to the uniform
  82055. * @return the texture itself allowing "fluent" like uniform updates
  82056. */
  82057. setColor4(name: string, value: Color4): ProceduralTexture;
  82058. /**
  82059. * Set a vec2 in the shader from a Vector2.
  82060. * @param name Define the name of the uniform as defined in the shader
  82061. * @param value Define the value to give to the uniform
  82062. * @return the texture itself allowing "fluent" like uniform updates
  82063. */
  82064. setVector2(name: string, value: Vector2): ProceduralTexture;
  82065. /**
  82066. * Set a vec3 in the shader from a Vector3.
  82067. * @param name Define the name of the uniform as defined in the shader
  82068. * @param value Define the value to give to the uniform
  82069. * @return the texture itself allowing "fluent" like uniform updates
  82070. */
  82071. setVector3(name: string, value: Vector3): ProceduralTexture;
  82072. /**
  82073. * Set a mat4 in the shader from a MAtrix.
  82074. * @param name Define the name of the uniform as defined in the shader
  82075. * @param value Define the value to give to the uniform
  82076. * @return the texture itself allowing "fluent" like uniform updates
  82077. */
  82078. setMatrix(name: string, value: Matrix): ProceduralTexture;
  82079. /**
  82080. * Render the texture to its associated render target.
  82081. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  82082. */
  82083. render(useCameraPostProcess?: boolean): void;
  82084. /**
  82085. * Clone the texture.
  82086. * @returns the cloned texture
  82087. */
  82088. clone(): ProceduralTexture;
  82089. /**
  82090. * Dispose the texture and release its asoociated resources.
  82091. */
  82092. dispose(): void;
  82093. }
  82094. }
  82095. declare module BABYLON {
  82096. /**
  82097. * This represents the base class for particle system in Babylon.
  82098. * 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.
  82099. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82100. * @example https://doc.babylonjs.com/babylon101/particles
  82101. */
  82102. export class BaseParticleSystem {
  82103. /**
  82104. * Source color is added to the destination color without alpha affecting the result
  82105. */
  82106. static BLENDMODE_ONEONE: number;
  82107. /**
  82108. * Blend current color and particle color using particle’s alpha
  82109. */
  82110. static BLENDMODE_STANDARD: number;
  82111. /**
  82112. * Add current color and particle color multiplied by particle’s alpha
  82113. */
  82114. static BLENDMODE_ADD: number;
  82115. /**
  82116. * Multiply current color with particle color
  82117. */
  82118. static BLENDMODE_MULTIPLY: number;
  82119. /**
  82120. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  82121. */
  82122. static BLENDMODE_MULTIPLYADD: number;
  82123. /**
  82124. * List of animations used by the particle system.
  82125. */
  82126. animations: Animation[];
  82127. /**
  82128. * The id of the Particle system.
  82129. */
  82130. id: string;
  82131. /**
  82132. * The friendly name of the Particle system.
  82133. */
  82134. name: string;
  82135. /**
  82136. * The rendering group used by the Particle system to chose when to render.
  82137. */
  82138. renderingGroupId: number;
  82139. /**
  82140. * The emitter represents the Mesh or position we are attaching the particle system to.
  82141. */
  82142. emitter: Nullable<AbstractMesh | Vector3>;
  82143. /**
  82144. * The maximum number of particles to emit per frame
  82145. */
  82146. emitRate: number;
  82147. /**
  82148. * If you want to launch only a few particles at once, that can be done, as well.
  82149. */
  82150. manualEmitCount: number;
  82151. /**
  82152. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82153. */
  82154. updateSpeed: number;
  82155. /**
  82156. * The amount of time the particle system is running (depends of the overall update speed).
  82157. */
  82158. targetStopDuration: number;
  82159. /**
  82160. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82161. */
  82162. disposeOnStop: boolean;
  82163. /**
  82164. * Minimum power of emitting particles.
  82165. */
  82166. minEmitPower: number;
  82167. /**
  82168. * Maximum power of emitting particles.
  82169. */
  82170. maxEmitPower: number;
  82171. /**
  82172. * Minimum life time of emitting particles.
  82173. */
  82174. minLifeTime: number;
  82175. /**
  82176. * Maximum life time of emitting particles.
  82177. */
  82178. maxLifeTime: number;
  82179. /**
  82180. * Minimum Size of emitting particles.
  82181. */
  82182. minSize: number;
  82183. /**
  82184. * Maximum Size of emitting particles.
  82185. */
  82186. maxSize: number;
  82187. /**
  82188. * Minimum scale of emitting particles on X axis.
  82189. */
  82190. minScaleX: number;
  82191. /**
  82192. * Maximum scale of emitting particles on X axis.
  82193. */
  82194. maxScaleX: number;
  82195. /**
  82196. * Minimum scale of emitting particles on Y axis.
  82197. */
  82198. minScaleY: number;
  82199. /**
  82200. * Maximum scale of emitting particles on Y axis.
  82201. */
  82202. maxScaleY: number;
  82203. /**
  82204. * Gets or sets the minimal initial rotation in radians.
  82205. */
  82206. minInitialRotation: number;
  82207. /**
  82208. * Gets or sets the maximal initial rotation in radians.
  82209. */
  82210. maxInitialRotation: number;
  82211. /**
  82212. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82213. */
  82214. minAngularSpeed: number;
  82215. /**
  82216. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82217. */
  82218. maxAngularSpeed: number;
  82219. /**
  82220. * The texture used to render each particle. (this can be a spritesheet)
  82221. */
  82222. particleTexture: Nullable<Texture>;
  82223. /**
  82224. * The layer mask we are rendering the particles through.
  82225. */
  82226. layerMask: number;
  82227. /**
  82228. * This can help using your own shader to render the particle system.
  82229. * The according effect will be created
  82230. */
  82231. customShader: any;
  82232. /**
  82233. * By default particle system starts as soon as they are created. This prevents the
  82234. * automatic start to happen and let you decide when to start emitting particles.
  82235. */
  82236. preventAutoStart: boolean;
  82237. private _noiseTexture;
  82238. /**
  82239. * Gets or sets a texture used to add random noise to particle positions
  82240. */
  82241. noiseTexture: Nullable<ProceduralTexture>;
  82242. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82243. noiseStrength: Vector3;
  82244. /**
  82245. * Callback triggered when the particle animation is ending.
  82246. */
  82247. onAnimationEnd: Nullable<() => void>;
  82248. /**
  82249. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82250. */
  82251. blendMode: number;
  82252. /**
  82253. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82254. * to override the particles.
  82255. */
  82256. forceDepthWrite: boolean;
  82257. /** 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 */
  82258. preWarmCycles: number;
  82259. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82260. preWarmStepOffset: number;
  82261. /**
  82262. * 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)
  82263. */
  82264. spriteCellChangeSpeed: number;
  82265. /**
  82266. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82267. */
  82268. startSpriteCellID: number;
  82269. /**
  82270. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82271. */
  82272. endSpriteCellID: number;
  82273. /**
  82274. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82275. */
  82276. spriteCellWidth: number;
  82277. /**
  82278. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82279. */
  82280. spriteCellHeight: number;
  82281. /**
  82282. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82283. */
  82284. spriteRandomStartCell: boolean;
  82285. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82286. translationPivot: Vector2;
  82287. /** @hidden */
  82288. protected _isAnimationSheetEnabled: boolean;
  82289. /**
  82290. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82291. */
  82292. beginAnimationOnStart: boolean;
  82293. /**
  82294. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82295. */
  82296. beginAnimationFrom: number;
  82297. /**
  82298. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82299. */
  82300. beginAnimationTo: number;
  82301. /**
  82302. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82303. */
  82304. beginAnimationLoop: boolean;
  82305. /**
  82306. * Gets or sets a world offset applied to all particles
  82307. */
  82308. worldOffset: Vector3;
  82309. /**
  82310. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82311. */
  82312. isAnimationSheetEnabled: boolean;
  82313. /**
  82314. * Get hosting scene
  82315. * @returns the scene
  82316. */
  82317. getScene(): Scene;
  82318. /**
  82319. * You can use gravity if you want to give an orientation to your particles.
  82320. */
  82321. gravity: Vector3;
  82322. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82323. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82324. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82325. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82326. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82327. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82328. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82329. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82330. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82331. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82332. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82333. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82334. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82335. /**
  82336. * Defines the delay in milliseconds before starting the system (0 by default)
  82337. */
  82338. startDelay: number;
  82339. /**
  82340. * Gets the current list of drag gradients.
  82341. * You must use addDragGradient and removeDragGradient to udpate this list
  82342. * @returns the list of drag gradients
  82343. */
  82344. getDragGradients(): Nullable<Array<FactorGradient>>;
  82345. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82346. limitVelocityDamping: number;
  82347. /**
  82348. * Gets the current list of limit velocity gradients.
  82349. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82350. * @returns the list of limit velocity gradients
  82351. */
  82352. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82353. /**
  82354. * Gets the current list of color gradients.
  82355. * You must use addColorGradient and removeColorGradient to udpate this list
  82356. * @returns the list of color gradients
  82357. */
  82358. getColorGradients(): Nullable<Array<ColorGradient>>;
  82359. /**
  82360. * Gets the current list of size gradients.
  82361. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82362. * @returns the list of size gradients
  82363. */
  82364. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82365. /**
  82366. * Gets the current list of color remap gradients.
  82367. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82368. * @returns the list of color remap gradients
  82369. */
  82370. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82371. /**
  82372. * Gets the current list of alpha remap gradients.
  82373. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82374. * @returns the list of alpha remap gradients
  82375. */
  82376. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82377. /**
  82378. * Gets the current list of life time gradients.
  82379. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82380. * @returns the list of life time gradients
  82381. */
  82382. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82383. /**
  82384. * Gets the current list of angular speed gradients.
  82385. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82386. * @returns the list of angular speed gradients
  82387. */
  82388. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82389. /**
  82390. * Gets the current list of velocity gradients.
  82391. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82392. * @returns the list of velocity gradients
  82393. */
  82394. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82395. /**
  82396. * Gets the current list of start size gradients.
  82397. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82398. * @returns the list of start size gradients
  82399. */
  82400. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82401. /**
  82402. * Gets the current list of emit rate gradients.
  82403. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82404. * @returns the list of emit rate gradients
  82405. */
  82406. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82407. /**
  82408. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82409. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82410. */
  82411. direction1: Vector3;
  82412. /**
  82413. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82414. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82415. */
  82416. direction2: Vector3;
  82417. /**
  82418. * 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.
  82419. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82420. */
  82421. minEmitBox: Vector3;
  82422. /**
  82423. * 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.
  82424. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82425. */
  82426. maxEmitBox: Vector3;
  82427. /**
  82428. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82429. */
  82430. color1: Color4;
  82431. /**
  82432. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82433. */
  82434. color2: Color4;
  82435. /**
  82436. * Color the particle will have at the end of its lifetime
  82437. */
  82438. colorDead: Color4;
  82439. /**
  82440. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82441. */
  82442. textureMask: Color4;
  82443. /**
  82444. * The particle emitter type defines the emitter used by the particle system.
  82445. * It can be for example box, sphere, or cone...
  82446. */
  82447. particleEmitterType: IParticleEmitterType;
  82448. /** @hidden */
  82449. _isSubEmitter: boolean;
  82450. /**
  82451. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82452. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82453. */
  82454. billboardMode: number;
  82455. protected _isBillboardBased: boolean;
  82456. /**
  82457. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82458. */
  82459. isBillboardBased: boolean;
  82460. /**
  82461. * The scene the particle system belongs to.
  82462. */
  82463. protected _scene: Scene;
  82464. /**
  82465. * Local cache of defines for image processing.
  82466. */
  82467. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82468. /**
  82469. * Default configuration related to image processing available in the standard Material.
  82470. */
  82471. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82472. /**
  82473. * Gets the image processing configuration used either in this material.
  82474. */
  82475. /**
  82476. * Sets the Default image processing configuration used either in the this material.
  82477. *
  82478. * If sets to null, the scene one is in use.
  82479. */
  82480. imageProcessingConfiguration: ImageProcessingConfiguration;
  82481. /**
  82482. * Attaches a new image processing configuration to the Standard Material.
  82483. * @param configuration
  82484. */
  82485. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82486. /** @hidden */
  82487. protected _reset(): void;
  82488. /** @hidden */
  82489. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82490. /**
  82491. * Instantiates a particle system.
  82492. * 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.
  82493. * @param name The name of the particle system
  82494. */
  82495. constructor(name: string);
  82496. /**
  82497. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82498. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82499. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82500. * @returns the emitter
  82501. */
  82502. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82503. /**
  82504. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82505. * @param radius The radius of the hemisphere to emit from
  82506. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82507. * @returns the emitter
  82508. */
  82509. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82510. /**
  82511. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82512. * @param radius The radius of the sphere to emit from
  82513. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82514. * @returns the emitter
  82515. */
  82516. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82517. /**
  82518. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82519. * @param radius The radius of the sphere to emit from
  82520. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82521. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82522. * @returns the emitter
  82523. */
  82524. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82525. /**
  82526. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82527. * @param radius The radius of the emission cylinder
  82528. * @param height The height of the emission cylinder
  82529. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82530. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82531. * @returns the emitter
  82532. */
  82533. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82534. /**
  82535. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82536. * @param radius The radius of the cylinder to emit from
  82537. * @param height The height of the emission cylinder
  82538. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82539. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82540. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82541. * @returns the emitter
  82542. */
  82543. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82544. /**
  82545. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82546. * @param radius The radius of the cone to emit from
  82547. * @param angle The base angle of the cone
  82548. * @returns the emitter
  82549. */
  82550. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82551. /**
  82552. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82553. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82554. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82555. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82556. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82557. * @returns the emitter
  82558. */
  82559. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82560. }
  82561. }
  82562. declare module BABYLON {
  82563. /**
  82564. * Type of sub emitter
  82565. */
  82566. export enum SubEmitterType {
  82567. /**
  82568. * Attached to the particle over it's lifetime
  82569. */
  82570. ATTACHED = 0,
  82571. /**
  82572. * Created when the particle dies
  82573. */
  82574. END = 1
  82575. }
  82576. /**
  82577. * Sub emitter class used to emit particles from an existing particle
  82578. */
  82579. export class SubEmitter {
  82580. /**
  82581. * the particle system to be used by the sub emitter
  82582. */
  82583. particleSystem: ParticleSystem;
  82584. /**
  82585. * Type of the submitter (Default: END)
  82586. */
  82587. type: SubEmitterType;
  82588. /**
  82589. * 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)
  82590. * Note: This only is supported when using an emitter of type Mesh
  82591. */
  82592. inheritDirection: boolean;
  82593. /**
  82594. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82595. */
  82596. inheritedVelocityAmount: number;
  82597. /**
  82598. * Creates a sub emitter
  82599. * @param particleSystem the particle system to be used by the sub emitter
  82600. */
  82601. constructor(
  82602. /**
  82603. * the particle system to be used by the sub emitter
  82604. */
  82605. particleSystem: ParticleSystem);
  82606. /**
  82607. * Clones the sub emitter
  82608. * @returns the cloned sub emitter
  82609. */
  82610. clone(): SubEmitter;
  82611. /**
  82612. * Serialize current object to a JSON object
  82613. * @returns the serialized object
  82614. */
  82615. serialize(): any;
  82616. /** @hidden */
  82617. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82618. /**
  82619. * Creates a new SubEmitter from a serialized JSON version
  82620. * @param serializationObject defines the JSON object to read from
  82621. * @param scene defines the hosting scene
  82622. * @param rootUrl defines the rootUrl for data loading
  82623. * @returns a new SubEmitter
  82624. */
  82625. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82626. /** Release associated resources */
  82627. dispose(): void;
  82628. }
  82629. }
  82630. declare module BABYLON {
  82631. /** @hidden */
  82632. export var clipPlaneFragmentDeclaration: {
  82633. name: string;
  82634. shader: string;
  82635. };
  82636. }
  82637. declare module BABYLON {
  82638. /** @hidden */
  82639. export var imageProcessingDeclaration: {
  82640. name: string;
  82641. shader: string;
  82642. };
  82643. }
  82644. declare module BABYLON {
  82645. /** @hidden */
  82646. export var imageProcessingFunctions: {
  82647. name: string;
  82648. shader: string;
  82649. };
  82650. }
  82651. declare module BABYLON {
  82652. /** @hidden */
  82653. export var clipPlaneFragment: {
  82654. name: string;
  82655. shader: string;
  82656. };
  82657. }
  82658. declare module BABYLON {
  82659. /** @hidden */
  82660. export var particlesPixelShader: {
  82661. name: string;
  82662. shader: string;
  82663. };
  82664. }
  82665. declare module BABYLON {
  82666. /** @hidden */
  82667. export var clipPlaneVertexDeclaration: {
  82668. name: string;
  82669. shader: string;
  82670. };
  82671. }
  82672. declare module BABYLON {
  82673. /** @hidden */
  82674. export var clipPlaneVertex: {
  82675. name: string;
  82676. shader: string;
  82677. };
  82678. }
  82679. declare module BABYLON {
  82680. /** @hidden */
  82681. export var particlesVertexShader: {
  82682. name: string;
  82683. shader: string;
  82684. };
  82685. }
  82686. declare module BABYLON {
  82687. /**
  82688. * This represents a particle system in Babylon.
  82689. * 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.
  82690. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82691. * @example https://doc.babylonjs.com/babylon101/particles
  82692. */
  82693. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82694. /**
  82695. * Billboard mode will only apply to Y axis
  82696. */
  82697. static readonly BILLBOARDMODE_Y: number;
  82698. /**
  82699. * Billboard mode will apply to all axes
  82700. */
  82701. static readonly BILLBOARDMODE_ALL: number;
  82702. /**
  82703. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82704. */
  82705. static readonly BILLBOARDMODE_STRETCHED: number;
  82706. /**
  82707. * This function can be defined to provide custom update for active particles.
  82708. * This function will be called instead of regular update (age, position, color, etc.).
  82709. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82710. */
  82711. updateFunction: (particles: Particle[]) => void;
  82712. private _emitterWorldMatrix;
  82713. /**
  82714. * This function can be defined to specify initial direction for every new particle.
  82715. * It by default use the emitterType defined function
  82716. */
  82717. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82718. /**
  82719. * This function can be defined to specify initial position for every new particle.
  82720. * It by default use the emitterType defined function
  82721. */
  82722. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82723. /**
  82724. * @hidden
  82725. */
  82726. _inheritedVelocityOffset: Vector3;
  82727. /**
  82728. * An event triggered when the system is disposed
  82729. */
  82730. onDisposeObservable: Observable<ParticleSystem>;
  82731. private _onDisposeObserver;
  82732. /**
  82733. * Sets a callback that will be triggered when the system is disposed
  82734. */
  82735. onDispose: () => void;
  82736. private _particles;
  82737. private _epsilon;
  82738. private _capacity;
  82739. private _stockParticles;
  82740. private _newPartsExcess;
  82741. private _vertexData;
  82742. private _vertexBuffer;
  82743. private _vertexBuffers;
  82744. private _spriteBuffer;
  82745. private _indexBuffer;
  82746. private _effect;
  82747. private _customEffect;
  82748. private _cachedDefines;
  82749. private _scaledColorStep;
  82750. private _colorDiff;
  82751. private _scaledDirection;
  82752. private _scaledGravity;
  82753. private _currentRenderId;
  82754. private _alive;
  82755. private _useInstancing;
  82756. private _started;
  82757. private _stopped;
  82758. private _actualFrame;
  82759. private _scaledUpdateSpeed;
  82760. private _vertexBufferSize;
  82761. /** @hidden */
  82762. _currentEmitRateGradient: Nullable<FactorGradient>;
  82763. /** @hidden */
  82764. _currentEmitRate1: number;
  82765. /** @hidden */
  82766. _currentEmitRate2: number;
  82767. /** @hidden */
  82768. _currentStartSizeGradient: Nullable<FactorGradient>;
  82769. /** @hidden */
  82770. _currentStartSize1: number;
  82771. /** @hidden */
  82772. _currentStartSize2: number;
  82773. private readonly _rawTextureWidth;
  82774. private _rampGradientsTexture;
  82775. private _useRampGradients;
  82776. /** Gets or sets a boolean indicating that ramp gradients must be used
  82777. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82778. */
  82779. useRampGradients: boolean;
  82780. /**
  82781. * 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.
  82782. * 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: [])
  82783. */
  82784. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82785. private _subEmitters;
  82786. /**
  82787. * @hidden
  82788. * If the particle systems emitter should be disposed when the particle system is disposed
  82789. */
  82790. _disposeEmitterOnDispose: boolean;
  82791. /**
  82792. * The current active Sub-systems, this property is used by the root particle system only.
  82793. */
  82794. activeSubSystems: Array<ParticleSystem>;
  82795. private _rootParticleSystem;
  82796. /**
  82797. * Gets the current list of active particles
  82798. */
  82799. readonly particles: Particle[];
  82800. /**
  82801. * Returns the string "ParticleSystem"
  82802. * @returns a string containing the class name
  82803. */
  82804. getClassName(): string;
  82805. /**
  82806. * Instantiates a particle system.
  82807. * 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.
  82808. * @param name The name of the particle system
  82809. * @param capacity The max number of particles alive at the same time
  82810. * @param scene The scene the particle system belongs to
  82811. * @param customEffect a custom effect used to change the way particles are rendered by default
  82812. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82813. * @param epsilon Offset used to render the particles
  82814. */
  82815. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82816. private _addFactorGradient;
  82817. private _removeFactorGradient;
  82818. /**
  82819. * Adds a new life time gradient
  82820. * @param gradient defines the gradient to use (between 0 and 1)
  82821. * @param factor defines the life time factor to affect to the specified gradient
  82822. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82823. * @returns the current particle system
  82824. */
  82825. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82826. /**
  82827. * Remove a specific life time gradient
  82828. * @param gradient defines the gradient to remove
  82829. * @returns the current particle system
  82830. */
  82831. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82832. /**
  82833. * Adds a new size gradient
  82834. * @param gradient defines the gradient to use (between 0 and 1)
  82835. * @param factor defines the size factor to affect to the specified gradient
  82836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82837. * @returns the current particle system
  82838. */
  82839. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82840. /**
  82841. * Remove a specific size gradient
  82842. * @param gradient defines the gradient to remove
  82843. * @returns the current particle system
  82844. */
  82845. removeSizeGradient(gradient: number): IParticleSystem;
  82846. /**
  82847. * Adds a new color remap gradient
  82848. * @param gradient defines the gradient to use (between 0 and 1)
  82849. * @param min defines the color remap minimal range
  82850. * @param max defines the color remap maximal range
  82851. * @returns the current particle system
  82852. */
  82853. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82854. /**
  82855. * Remove a specific color remap gradient
  82856. * @param gradient defines the gradient to remove
  82857. * @returns the current particle system
  82858. */
  82859. removeColorRemapGradient(gradient: number): IParticleSystem;
  82860. /**
  82861. * Adds a new alpha remap gradient
  82862. * @param gradient defines the gradient to use (between 0 and 1)
  82863. * @param min defines the alpha remap minimal range
  82864. * @param max defines the alpha remap maximal range
  82865. * @returns the current particle system
  82866. */
  82867. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82868. /**
  82869. * Remove a specific alpha remap gradient
  82870. * @param gradient defines the gradient to remove
  82871. * @returns the current particle system
  82872. */
  82873. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82874. /**
  82875. * Adds a new angular speed gradient
  82876. * @param gradient defines the gradient to use (between 0 and 1)
  82877. * @param factor defines the angular speed to affect to the specified gradient
  82878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82879. * @returns the current particle system
  82880. */
  82881. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82882. /**
  82883. * Remove a specific angular speed gradient
  82884. * @param gradient defines the gradient to remove
  82885. * @returns the current particle system
  82886. */
  82887. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82888. /**
  82889. * Adds a new velocity gradient
  82890. * @param gradient defines the gradient to use (between 0 and 1)
  82891. * @param factor defines the velocity to affect to the specified gradient
  82892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82893. * @returns the current particle system
  82894. */
  82895. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82896. /**
  82897. * Remove a specific velocity gradient
  82898. * @param gradient defines the gradient to remove
  82899. * @returns the current particle system
  82900. */
  82901. removeVelocityGradient(gradient: number): IParticleSystem;
  82902. /**
  82903. * Adds a new limit velocity gradient
  82904. * @param gradient defines the gradient to use (between 0 and 1)
  82905. * @param factor defines the limit velocity value to affect to the specified gradient
  82906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82907. * @returns the current particle system
  82908. */
  82909. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82910. /**
  82911. * Remove a specific limit velocity gradient
  82912. * @param gradient defines the gradient to remove
  82913. * @returns the current particle system
  82914. */
  82915. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82916. /**
  82917. * Adds a new drag gradient
  82918. * @param gradient defines the gradient to use (between 0 and 1)
  82919. * @param factor defines the drag value to affect to the specified gradient
  82920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82921. * @returns the current particle system
  82922. */
  82923. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82924. /**
  82925. * Remove a specific drag gradient
  82926. * @param gradient defines the gradient to remove
  82927. * @returns the current particle system
  82928. */
  82929. removeDragGradient(gradient: number): IParticleSystem;
  82930. /**
  82931. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82932. * @param gradient defines the gradient to use (between 0 and 1)
  82933. * @param factor defines the emit rate value to affect to the specified gradient
  82934. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82935. * @returns the current particle system
  82936. */
  82937. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82938. /**
  82939. * Remove a specific emit rate gradient
  82940. * @param gradient defines the gradient to remove
  82941. * @returns the current particle system
  82942. */
  82943. removeEmitRateGradient(gradient: number): IParticleSystem;
  82944. /**
  82945. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82946. * @param gradient defines the gradient to use (between 0 and 1)
  82947. * @param factor defines the start size value to affect to the specified gradient
  82948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82949. * @returns the current particle system
  82950. */
  82951. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82952. /**
  82953. * Remove a specific start size gradient
  82954. * @param gradient defines the gradient to remove
  82955. * @returns the current particle system
  82956. */
  82957. removeStartSizeGradient(gradient: number): IParticleSystem;
  82958. private _createRampGradientTexture;
  82959. /**
  82960. * Gets the current list of ramp gradients.
  82961. * You must use addRampGradient and removeRampGradient to udpate this list
  82962. * @returns the list of ramp gradients
  82963. */
  82964. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82965. /**
  82966. * Adds a new ramp gradient used to remap particle colors
  82967. * @param gradient defines the gradient to use (between 0 and 1)
  82968. * @param color defines the color to affect to the specified gradient
  82969. * @returns the current particle system
  82970. */
  82971. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82972. /**
  82973. * Remove a specific ramp gradient
  82974. * @param gradient defines the gradient to remove
  82975. * @returns the current particle system
  82976. */
  82977. removeRampGradient(gradient: number): ParticleSystem;
  82978. /**
  82979. * Adds a new color gradient
  82980. * @param gradient defines the gradient to use (between 0 and 1)
  82981. * @param color1 defines the color to affect to the specified gradient
  82982. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82983. * @returns this particle system
  82984. */
  82985. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82986. /**
  82987. * Remove a specific color gradient
  82988. * @param gradient defines the gradient to remove
  82989. * @returns this particle system
  82990. */
  82991. removeColorGradient(gradient: number): IParticleSystem;
  82992. private _fetchR;
  82993. protected _reset(): void;
  82994. private _resetEffect;
  82995. private _createVertexBuffers;
  82996. private _createIndexBuffer;
  82997. /**
  82998. * Gets the maximum number of particles active at the same time.
  82999. * @returns The max number of active particles.
  83000. */
  83001. getCapacity(): number;
  83002. /**
  83003. * Gets whether there are still active particles in the system.
  83004. * @returns True if it is alive, otherwise false.
  83005. */
  83006. isAlive(): boolean;
  83007. /**
  83008. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83009. * @returns True if it has been started, otherwise false.
  83010. */
  83011. isStarted(): boolean;
  83012. private _prepareSubEmitterInternalArray;
  83013. /**
  83014. * Starts the particle system and begins to emit
  83015. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  83016. */
  83017. start(delay?: number): void;
  83018. /**
  83019. * Stops the particle system.
  83020. * @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.
  83021. */
  83022. stop(stopSubEmitters?: boolean): void;
  83023. /**
  83024. * Remove all active particles
  83025. */
  83026. reset(): void;
  83027. /**
  83028. * @hidden (for internal use only)
  83029. */
  83030. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  83031. /**
  83032. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  83033. * Its lifetime will start back at 0.
  83034. */
  83035. recycleParticle: (particle: Particle) => void;
  83036. private _stopSubEmitters;
  83037. private _createParticle;
  83038. private _removeFromRoot;
  83039. private _emitFromParticle;
  83040. private _update;
  83041. /** @hidden */
  83042. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  83043. /** @hidden */
  83044. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  83045. /** @hidden */
  83046. private _getEffect;
  83047. /**
  83048. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  83049. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  83050. */
  83051. animate(preWarmOnly?: boolean): void;
  83052. private _appendParticleVertices;
  83053. /**
  83054. * Rebuilds the particle system.
  83055. */
  83056. rebuild(): void;
  83057. /**
  83058. * Is this system ready to be used/rendered
  83059. * @return true if the system is ready
  83060. */
  83061. isReady(): boolean;
  83062. private _render;
  83063. /**
  83064. * Renders the particle system in its current state.
  83065. * @returns the current number of particles
  83066. */
  83067. render(): number;
  83068. /**
  83069. * Disposes the particle system and free the associated resources
  83070. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83071. */
  83072. dispose(disposeTexture?: boolean): void;
  83073. /**
  83074. * Clones the particle system.
  83075. * @param name The name of the cloned object
  83076. * @param newEmitter The new emitter to use
  83077. * @returns the cloned particle system
  83078. */
  83079. clone(name: string, newEmitter: any): ParticleSystem;
  83080. /**
  83081. * Serializes the particle system to a JSON object.
  83082. * @returns the JSON object
  83083. */
  83084. serialize(): any;
  83085. /** @hidden */
  83086. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  83087. /** @hidden */
  83088. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  83089. /**
  83090. * Parses a JSON object to create a particle system.
  83091. * @param parsedParticleSystem The JSON object to parse
  83092. * @param scene The scene to create the particle system in
  83093. * @param rootUrl The root url to use to load external dependencies like texture
  83094. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  83095. * @returns the Parsed particle system
  83096. */
  83097. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  83098. }
  83099. }
  83100. declare module BABYLON {
  83101. /**
  83102. * A particle represents one of the element emitted by a particle system.
  83103. * This is mainly define by its coordinates, direction, velocity and age.
  83104. */
  83105. export class Particle {
  83106. /**
  83107. * The particle system the particle belongs to.
  83108. */
  83109. particleSystem: ParticleSystem;
  83110. private static _Count;
  83111. /**
  83112. * Unique ID of the particle
  83113. */
  83114. id: number;
  83115. /**
  83116. * The world position of the particle in the scene.
  83117. */
  83118. position: Vector3;
  83119. /**
  83120. * The world direction of the particle in the scene.
  83121. */
  83122. direction: Vector3;
  83123. /**
  83124. * The color of the particle.
  83125. */
  83126. color: Color4;
  83127. /**
  83128. * The color change of the particle per step.
  83129. */
  83130. colorStep: Color4;
  83131. /**
  83132. * Defines how long will the life of the particle be.
  83133. */
  83134. lifeTime: number;
  83135. /**
  83136. * The current age of the particle.
  83137. */
  83138. age: number;
  83139. /**
  83140. * The current size of the particle.
  83141. */
  83142. size: number;
  83143. /**
  83144. * The current scale of the particle.
  83145. */
  83146. scale: Vector2;
  83147. /**
  83148. * The current angle of the particle.
  83149. */
  83150. angle: number;
  83151. /**
  83152. * Defines how fast is the angle changing.
  83153. */
  83154. angularSpeed: number;
  83155. /**
  83156. * Defines the cell index used by the particle to be rendered from a sprite.
  83157. */
  83158. cellIndex: number;
  83159. /**
  83160. * The information required to support color remapping
  83161. */
  83162. remapData: Vector4;
  83163. /** @hidden */
  83164. _randomCellOffset?: number;
  83165. /** @hidden */
  83166. _initialDirection: Nullable<Vector3>;
  83167. /** @hidden */
  83168. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  83169. /** @hidden */
  83170. _initialStartSpriteCellID: number;
  83171. /** @hidden */
  83172. _initialEndSpriteCellID: number;
  83173. /** @hidden */
  83174. _currentColorGradient: Nullable<ColorGradient>;
  83175. /** @hidden */
  83176. _currentColor1: Color4;
  83177. /** @hidden */
  83178. _currentColor2: Color4;
  83179. /** @hidden */
  83180. _currentSizeGradient: Nullable<FactorGradient>;
  83181. /** @hidden */
  83182. _currentSize1: number;
  83183. /** @hidden */
  83184. _currentSize2: number;
  83185. /** @hidden */
  83186. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83187. /** @hidden */
  83188. _currentAngularSpeed1: number;
  83189. /** @hidden */
  83190. _currentAngularSpeed2: number;
  83191. /** @hidden */
  83192. _currentVelocityGradient: Nullable<FactorGradient>;
  83193. /** @hidden */
  83194. _currentVelocity1: number;
  83195. /** @hidden */
  83196. _currentVelocity2: number;
  83197. /** @hidden */
  83198. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83199. /** @hidden */
  83200. _currentLimitVelocity1: number;
  83201. /** @hidden */
  83202. _currentLimitVelocity2: number;
  83203. /** @hidden */
  83204. _currentDragGradient: Nullable<FactorGradient>;
  83205. /** @hidden */
  83206. _currentDrag1: number;
  83207. /** @hidden */
  83208. _currentDrag2: number;
  83209. /** @hidden */
  83210. _randomNoiseCoordinates1: Vector3;
  83211. /** @hidden */
  83212. _randomNoiseCoordinates2: Vector3;
  83213. /**
  83214. * Creates a new instance Particle
  83215. * @param particleSystem the particle system the particle belongs to
  83216. */
  83217. constructor(
  83218. /**
  83219. * The particle system the particle belongs to.
  83220. */
  83221. particleSystem: ParticleSystem);
  83222. private updateCellInfoFromSystem;
  83223. /**
  83224. * Defines how the sprite cell index is updated for the particle
  83225. */
  83226. updateCellIndex(): void;
  83227. /** @hidden */
  83228. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83229. /** @hidden */
  83230. _inheritParticleInfoToSubEmitters(): void;
  83231. /** @hidden */
  83232. _reset(): void;
  83233. /**
  83234. * Copy the properties of particle to another one.
  83235. * @param other the particle to copy the information to.
  83236. */
  83237. copyTo(other: Particle): void;
  83238. }
  83239. }
  83240. declare module BABYLON {
  83241. /**
  83242. * Particle emitter represents a volume emitting particles.
  83243. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83244. */
  83245. export interface IParticleEmitterType {
  83246. /**
  83247. * Called by the particle System when the direction is computed for the created particle.
  83248. * @param worldMatrix is the world matrix of the particle system
  83249. * @param directionToUpdate is the direction vector to update with the result
  83250. * @param particle is the particle we are computed the direction for
  83251. */
  83252. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83253. /**
  83254. * Called by the particle System when the position is computed for the created particle.
  83255. * @param worldMatrix is the world matrix of the particle system
  83256. * @param positionToUpdate is the position vector to update with the result
  83257. * @param particle is the particle we are computed the position for
  83258. */
  83259. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83260. /**
  83261. * Clones the current emitter and returns a copy of it
  83262. * @returns the new emitter
  83263. */
  83264. clone(): IParticleEmitterType;
  83265. /**
  83266. * Called by the GPUParticleSystem to setup the update shader
  83267. * @param effect defines the update shader
  83268. */
  83269. applyToShader(effect: Effect): void;
  83270. /**
  83271. * Returns a string to use to update the GPU particles update shader
  83272. * @returns the effect defines string
  83273. */
  83274. getEffectDefines(): string;
  83275. /**
  83276. * Returns a string representing the class name
  83277. * @returns a string containing the class name
  83278. */
  83279. getClassName(): string;
  83280. /**
  83281. * Serializes the particle system to a JSON object.
  83282. * @returns the JSON object
  83283. */
  83284. serialize(): any;
  83285. /**
  83286. * Parse properties from a JSON object
  83287. * @param serializationObject defines the JSON object
  83288. */
  83289. parse(serializationObject: any): void;
  83290. }
  83291. }
  83292. declare module BABYLON {
  83293. /**
  83294. * Particle emitter emitting particles from the inside of a box.
  83295. * It emits the particles randomly between 2 given directions.
  83296. */
  83297. export class BoxParticleEmitter implements IParticleEmitterType {
  83298. /**
  83299. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83300. */
  83301. direction1: Vector3;
  83302. /**
  83303. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83304. */
  83305. direction2: Vector3;
  83306. /**
  83307. * 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.
  83308. */
  83309. minEmitBox: Vector3;
  83310. /**
  83311. * 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.
  83312. */
  83313. maxEmitBox: Vector3;
  83314. /**
  83315. * Creates a new instance BoxParticleEmitter
  83316. */
  83317. constructor();
  83318. /**
  83319. * Called by the particle System when the direction is computed for the created particle.
  83320. * @param worldMatrix is the world matrix of the particle system
  83321. * @param directionToUpdate is the direction vector to update with the result
  83322. * @param particle is the particle we are computed the direction for
  83323. */
  83324. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83325. /**
  83326. * Called by the particle System when the position is computed for the created particle.
  83327. * @param worldMatrix is the world matrix of the particle system
  83328. * @param positionToUpdate is the position vector to update with the result
  83329. * @param particle is the particle we are computed the position for
  83330. */
  83331. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83332. /**
  83333. * Clones the current emitter and returns a copy of it
  83334. * @returns the new emitter
  83335. */
  83336. clone(): BoxParticleEmitter;
  83337. /**
  83338. * Called by the GPUParticleSystem to setup the update shader
  83339. * @param effect defines the update shader
  83340. */
  83341. applyToShader(effect: Effect): void;
  83342. /**
  83343. * Returns a string to use to update the GPU particles update shader
  83344. * @returns a string containng the defines string
  83345. */
  83346. getEffectDefines(): string;
  83347. /**
  83348. * Returns the string "BoxParticleEmitter"
  83349. * @returns a string containing the class name
  83350. */
  83351. getClassName(): string;
  83352. /**
  83353. * Serializes the particle system to a JSON object.
  83354. * @returns the JSON object
  83355. */
  83356. serialize(): any;
  83357. /**
  83358. * Parse properties from a JSON object
  83359. * @param serializationObject defines the JSON object
  83360. */
  83361. parse(serializationObject: any): void;
  83362. }
  83363. }
  83364. declare module BABYLON {
  83365. /**
  83366. * Particle emitter emitting particles from the inside of a cone.
  83367. * It emits the particles alongside the cone volume from the base to the particle.
  83368. * The emission direction might be randomized.
  83369. */
  83370. export class ConeParticleEmitter implements IParticleEmitterType {
  83371. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83372. directionRandomizer: number;
  83373. private _radius;
  83374. private _angle;
  83375. private _height;
  83376. /**
  83377. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83378. */
  83379. radiusRange: number;
  83380. /**
  83381. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83382. */
  83383. heightRange: number;
  83384. /**
  83385. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83386. */
  83387. emitFromSpawnPointOnly: boolean;
  83388. /**
  83389. * Gets or sets the radius of the emission cone
  83390. */
  83391. radius: number;
  83392. /**
  83393. * Gets or sets the angle of the emission cone
  83394. */
  83395. angle: number;
  83396. private _buildHeight;
  83397. /**
  83398. * Creates a new instance ConeParticleEmitter
  83399. * @param radius the radius of the emission cone (1 by default)
  83400. * @param angle the cone base angle (PI by default)
  83401. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83402. */
  83403. constructor(radius?: number, angle?: number,
  83404. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83405. directionRandomizer?: number);
  83406. /**
  83407. * Called by the particle System when the direction is computed for the created particle.
  83408. * @param worldMatrix is the world matrix of the particle system
  83409. * @param directionToUpdate is the direction vector to update with the result
  83410. * @param particle is the particle we are computed the direction for
  83411. */
  83412. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83413. /**
  83414. * Called by the particle System when the position is computed for the created particle.
  83415. * @param worldMatrix is the world matrix of the particle system
  83416. * @param positionToUpdate is the position vector to update with the result
  83417. * @param particle is the particle we are computed the position for
  83418. */
  83419. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83420. /**
  83421. * Clones the current emitter and returns a copy of it
  83422. * @returns the new emitter
  83423. */
  83424. clone(): ConeParticleEmitter;
  83425. /**
  83426. * Called by the GPUParticleSystem to setup the update shader
  83427. * @param effect defines the update shader
  83428. */
  83429. applyToShader(effect: Effect): void;
  83430. /**
  83431. * Returns a string to use to update the GPU particles update shader
  83432. * @returns a string containng the defines string
  83433. */
  83434. getEffectDefines(): string;
  83435. /**
  83436. * Returns the string "ConeParticleEmitter"
  83437. * @returns a string containing the class name
  83438. */
  83439. getClassName(): string;
  83440. /**
  83441. * Serializes the particle system to a JSON object.
  83442. * @returns the JSON object
  83443. */
  83444. serialize(): any;
  83445. /**
  83446. * Parse properties from a JSON object
  83447. * @param serializationObject defines the JSON object
  83448. */
  83449. parse(serializationObject: any): void;
  83450. }
  83451. }
  83452. declare module BABYLON {
  83453. /**
  83454. * Particle emitter emitting particles from the inside of a cylinder.
  83455. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83456. */
  83457. export class CylinderParticleEmitter implements IParticleEmitterType {
  83458. /**
  83459. * The radius of the emission cylinder.
  83460. */
  83461. radius: number;
  83462. /**
  83463. * The height of the emission cylinder.
  83464. */
  83465. height: number;
  83466. /**
  83467. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83468. */
  83469. radiusRange: number;
  83470. /**
  83471. * How much to randomize the particle direction [0-1].
  83472. */
  83473. directionRandomizer: number;
  83474. /**
  83475. * Creates a new instance CylinderParticleEmitter
  83476. * @param radius the radius of the emission cylinder (1 by default)
  83477. * @param height the height of the emission cylinder (1 by default)
  83478. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83479. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83480. */
  83481. constructor(
  83482. /**
  83483. * The radius of the emission cylinder.
  83484. */
  83485. radius?: number,
  83486. /**
  83487. * The height of the emission cylinder.
  83488. */
  83489. height?: number,
  83490. /**
  83491. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83492. */
  83493. radiusRange?: number,
  83494. /**
  83495. * How much to randomize the particle direction [0-1].
  83496. */
  83497. directionRandomizer?: number);
  83498. /**
  83499. * Called by the particle System when the direction is computed for the created particle.
  83500. * @param worldMatrix is the world matrix of the particle system
  83501. * @param directionToUpdate is the direction vector to update with the result
  83502. * @param particle is the particle we are computed the direction for
  83503. */
  83504. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83505. /**
  83506. * Called by the particle System when the position is computed for the created particle.
  83507. * @param worldMatrix is the world matrix of the particle system
  83508. * @param positionToUpdate is the position vector to update with the result
  83509. * @param particle is the particle we are computed the position for
  83510. */
  83511. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83512. /**
  83513. * Clones the current emitter and returns a copy of it
  83514. * @returns the new emitter
  83515. */
  83516. clone(): CylinderParticleEmitter;
  83517. /**
  83518. * Called by the GPUParticleSystem to setup the update shader
  83519. * @param effect defines the update shader
  83520. */
  83521. applyToShader(effect: Effect): void;
  83522. /**
  83523. * Returns a string to use to update the GPU particles update shader
  83524. * @returns a string containng the defines string
  83525. */
  83526. getEffectDefines(): string;
  83527. /**
  83528. * Returns the string "CylinderParticleEmitter"
  83529. * @returns a string containing the class name
  83530. */
  83531. getClassName(): string;
  83532. /**
  83533. * Serializes the particle system to a JSON object.
  83534. * @returns the JSON object
  83535. */
  83536. serialize(): any;
  83537. /**
  83538. * Parse properties from a JSON object
  83539. * @param serializationObject defines the JSON object
  83540. */
  83541. parse(serializationObject: any): void;
  83542. }
  83543. /**
  83544. * Particle emitter emitting particles from the inside of a cylinder.
  83545. * It emits the particles randomly between two vectors.
  83546. */
  83547. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83548. /**
  83549. * The min limit of the emission direction.
  83550. */
  83551. direction1: Vector3;
  83552. /**
  83553. * The max limit of the emission direction.
  83554. */
  83555. direction2: Vector3;
  83556. /**
  83557. * Creates a new instance CylinderDirectedParticleEmitter
  83558. * @param radius the radius of the emission cylinder (1 by default)
  83559. * @param height the height of the emission cylinder (1 by default)
  83560. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83561. * @param direction1 the min limit of the emission direction (up vector by default)
  83562. * @param direction2 the max limit of the emission direction (up vector by default)
  83563. */
  83564. constructor(radius?: number, height?: number, radiusRange?: number,
  83565. /**
  83566. * The min limit of the emission direction.
  83567. */
  83568. direction1?: Vector3,
  83569. /**
  83570. * The max limit of the emission direction.
  83571. */
  83572. direction2?: Vector3);
  83573. /**
  83574. * Called by the particle System when the direction is computed for the created particle.
  83575. * @param worldMatrix is the world matrix of the particle system
  83576. * @param directionToUpdate is the direction vector to update with the result
  83577. * @param particle is the particle we are computed the direction for
  83578. */
  83579. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83580. /**
  83581. * Clones the current emitter and returns a copy of it
  83582. * @returns the new emitter
  83583. */
  83584. clone(): CylinderDirectedParticleEmitter;
  83585. /**
  83586. * Called by the GPUParticleSystem to setup the update shader
  83587. * @param effect defines the update shader
  83588. */
  83589. applyToShader(effect: Effect): void;
  83590. /**
  83591. * Returns a string to use to update the GPU particles update shader
  83592. * @returns a string containng the defines string
  83593. */
  83594. getEffectDefines(): string;
  83595. /**
  83596. * Returns the string "CylinderDirectedParticleEmitter"
  83597. * @returns a string containing the class name
  83598. */
  83599. getClassName(): string;
  83600. /**
  83601. * Serializes the particle system to a JSON object.
  83602. * @returns the JSON object
  83603. */
  83604. serialize(): any;
  83605. /**
  83606. * Parse properties from a JSON object
  83607. * @param serializationObject defines the JSON object
  83608. */
  83609. parse(serializationObject: any): void;
  83610. }
  83611. }
  83612. declare module BABYLON {
  83613. /**
  83614. * Particle emitter emitting particles from the inside of a hemisphere.
  83615. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83616. */
  83617. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83618. /**
  83619. * The radius of the emission hemisphere.
  83620. */
  83621. radius: number;
  83622. /**
  83623. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83624. */
  83625. radiusRange: number;
  83626. /**
  83627. * How much to randomize the particle direction [0-1].
  83628. */
  83629. directionRandomizer: number;
  83630. /**
  83631. * Creates a new instance HemisphericParticleEmitter
  83632. * @param radius the radius of the emission hemisphere (1 by default)
  83633. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83634. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83635. */
  83636. constructor(
  83637. /**
  83638. * The radius of the emission hemisphere.
  83639. */
  83640. radius?: number,
  83641. /**
  83642. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83643. */
  83644. radiusRange?: number,
  83645. /**
  83646. * How much to randomize the particle direction [0-1].
  83647. */
  83648. directionRandomizer?: number);
  83649. /**
  83650. * Called by the particle System when the direction is computed for the created particle.
  83651. * @param worldMatrix is the world matrix of the particle system
  83652. * @param directionToUpdate is the direction vector to update with the result
  83653. * @param particle is the particle we are computed the direction for
  83654. */
  83655. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83656. /**
  83657. * Called by the particle System when the position is computed for the created particle.
  83658. * @param worldMatrix is the world matrix of the particle system
  83659. * @param positionToUpdate is the position vector to update with the result
  83660. * @param particle is the particle we are computed the position for
  83661. */
  83662. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83663. /**
  83664. * Clones the current emitter and returns a copy of it
  83665. * @returns the new emitter
  83666. */
  83667. clone(): HemisphericParticleEmitter;
  83668. /**
  83669. * Called by the GPUParticleSystem to setup the update shader
  83670. * @param effect defines the update shader
  83671. */
  83672. applyToShader(effect: Effect): void;
  83673. /**
  83674. * Returns a string to use to update the GPU particles update shader
  83675. * @returns a string containng the defines string
  83676. */
  83677. getEffectDefines(): string;
  83678. /**
  83679. * Returns the string "HemisphericParticleEmitter"
  83680. * @returns a string containing the class name
  83681. */
  83682. getClassName(): string;
  83683. /**
  83684. * Serializes the particle system to a JSON object.
  83685. * @returns the JSON object
  83686. */
  83687. serialize(): any;
  83688. /**
  83689. * Parse properties from a JSON object
  83690. * @param serializationObject defines the JSON object
  83691. */
  83692. parse(serializationObject: any): void;
  83693. }
  83694. }
  83695. declare module BABYLON {
  83696. /**
  83697. * Particle emitter emitting particles from a point.
  83698. * It emits the particles randomly between 2 given directions.
  83699. */
  83700. export class PointParticleEmitter implements IParticleEmitterType {
  83701. /**
  83702. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83703. */
  83704. direction1: Vector3;
  83705. /**
  83706. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83707. */
  83708. direction2: Vector3;
  83709. /**
  83710. * Creates a new instance PointParticleEmitter
  83711. */
  83712. constructor();
  83713. /**
  83714. * Called by the particle System when the direction is computed for the created particle.
  83715. * @param worldMatrix is the world matrix of the particle system
  83716. * @param directionToUpdate is the direction vector to update with the result
  83717. * @param particle is the particle we are computed the direction for
  83718. */
  83719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83720. /**
  83721. * Called by the particle System when the position is computed for the created particle.
  83722. * @param worldMatrix is the world matrix of the particle system
  83723. * @param positionToUpdate is the position vector to update with the result
  83724. * @param particle is the particle we are computed the position for
  83725. */
  83726. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83727. /**
  83728. * Clones the current emitter and returns a copy of it
  83729. * @returns the new emitter
  83730. */
  83731. clone(): PointParticleEmitter;
  83732. /**
  83733. * Called by the GPUParticleSystem to setup the update shader
  83734. * @param effect defines the update shader
  83735. */
  83736. applyToShader(effect: Effect): void;
  83737. /**
  83738. * Returns a string to use to update the GPU particles update shader
  83739. * @returns a string containng the defines string
  83740. */
  83741. getEffectDefines(): string;
  83742. /**
  83743. * Returns the string "PointParticleEmitter"
  83744. * @returns a string containing the class name
  83745. */
  83746. getClassName(): string;
  83747. /**
  83748. * Serializes the particle system to a JSON object.
  83749. * @returns the JSON object
  83750. */
  83751. serialize(): any;
  83752. /**
  83753. * Parse properties from a JSON object
  83754. * @param serializationObject defines the JSON object
  83755. */
  83756. parse(serializationObject: any): void;
  83757. }
  83758. }
  83759. declare module BABYLON {
  83760. /**
  83761. * Particle emitter emitting particles from the inside of a sphere.
  83762. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83763. */
  83764. export class SphereParticleEmitter implements IParticleEmitterType {
  83765. /**
  83766. * The radius of the emission sphere.
  83767. */
  83768. radius: number;
  83769. /**
  83770. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83771. */
  83772. radiusRange: number;
  83773. /**
  83774. * How much to randomize the particle direction [0-1].
  83775. */
  83776. directionRandomizer: number;
  83777. /**
  83778. * Creates a new instance SphereParticleEmitter
  83779. * @param radius the radius of the emission sphere (1 by default)
  83780. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83781. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83782. */
  83783. constructor(
  83784. /**
  83785. * The radius of the emission sphere.
  83786. */
  83787. radius?: number,
  83788. /**
  83789. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83790. */
  83791. radiusRange?: number,
  83792. /**
  83793. * How much to randomize the particle direction [0-1].
  83794. */
  83795. directionRandomizer?: number);
  83796. /**
  83797. * Called by the particle System when the direction is computed for the created particle.
  83798. * @param worldMatrix is the world matrix of the particle system
  83799. * @param directionToUpdate is the direction vector to update with the result
  83800. * @param particle is the particle we are computed the direction for
  83801. */
  83802. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83803. /**
  83804. * Called by the particle System when the position is computed for the created particle.
  83805. * @param worldMatrix is the world matrix of the particle system
  83806. * @param positionToUpdate is the position vector to update with the result
  83807. * @param particle is the particle we are computed the position for
  83808. */
  83809. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83810. /**
  83811. * Clones the current emitter and returns a copy of it
  83812. * @returns the new emitter
  83813. */
  83814. clone(): SphereParticleEmitter;
  83815. /**
  83816. * Called by the GPUParticleSystem to setup the update shader
  83817. * @param effect defines the update shader
  83818. */
  83819. applyToShader(effect: Effect): void;
  83820. /**
  83821. * Returns a string to use to update the GPU particles update shader
  83822. * @returns a string containng the defines string
  83823. */
  83824. getEffectDefines(): string;
  83825. /**
  83826. * Returns the string "SphereParticleEmitter"
  83827. * @returns a string containing the class name
  83828. */
  83829. getClassName(): string;
  83830. /**
  83831. * Serializes the particle system to a JSON object.
  83832. * @returns the JSON object
  83833. */
  83834. serialize(): any;
  83835. /**
  83836. * Parse properties from a JSON object
  83837. * @param serializationObject defines the JSON object
  83838. */
  83839. parse(serializationObject: any): void;
  83840. }
  83841. /**
  83842. * Particle emitter emitting particles from the inside of a sphere.
  83843. * It emits the particles randomly between two vectors.
  83844. */
  83845. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83846. /**
  83847. * The min limit of the emission direction.
  83848. */
  83849. direction1: Vector3;
  83850. /**
  83851. * The max limit of the emission direction.
  83852. */
  83853. direction2: Vector3;
  83854. /**
  83855. * Creates a new instance SphereDirectedParticleEmitter
  83856. * @param radius the radius of the emission sphere (1 by default)
  83857. * @param direction1 the min limit of the emission direction (up vector by default)
  83858. * @param direction2 the max limit of the emission direction (up vector by default)
  83859. */
  83860. constructor(radius?: number,
  83861. /**
  83862. * The min limit of the emission direction.
  83863. */
  83864. direction1?: Vector3,
  83865. /**
  83866. * The max limit of the emission direction.
  83867. */
  83868. direction2?: Vector3);
  83869. /**
  83870. * Called by the particle System when the direction is computed for the created particle.
  83871. * @param worldMatrix is the world matrix of the particle system
  83872. * @param directionToUpdate is the direction vector to update with the result
  83873. * @param particle is the particle we are computed the direction for
  83874. */
  83875. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83876. /**
  83877. * Clones the current emitter and returns a copy of it
  83878. * @returns the new emitter
  83879. */
  83880. clone(): SphereDirectedParticleEmitter;
  83881. /**
  83882. * Called by the GPUParticleSystem to setup the update shader
  83883. * @param effect defines the update shader
  83884. */
  83885. applyToShader(effect: Effect): void;
  83886. /**
  83887. * Returns a string to use to update the GPU particles update shader
  83888. * @returns a string containng the defines string
  83889. */
  83890. getEffectDefines(): string;
  83891. /**
  83892. * Returns the string "SphereDirectedParticleEmitter"
  83893. * @returns a string containing the class name
  83894. */
  83895. getClassName(): string;
  83896. /**
  83897. * Serializes the particle system to a JSON object.
  83898. * @returns the JSON object
  83899. */
  83900. serialize(): any;
  83901. /**
  83902. * Parse properties from a JSON object
  83903. * @param serializationObject defines the JSON object
  83904. */
  83905. parse(serializationObject: any): void;
  83906. }
  83907. }
  83908. declare module BABYLON {
  83909. /**
  83910. * Interface representing a particle system in Babylon.js.
  83911. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83912. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83913. */
  83914. export interface IParticleSystem {
  83915. /**
  83916. * List of animations used by the particle system.
  83917. */
  83918. animations: Animation[];
  83919. /**
  83920. * The id of the Particle system.
  83921. */
  83922. id: string;
  83923. /**
  83924. * The name of the Particle system.
  83925. */
  83926. name: string;
  83927. /**
  83928. * The emitter represents the Mesh or position we are attaching the particle system to.
  83929. */
  83930. emitter: Nullable<AbstractMesh | Vector3>;
  83931. /**
  83932. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83933. */
  83934. isBillboardBased: boolean;
  83935. /**
  83936. * The rendering group used by the Particle system to chose when to render.
  83937. */
  83938. renderingGroupId: number;
  83939. /**
  83940. * The layer mask we are rendering the particles through.
  83941. */
  83942. layerMask: number;
  83943. /**
  83944. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83945. */
  83946. updateSpeed: number;
  83947. /**
  83948. * The amount of time the particle system is running (depends of the overall update speed).
  83949. */
  83950. targetStopDuration: number;
  83951. /**
  83952. * The texture used to render each particle. (this can be a spritesheet)
  83953. */
  83954. particleTexture: Nullable<Texture>;
  83955. /**
  83956. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83957. */
  83958. blendMode: number;
  83959. /**
  83960. * Minimum life time of emitting particles.
  83961. */
  83962. minLifeTime: number;
  83963. /**
  83964. * Maximum life time of emitting particles.
  83965. */
  83966. maxLifeTime: number;
  83967. /**
  83968. * Minimum Size of emitting particles.
  83969. */
  83970. minSize: number;
  83971. /**
  83972. * Maximum Size of emitting particles.
  83973. */
  83974. maxSize: number;
  83975. /**
  83976. * Minimum scale of emitting particles on X axis.
  83977. */
  83978. minScaleX: number;
  83979. /**
  83980. * Maximum scale of emitting particles on X axis.
  83981. */
  83982. maxScaleX: number;
  83983. /**
  83984. * Minimum scale of emitting particles on Y axis.
  83985. */
  83986. minScaleY: number;
  83987. /**
  83988. * Maximum scale of emitting particles on Y axis.
  83989. */
  83990. maxScaleY: number;
  83991. /**
  83992. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83993. */
  83994. color1: Color4;
  83995. /**
  83996. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83997. */
  83998. color2: Color4;
  83999. /**
  84000. * Color the particle will have at the end of its lifetime.
  84001. */
  84002. colorDead: Color4;
  84003. /**
  84004. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  84005. */
  84006. emitRate: number;
  84007. /**
  84008. * You can use gravity if you want to give an orientation to your particles.
  84009. */
  84010. gravity: Vector3;
  84011. /**
  84012. * Minimum power of emitting particles.
  84013. */
  84014. minEmitPower: number;
  84015. /**
  84016. * Maximum power of emitting particles.
  84017. */
  84018. maxEmitPower: number;
  84019. /**
  84020. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84021. */
  84022. minAngularSpeed: number;
  84023. /**
  84024. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84025. */
  84026. maxAngularSpeed: number;
  84027. /**
  84028. * Gets or sets the minimal initial rotation in radians.
  84029. */
  84030. minInitialRotation: number;
  84031. /**
  84032. * Gets or sets the maximal initial rotation in radians.
  84033. */
  84034. maxInitialRotation: number;
  84035. /**
  84036. * The particle emitter type defines the emitter used by the particle system.
  84037. * It can be for example box, sphere, or cone...
  84038. */
  84039. particleEmitterType: Nullable<IParticleEmitterType>;
  84040. /**
  84041. * Defines the delay in milliseconds before starting the system (0 by default)
  84042. */
  84043. startDelay: number;
  84044. /**
  84045. * 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
  84046. */
  84047. preWarmCycles: number;
  84048. /**
  84049. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  84050. */
  84051. preWarmStepOffset: number;
  84052. /**
  84053. * 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)
  84054. */
  84055. spriteCellChangeSpeed: number;
  84056. /**
  84057. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84058. */
  84059. startSpriteCellID: number;
  84060. /**
  84061. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84062. */
  84063. endSpriteCellID: number;
  84064. /**
  84065. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84066. */
  84067. spriteCellWidth: number;
  84068. /**
  84069. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84070. */
  84071. spriteCellHeight: number;
  84072. /**
  84073. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84074. */
  84075. spriteRandomStartCell: boolean;
  84076. /**
  84077. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  84078. */
  84079. isAnimationSheetEnabled: boolean;
  84080. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84081. translationPivot: Vector2;
  84082. /**
  84083. * Gets or sets a texture used to add random noise to particle positions
  84084. */
  84085. noiseTexture: Nullable<BaseTexture>;
  84086. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84087. noiseStrength: Vector3;
  84088. /**
  84089. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84090. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84091. */
  84092. billboardMode: number;
  84093. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84094. limitVelocityDamping: number;
  84095. /**
  84096. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84097. */
  84098. beginAnimationOnStart: boolean;
  84099. /**
  84100. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84101. */
  84102. beginAnimationFrom: number;
  84103. /**
  84104. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84105. */
  84106. beginAnimationTo: number;
  84107. /**
  84108. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84109. */
  84110. beginAnimationLoop: boolean;
  84111. /**
  84112. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84113. */
  84114. disposeOnStop: boolean;
  84115. /**
  84116. * Gets the maximum number of particles active at the same time.
  84117. * @returns The max number of active particles.
  84118. */
  84119. getCapacity(): number;
  84120. /**
  84121. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84122. * @returns True if it has been started, otherwise false.
  84123. */
  84124. isStarted(): boolean;
  84125. /**
  84126. * Animates the particle system for this frame.
  84127. */
  84128. animate(): void;
  84129. /**
  84130. * Renders the particle system in its current state.
  84131. * @returns the current number of particles
  84132. */
  84133. render(): number;
  84134. /**
  84135. * Dispose the particle system and frees its associated resources.
  84136. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84137. */
  84138. dispose(disposeTexture?: boolean): void;
  84139. /**
  84140. * Clones the particle system.
  84141. * @param name The name of the cloned object
  84142. * @param newEmitter The new emitter to use
  84143. * @returns the cloned particle system
  84144. */
  84145. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  84146. /**
  84147. * Serializes the particle system to a JSON object.
  84148. * @returns the JSON object
  84149. */
  84150. serialize(): any;
  84151. /**
  84152. * Rebuild the particle system
  84153. */
  84154. rebuild(): void;
  84155. /**
  84156. * Starts the particle system and begins to emit
  84157. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  84158. */
  84159. start(delay?: number): void;
  84160. /**
  84161. * Stops the particle system.
  84162. */
  84163. stop(): void;
  84164. /**
  84165. * Remove all active particles
  84166. */
  84167. reset(): void;
  84168. /**
  84169. * Is this system ready to be used/rendered
  84170. * @return true if the system is ready
  84171. */
  84172. isReady(): boolean;
  84173. /**
  84174. * Adds a new color gradient
  84175. * @param gradient defines the gradient to use (between 0 and 1)
  84176. * @param color1 defines the color to affect to the specified gradient
  84177. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84178. * @returns the current particle system
  84179. */
  84180. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84181. /**
  84182. * Remove a specific color gradient
  84183. * @param gradient defines the gradient to remove
  84184. * @returns the current particle system
  84185. */
  84186. removeColorGradient(gradient: number): IParticleSystem;
  84187. /**
  84188. * Adds a new size gradient
  84189. * @param gradient defines the gradient to use (between 0 and 1)
  84190. * @param factor defines the size factor to affect to the specified gradient
  84191. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84192. * @returns the current particle system
  84193. */
  84194. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84195. /**
  84196. * Remove a specific size gradient
  84197. * @param gradient defines the gradient to remove
  84198. * @returns the current particle system
  84199. */
  84200. removeSizeGradient(gradient: number): IParticleSystem;
  84201. /**
  84202. * Gets the current list of color gradients.
  84203. * You must use addColorGradient and removeColorGradient to udpate this list
  84204. * @returns the list of color gradients
  84205. */
  84206. getColorGradients(): Nullable<Array<ColorGradient>>;
  84207. /**
  84208. * Gets the current list of size gradients.
  84209. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84210. * @returns the list of size gradients
  84211. */
  84212. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84213. /**
  84214. * Gets the current list of angular speed gradients.
  84215. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84216. * @returns the list of angular speed gradients
  84217. */
  84218. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84219. /**
  84220. * Adds a new angular speed gradient
  84221. * @param gradient defines the gradient to use (between 0 and 1)
  84222. * @param factor defines the angular speed to affect to the specified gradient
  84223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84224. * @returns the current particle system
  84225. */
  84226. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84227. /**
  84228. * Remove a specific angular speed gradient
  84229. * @param gradient defines the gradient to remove
  84230. * @returns the current particle system
  84231. */
  84232. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84233. /**
  84234. * Gets the current list of velocity gradients.
  84235. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84236. * @returns the list of velocity gradients
  84237. */
  84238. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84239. /**
  84240. * Adds a new velocity gradient
  84241. * @param gradient defines the gradient to use (between 0 and 1)
  84242. * @param factor defines the velocity to affect to the specified gradient
  84243. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84244. * @returns the current particle system
  84245. */
  84246. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84247. /**
  84248. * Remove a specific velocity gradient
  84249. * @param gradient defines the gradient to remove
  84250. * @returns the current particle system
  84251. */
  84252. removeVelocityGradient(gradient: number): IParticleSystem;
  84253. /**
  84254. * Gets the current list of limit velocity gradients.
  84255. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84256. * @returns the list of limit velocity gradients
  84257. */
  84258. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84259. /**
  84260. * Adds a new limit velocity gradient
  84261. * @param gradient defines the gradient to use (between 0 and 1)
  84262. * @param factor defines the limit velocity to affect to the specified gradient
  84263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84264. * @returns the current particle system
  84265. */
  84266. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84267. /**
  84268. * Remove a specific limit velocity gradient
  84269. * @param gradient defines the gradient to remove
  84270. * @returns the current particle system
  84271. */
  84272. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84273. /**
  84274. * Adds a new drag gradient
  84275. * @param gradient defines the gradient to use (between 0 and 1)
  84276. * @param factor defines the drag to affect to the specified gradient
  84277. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84278. * @returns the current particle system
  84279. */
  84280. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84281. /**
  84282. * Remove a specific drag gradient
  84283. * @param gradient defines the gradient to remove
  84284. * @returns the current particle system
  84285. */
  84286. removeDragGradient(gradient: number): IParticleSystem;
  84287. /**
  84288. * Gets the current list of drag gradients.
  84289. * You must use addDragGradient and removeDragGradient to udpate this list
  84290. * @returns the list of drag gradients
  84291. */
  84292. getDragGradients(): Nullable<Array<FactorGradient>>;
  84293. /**
  84294. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84295. * @param gradient defines the gradient to use (between 0 and 1)
  84296. * @param factor defines the emit rate to affect to the specified gradient
  84297. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84298. * @returns the current particle system
  84299. */
  84300. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84301. /**
  84302. * Remove a specific emit rate gradient
  84303. * @param gradient defines the gradient to remove
  84304. * @returns the current particle system
  84305. */
  84306. removeEmitRateGradient(gradient: number): IParticleSystem;
  84307. /**
  84308. * Gets the current list of emit rate gradients.
  84309. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84310. * @returns the list of emit rate gradients
  84311. */
  84312. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84313. /**
  84314. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84315. * @param gradient defines the gradient to use (between 0 and 1)
  84316. * @param factor defines the start size to affect to the specified gradient
  84317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84318. * @returns the current particle system
  84319. */
  84320. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84321. /**
  84322. * Remove a specific start size gradient
  84323. * @param gradient defines the gradient to remove
  84324. * @returns the current particle system
  84325. */
  84326. removeStartSizeGradient(gradient: number): IParticleSystem;
  84327. /**
  84328. * Gets the current list of start size gradients.
  84329. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84330. * @returns the list of start size gradients
  84331. */
  84332. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84333. /**
  84334. * Adds a new life time gradient
  84335. * @param gradient defines the gradient to use (between 0 and 1)
  84336. * @param factor defines the life time factor to affect to the specified gradient
  84337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84338. * @returns the current particle system
  84339. */
  84340. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84341. /**
  84342. * Remove a specific life time gradient
  84343. * @param gradient defines the gradient to remove
  84344. * @returns the current particle system
  84345. */
  84346. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84347. /**
  84348. * Gets the current list of life time gradients.
  84349. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84350. * @returns the list of life time gradients
  84351. */
  84352. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84353. /**
  84354. * Gets the current list of color gradients.
  84355. * You must use addColorGradient and removeColorGradient to udpate this list
  84356. * @returns the list of color gradients
  84357. */
  84358. getColorGradients(): Nullable<Array<ColorGradient>>;
  84359. /**
  84360. * Adds a new ramp gradient used to remap particle colors
  84361. * @param gradient defines the gradient to use (between 0 and 1)
  84362. * @param color defines the color to affect to the specified gradient
  84363. * @returns the current particle system
  84364. */
  84365. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84366. /**
  84367. * Gets the current list of ramp gradients.
  84368. * You must use addRampGradient and removeRampGradient to udpate this list
  84369. * @returns the list of ramp gradients
  84370. */
  84371. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84372. /** Gets or sets a boolean indicating that ramp gradients must be used
  84373. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84374. */
  84375. useRampGradients: boolean;
  84376. /**
  84377. * Adds a new color remap gradient
  84378. * @param gradient defines the gradient to use (between 0 and 1)
  84379. * @param min defines the color remap minimal range
  84380. * @param max defines the color remap maximal range
  84381. * @returns the current particle system
  84382. */
  84383. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84384. /**
  84385. * Gets the current list of color remap gradients.
  84386. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84387. * @returns the list of color remap gradients
  84388. */
  84389. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84390. /**
  84391. * Adds a new alpha remap gradient
  84392. * @param gradient defines the gradient to use (between 0 and 1)
  84393. * @param min defines the alpha remap minimal range
  84394. * @param max defines the alpha remap maximal range
  84395. * @returns the current particle system
  84396. */
  84397. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84398. /**
  84399. * Gets the current list of alpha remap gradients.
  84400. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84401. * @returns the list of alpha remap gradients
  84402. */
  84403. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84404. /**
  84405. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84406. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84407. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84408. * @returns the emitter
  84409. */
  84410. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84411. /**
  84412. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84413. * @param radius The radius of the hemisphere to emit from
  84414. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84415. * @returns the emitter
  84416. */
  84417. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84418. /**
  84419. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84420. * @param radius The radius of the sphere to emit from
  84421. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84422. * @returns the emitter
  84423. */
  84424. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84425. /**
  84426. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84427. * @param radius The radius of the sphere to emit from
  84428. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84429. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84430. * @returns the emitter
  84431. */
  84432. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84433. /**
  84434. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84435. * @param radius The radius of the emission cylinder
  84436. * @param height The height of the emission cylinder
  84437. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84438. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84439. * @returns the emitter
  84440. */
  84441. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84442. /**
  84443. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84444. * @param radius The radius of the cylinder to emit from
  84445. * @param height The height of the emission cylinder
  84446. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84449. * @returns the emitter
  84450. */
  84451. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84452. /**
  84453. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84454. * @param radius The radius of the cone to emit from
  84455. * @param angle The base angle of the cone
  84456. * @returns the emitter
  84457. */
  84458. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84459. /**
  84460. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84461. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84462. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84463. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84464. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84465. * @returns the emitter
  84466. */
  84467. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84468. /**
  84469. * Get hosting scene
  84470. * @returns the scene
  84471. */
  84472. getScene(): Scene;
  84473. }
  84474. }
  84475. declare module BABYLON {
  84476. /**
  84477. * Creates an instance based on a source mesh.
  84478. */
  84479. export class InstancedMesh extends AbstractMesh {
  84480. private _sourceMesh;
  84481. private _currentLOD;
  84482. /** @hidden */
  84483. _indexInSourceMeshInstanceArray: number;
  84484. constructor(name: string, source: Mesh);
  84485. /**
  84486. * Returns the string "InstancedMesh".
  84487. */
  84488. getClassName(): string;
  84489. /** Gets the list of lights affecting that mesh */
  84490. readonly lightSources: Light[];
  84491. _resyncLightSources(): void;
  84492. _resyncLighSource(light: Light): void;
  84493. _removeLightSource(light: Light, dispose: boolean): void;
  84494. /**
  84495. * If the source mesh receives shadows
  84496. */
  84497. readonly receiveShadows: boolean;
  84498. /**
  84499. * The material of the source mesh
  84500. */
  84501. readonly material: Nullable<Material>;
  84502. /**
  84503. * Visibility of the source mesh
  84504. */
  84505. readonly visibility: number;
  84506. /**
  84507. * Skeleton of the source mesh
  84508. */
  84509. readonly skeleton: Nullable<Skeleton>;
  84510. /**
  84511. * Rendering ground id of the source mesh
  84512. */
  84513. renderingGroupId: number;
  84514. /**
  84515. * Returns the total number of vertices (integer).
  84516. */
  84517. getTotalVertices(): number;
  84518. /**
  84519. * Returns a positive integer : the total number of indices in this mesh geometry.
  84520. * @returns the numner of indices or zero if the mesh has no geometry.
  84521. */
  84522. getTotalIndices(): number;
  84523. /**
  84524. * The source mesh of the instance
  84525. */
  84526. readonly sourceMesh: Mesh;
  84527. /**
  84528. * Is this node ready to be used/rendered
  84529. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84530. * @return {boolean} is it ready
  84531. */
  84532. isReady(completeCheck?: boolean): boolean;
  84533. /**
  84534. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84535. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  84536. * @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.
  84537. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  84538. */
  84539. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  84540. /**
  84541. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84542. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84543. * The `data` are either a numeric array either a Float32Array.
  84544. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  84545. * 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).
  84546. * Note that a new underlying VertexBuffer object is created each call.
  84547. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84548. *
  84549. * Possible `kind` values :
  84550. * - VertexBuffer.PositionKind
  84551. * - VertexBuffer.UVKind
  84552. * - VertexBuffer.UV2Kind
  84553. * - VertexBuffer.UV3Kind
  84554. * - VertexBuffer.UV4Kind
  84555. * - VertexBuffer.UV5Kind
  84556. * - VertexBuffer.UV6Kind
  84557. * - VertexBuffer.ColorKind
  84558. * - VertexBuffer.MatricesIndicesKind
  84559. * - VertexBuffer.MatricesIndicesExtraKind
  84560. * - VertexBuffer.MatricesWeightsKind
  84561. * - VertexBuffer.MatricesWeightsExtraKind
  84562. *
  84563. * Returns the Mesh.
  84564. */
  84565. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84566. /**
  84567. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84568. * If the mesh has no geometry, it is simply returned as it is.
  84569. * The `data` are either a numeric array either a Float32Array.
  84570. * No new underlying VertexBuffer object is created.
  84571. * 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.
  84572. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  84573. *
  84574. * Possible `kind` values :
  84575. * - VertexBuffer.PositionKind
  84576. * - VertexBuffer.UVKind
  84577. * - VertexBuffer.UV2Kind
  84578. * - VertexBuffer.UV3Kind
  84579. * - VertexBuffer.UV4Kind
  84580. * - VertexBuffer.UV5Kind
  84581. * - VertexBuffer.UV6Kind
  84582. * - VertexBuffer.ColorKind
  84583. * - VertexBuffer.MatricesIndicesKind
  84584. * - VertexBuffer.MatricesIndicesExtraKind
  84585. * - VertexBuffer.MatricesWeightsKind
  84586. * - VertexBuffer.MatricesWeightsExtraKind
  84587. *
  84588. * Returns the Mesh.
  84589. */
  84590. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  84591. /**
  84592. * Sets the mesh indices.
  84593. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  84594. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84595. * This method creates a new index buffer each call.
  84596. * Returns the Mesh.
  84597. */
  84598. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  84599. /**
  84600. * Boolean : True if the mesh owns the requested kind of data.
  84601. */
  84602. isVerticesDataPresent(kind: string): boolean;
  84603. /**
  84604. * Returns an array of indices (IndicesArray).
  84605. */
  84606. getIndices(): Nullable<IndicesArray>;
  84607. readonly _positions: Nullable<Vector3[]>;
  84608. /**
  84609. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84610. * This means the mesh underlying bounding box and sphere are recomputed.
  84611. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84612. * @returns the current mesh
  84613. */
  84614. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  84615. /** @hidden */
  84616. _preActivate(): InstancedMesh;
  84617. /** @hidden */
  84618. _activate(renderId: number, intermediateRendering: boolean): boolean;
  84619. /** @hidden */
  84620. _postActivate(): void;
  84621. getWorldMatrix(): Matrix;
  84622. readonly isAnInstance: boolean;
  84623. /**
  84624. * Returns the current associated LOD AbstractMesh.
  84625. */
  84626. getLOD(camera: Camera): AbstractMesh;
  84627. /** @hidden */
  84628. _syncSubMeshes(): InstancedMesh;
  84629. /** @hidden */
  84630. _generatePointsArray(): boolean;
  84631. /**
  84632. * Creates a new InstancedMesh from the current mesh.
  84633. * - name (string) : the cloned mesh name
  84634. * - newParent (optional Node) : the optional Node to parent the clone to.
  84635. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  84636. *
  84637. * Returns the clone.
  84638. */
  84639. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84640. /**
  84641. * Disposes the InstancedMesh.
  84642. * Returns nothing.
  84643. */
  84644. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84645. }
  84646. }
  84647. declare module BABYLON {
  84648. /**
  84649. * Defines the options associated with the creation of a shader material.
  84650. */
  84651. export interface IShaderMaterialOptions {
  84652. /**
  84653. * Does the material work in alpha blend mode
  84654. */
  84655. needAlphaBlending: boolean;
  84656. /**
  84657. * Does the material work in alpha test mode
  84658. */
  84659. needAlphaTesting: boolean;
  84660. /**
  84661. * The list of attribute names used in the shader
  84662. */
  84663. attributes: string[];
  84664. /**
  84665. * The list of unifrom names used in the shader
  84666. */
  84667. uniforms: string[];
  84668. /**
  84669. * The list of UBO names used in the shader
  84670. */
  84671. uniformBuffers: string[];
  84672. /**
  84673. * The list of sampler names used in the shader
  84674. */
  84675. samplers: string[];
  84676. /**
  84677. * The list of defines used in the shader
  84678. */
  84679. defines: string[];
  84680. }
  84681. /**
  84682. * 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.
  84683. *
  84684. * This returned material effects how the mesh will look based on the code in the shaders.
  84685. *
  84686. * @see http://doc.babylonjs.com/how_to/shader_material
  84687. */
  84688. export class ShaderMaterial extends Material {
  84689. private _shaderPath;
  84690. private _options;
  84691. private _textures;
  84692. private _textureArrays;
  84693. private _floats;
  84694. private _ints;
  84695. private _floatsArrays;
  84696. private _colors3;
  84697. private _colors3Arrays;
  84698. private _colors4;
  84699. private _colors4Arrays;
  84700. private _vectors2;
  84701. private _vectors3;
  84702. private _vectors4;
  84703. private _matrices;
  84704. private _matrices3x3;
  84705. private _matrices2x2;
  84706. private _vectors2Arrays;
  84707. private _vectors3Arrays;
  84708. private _vectors4Arrays;
  84709. private _cachedWorldViewMatrix;
  84710. private _cachedWorldViewProjectionMatrix;
  84711. private _renderId;
  84712. /**
  84713. * Instantiate a new shader material.
  84714. * 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.
  84715. * This returned material effects how the mesh will look based on the code in the shaders.
  84716. * @see http://doc.babylonjs.com/how_to/shader_material
  84717. * @param name Define the name of the material in the scene
  84718. * @param scene Define the scene the material belongs to
  84719. * @param shaderPath Defines the route to the shader code in one of three ways:
  84720. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  84721. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  84722. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  84723. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  84724. * @param options Define the options used to create the shader
  84725. */
  84726. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  84727. /**
  84728. * Gets the options used to compile the shader.
  84729. * They can be modified to trigger a new compilation
  84730. */
  84731. readonly options: IShaderMaterialOptions;
  84732. /**
  84733. * Gets the current class name of the material e.g. "ShaderMaterial"
  84734. * Mainly use in serialization.
  84735. * @returns the class name
  84736. */
  84737. getClassName(): string;
  84738. /**
  84739. * Specifies if the material will require alpha blending
  84740. * @returns a boolean specifying if alpha blending is needed
  84741. */
  84742. needAlphaBlending(): boolean;
  84743. /**
  84744. * Specifies if this material should be rendered in alpha test mode
  84745. * @returns a boolean specifying if an alpha test is needed.
  84746. */
  84747. needAlphaTesting(): boolean;
  84748. private _checkUniform;
  84749. /**
  84750. * Set a texture in the shader.
  84751. * @param name Define the name of the uniform samplers as defined in the shader
  84752. * @param texture Define the texture to bind to this sampler
  84753. * @return the material itself allowing "fluent" like uniform updates
  84754. */
  84755. setTexture(name: string, texture: Texture): ShaderMaterial;
  84756. /**
  84757. * Set a texture array in the shader.
  84758. * @param name Define the name of the uniform sampler array as defined in the shader
  84759. * @param textures Define the list of textures to bind to this sampler
  84760. * @return the material itself allowing "fluent" like uniform updates
  84761. */
  84762. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  84763. /**
  84764. * Set a float in the shader.
  84765. * @param name Define the name of the uniform as defined in the shader
  84766. * @param value Define the value to give to the uniform
  84767. * @return the material itself allowing "fluent" like uniform updates
  84768. */
  84769. setFloat(name: string, value: number): ShaderMaterial;
  84770. /**
  84771. * Set a int in the shader.
  84772. * @param name Define the name of the uniform as defined in the shader
  84773. * @param value Define the value to give to the uniform
  84774. * @return the material itself allowing "fluent" like uniform updates
  84775. */
  84776. setInt(name: string, value: number): ShaderMaterial;
  84777. /**
  84778. * Set an array of floats in the shader.
  84779. * @param name Define the name of the uniform as defined in the shader
  84780. * @param value Define the value to give to the uniform
  84781. * @return the material itself allowing "fluent" like uniform updates
  84782. */
  84783. setFloats(name: string, value: number[]): ShaderMaterial;
  84784. /**
  84785. * Set a vec3 in the shader from a Color3.
  84786. * @param name Define the name of the uniform as defined in the shader
  84787. * @param value Define the value to give to the uniform
  84788. * @return the material itself allowing "fluent" like uniform updates
  84789. */
  84790. setColor3(name: string, value: Color3): ShaderMaterial;
  84791. /**
  84792. * Set a vec3 array in the shader from a Color3 array.
  84793. * @param name Define the name of the uniform as defined in the shader
  84794. * @param value Define the value to give to the uniform
  84795. * @return the material itself allowing "fluent" like uniform updates
  84796. */
  84797. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  84798. /**
  84799. * Set a vec4 in the shader from a Color4.
  84800. * @param name Define the name of the uniform as defined in the shader
  84801. * @param value Define the value to give to the uniform
  84802. * @return the material itself allowing "fluent" like uniform updates
  84803. */
  84804. setColor4(name: string, value: Color4): ShaderMaterial;
  84805. /**
  84806. * Set a vec4 array in the shader from a Color4 array.
  84807. * @param name Define the name of the uniform as defined in the shader
  84808. * @param value Define the value to give to the uniform
  84809. * @return the material itself allowing "fluent" like uniform updates
  84810. */
  84811. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  84812. /**
  84813. * Set a vec2 in the shader from a Vector2.
  84814. * @param name Define the name of the uniform as defined in the shader
  84815. * @param value Define the value to give to the uniform
  84816. * @return the material itself allowing "fluent" like uniform updates
  84817. */
  84818. setVector2(name: string, value: Vector2): ShaderMaterial;
  84819. /**
  84820. * Set a vec3 in the shader from a Vector3.
  84821. * @param name Define the name of the uniform as defined in the shader
  84822. * @param value Define the value to give to the uniform
  84823. * @return the material itself allowing "fluent" like uniform updates
  84824. */
  84825. setVector3(name: string, value: Vector3): ShaderMaterial;
  84826. /**
  84827. * Set a vec4 in the shader from a Vector4.
  84828. * @param name Define the name of the uniform as defined in the shader
  84829. * @param value Define the value to give to the uniform
  84830. * @return the material itself allowing "fluent" like uniform updates
  84831. */
  84832. setVector4(name: string, value: Vector4): ShaderMaterial;
  84833. /**
  84834. * Set a mat4 in the shader from a Matrix.
  84835. * @param name Define the name of the uniform as defined in the shader
  84836. * @param value Define the value to give to the uniform
  84837. * @return the material itself allowing "fluent" like uniform updates
  84838. */
  84839. setMatrix(name: string, value: Matrix): ShaderMaterial;
  84840. /**
  84841. * Set a mat3 in the shader from a Float32Array.
  84842. * @param name Define the name of the uniform as defined in the shader
  84843. * @param value Define the value to give to the uniform
  84844. * @return the material itself allowing "fluent" like uniform updates
  84845. */
  84846. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  84847. /**
  84848. * Set a mat2 in the shader from a Float32Array.
  84849. * @param name Define the name of the uniform as defined in the shader
  84850. * @param value Define the value to give to the uniform
  84851. * @return the material itself allowing "fluent" like uniform updates
  84852. */
  84853. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  84854. /**
  84855. * Set a vec2 array in the shader from a number array.
  84856. * @param name Define the name of the uniform as defined in the shader
  84857. * @param value Define the value to give to the uniform
  84858. * @return the material itself allowing "fluent" like uniform updates
  84859. */
  84860. setArray2(name: string, value: number[]): ShaderMaterial;
  84861. /**
  84862. * Set a vec3 array in the shader from a number array.
  84863. * @param name Define the name of the uniform as defined in the shader
  84864. * @param value Define the value to give to the uniform
  84865. * @return the material itself allowing "fluent" like uniform updates
  84866. */
  84867. setArray3(name: string, value: number[]): ShaderMaterial;
  84868. /**
  84869. * Set a vec4 array in the shader from a number array.
  84870. * @param name Define the name of the uniform as defined in the shader
  84871. * @param value Define the value to give to the uniform
  84872. * @return the material itself allowing "fluent" like uniform updates
  84873. */
  84874. setArray4(name: string, value: number[]): ShaderMaterial;
  84875. private _checkCache;
  84876. /**
  84877. * Specifies that the submesh is ready to be used
  84878. * @param mesh defines the mesh to check
  84879. * @param subMesh defines which submesh to check
  84880. * @param useInstances specifies that instances should be used
  84881. * @returns a boolean indicating that the submesh is ready or not
  84882. */
  84883. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84884. /**
  84885. * Checks if the material is ready to render the requested mesh
  84886. * @param mesh Define the mesh to render
  84887. * @param useInstances Define whether or not the material is used with instances
  84888. * @returns true if ready, otherwise false
  84889. */
  84890. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84891. /**
  84892. * Binds the world matrix to the material
  84893. * @param world defines the world transformation matrix
  84894. */
  84895. bindOnlyWorldMatrix(world: Matrix): void;
  84896. /**
  84897. * Binds the material to the mesh
  84898. * @param world defines the world transformation matrix
  84899. * @param mesh defines the mesh to bind the material to
  84900. */
  84901. bind(world: Matrix, mesh?: Mesh): void;
  84902. /**
  84903. * Gets the active textures from the material
  84904. * @returns an array of textures
  84905. */
  84906. getActiveTextures(): BaseTexture[];
  84907. /**
  84908. * Specifies if the material uses a texture
  84909. * @param texture defines the texture to check against the material
  84910. * @returns a boolean specifying if the material uses the texture
  84911. */
  84912. hasTexture(texture: BaseTexture): boolean;
  84913. /**
  84914. * Makes a duplicate of the material, and gives it a new name
  84915. * @param name defines the new name for the duplicated material
  84916. * @returns the cloned material
  84917. */
  84918. clone(name: string): ShaderMaterial;
  84919. /**
  84920. * Disposes the material
  84921. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84922. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84923. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84924. */
  84925. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84926. /**
  84927. * Serializes this material in a JSON representation
  84928. * @returns the serialized material object
  84929. */
  84930. serialize(): any;
  84931. /**
  84932. * Creates a shader material from parsed shader material data
  84933. * @param source defines the JSON represnetation of the material
  84934. * @param scene defines the hosting scene
  84935. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84936. * @returns a new material
  84937. */
  84938. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  84939. }
  84940. }
  84941. declare module BABYLON {
  84942. /** @hidden */
  84943. export var colorPixelShader: {
  84944. name: string;
  84945. shader: string;
  84946. };
  84947. }
  84948. declare module BABYLON {
  84949. /** @hidden */
  84950. export var colorVertexShader: {
  84951. name: string;
  84952. shader: string;
  84953. };
  84954. }
  84955. declare module BABYLON {
  84956. /**
  84957. * Line mesh
  84958. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  84959. */
  84960. export class LinesMesh extends Mesh {
  84961. /**
  84962. * If vertex color should be applied to the mesh
  84963. */
  84964. readonly useVertexColor?: boolean | undefined;
  84965. /**
  84966. * If vertex alpha should be applied to the mesh
  84967. */
  84968. readonly useVertexAlpha?: boolean | undefined;
  84969. /**
  84970. * Color of the line (Default: White)
  84971. */
  84972. color: Color3;
  84973. /**
  84974. * Alpha of the line (Default: 1)
  84975. */
  84976. alpha: number;
  84977. /**
  84978. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84979. * This margin is expressed in world space coordinates, so its value may vary.
  84980. * Default value is 0.1
  84981. */
  84982. intersectionThreshold: number;
  84983. private _colorShader;
  84984. private color4;
  84985. /**
  84986. * Creates a new LinesMesh
  84987. * @param name defines the name
  84988. * @param scene defines the hosting scene
  84989. * @param parent defines the parent mesh if any
  84990. * @param source defines the optional source LinesMesh used to clone data from
  84991. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  84992. * When false, achieved by calling a clone(), also passing False.
  84993. * This will make creation of children, recursive.
  84994. * @param useVertexColor defines if this LinesMesh supports vertex color
  84995. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  84996. */
  84997. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  84998. /**
  84999. * If vertex color should be applied to the mesh
  85000. */
  85001. useVertexColor?: boolean | undefined,
  85002. /**
  85003. * If vertex alpha should be applied to the mesh
  85004. */
  85005. useVertexAlpha?: boolean | undefined);
  85006. private _addClipPlaneDefine;
  85007. private _removeClipPlaneDefine;
  85008. isReady(): boolean;
  85009. /**
  85010. * Returns the string "LineMesh"
  85011. */
  85012. getClassName(): string;
  85013. /**
  85014. * @hidden
  85015. */
  85016. /**
  85017. * @hidden
  85018. */
  85019. material: Material;
  85020. /**
  85021. * @hidden
  85022. */
  85023. readonly checkCollisions: boolean;
  85024. /** @hidden */
  85025. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  85026. /** @hidden */
  85027. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  85028. /**
  85029. * Disposes of the line mesh
  85030. * @param doNotRecurse If children should be disposed
  85031. */
  85032. dispose(doNotRecurse?: boolean): void;
  85033. /**
  85034. * Returns a new LineMesh object cloned from the current one.
  85035. */
  85036. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85037. /**
  85038. * Creates a new InstancedLinesMesh object from the mesh model.
  85039. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85040. * @param name defines the name of the new instance
  85041. * @returns a new InstancedLinesMesh
  85042. */
  85043. createInstance(name: string): InstancedLinesMesh;
  85044. }
  85045. /**
  85046. * Creates an instance based on a source LinesMesh
  85047. */
  85048. export class InstancedLinesMesh extends InstancedMesh {
  85049. /**
  85050. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85051. * This margin is expressed in world space coordinates, so its value may vary.
  85052. * Initilized with the intersectionThreshold value of the source LinesMesh
  85053. */
  85054. intersectionThreshold: number;
  85055. constructor(name: string, source: LinesMesh);
  85056. /**
  85057. * Returns the string "InstancedLinesMesh".
  85058. */
  85059. getClassName(): string;
  85060. }
  85061. }
  85062. declare module BABYLON {
  85063. /** @hidden */
  85064. export var linePixelShader: {
  85065. name: string;
  85066. shader: string;
  85067. };
  85068. }
  85069. declare module BABYLON {
  85070. /** @hidden */
  85071. export var lineVertexShader: {
  85072. name: string;
  85073. shader: string;
  85074. };
  85075. }
  85076. declare module BABYLON {
  85077. interface AbstractMesh {
  85078. /**
  85079. * Gets the edgesRenderer associated with the mesh
  85080. */
  85081. edgesRenderer: Nullable<EdgesRenderer>;
  85082. }
  85083. interface LinesMesh {
  85084. /**
  85085. * Enables the edge rendering mode on the mesh.
  85086. * This mode makes the mesh edges visible
  85087. * @param epsilon defines the maximal distance between two angles to detect a face
  85088. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85089. * @returns the currentAbstractMesh
  85090. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85091. */
  85092. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  85093. }
  85094. interface InstancedLinesMesh {
  85095. /**
  85096. * Enables the edge rendering mode on the mesh.
  85097. * This mode makes the mesh edges visible
  85098. * @param epsilon defines the maximal distance between two angles to detect a face
  85099. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85100. * @returns the current InstancedLinesMesh
  85101. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85102. */
  85103. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  85104. }
  85105. /**
  85106. * Defines the minimum contract an Edges renderer should follow.
  85107. */
  85108. export interface IEdgesRenderer extends IDisposable {
  85109. /**
  85110. * Gets or sets a boolean indicating if the edgesRenderer is active
  85111. */
  85112. isEnabled: boolean;
  85113. /**
  85114. * Renders the edges of the attached mesh,
  85115. */
  85116. render(): void;
  85117. /**
  85118. * Checks wether or not the edges renderer is ready to render.
  85119. * @return true if ready, otherwise false.
  85120. */
  85121. isReady(): boolean;
  85122. }
  85123. /**
  85124. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  85125. */
  85126. export class EdgesRenderer implements IEdgesRenderer {
  85127. /**
  85128. * Define the size of the edges with an orthographic camera
  85129. */
  85130. edgesWidthScalerForOrthographic: number;
  85131. /**
  85132. * Define the size of the edges with a perspective camera
  85133. */
  85134. edgesWidthScalerForPerspective: number;
  85135. protected _source: AbstractMesh;
  85136. protected _linesPositions: number[];
  85137. protected _linesNormals: number[];
  85138. protected _linesIndices: number[];
  85139. protected _epsilon: number;
  85140. protected _indicesCount: number;
  85141. protected _lineShader: ShaderMaterial;
  85142. protected _ib: DataBuffer;
  85143. protected _buffers: {
  85144. [key: string]: Nullable<VertexBuffer>;
  85145. };
  85146. protected _checkVerticesInsteadOfIndices: boolean;
  85147. private _meshRebuildObserver;
  85148. private _meshDisposeObserver;
  85149. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  85150. isEnabled: boolean;
  85151. /**
  85152. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  85153. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  85154. * @param source Mesh used to create edges
  85155. * @param epsilon sum of angles in adjacency to check for edge
  85156. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  85157. * @param generateEdgesLines - should generate Lines or only prepare resources.
  85158. */
  85159. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  85160. protected _prepareRessources(): void;
  85161. /** @hidden */
  85162. _rebuild(): void;
  85163. /**
  85164. * Releases the required resources for the edges renderer
  85165. */
  85166. dispose(): void;
  85167. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  85168. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  85169. /**
  85170. * Checks if the pair of p0 and p1 is en edge
  85171. * @param faceIndex
  85172. * @param edge
  85173. * @param faceNormals
  85174. * @param p0
  85175. * @param p1
  85176. * @private
  85177. */
  85178. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  85179. /**
  85180. * push line into the position, normal and index buffer
  85181. * @protected
  85182. */
  85183. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  85184. /**
  85185. * Generates lines edges from adjacencjes
  85186. * @private
  85187. */
  85188. _generateEdgesLines(): void;
  85189. /**
  85190. * Checks wether or not the edges renderer is ready to render.
  85191. * @return true if ready, otherwise false.
  85192. */
  85193. isReady(): boolean;
  85194. /**
  85195. * Renders the edges of the attached mesh,
  85196. */
  85197. render(): void;
  85198. }
  85199. /**
  85200. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  85201. */
  85202. export class LineEdgesRenderer extends EdgesRenderer {
  85203. /**
  85204. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  85205. * @param source LineMesh used to generate edges
  85206. * @param epsilon not important (specified angle for edge detection)
  85207. * @param checkVerticesInsteadOfIndices not important for LineMesh
  85208. */
  85209. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  85210. /**
  85211. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  85212. */
  85213. _generateEdgesLines(): void;
  85214. }
  85215. }
  85216. declare module BABYLON {
  85217. /**
  85218. * This represents the object necessary to create a rendering group.
  85219. * This is exclusively used and created by the rendering manager.
  85220. * To modify the behavior, you use the available helpers in your scene or meshes.
  85221. * @hidden
  85222. */
  85223. export class RenderingGroup {
  85224. index: number;
  85225. private static _zeroVector;
  85226. private _scene;
  85227. private _opaqueSubMeshes;
  85228. private _transparentSubMeshes;
  85229. private _alphaTestSubMeshes;
  85230. private _depthOnlySubMeshes;
  85231. private _particleSystems;
  85232. private _spriteManagers;
  85233. private _opaqueSortCompareFn;
  85234. private _alphaTestSortCompareFn;
  85235. private _transparentSortCompareFn;
  85236. private _renderOpaque;
  85237. private _renderAlphaTest;
  85238. private _renderTransparent;
  85239. /** @hidden */
  85240. _edgesRenderers: SmartArray<IEdgesRenderer>;
  85241. onBeforeTransparentRendering: () => void;
  85242. /**
  85243. * Set the opaque sort comparison function.
  85244. * If null the sub meshes will be render in the order they were created
  85245. */
  85246. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85247. /**
  85248. * Set the alpha test sort comparison function.
  85249. * If null the sub meshes will be render in the order they were created
  85250. */
  85251. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85252. /**
  85253. * Set the transparent sort comparison function.
  85254. * If null the sub meshes will be render in the order they were created
  85255. */
  85256. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85257. /**
  85258. * Creates a new rendering group.
  85259. * @param index The rendering group index
  85260. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  85261. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  85262. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  85263. */
  85264. 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>);
  85265. /**
  85266. * Render all the sub meshes contained in the group.
  85267. * @param customRenderFunction Used to override the default render behaviour of the group.
  85268. * @returns true if rendered some submeshes.
  85269. */
  85270. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  85271. /**
  85272. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  85273. * @param subMeshes The submeshes to render
  85274. */
  85275. private renderOpaqueSorted;
  85276. /**
  85277. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  85278. * @param subMeshes The submeshes to render
  85279. */
  85280. private renderAlphaTestSorted;
  85281. /**
  85282. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  85283. * @param subMeshes The submeshes to render
  85284. */
  85285. private renderTransparentSorted;
  85286. /**
  85287. * Renders the submeshes in a specified order.
  85288. * @param subMeshes The submeshes to sort before render
  85289. * @param sortCompareFn The comparison function use to sort
  85290. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  85291. * @param transparent Specifies to activate blending if true
  85292. */
  85293. private static renderSorted;
  85294. /**
  85295. * Renders the submeshes in the order they were dispatched (no sort applied).
  85296. * @param subMeshes The submeshes to render
  85297. */
  85298. private static renderUnsorted;
  85299. /**
  85300. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85301. * are rendered back to front if in the same alpha index.
  85302. *
  85303. * @param a The first submesh
  85304. * @param b The second submesh
  85305. * @returns The result of the comparison
  85306. */
  85307. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  85308. /**
  85309. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85310. * are rendered back to front.
  85311. *
  85312. * @param a The first submesh
  85313. * @param b The second submesh
  85314. * @returns The result of the comparison
  85315. */
  85316. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  85317. /**
  85318. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85319. * are rendered front to back (prevent overdraw).
  85320. *
  85321. * @param a The first submesh
  85322. * @param b The second submesh
  85323. * @returns The result of the comparison
  85324. */
  85325. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  85326. /**
  85327. * Resets the different lists of submeshes to prepare a new frame.
  85328. */
  85329. prepare(): void;
  85330. dispose(): void;
  85331. /**
  85332. * Inserts the submesh in its correct queue depending on its material.
  85333. * @param subMesh The submesh to dispatch
  85334. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85335. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85336. */
  85337. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85338. dispatchSprites(spriteManager: ISpriteManager): void;
  85339. dispatchParticles(particleSystem: IParticleSystem): void;
  85340. private _renderParticles;
  85341. private _renderSprites;
  85342. }
  85343. }
  85344. declare module BABYLON {
  85345. /**
  85346. * Interface describing the different options available in the rendering manager
  85347. * regarding Auto Clear between groups.
  85348. */
  85349. export interface IRenderingManagerAutoClearSetup {
  85350. /**
  85351. * Defines whether or not autoclear is enable.
  85352. */
  85353. autoClear: boolean;
  85354. /**
  85355. * Defines whether or not to autoclear the depth buffer.
  85356. */
  85357. depth: boolean;
  85358. /**
  85359. * Defines whether or not to autoclear the stencil buffer.
  85360. */
  85361. stencil: boolean;
  85362. }
  85363. /**
  85364. * This class is used by the onRenderingGroupObservable
  85365. */
  85366. export class RenderingGroupInfo {
  85367. /**
  85368. * The Scene that being rendered
  85369. */
  85370. scene: Scene;
  85371. /**
  85372. * The camera currently used for the rendering pass
  85373. */
  85374. camera: Nullable<Camera>;
  85375. /**
  85376. * The ID of the renderingGroup being processed
  85377. */
  85378. renderingGroupId: number;
  85379. }
  85380. /**
  85381. * This is the manager responsible of all the rendering for meshes sprites and particles.
  85382. * It is enable to manage the different groups as well as the different necessary sort functions.
  85383. * This should not be used directly aside of the few static configurations
  85384. */
  85385. export class RenderingManager {
  85386. /**
  85387. * The max id used for rendering groups (not included)
  85388. */
  85389. static MAX_RENDERINGGROUPS: number;
  85390. /**
  85391. * The min id used for rendering groups (included)
  85392. */
  85393. static MIN_RENDERINGGROUPS: number;
  85394. /**
  85395. * Used to globally prevent autoclearing scenes.
  85396. */
  85397. static AUTOCLEAR: boolean;
  85398. /**
  85399. * @hidden
  85400. */
  85401. _useSceneAutoClearSetup: boolean;
  85402. private _scene;
  85403. private _renderingGroups;
  85404. private _depthStencilBufferAlreadyCleaned;
  85405. private _autoClearDepthStencil;
  85406. private _customOpaqueSortCompareFn;
  85407. private _customAlphaTestSortCompareFn;
  85408. private _customTransparentSortCompareFn;
  85409. private _renderingGroupInfo;
  85410. /**
  85411. * Instantiates a new rendering group for a particular scene
  85412. * @param scene Defines the scene the groups belongs to
  85413. */
  85414. constructor(scene: Scene);
  85415. private _clearDepthStencilBuffer;
  85416. /**
  85417. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  85418. * @hidden
  85419. */
  85420. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  85421. /**
  85422. * Resets the different information of the group to prepare a new frame
  85423. * @hidden
  85424. */
  85425. reset(): void;
  85426. /**
  85427. * Dispose and release the group and its associated resources.
  85428. * @hidden
  85429. */
  85430. dispose(): void;
  85431. /**
  85432. * Clear the info related to rendering groups preventing retention points during dispose.
  85433. */
  85434. freeRenderingGroups(): void;
  85435. private _prepareRenderingGroup;
  85436. /**
  85437. * Add a sprite manager to the rendering manager in order to render it this frame.
  85438. * @param spriteManager Define the sprite manager to render
  85439. */
  85440. dispatchSprites(spriteManager: ISpriteManager): void;
  85441. /**
  85442. * Add a particle system to the rendering manager in order to render it this frame.
  85443. * @param particleSystem Define the particle system to render
  85444. */
  85445. dispatchParticles(particleSystem: IParticleSystem): void;
  85446. /**
  85447. * Add a submesh to the manager in order to render it this frame
  85448. * @param subMesh The submesh to dispatch
  85449. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85450. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85451. */
  85452. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85453. /**
  85454. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85455. * This allowed control for front to back rendering or reversly depending of the special needs.
  85456. *
  85457. * @param renderingGroupId The rendering group id corresponding to its index
  85458. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85459. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85460. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85461. */
  85462. 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;
  85463. /**
  85464. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85465. *
  85466. * @param renderingGroupId The rendering group id corresponding to its index
  85467. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85468. * @param depth Automatically clears depth between groups if true and autoClear is true.
  85469. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  85470. */
  85471. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  85472. /**
  85473. * Gets the current auto clear configuration for one rendering group of the rendering
  85474. * manager.
  85475. * @param index the rendering group index to get the information for
  85476. * @returns The auto clear setup for the requested rendering group
  85477. */
  85478. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  85479. }
  85480. }
  85481. declare module BABYLON {
  85482. /**
  85483. * This Helps creating a texture that will be created from a camera in your scene.
  85484. * It is basically a dynamic texture that could be used to create special effects for instance.
  85485. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  85486. */
  85487. export class RenderTargetTexture extends Texture {
  85488. isCube: boolean;
  85489. /**
  85490. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  85491. */
  85492. static readonly REFRESHRATE_RENDER_ONCE: number;
  85493. /**
  85494. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  85495. */
  85496. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  85497. /**
  85498. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  85499. * the central point of your effect and can save a lot of performances.
  85500. */
  85501. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  85502. /**
  85503. * Use this predicate to dynamically define the list of mesh you want to render.
  85504. * If set, the renderList property will be overwritten.
  85505. */
  85506. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  85507. private _renderList;
  85508. /**
  85509. * Use this list to define the list of mesh you want to render.
  85510. */
  85511. renderList: Nullable<Array<AbstractMesh>>;
  85512. private _hookArray;
  85513. /**
  85514. * Define if particles should be rendered in your texture.
  85515. */
  85516. renderParticles: boolean;
  85517. /**
  85518. * Define if sprites should be rendered in your texture.
  85519. */
  85520. renderSprites: boolean;
  85521. /**
  85522. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  85523. */
  85524. coordinatesMode: number;
  85525. /**
  85526. * Define the camera used to render the texture.
  85527. */
  85528. activeCamera: Nullable<Camera>;
  85529. /**
  85530. * Override the render function of the texture with your own one.
  85531. */
  85532. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  85533. /**
  85534. * Define if camera post processes should be use while rendering the texture.
  85535. */
  85536. useCameraPostProcesses: boolean;
  85537. /**
  85538. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  85539. */
  85540. ignoreCameraViewport: boolean;
  85541. private _postProcessManager;
  85542. private _postProcesses;
  85543. private _resizeObserver;
  85544. /**
  85545. * An event triggered when the texture is unbind.
  85546. */
  85547. onBeforeBindObservable: Observable<RenderTargetTexture>;
  85548. /**
  85549. * An event triggered when the texture is unbind.
  85550. */
  85551. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  85552. private _onAfterUnbindObserver;
  85553. /**
  85554. * Set a after unbind callback in the texture.
  85555. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  85556. */
  85557. onAfterUnbind: () => void;
  85558. /**
  85559. * An event triggered before rendering the texture
  85560. */
  85561. onBeforeRenderObservable: Observable<number>;
  85562. private _onBeforeRenderObserver;
  85563. /**
  85564. * Set a before render callback in the texture.
  85565. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  85566. */
  85567. onBeforeRender: (faceIndex: number) => void;
  85568. /**
  85569. * An event triggered after rendering the texture
  85570. */
  85571. onAfterRenderObservable: Observable<number>;
  85572. private _onAfterRenderObserver;
  85573. /**
  85574. * Set a after render callback in the texture.
  85575. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  85576. */
  85577. onAfterRender: (faceIndex: number) => void;
  85578. /**
  85579. * An event triggered after the texture clear
  85580. */
  85581. onClearObservable: Observable<Engine>;
  85582. private _onClearObserver;
  85583. /**
  85584. * Set a clear callback in the texture.
  85585. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  85586. */
  85587. onClear: (Engine: Engine) => void;
  85588. /**
  85589. * An event triggered when the texture is resized.
  85590. */
  85591. onResizeObservable: Observable<RenderTargetTexture>;
  85592. /**
  85593. * Define the clear color of the Render Target if it should be different from the scene.
  85594. */
  85595. clearColor: Color4;
  85596. protected _size: number | {
  85597. width: number;
  85598. height: number;
  85599. };
  85600. protected _initialSizeParameter: number | {
  85601. width: number;
  85602. height: number;
  85603. } | {
  85604. ratio: number;
  85605. };
  85606. protected _sizeRatio: Nullable<number>;
  85607. /** @hidden */
  85608. _generateMipMaps: boolean;
  85609. protected _renderingManager: RenderingManager;
  85610. /** @hidden */
  85611. _waitingRenderList: string[];
  85612. protected _doNotChangeAspectRatio: boolean;
  85613. protected _currentRefreshId: number;
  85614. protected _refreshRate: number;
  85615. protected _textureMatrix: Matrix;
  85616. protected _samples: number;
  85617. protected _renderTargetOptions: RenderTargetCreationOptions;
  85618. /**
  85619. * Gets render target creation options that were used.
  85620. */
  85621. readonly renderTargetOptions: RenderTargetCreationOptions;
  85622. protected _engine: Engine;
  85623. protected _onRatioRescale(): void;
  85624. /**
  85625. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  85626. * It must define where the camera used to render the texture is set
  85627. */
  85628. boundingBoxPosition: Vector3;
  85629. private _boundingBoxSize;
  85630. /**
  85631. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  85632. * When defined, the cubemap will switch to local mode
  85633. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85634. * @example https://www.babylonjs-playground.com/#RNASML
  85635. */
  85636. boundingBoxSize: Vector3;
  85637. /**
  85638. * In case the RTT has been created with a depth texture, get the associated
  85639. * depth texture.
  85640. * Otherwise, return null.
  85641. */
  85642. depthStencilTexture: Nullable<InternalTexture>;
  85643. /**
  85644. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  85645. * or used a shadow, depth texture...
  85646. * @param name The friendly name of the texture
  85647. * @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)
  85648. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  85649. * @param generateMipMaps True if mip maps need to be generated after render.
  85650. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  85651. * @param type The type of the buffer in the RTT (int, half float, float...)
  85652. * @param isCube True if a cube texture needs to be created
  85653. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  85654. * @param generateDepthBuffer True to generate a depth buffer
  85655. * @param generateStencilBuffer True to generate a stencil buffer
  85656. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  85657. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  85658. * @param delayAllocation if the texture allocation should be delayed (default: false)
  85659. */
  85660. constructor(name: string, size: number | {
  85661. width: number;
  85662. height: number;
  85663. } | {
  85664. ratio: number;
  85665. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  85666. /**
  85667. * Creates a depth stencil texture.
  85668. * This is only available in WebGL 2 or with the depth texture extension available.
  85669. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  85670. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  85671. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  85672. */
  85673. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  85674. private _processSizeParameter;
  85675. /**
  85676. * Define the number of samples to use in case of MSAA.
  85677. * It defaults to one meaning no MSAA has been enabled.
  85678. */
  85679. samples: number;
  85680. /**
  85681. * Resets the refresh counter of the texture and start bak from scratch.
  85682. * Could be useful to regenerate the texture if it is setup to render only once.
  85683. */
  85684. resetRefreshCounter(): void;
  85685. /**
  85686. * Define the refresh rate of the texture or the rendering frequency.
  85687. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85688. */
  85689. refreshRate: number;
  85690. /**
  85691. * Adds a post process to the render target rendering passes.
  85692. * @param postProcess define the post process to add
  85693. */
  85694. addPostProcess(postProcess: PostProcess): void;
  85695. /**
  85696. * Clear all the post processes attached to the render target
  85697. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  85698. */
  85699. clearPostProcesses(dispose?: boolean): void;
  85700. /**
  85701. * Remove one of the post process from the list of attached post processes to the texture
  85702. * @param postProcess define the post process to remove from the list
  85703. */
  85704. removePostProcess(postProcess: PostProcess): void;
  85705. /** @hidden */
  85706. _shouldRender(): boolean;
  85707. /**
  85708. * Gets the actual render size of the texture.
  85709. * @returns the width of the render size
  85710. */
  85711. getRenderSize(): number;
  85712. /**
  85713. * Gets the actual render width of the texture.
  85714. * @returns the width of the render size
  85715. */
  85716. getRenderWidth(): number;
  85717. /**
  85718. * Gets the actual render height of the texture.
  85719. * @returns the height of the render size
  85720. */
  85721. getRenderHeight(): number;
  85722. /**
  85723. * Get if the texture can be rescaled or not.
  85724. */
  85725. readonly canRescale: boolean;
  85726. /**
  85727. * Resize the texture using a ratio.
  85728. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  85729. */
  85730. scale(ratio: number): void;
  85731. /**
  85732. * Get the texture reflection matrix used to rotate/transform the reflection.
  85733. * @returns the reflection matrix
  85734. */
  85735. getReflectionTextureMatrix(): Matrix;
  85736. /**
  85737. * Resize the texture to a new desired size.
  85738. * Be carrefull as it will recreate all the data in the new texture.
  85739. * @param size Define the new size. It can be:
  85740. * - a number for squared texture,
  85741. * - an object containing { width: number, height: number }
  85742. * - or an object containing a ratio { ratio: number }
  85743. */
  85744. resize(size: number | {
  85745. width: number;
  85746. height: number;
  85747. } | {
  85748. ratio: number;
  85749. }): void;
  85750. /**
  85751. * Renders all the objects from the render list into the texture.
  85752. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  85753. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  85754. */
  85755. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  85756. private _bestReflectionRenderTargetDimension;
  85757. /**
  85758. * @hidden
  85759. * @param faceIndex face index to bind to if this is a cubetexture
  85760. */
  85761. _bindFrameBuffer(faceIndex?: number): void;
  85762. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85763. private renderToTarget;
  85764. /**
  85765. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85766. * This allowed control for front to back rendering or reversly depending of the special needs.
  85767. *
  85768. * @param renderingGroupId The rendering group id corresponding to its index
  85769. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85770. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85771. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85772. */
  85773. 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;
  85774. /**
  85775. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85776. *
  85777. * @param renderingGroupId The rendering group id corresponding to its index
  85778. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85779. */
  85780. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85781. /**
  85782. * Clones the texture.
  85783. * @returns the cloned texture
  85784. */
  85785. clone(): RenderTargetTexture;
  85786. /**
  85787. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85788. * @returns The JSON representation of the texture
  85789. */
  85790. serialize(): any;
  85791. /**
  85792. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85793. */
  85794. disposeFramebufferObjects(): void;
  85795. /**
  85796. * Dispose the texture and release its associated resources.
  85797. */
  85798. dispose(): void;
  85799. /** @hidden */
  85800. _rebuild(): void;
  85801. /**
  85802. * Clear the info related to rendering groups preventing retention point in material dispose.
  85803. */
  85804. freeRenderingGroups(): void;
  85805. /**
  85806. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85807. * @returns the view count
  85808. */
  85809. getViewCount(): number;
  85810. }
  85811. }
  85812. declare module BABYLON {
  85813. /**
  85814. * Base class for the main features of a material in Babylon.js
  85815. */
  85816. export class Material implements IAnimatable {
  85817. /**
  85818. * Returns the triangle fill mode
  85819. */
  85820. static readonly TriangleFillMode: number;
  85821. /**
  85822. * Returns the wireframe mode
  85823. */
  85824. static readonly WireFrameFillMode: number;
  85825. /**
  85826. * Returns the point fill mode
  85827. */
  85828. static readonly PointFillMode: number;
  85829. /**
  85830. * Returns the point list draw mode
  85831. */
  85832. static readonly PointListDrawMode: number;
  85833. /**
  85834. * Returns the line list draw mode
  85835. */
  85836. static readonly LineListDrawMode: number;
  85837. /**
  85838. * Returns the line loop draw mode
  85839. */
  85840. static readonly LineLoopDrawMode: number;
  85841. /**
  85842. * Returns the line strip draw mode
  85843. */
  85844. static readonly LineStripDrawMode: number;
  85845. /**
  85846. * Returns the triangle strip draw mode
  85847. */
  85848. static readonly TriangleStripDrawMode: number;
  85849. /**
  85850. * Returns the triangle fan draw mode
  85851. */
  85852. static readonly TriangleFanDrawMode: number;
  85853. /**
  85854. * Stores the clock-wise side orientation
  85855. */
  85856. static readonly ClockWiseSideOrientation: number;
  85857. /**
  85858. * Stores the counter clock-wise side orientation
  85859. */
  85860. static readonly CounterClockWiseSideOrientation: number;
  85861. /**
  85862. * The dirty texture flag value
  85863. */
  85864. static readonly TextureDirtyFlag: number;
  85865. /**
  85866. * The dirty light flag value
  85867. */
  85868. static readonly LightDirtyFlag: number;
  85869. /**
  85870. * The dirty fresnel flag value
  85871. */
  85872. static readonly FresnelDirtyFlag: number;
  85873. /**
  85874. * The dirty attribute flag value
  85875. */
  85876. static readonly AttributesDirtyFlag: number;
  85877. /**
  85878. * The dirty misc flag value
  85879. */
  85880. static readonly MiscDirtyFlag: number;
  85881. /**
  85882. * The all dirty flag value
  85883. */
  85884. static readonly AllDirtyFlag: number;
  85885. /**
  85886. * The ID of the material
  85887. */
  85888. id: string;
  85889. /**
  85890. * Gets or sets the unique id of the material
  85891. */
  85892. uniqueId: number;
  85893. /**
  85894. * The name of the material
  85895. */
  85896. name: string;
  85897. /**
  85898. * Gets or sets user defined metadata
  85899. */
  85900. metadata: any;
  85901. /**
  85902. * For internal use only. Please do not use.
  85903. */
  85904. reservedDataStore: any;
  85905. /**
  85906. * Specifies if the ready state should be checked on each call
  85907. */
  85908. checkReadyOnEveryCall: boolean;
  85909. /**
  85910. * Specifies if the ready state should be checked once
  85911. */
  85912. checkReadyOnlyOnce: boolean;
  85913. /**
  85914. * The state of the material
  85915. */
  85916. state: string;
  85917. /**
  85918. * The alpha value of the material
  85919. */
  85920. protected _alpha: number;
  85921. /**
  85922. * List of inspectable custom properties (used by the Inspector)
  85923. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85924. */
  85925. inspectableCustomProperties: IInspectable[];
  85926. /**
  85927. * Sets the alpha value of the material
  85928. */
  85929. /**
  85930. * Gets the alpha value of the material
  85931. */
  85932. alpha: number;
  85933. /**
  85934. * Specifies if back face culling is enabled
  85935. */
  85936. protected _backFaceCulling: boolean;
  85937. /**
  85938. * Sets the back-face culling state
  85939. */
  85940. /**
  85941. * Gets the back-face culling state
  85942. */
  85943. backFaceCulling: boolean;
  85944. /**
  85945. * Stores the value for side orientation
  85946. */
  85947. sideOrientation: number;
  85948. /**
  85949. * Callback triggered when the material is compiled
  85950. */
  85951. onCompiled: Nullable<(effect: Effect) => void>;
  85952. /**
  85953. * Callback triggered when an error occurs
  85954. */
  85955. onError: Nullable<(effect: Effect, errors: string) => void>;
  85956. /**
  85957. * Callback triggered to get the render target textures
  85958. */
  85959. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85960. /**
  85961. * Gets a boolean indicating that current material needs to register RTT
  85962. */
  85963. readonly hasRenderTargetTextures: boolean;
  85964. /**
  85965. * Specifies if the material should be serialized
  85966. */
  85967. doNotSerialize: boolean;
  85968. /**
  85969. * @hidden
  85970. */
  85971. _storeEffectOnSubMeshes: boolean;
  85972. /**
  85973. * Stores the animations for the material
  85974. */
  85975. animations: Nullable<Array<Animation>>;
  85976. /**
  85977. * An event triggered when the material is disposed
  85978. */
  85979. onDisposeObservable: Observable<Material>;
  85980. /**
  85981. * An observer which watches for dispose events
  85982. */
  85983. private _onDisposeObserver;
  85984. private _onUnBindObservable;
  85985. /**
  85986. * Called during a dispose event
  85987. */
  85988. onDispose: () => void;
  85989. private _onBindObservable;
  85990. /**
  85991. * An event triggered when the material is bound
  85992. */
  85993. readonly onBindObservable: Observable<AbstractMesh>;
  85994. /**
  85995. * An observer which watches for bind events
  85996. */
  85997. private _onBindObserver;
  85998. /**
  85999. * Called during a bind event
  86000. */
  86001. onBind: (Mesh: AbstractMesh) => void;
  86002. /**
  86003. * An event triggered when the material is unbound
  86004. */
  86005. readonly onUnBindObservable: Observable<Material>;
  86006. /**
  86007. * Stores the value of the alpha mode
  86008. */
  86009. private _alphaMode;
  86010. /**
  86011. * Sets the value of the alpha mode.
  86012. *
  86013. * | Value | Type | Description |
  86014. * | --- | --- | --- |
  86015. * | 0 | ALPHA_DISABLE | |
  86016. * | 1 | ALPHA_ADD | |
  86017. * | 2 | ALPHA_COMBINE | |
  86018. * | 3 | ALPHA_SUBTRACT | |
  86019. * | 4 | ALPHA_MULTIPLY | |
  86020. * | 5 | ALPHA_MAXIMIZED | |
  86021. * | 6 | ALPHA_ONEONE | |
  86022. * | 7 | ALPHA_PREMULTIPLIED | |
  86023. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  86024. * | 9 | ALPHA_INTERPOLATE | |
  86025. * | 10 | ALPHA_SCREENMODE | |
  86026. *
  86027. */
  86028. /**
  86029. * Gets the value of the alpha mode
  86030. */
  86031. alphaMode: number;
  86032. /**
  86033. * Stores the state of the need depth pre-pass value
  86034. */
  86035. private _needDepthPrePass;
  86036. /**
  86037. * Sets the need depth pre-pass value
  86038. */
  86039. /**
  86040. * Gets the depth pre-pass value
  86041. */
  86042. needDepthPrePass: boolean;
  86043. /**
  86044. * Specifies if depth writing should be disabled
  86045. */
  86046. disableDepthWrite: boolean;
  86047. /**
  86048. * Specifies if depth writing should be forced
  86049. */
  86050. forceDepthWrite: boolean;
  86051. /**
  86052. * Specifies if there should be a separate pass for culling
  86053. */
  86054. separateCullingPass: boolean;
  86055. /**
  86056. * Stores the state specifing if fog should be enabled
  86057. */
  86058. private _fogEnabled;
  86059. /**
  86060. * Sets the state for enabling fog
  86061. */
  86062. /**
  86063. * Gets the value of the fog enabled state
  86064. */
  86065. fogEnabled: boolean;
  86066. /**
  86067. * Stores the size of points
  86068. */
  86069. pointSize: number;
  86070. /**
  86071. * Stores the z offset value
  86072. */
  86073. zOffset: number;
  86074. /**
  86075. * Gets a value specifying if wireframe mode is enabled
  86076. */
  86077. /**
  86078. * Sets the state of wireframe mode
  86079. */
  86080. wireframe: boolean;
  86081. /**
  86082. * Gets the value specifying if point clouds are enabled
  86083. */
  86084. /**
  86085. * Sets the state of point cloud mode
  86086. */
  86087. pointsCloud: boolean;
  86088. /**
  86089. * Gets the material fill mode
  86090. */
  86091. /**
  86092. * Sets the material fill mode
  86093. */
  86094. fillMode: number;
  86095. /**
  86096. * @hidden
  86097. * Stores the effects for the material
  86098. */
  86099. _effect: Nullable<Effect>;
  86100. /**
  86101. * @hidden
  86102. * Specifies if the material was previously ready
  86103. */
  86104. _wasPreviouslyReady: boolean;
  86105. /**
  86106. * Specifies if uniform buffers should be used
  86107. */
  86108. private _useUBO;
  86109. /**
  86110. * Stores a reference to the scene
  86111. */
  86112. private _scene;
  86113. /**
  86114. * Stores the fill mode state
  86115. */
  86116. private _fillMode;
  86117. /**
  86118. * Specifies if the depth write state should be cached
  86119. */
  86120. private _cachedDepthWriteState;
  86121. /**
  86122. * Stores the uniform buffer
  86123. */
  86124. protected _uniformBuffer: UniformBuffer;
  86125. /** @hidden */
  86126. _indexInSceneMaterialArray: number;
  86127. /** @hidden */
  86128. meshMap: Nullable<{
  86129. [id: string]: AbstractMesh | undefined;
  86130. }>;
  86131. /**
  86132. * Creates a material instance
  86133. * @param name defines the name of the material
  86134. * @param scene defines the scene to reference
  86135. * @param doNotAdd specifies if the material should be added to the scene
  86136. */
  86137. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  86138. /**
  86139. * Returns a string representation of the current material
  86140. * @param fullDetails defines a boolean indicating which levels of logging is desired
  86141. * @returns a string with material information
  86142. */
  86143. toString(fullDetails?: boolean): string;
  86144. /**
  86145. * Gets the class name of the material
  86146. * @returns a string with the class name of the material
  86147. */
  86148. getClassName(): string;
  86149. /**
  86150. * Specifies if updates for the material been locked
  86151. */
  86152. readonly isFrozen: boolean;
  86153. /**
  86154. * Locks updates for the material
  86155. */
  86156. freeze(): void;
  86157. /**
  86158. * Unlocks updates for the material
  86159. */
  86160. unfreeze(): void;
  86161. /**
  86162. * Specifies if the material is ready to be used
  86163. * @param mesh defines the mesh to check
  86164. * @param useInstances specifies if instances should be used
  86165. * @returns a boolean indicating if the material is ready to be used
  86166. */
  86167. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86168. /**
  86169. * Specifies that the submesh is ready to be used
  86170. * @param mesh defines the mesh to check
  86171. * @param subMesh defines which submesh to check
  86172. * @param useInstances specifies that instances should be used
  86173. * @returns a boolean indicating that the submesh is ready or not
  86174. */
  86175. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86176. /**
  86177. * Returns the material effect
  86178. * @returns the effect associated with the material
  86179. */
  86180. getEffect(): Nullable<Effect>;
  86181. /**
  86182. * Returns the current scene
  86183. * @returns a Scene
  86184. */
  86185. getScene(): Scene;
  86186. /**
  86187. * Specifies if the material will require alpha blending
  86188. * @returns a boolean specifying if alpha blending is needed
  86189. */
  86190. needAlphaBlending(): boolean;
  86191. /**
  86192. * Specifies if the mesh will require alpha blending
  86193. * @param mesh defines the mesh to check
  86194. * @returns a boolean specifying if alpha blending is needed for the mesh
  86195. */
  86196. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  86197. /**
  86198. * Specifies if this material should be rendered in alpha test mode
  86199. * @returns a boolean specifying if an alpha test is needed.
  86200. */
  86201. needAlphaTesting(): boolean;
  86202. /**
  86203. * Gets the texture used for the alpha test
  86204. * @returns the texture to use for alpha testing
  86205. */
  86206. getAlphaTestTexture(): Nullable<BaseTexture>;
  86207. /**
  86208. * Marks the material to indicate that it needs to be re-calculated
  86209. */
  86210. markDirty(): void;
  86211. /** @hidden */
  86212. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  86213. /**
  86214. * Binds the material to the mesh
  86215. * @param world defines the world transformation matrix
  86216. * @param mesh defines the mesh to bind the material to
  86217. */
  86218. bind(world: Matrix, mesh?: Mesh): void;
  86219. /**
  86220. * Binds the submesh to the material
  86221. * @param world defines the world transformation matrix
  86222. * @param mesh defines the mesh containing the submesh
  86223. * @param subMesh defines the submesh to bind the material to
  86224. */
  86225. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  86226. /**
  86227. * Binds the world matrix to the material
  86228. * @param world defines the world transformation matrix
  86229. */
  86230. bindOnlyWorldMatrix(world: Matrix): void;
  86231. /**
  86232. * Binds the scene's uniform buffer to the effect.
  86233. * @param effect defines the effect to bind to the scene uniform buffer
  86234. * @param sceneUbo defines the uniform buffer storing scene data
  86235. */
  86236. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  86237. /**
  86238. * Binds the view matrix to the effect
  86239. * @param effect defines the effect to bind the view matrix to
  86240. */
  86241. bindView(effect: Effect): void;
  86242. /**
  86243. * Binds the view projection matrix to the effect
  86244. * @param effect defines the effect to bind the view projection matrix to
  86245. */
  86246. bindViewProjection(effect: Effect): void;
  86247. /**
  86248. * Specifies if material alpha testing should be turned on for the mesh
  86249. * @param mesh defines the mesh to check
  86250. */
  86251. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  86252. /**
  86253. * Processes to execute after binding the material to a mesh
  86254. * @param mesh defines the rendered mesh
  86255. */
  86256. protected _afterBind(mesh?: Mesh): void;
  86257. /**
  86258. * Unbinds the material from the mesh
  86259. */
  86260. unbind(): void;
  86261. /**
  86262. * Gets the active textures from the material
  86263. * @returns an array of textures
  86264. */
  86265. getActiveTextures(): BaseTexture[];
  86266. /**
  86267. * Specifies if the material uses a texture
  86268. * @param texture defines the texture to check against the material
  86269. * @returns a boolean specifying if the material uses the texture
  86270. */
  86271. hasTexture(texture: BaseTexture): boolean;
  86272. /**
  86273. * Makes a duplicate of the material, and gives it a new name
  86274. * @param name defines the new name for the duplicated material
  86275. * @returns the cloned material
  86276. */
  86277. clone(name: string): Nullable<Material>;
  86278. /**
  86279. * Gets the meshes bound to the material
  86280. * @returns an array of meshes bound to the material
  86281. */
  86282. getBindedMeshes(): AbstractMesh[];
  86283. /**
  86284. * Force shader compilation
  86285. * @param mesh defines the mesh associated with this material
  86286. * @param onCompiled defines a function to execute once the material is compiled
  86287. * @param options defines the options to configure the compilation
  86288. */
  86289. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  86290. clipPlane: boolean;
  86291. }>): void;
  86292. /**
  86293. * Force shader compilation
  86294. * @param mesh defines the mesh that will use this material
  86295. * @param options defines additional options for compiling the shaders
  86296. * @returns a promise that resolves when the compilation completes
  86297. */
  86298. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  86299. clipPlane: boolean;
  86300. }>): Promise<void>;
  86301. private static readonly _AllDirtyCallBack;
  86302. private static readonly _ImageProcessingDirtyCallBack;
  86303. private static readonly _TextureDirtyCallBack;
  86304. private static readonly _FresnelDirtyCallBack;
  86305. private static readonly _MiscDirtyCallBack;
  86306. private static readonly _LightsDirtyCallBack;
  86307. private static readonly _AttributeDirtyCallBack;
  86308. private static _FresnelAndMiscDirtyCallBack;
  86309. private static _TextureAndMiscDirtyCallBack;
  86310. private static readonly _DirtyCallbackArray;
  86311. private static readonly _RunDirtyCallBacks;
  86312. /**
  86313. * Marks a define in the material to indicate that it needs to be re-computed
  86314. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  86315. */
  86316. markAsDirty(flag: number): void;
  86317. /**
  86318. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  86319. * @param func defines a function which checks material defines against the submeshes
  86320. */
  86321. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  86322. /**
  86323. * Indicates that we need to re-calculated for all submeshes
  86324. */
  86325. protected _markAllSubMeshesAsAllDirty(): void;
  86326. /**
  86327. * Indicates that image processing needs to be re-calculated for all submeshes
  86328. */
  86329. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  86330. /**
  86331. * Indicates that textures need to be re-calculated for all submeshes
  86332. */
  86333. protected _markAllSubMeshesAsTexturesDirty(): void;
  86334. /**
  86335. * Indicates that fresnel needs to be re-calculated for all submeshes
  86336. */
  86337. protected _markAllSubMeshesAsFresnelDirty(): void;
  86338. /**
  86339. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  86340. */
  86341. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  86342. /**
  86343. * Indicates that lights need to be re-calculated for all submeshes
  86344. */
  86345. protected _markAllSubMeshesAsLightsDirty(): void;
  86346. /**
  86347. * Indicates that attributes need to be re-calculated for all submeshes
  86348. */
  86349. protected _markAllSubMeshesAsAttributesDirty(): void;
  86350. /**
  86351. * Indicates that misc needs to be re-calculated for all submeshes
  86352. */
  86353. protected _markAllSubMeshesAsMiscDirty(): void;
  86354. /**
  86355. * Indicates that textures and misc need to be re-calculated for all submeshes
  86356. */
  86357. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  86358. /**
  86359. * Disposes the material
  86360. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86361. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86362. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86363. */
  86364. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86365. /** @hidden */
  86366. private releaseVertexArrayObject;
  86367. /**
  86368. * Serializes this material
  86369. * @returns the serialized material object
  86370. */
  86371. serialize(): any;
  86372. /**
  86373. * Creates a material from parsed material data
  86374. * @param parsedMaterial defines parsed material data
  86375. * @param scene defines the hosting scene
  86376. * @param rootUrl defines the root URL to use to load textures
  86377. * @returns a new material
  86378. */
  86379. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  86380. }
  86381. }
  86382. declare module BABYLON {
  86383. /**
  86384. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86385. * separate meshes. This can be use to improve performances.
  86386. * @see http://doc.babylonjs.com/how_to/multi_materials
  86387. */
  86388. export class MultiMaterial extends Material {
  86389. private _subMaterials;
  86390. /**
  86391. * Gets or Sets the list of Materials used within the multi material.
  86392. * They need to be ordered according to the submeshes order in the associated mesh
  86393. */
  86394. subMaterials: Nullable<Material>[];
  86395. /**
  86396. * Function used to align with Node.getChildren()
  86397. * @returns the list of Materials used within the multi material
  86398. */
  86399. getChildren(): Nullable<Material>[];
  86400. /**
  86401. * Instantiates a new Multi Material
  86402. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86403. * separate meshes. This can be use to improve performances.
  86404. * @see http://doc.babylonjs.com/how_to/multi_materials
  86405. * @param name Define the name in the scene
  86406. * @param scene Define the scene the material belongs to
  86407. */
  86408. constructor(name: string, scene: Scene);
  86409. private _hookArray;
  86410. /**
  86411. * Get one of the submaterial by its index in the submaterials array
  86412. * @param index The index to look the sub material at
  86413. * @returns The Material if the index has been defined
  86414. */
  86415. getSubMaterial(index: number): Nullable<Material>;
  86416. /**
  86417. * Get the list of active textures for the whole sub materials list.
  86418. * @returns All the textures that will be used during the rendering
  86419. */
  86420. getActiveTextures(): BaseTexture[];
  86421. /**
  86422. * Gets the current class name of the material e.g. "MultiMaterial"
  86423. * Mainly use in serialization.
  86424. * @returns the class name
  86425. */
  86426. getClassName(): string;
  86427. /**
  86428. * Checks if the material is ready to render the requested sub mesh
  86429. * @param mesh Define the mesh the submesh belongs to
  86430. * @param subMesh Define the sub mesh to look readyness for
  86431. * @param useInstances Define whether or not the material is used with instances
  86432. * @returns true if ready, otherwise false
  86433. */
  86434. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86435. /**
  86436. * Clones the current material and its related sub materials
  86437. * @param name Define the name of the newly cloned material
  86438. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  86439. * @returns the cloned material
  86440. */
  86441. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  86442. /**
  86443. * Serializes the materials into a JSON representation.
  86444. * @returns the JSON representation
  86445. */
  86446. serialize(): any;
  86447. /**
  86448. * Dispose the material and release its associated resources
  86449. * @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)
  86450. * @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)
  86451. * @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)
  86452. */
  86453. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  86454. /**
  86455. * Creates a MultiMaterial from parsed MultiMaterial data.
  86456. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  86457. * @param scene defines the hosting scene
  86458. * @returns a new MultiMaterial
  86459. */
  86460. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  86461. }
  86462. }
  86463. declare module BABYLON {
  86464. /**
  86465. * Base class for submeshes
  86466. */
  86467. export class BaseSubMesh {
  86468. /** @hidden */
  86469. _materialDefines: Nullable<MaterialDefines>;
  86470. /** @hidden */
  86471. _materialEffect: Nullable<Effect>;
  86472. /**
  86473. * Gets associated effect
  86474. */
  86475. readonly effect: Nullable<Effect>;
  86476. /**
  86477. * Sets associated effect (effect used to render this submesh)
  86478. * @param effect defines the effect to associate with
  86479. * @param defines defines the set of defines used to compile this effect
  86480. */
  86481. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  86482. }
  86483. /**
  86484. * Defines a subdivision inside a mesh
  86485. */
  86486. export class SubMesh extends BaseSubMesh implements ICullable {
  86487. /** the material index to use */
  86488. materialIndex: number;
  86489. /** vertex index start */
  86490. verticesStart: number;
  86491. /** vertices count */
  86492. verticesCount: number;
  86493. /** index start */
  86494. indexStart: number;
  86495. /** indices count */
  86496. indexCount: number;
  86497. /** @hidden */
  86498. _linesIndexCount: number;
  86499. private _mesh;
  86500. private _renderingMesh;
  86501. private _boundingInfo;
  86502. private _linesIndexBuffer;
  86503. /** @hidden */
  86504. _lastColliderWorldVertices: Nullable<Vector3[]>;
  86505. /** @hidden */
  86506. _trianglePlanes: Plane[];
  86507. /** @hidden */
  86508. _lastColliderTransformMatrix: Nullable<Matrix>;
  86509. /** @hidden */
  86510. _renderId: number;
  86511. /** @hidden */
  86512. _alphaIndex: number;
  86513. /** @hidden */
  86514. _distanceToCamera: number;
  86515. /** @hidden */
  86516. _id: number;
  86517. private _currentMaterial;
  86518. /**
  86519. * Add a new submesh to a mesh
  86520. * @param materialIndex defines the material index to use
  86521. * @param verticesStart defines vertex index start
  86522. * @param verticesCount defines vertices count
  86523. * @param indexStart defines index start
  86524. * @param indexCount defines indices count
  86525. * @param mesh defines the parent mesh
  86526. * @param renderingMesh defines an optional rendering mesh
  86527. * @param createBoundingBox defines if bounding box should be created for this submesh
  86528. * @returns the new submesh
  86529. */
  86530. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  86531. /**
  86532. * Creates a new submesh
  86533. * @param materialIndex defines the material index to use
  86534. * @param verticesStart defines vertex index start
  86535. * @param verticesCount defines vertices count
  86536. * @param indexStart defines index start
  86537. * @param indexCount defines indices count
  86538. * @param mesh defines the parent mesh
  86539. * @param renderingMesh defines an optional rendering mesh
  86540. * @param createBoundingBox defines if bounding box should be created for this submesh
  86541. */
  86542. constructor(
  86543. /** the material index to use */
  86544. materialIndex: number,
  86545. /** vertex index start */
  86546. verticesStart: number,
  86547. /** vertices count */
  86548. verticesCount: number,
  86549. /** index start */
  86550. indexStart: number,
  86551. /** indices count */
  86552. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  86553. /**
  86554. * Returns true if this submesh covers the entire parent mesh
  86555. * @ignorenaming
  86556. */
  86557. readonly IsGlobal: boolean;
  86558. /**
  86559. * Returns the submesh BoudingInfo object
  86560. * @returns current bounding info (or mesh's one if the submesh is global)
  86561. */
  86562. getBoundingInfo(): BoundingInfo;
  86563. /**
  86564. * Sets the submesh BoundingInfo
  86565. * @param boundingInfo defines the new bounding info to use
  86566. * @returns the SubMesh
  86567. */
  86568. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  86569. /**
  86570. * Returns the mesh of the current submesh
  86571. * @return the parent mesh
  86572. */
  86573. getMesh(): AbstractMesh;
  86574. /**
  86575. * Returns the rendering mesh of the submesh
  86576. * @returns the rendering mesh (could be different from parent mesh)
  86577. */
  86578. getRenderingMesh(): Mesh;
  86579. /**
  86580. * Returns the submesh material
  86581. * @returns null or the current material
  86582. */
  86583. getMaterial(): Nullable<Material>;
  86584. /**
  86585. * Sets a new updated BoundingInfo object to the submesh
  86586. * @param data defines an optional position array to use to determine the bounding info
  86587. * @returns the SubMesh
  86588. */
  86589. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  86590. /** @hidden */
  86591. _checkCollision(collider: Collider): boolean;
  86592. /**
  86593. * Updates the submesh BoundingInfo
  86594. * @param world defines the world matrix to use to update the bounding info
  86595. * @returns the submesh
  86596. */
  86597. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  86598. /**
  86599. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  86600. * @param frustumPlanes defines the frustum planes
  86601. * @returns true if the submesh is intersecting with the frustum
  86602. */
  86603. isInFrustum(frustumPlanes: Plane[]): boolean;
  86604. /**
  86605. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  86606. * @param frustumPlanes defines the frustum planes
  86607. * @returns true if the submesh is inside the frustum
  86608. */
  86609. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86610. /**
  86611. * Renders the submesh
  86612. * @param enableAlphaMode defines if alpha needs to be used
  86613. * @returns the submesh
  86614. */
  86615. render(enableAlphaMode: boolean): SubMesh;
  86616. /**
  86617. * @hidden
  86618. */
  86619. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  86620. /**
  86621. * Checks if the submesh intersects with a ray
  86622. * @param ray defines the ray to test
  86623. * @returns true is the passed ray intersects the submesh bounding box
  86624. */
  86625. canIntersects(ray: Ray): boolean;
  86626. /**
  86627. * Intersects current submesh with a ray
  86628. * @param ray defines the ray to test
  86629. * @param positions defines mesh's positions array
  86630. * @param indices defines mesh's indices array
  86631. * @param fastCheck defines if only bounding info should be used
  86632. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  86633. * @returns intersection info or null if no intersection
  86634. */
  86635. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  86636. /** @hidden */
  86637. private _intersectLines;
  86638. /** @hidden */
  86639. private _intersectUnIndexedLines;
  86640. /** @hidden */
  86641. private _intersectTriangles;
  86642. /** @hidden */
  86643. private _intersectUnIndexedTriangles;
  86644. /** @hidden */
  86645. _rebuild(): void;
  86646. /**
  86647. * Creates a new submesh from the passed mesh
  86648. * @param newMesh defines the new hosting mesh
  86649. * @param newRenderingMesh defines an optional rendering mesh
  86650. * @returns the new submesh
  86651. */
  86652. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  86653. /**
  86654. * Release associated resources
  86655. */
  86656. dispose(): void;
  86657. /**
  86658. * Gets the class name
  86659. * @returns the string "SubMesh".
  86660. */
  86661. getClassName(): string;
  86662. /**
  86663. * Creates a new submesh from indices data
  86664. * @param materialIndex the index of the main mesh material
  86665. * @param startIndex the index where to start the copy in the mesh indices array
  86666. * @param indexCount the number of indices to copy then from the startIndex
  86667. * @param mesh the main mesh to create the submesh from
  86668. * @param renderingMesh the optional rendering mesh
  86669. * @returns a new submesh
  86670. */
  86671. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  86672. }
  86673. }
  86674. declare module BABYLON {
  86675. /**
  86676. * Class used to represent data loading progression
  86677. */
  86678. export class SceneLoaderFlags {
  86679. private static _ForceFullSceneLoadingForIncremental;
  86680. private static _ShowLoadingScreen;
  86681. private static _CleanBoneMatrixWeights;
  86682. private static _loggingLevel;
  86683. /**
  86684. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  86685. */
  86686. static ForceFullSceneLoadingForIncremental: boolean;
  86687. /**
  86688. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  86689. */
  86690. static ShowLoadingScreen: boolean;
  86691. /**
  86692. * Defines the current logging level (while loading the scene)
  86693. * @ignorenaming
  86694. */
  86695. static loggingLevel: number;
  86696. /**
  86697. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  86698. */
  86699. static CleanBoneMatrixWeights: boolean;
  86700. }
  86701. }
  86702. declare module BABYLON {
  86703. /**
  86704. * Class used to store geometry data (vertex buffers + index buffer)
  86705. */
  86706. export class Geometry implements IGetSetVerticesData {
  86707. /**
  86708. * Gets or sets the ID of the geometry
  86709. */
  86710. id: string;
  86711. /**
  86712. * Gets or sets the unique ID of the geometry
  86713. */
  86714. uniqueId: number;
  86715. /**
  86716. * Gets the delay loading state of the geometry (none by default which means not delayed)
  86717. */
  86718. delayLoadState: number;
  86719. /**
  86720. * Gets the file containing the data to load when running in delay load state
  86721. */
  86722. delayLoadingFile: Nullable<string>;
  86723. /**
  86724. * Callback called when the geometry is updated
  86725. */
  86726. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  86727. private _scene;
  86728. private _engine;
  86729. private _meshes;
  86730. private _totalVertices;
  86731. /** @hidden */
  86732. _indices: IndicesArray;
  86733. /** @hidden */
  86734. _vertexBuffers: {
  86735. [key: string]: VertexBuffer;
  86736. };
  86737. private _isDisposed;
  86738. private _extend;
  86739. private _boundingBias;
  86740. /** @hidden */
  86741. _delayInfo: Array<string>;
  86742. private _indexBuffer;
  86743. private _indexBufferIsUpdatable;
  86744. /** @hidden */
  86745. _boundingInfo: Nullable<BoundingInfo>;
  86746. /** @hidden */
  86747. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  86748. /** @hidden */
  86749. _softwareSkinningFrameId: number;
  86750. private _vertexArrayObjects;
  86751. private _updatable;
  86752. /** @hidden */
  86753. _positions: Nullable<Vector3[]>;
  86754. /**
  86755. * 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
  86756. */
  86757. /**
  86758. * 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
  86759. */
  86760. boundingBias: Vector2;
  86761. /**
  86762. * Static function used to attach a new empty geometry to a mesh
  86763. * @param mesh defines the mesh to attach the geometry to
  86764. * @returns the new Geometry
  86765. */
  86766. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  86767. /**
  86768. * Creates a new geometry
  86769. * @param id defines the unique ID
  86770. * @param scene defines the hosting scene
  86771. * @param vertexData defines the VertexData used to get geometry data
  86772. * @param updatable defines if geometry must be updatable (false by default)
  86773. * @param mesh defines the mesh that will be associated with the geometry
  86774. */
  86775. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  86776. /**
  86777. * Gets the current extend of the geometry
  86778. */
  86779. readonly extend: {
  86780. minimum: Vector3;
  86781. maximum: Vector3;
  86782. };
  86783. /**
  86784. * Gets the hosting scene
  86785. * @returns the hosting Scene
  86786. */
  86787. getScene(): Scene;
  86788. /**
  86789. * Gets the hosting engine
  86790. * @returns the hosting Engine
  86791. */
  86792. getEngine(): Engine;
  86793. /**
  86794. * Defines if the geometry is ready to use
  86795. * @returns true if the geometry is ready to be used
  86796. */
  86797. isReady(): boolean;
  86798. /**
  86799. * Gets a value indicating that the geometry should not be serialized
  86800. */
  86801. readonly doNotSerialize: boolean;
  86802. /** @hidden */
  86803. _rebuild(): void;
  86804. /**
  86805. * Affects all geometry data in one call
  86806. * @param vertexData defines the geometry data
  86807. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  86808. */
  86809. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  86810. /**
  86811. * Set specific vertex data
  86812. * @param kind defines the data kind (Position, normal, etc...)
  86813. * @param data defines the vertex data to use
  86814. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86815. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86816. */
  86817. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  86818. /**
  86819. * Removes a specific vertex data
  86820. * @param kind defines the data kind (Position, normal, etc...)
  86821. */
  86822. removeVerticesData(kind: string): void;
  86823. /**
  86824. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  86825. * @param buffer defines the vertex buffer to use
  86826. * @param totalVertices defines the total number of vertices for position kind (could be null)
  86827. */
  86828. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  86829. /**
  86830. * Update a specific vertex buffer
  86831. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86832. * It will do nothing if the buffer is not updatable
  86833. * @param kind defines the data kind (Position, normal, etc...)
  86834. * @param data defines the data to use
  86835. * @param offset defines the offset in the target buffer where to store the data
  86836. * @param useBytes set to true if the offset is in bytes
  86837. */
  86838. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86839. /**
  86840. * Update a specific vertex buffer
  86841. * This function will create a new buffer if the current one is not updatable
  86842. * @param kind defines the data kind (Position, normal, etc...)
  86843. * @param data defines the data to use
  86844. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86845. */
  86846. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86847. private _updateBoundingInfo;
  86848. /** @hidden */
  86849. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86850. /**
  86851. * Gets total number of vertices
  86852. * @returns the total number of vertices
  86853. */
  86854. getTotalVertices(): number;
  86855. /**
  86856. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86857. * @param kind defines the data kind (Position, normal, etc...)
  86858. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86859. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86860. * @returns a float array containing vertex data
  86861. */
  86862. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86863. /**
  86864. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  86865. * @param kind defines the data kind (Position, normal, etc...)
  86866. * @returns true if the vertex buffer with the specified kind is updatable
  86867. */
  86868. isVertexBufferUpdatable(kind: string): boolean;
  86869. /**
  86870. * Gets a specific vertex buffer
  86871. * @param kind defines the data kind (Position, normal, etc...)
  86872. * @returns a VertexBuffer
  86873. */
  86874. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  86875. /**
  86876. * Returns all vertex buffers
  86877. * @return an object holding all vertex buffers indexed by kind
  86878. */
  86879. getVertexBuffers(): Nullable<{
  86880. [key: string]: VertexBuffer;
  86881. }>;
  86882. /**
  86883. * Gets a boolean indicating if specific vertex buffer is present
  86884. * @param kind defines the data kind (Position, normal, etc...)
  86885. * @returns true if data is present
  86886. */
  86887. isVerticesDataPresent(kind: string): boolean;
  86888. /**
  86889. * Gets a list of all attached data kinds (Position, normal, etc...)
  86890. * @returns a list of string containing all kinds
  86891. */
  86892. getVerticesDataKinds(): string[];
  86893. /**
  86894. * Update index buffer
  86895. * @param indices defines the indices to store in the index buffer
  86896. * @param offset defines the offset in the target buffer where to store the data
  86897. * @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)
  86898. */
  86899. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86900. /**
  86901. * Creates a new index buffer
  86902. * @param indices defines the indices to store in the index buffer
  86903. * @param totalVertices defines the total number of vertices (could be null)
  86904. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86905. */
  86906. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86907. /**
  86908. * Return the total number of indices
  86909. * @returns the total number of indices
  86910. */
  86911. getTotalIndices(): number;
  86912. /**
  86913. * Gets the index buffer array
  86914. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86915. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86916. * @returns the index buffer array
  86917. */
  86918. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86919. /**
  86920. * Gets the index buffer
  86921. * @return the index buffer
  86922. */
  86923. getIndexBuffer(): Nullable<DataBuffer>;
  86924. /** @hidden */
  86925. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86926. /**
  86927. * Release the associated resources for a specific mesh
  86928. * @param mesh defines the source mesh
  86929. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86930. */
  86931. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86932. /**
  86933. * Apply current geometry to a given mesh
  86934. * @param mesh defines the mesh to apply geometry to
  86935. */
  86936. applyToMesh(mesh: Mesh): void;
  86937. private _updateExtend;
  86938. private _applyToMesh;
  86939. private notifyUpdate;
  86940. /**
  86941. * Load the geometry if it was flagged as delay loaded
  86942. * @param scene defines the hosting scene
  86943. * @param onLoaded defines a callback called when the geometry is loaded
  86944. */
  86945. load(scene: Scene, onLoaded?: () => void): void;
  86946. private _queueLoad;
  86947. /**
  86948. * Invert the geometry to move from a right handed system to a left handed one.
  86949. */
  86950. toLeftHanded(): void;
  86951. /** @hidden */
  86952. _resetPointsArrayCache(): void;
  86953. /** @hidden */
  86954. _generatePointsArray(): boolean;
  86955. /**
  86956. * Gets a value indicating if the geometry is disposed
  86957. * @returns true if the geometry was disposed
  86958. */
  86959. isDisposed(): boolean;
  86960. private _disposeVertexArrayObjects;
  86961. /**
  86962. * Free all associated resources
  86963. */
  86964. dispose(): void;
  86965. /**
  86966. * Clone the current geometry into a new geometry
  86967. * @param id defines the unique ID of the new geometry
  86968. * @returns a new geometry object
  86969. */
  86970. copy(id: string): Geometry;
  86971. /**
  86972. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86973. * @return a JSON representation of the current geometry data (without the vertices data)
  86974. */
  86975. serialize(): any;
  86976. private toNumberArray;
  86977. /**
  86978. * Serialize all vertices data into a JSON oject
  86979. * @returns a JSON representation of the current geometry data
  86980. */
  86981. serializeVerticeData(): any;
  86982. /**
  86983. * Extracts a clone of a mesh geometry
  86984. * @param mesh defines the source mesh
  86985. * @param id defines the unique ID of the new geometry object
  86986. * @returns the new geometry object
  86987. */
  86988. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86989. /**
  86990. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86991. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86992. * Be aware Math.random() could cause collisions, but:
  86993. * "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"
  86994. * @returns a string containing a new GUID
  86995. */
  86996. static RandomId(): string;
  86997. /** @hidden */
  86998. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86999. private static _CleanMatricesWeights;
  87000. /**
  87001. * Create a new geometry from persisted data (Using .babylon file format)
  87002. * @param parsedVertexData defines the persisted data
  87003. * @param scene defines the hosting scene
  87004. * @param rootUrl defines the root url to use to load assets (like delayed data)
  87005. * @returns the new geometry object
  87006. */
  87007. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  87008. }
  87009. }
  87010. declare module BABYLON {
  87011. /**
  87012. * Define an interface for all classes that will get and set the data on vertices
  87013. */
  87014. export interface IGetSetVerticesData {
  87015. /**
  87016. * Gets a boolean indicating if specific vertex data is present
  87017. * @param kind defines the vertex data kind to use
  87018. * @returns true is data kind is present
  87019. */
  87020. isVerticesDataPresent(kind: string): boolean;
  87021. /**
  87022. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87023. * @param kind defines the data kind (Position, normal, etc...)
  87024. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87025. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87026. * @returns a float array containing vertex data
  87027. */
  87028. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87029. /**
  87030. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87031. * @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.
  87032. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87033. * @returns the indices array or an empty array if the mesh has no geometry
  87034. */
  87035. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87036. /**
  87037. * Set specific vertex data
  87038. * @param kind defines the data kind (Position, normal, etc...)
  87039. * @param data defines the vertex data to use
  87040. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87041. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87042. */
  87043. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  87044. /**
  87045. * Update a specific associated vertex buffer
  87046. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87047. * - VertexBuffer.PositionKind
  87048. * - VertexBuffer.UVKind
  87049. * - VertexBuffer.UV2Kind
  87050. * - VertexBuffer.UV3Kind
  87051. * - VertexBuffer.UV4Kind
  87052. * - VertexBuffer.UV5Kind
  87053. * - VertexBuffer.UV6Kind
  87054. * - VertexBuffer.ColorKind
  87055. * - VertexBuffer.MatricesIndicesKind
  87056. * - VertexBuffer.MatricesIndicesExtraKind
  87057. * - VertexBuffer.MatricesWeightsKind
  87058. * - VertexBuffer.MatricesWeightsExtraKind
  87059. * @param data defines the data source
  87060. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87061. * @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)
  87062. */
  87063. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  87064. /**
  87065. * Creates a new index buffer
  87066. * @param indices defines the indices to store in the index buffer
  87067. * @param totalVertices defines the total number of vertices (could be null)
  87068. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87069. */
  87070. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  87071. }
  87072. /**
  87073. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  87074. */
  87075. export class VertexData {
  87076. /**
  87077. * Mesh side orientation : usually the external or front surface
  87078. */
  87079. static readonly FRONTSIDE: number;
  87080. /**
  87081. * Mesh side orientation : usually the internal or back surface
  87082. */
  87083. static readonly BACKSIDE: number;
  87084. /**
  87085. * Mesh side orientation : both internal and external or front and back surfaces
  87086. */
  87087. static readonly DOUBLESIDE: number;
  87088. /**
  87089. * Mesh side orientation : by default, `FRONTSIDE`
  87090. */
  87091. static readonly DEFAULTSIDE: number;
  87092. /**
  87093. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  87094. */
  87095. positions: Nullable<FloatArray>;
  87096. /**
  87097. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  87098. */
  87099. normals: Nullable<FloatArray>;
  87100. /**
  87101. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  87102. */
  87103. tangents: Nullable<FloatArray>;
  87104. /**
  87105. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87106. */
  87107. uvs: Nullable<FloatArray>;
  87108. /**
  87109. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87110. */
  87111. uvs2: Nullable<FloatArray>;
  87112. /**
  87113. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87114. */
  87115. uvs3: Nullable<FloatArray>;
  87116. /**
  87117. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87118. */
  87119. uvs4: Nullable<FloatArray>;
  87120. /**
  87121. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87122. */
  87123. uvs5: Nullable<FloatArray>;
  87124. /**
  87125. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87126. */
  87127. uvs6: Nullable<FloatArray>;
  87128. /**
  87129. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  87130. */
  87131. colors: Nullable<FloatArray>;
  87132. /**
  87133. * 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).
  87134. */
  87135. matricesIndices: Nullable<FloatArray>;
  87136. /**
  87137. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  87138. */
  87139. matricesWeights: Nullable<FloatArray>;
  87140. /**
  87141. * An array extending the number of possible indices
  87142. */
  87143. matricesIndicesExtra: Nullable<FloatArray>;
  87144. /**
  87145. * An array extending the number of possible weights when the number of indices is extended
  87146. */
  87147. matricesWeightsExtra: Nullable<FloatArray>;
  87148. /**
  87149. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  87150. */
  87151. indices: Nullable<IndicesArray>;
  87152. /**
  87153. * Uses the passed data array to set the set the values for the specified kind of data
  87154. * @param data a linear array of floating numbers
  87155. * @param kind the type of data that is being set, eg positions, colors etc
  87156. */
  87157. set(data: FloatArray, kind: string): void;
  87158. /**
  87159. * Associates the vertexData to the passed Mesh.
  87160. * Sets it as updatable or not (default `false`)
  87161. * @param mesh the mesh the vertexData is applied to
  87162. * @param updatable when used and having the value true allows new data to update the vertexData
  87163. * @returns the VertexData
  87164. */
  87165. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  87166. /**
  87167. * Associates the vertexData to the passed Geometry.
  87168. * Sets it as updatable or not (default `false`)
  87169. * @param geometry the geometry the vertexData is applied to
  87170. * @param updatable when used and having the value true allows new data to update the vertexData
  87171. * @returns VertexData
  87172. */
  87173. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  87174. /**
  87175. * Updates the associated mesh
  87176. * @param mesh the mesh to be updated
  87177. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87178. * @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
  87179. * @returns VertexData
  87180. */
  87181. updateMesh(mesh: Mesh): VertexData;
  87182. /**
  87183. * Updates the associated geometry
  87184. * @param geometry the geometry to be updated
  87185. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87186. * @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
  87187. * @returns VertexData.
  87188. */
  87189. updateGeometry(geometry: Geometry): VertexData;
  87190. private _applyTo;
  87191. private _update;
  87192. /**
  87193. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87194. * @param matrix the transforming matrix
  87195. * @returns the VertexData
  87196. */
  87197. transform(matrix: Matrix): VertexData;
  87198. /**
  87199. * Merges the passed VertexData into the current one
  87200. * @param other the VertexData to be merged into the current one
  87201. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87202. * @returns the modified VertexData
  87203. */
  87204. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  87205. private _mergeElement;
  87206. private _validate;
  87207. /**
  87208. * Serializes the VertexData
  87209. * @returns a serialized object
  87210. */
  87211. serialize(): any;
  87212. /**
  87213. * Extracts the vertexData from a mesh
  87214. * @param mesh the mesh from which to extract the VertexData
  87215. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87216. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87217. * @returns the object VertexData associated to the passed mesh
  87218. */
  87219. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87220. /**
  87221. * Extracts the vertexData from the geometry
  87222. * @param geometry the geometry from which to extract the VertexData
  87223. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87224. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87225. * @returns the object VertexData associated to the passed mesh
  87226. */
  87227. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87228. private static _ExtractFrom;
  87229. /**
  87230. * Creates the VertexData for a Ribbon
  87231. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87232. * * pathArray array of paths, each of which an array of successive Vector3
  87233. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87234. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87235. * * 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
  87236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87237. * * 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)
  87238. * * 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)
  87239. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87240. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87241. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87242. * @returns the VertexData of the ribbon
  87243. */
  87244. static CreateRibbon(options: {
  87245. pathArray: Vector3[][];
  87246. closeArray?: boolean;
  87247. closePath?: boolean;
  87248. offset?: number;
  87249. sideOrientation?: number;
  87250. frontUVs?: Vector4;
  87251. backUVs?: Vector4;
  87252. invertUV?: boolean;
  87253. uvs?: Vector2[];
  87254. colors?: Color4[];
  87255. }): VertexData;
  87256. /**
  87257. * Creates the VertexData for a box
  87258. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87259. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87260. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87261. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87262. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87263. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87264. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87265. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87266. * * 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)
  87267. * * 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)
  87268. * @returns the VertexData of the box
  87269. */
  87270. static CreateBox(options: {
  87271. size?: number;
  87272. width?: number;
  87273. height?: number;
  87274. depth?: number;
  87275. faceUV?: Vector4[];
  87276. faceColors?: Color4[];
  87277. sideOrientation?: number;
  87278. frontUVs?: Vector4;
  87279. backUVs?: Vector4;
  87280. }): VertexData;
  87281. /**
  87282. * Creates the VertexData for a tiled box
  87283. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87284. * * faceTiles sets the pattern, tile size and number of tiles for a face
  87285. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87286. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87287. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87288. * @returns the VertexData of the box
  87289. */
  87290. static CreateTiledBox(options: {
  87291. pattern?: number;
  87292. width?: number;
  87293. height?: number;
  87294. depth?: number;
  87295. tileSize?: number;
  87296. tileWidth?: number;
  87297. tileHeight?: number;
  87298. alignHorizontal?: number;
  87299. alignVertical?: number;
  87300. faceUV?: Vector4[];
  87301. faceColors?: Color4[];
  87302. sideOrientation?: number;
  87303. }): VertexData;
  87304. /**
  87305. * Creates the VertexData for a tiled plane
  87306. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87307. * * pattern a limited pattern arrangement depending on the number
  87308. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  87309. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  87310. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  87311. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87312. * * 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)
  87313. * * 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)
  87314. * @returns the VertexData of the tiled plane
  87315. */
  87316. static CreateTiledPlane(options: {
  87317. pattern?: number;
  87318. tileSize?: number;
  87319. tileWidth?: number;
  87320. tileHeight?: number;
  87321. size?: number;
  87322. width?: number;
  87323. height?: number;
  87324. alignHorizontal?: number;
  87325. alignVertical?: number;
  87326. sideOrientation?: number;
  87327. frontUVs?: Vector4;
  87328. backUVs?: Vector4;
  87329. }): VertexData;
  87330. /**
  87331. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87332. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87333. * * segments sets the number of horizontal strips optional, default 32
  87334. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87335. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87336. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87337. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87338. * * 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
  87339. * * 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
  87340. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87341. * * 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)
  87342. * * 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)
  87343. * @returns the VertexData of the ellipsoid
  87344. */
  87345. static CreateSphere(options: {
  87346. segments?: number;
  87347. diameter?: number;
  87348. diameterX?: number;
  87349. diameterY?: number;
  87350. diameterZ?: number;
  87351. arc?: number;
  87352. slice?: number;
  87353. sideOrientation?: number;
  87354. frontUVs?: Vector4;
  87355. backUVs?: Vector4;
  87356. }): VertexData;
  87357. /**
  87358. * Creates the VertexData for a cylinder, cone or prism
  87359. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87360. * * height sets the height (y direction) of the cylinder, optional, default 2
  87361. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87362. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87363. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87364. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87365. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87366. * * 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
  87367. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87368. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87369. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87370. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87371. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87372. * * 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)
  87373. * * 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)
  87374. * @returns the VertexData of the cylinder, cone or prism
  87375. */
  87376. static CreateCylinder(options: {
  87377. height?: number;
  87378. diameterTop?: number;
  87379. diameterBottom?: number;
  87380. diameter?: number;
  87381. tessellation?: number;
  87382. subdivisions?: number;
  87383. arc?: number;
  87384. faceColors?: Color4[];
  87385. faceUV?: Vector4[];
  87386. hasRings?: boolean;
  87387. enclose?: boolean;
  87388. sideOrientation?: number;
  87389. frontUVs?: Vector4;
  87390. backUVs?: Vector4;
  87391. }): VertexData;
  87392. /**
  87393. * Creates the VertexData for a torus
  87394. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87395. * * diameter the diameter of the torus, optional default 1
  87396. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87397. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87399. * * 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)
  87400. * * 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)
  87401. * @returns the VertexData of the torus
  87402. */
  87403. static CreateTorus(options: {
  87404. diameter?: number;
  87405. thickness?: number;
  87406. tessellation?: number;
  87407. sideOrientation?: number;
  87408. frontUVs?: Vector4;
  87409. backUVs?: Vector4;
  87410. }): VertexData;
  87411. /**
  87412. * Creates the VertexData of the LineSystem
  87413. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87414. * - lines an array of lines, each line being an array of successive Vector3
  87415. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87416. * @returns the VertexData of the LineSystem
  87417. */
  87418. static CreateLineSystem(options: {
  87419. lines: Vector3[][];
  87420. colors?: Nullable<Color4[][]>;
  87421. }): VertexData;
  87422. /**
  87423. * Create the VertexData for a DashedLines
  87424. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87425. * - points an array successive Vector3
  87426. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87427. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87428. * - dashNb the intended total number of dashes, optional, default 200
  87429. * @returns the VertexData for the DashedLines
  87430. */
  87431. static CreateDashedLines(options: {
  87432. points: Vector3[];
  87433. dashSize?: number;
  87434. gapSize?: number;
  87435. dashNb?: number;
  87436. }): VertexData;
  87437. /**
  87438. * Creates the VertexData for a Ground
  87439. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87440. * - width the width (x direction) of the ground, optional, default 1
  87441. * - height the height (z direction) of the ground, optional, default 1
  87442. * - subdivisions the number of subdivisions per side, optional, default 1
  87443. * @returns the VertexData of the Ground
  87444. */
  87445. static CreateGround(options: {
  87446. width?: number;
  87447. height?: number;
  87448. subdivisions?: number;
  87449. subdivisionsX?: number;
  87450. subdivisionsY?: number;
  87451. }): VertexData;
  87452. /**
  87453. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87454. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87455. * * xmin the ground minimum X coordinate, optional, default -1
  87456. * * zmin the ground minimum Z coordinate, optional, default -1
  87457. * * xmax the ground maximum X coordinate, optional, default 1
  87458. * * zmax the ground maximum Z coordinate, optional, default 1
  87459. * * 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}
  87460. * * 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}
  87461. * @returns the VertexData of the TiledGround
  87462. */
  87463. static CreateTiledGround(options: {
  87464. xmin: number;
  87465. zmin: number;
  87466. xmax: number;
  87467. zmax: number;
  87468. subdivisions?: {
  87469. w: number;
  87470. h: number;
  87471. };
  87472. precision?: {
  87473. w: number;
  87474. h: number;
  87475. };
  87476. }): VertexData;
  87477. /**
  87478. * Creates the VertexData of the Ground designed from a heightmap
  87479. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87480. * * width the width (x direction) of the ground
  87481. * * height the height (z direction) of the ground
  87482. * * subdivisions the number of subdivisions per side
  87483. * * minHeight the minimum altitude on the ground, optional, default 0
  87484. * * maxHeight the maximum altitude on the ground, optional default 1
  87485. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87486. * * buffer the array holding the image color data
  87487. * * bufferWidth the width of image
  87488. * * bufferHeight the height of image
  87489. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87490. * @returns the VertexData of the Ground designed from a heightmap
  87491. */
  87492. static CreateGroundFromHeightMap(options: {
  87493. width: number;
  87494. height: number;
  87495. subdivisions: number;
  87496. minHeight: number;
  87497. maxHeight: number;
  87498. colorFilter: Color3;
  87499. buffer: Uint8Array;
  87500. bufferWidth: number;
  87501. bufferHeight: number;
  87502. alphaFilter: number;
  87503. }): VertexData;
  87504. /**
  87505. * Creates the VertexData for a Plane
  87506. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87507. * * size sets the width and height of the plane to the value of size, optional default 1
  87508. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87509. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87510. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87511. * * 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)
  87512. * * 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)
  87513. * @returns the VertexData of the box
  87514. */
  87515. static CreatePlane(options: {
  87516. size?: number;
  87517. width?: number;
  87518. height?: number;
  87519. sideOrientation?: number;
  87520. frontUVs?: Vector4;
  87521. backUVs?: Vector4;
  87522. }): VertexData;
  87523. /**
  87524. * Creates the VertexData of the Disc or regular Polygon
  87525. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87526. * * radius the radius of the disc, optional default 0.5
  87527. * * tessellation the number of polygon sides, optional, default 64
  87528. * * 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
  87529. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87530. * * 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)
  87531. * * 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)
  87532. * @returns the VertexData of the box
  87533. */
  87534. static CreateDisc(options: {
  87535. radius?: number;
  87536. tessellation?: number;
  87537. arc?: number;
  87538. sideOrientation?: number;
  87539. frontUVs?: Vector4;
  87540. backUVs?: Vector4;
  87541. }): VertexData;
  87542. /**
  87543. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87544. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87545. * @param polygon a mesh built from polygonTriangulation.build()
  87546. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87547. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87548. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87549. * @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)
  87550. * @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)
  87551. * @returns the VertexData of the Polygon
  87552. */
  87553. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  87554. /**
  87555. * Creates the VertexData of the IcoSphere
  87556. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87557. * * radius the radius of the IcoSphere, optional default 1
  87558. * * radiusX allows stretching in the x direction, optional, default radius
  87559. * * radiusY allows stretching in the y direction, optional, default radius
  87560. * * radiusZ allows stretching in the z direction, optional, default radius
  87561. * * flat when true creates a flat shaded mesh, optional, default true
  87562. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87563. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87564. * * 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)
  87565. * * 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)
  87566. * @returns the VertexData of the IcoSphere
  87567. */
  87568. static CreateIcoSphere(options: {
  87569. radius?: number;
  87570. radiusX?: number;
  87571. radiusY?: number;
  87572. radiusZ?: number;
  87573. flat?: boolean;
  87574. subdivisions?: number;
  87575. sideOrientation?: number;
  87576. frontUVs?: Vector4;
  87577. backUVs?: Vector4;
  87578. }): VertexData;
  87579. /**
  87580. * Creates the VertexData for a Polyhedron
  87581. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87582. * * type provided types are:
  87583. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87584. * * 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)
  87585. * * size the size of the IcoSphere, optional default 1
  87586. * * sizeX allows stretching in the x direction, optional, default size
  87587. * * sizeY allows stretching in the y direction, optional, default size
  87588. * * sizeZ allows stretching in the z direction, optional, default size
  87589. * * 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
  87590. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87591. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87592. * * flat when true creates a flat shaded mesh, optional, default true
  87593. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87594. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87595. * * 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)
  87596. * * 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)
  87597. * @returns the VertexData of the Polyhedron
  87598. */
  87599. static CreatePolyhedron(options: {
  87600. type?: number;
  87601. size?: number;
  87602. sizeX?: number;
  87603. sizeY?: number;
  87604. sizeZ?: number;
  87605. custom?: any;
  87606. faceUV?: Vector4[];
  87607. faceColors?: Color4[];
  87608. flat?: boolean;
  87609. sideOrientation?: number;
  87610. frontUVs?: Vector4;
  87611. backUVs?: Vector4;
  87612. }): VertexData;
  87613. /**
  87614. * Creates the VertexData for a TorusKnot
  87615. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87616. * * radius the radius of the torus knot, optional, default 2
  87617. * * tube the thickness of the tube, optional, default 0.5
  87618. * * radialSegments the number of sides on each tube segments, optional, default 32
  87619. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87620. * * p the number of windings around the z axis, optional, default 2
  87621. * * q the number of windings around the x axis, optional, default 3
  87622. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87623. * * 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)
  87624. * * 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)
  87625. * @returns the VertexData of the Torus Knot
  87626. */
  87627. static CreateTorusKnot(options: {
  87628. radius?: number;
  87629. tube?: number;
  87630. radialSegments?: number;
  87631. tubularSegments?: number;
  87632. p?: number;
  87633. q?: number;
  87634. sideOrientation?: number;
  87635. frontUVs?: Vector4;
  87636. backUVs?: Vector4;
  87637. }): VertexData;
  87638. /**
  87639. * Compute normals for given positions and indices
  87640. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87641. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87642. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87643. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87644. * * facetNormals : optional array of facet normals (vector3)
  87645. * * facetPositions : optional array of facet positions (vector3)
  87646. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87647. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87648. * * bInfo : optional bounding info, required for facetPartitioning computation
  87649. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87650. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87651. * * useRightHandedSystem: optional boolean to for right handed system computation
  87652. * * depthSort : optional boolean to enable the facet depth sort computation
  87653. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87654. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87655. */
  87656. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  87657. facetNormals?: any;
  87658. facetPositions?: any;
  87659. facetPartitioning?: any;
  87660. ratio?: number;
  87661. bInfo?: any;
  87662. bbSize?: Vector3;
  87663. subDiv?: any;
  87664. useRightHandedSystem?: boolean;
  87665. depthSort?: boolean;
  87666. distanceTo?: Vector3;
  87667. depthSortedFacets?: any;
  87668. }): void;
  87669. /** @hidden */
  87670. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  87671. /**
  87672. * Applies VertexData created from the imported parameters to the geometry
  87673. * @param parsedVertexData the parsed data from an imported file
  87674. * @param geometry the geometry to apply the VertexData to
  87675. */
  87676. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  87677. }
  87678. }
  87679. declare module BABYLON {
  87680. /**
  87681. * Defines a target to use with MorphTargetManager
  87682. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87683. */
  87684. export class MorphTarget implements IAnimatable {
  87685. /** defines the name of the target */
  87686. name: string;
  87687. /**
  87688. * Gets or sets the list of animations
  87689. */
  87690. animations: Animation[];
  87691. private _scene;
  87692. private _positions;
  87693. private _normals;
  87694. private _tangents;
  87695. private _uvs;
  87696. private _influence;
  87697. /**
  87698. * Observable raised when the influence changes
  87699. */
  87700. onInfluenceChanged: Observable<boolean>;
  87701. /** @hidden */
  87702. _onDataLayoutChanged: Observable<void>;
  87703. /**
  87704. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  87705. */
  87706. influence: number;
  87707. /**
  87708. * Gets or sets the id of the morph Target
  87709. */
  87710. id: string;
  87711. private _animationPropertiesOverride;
  87712. /**
  87713. * Gets or sets the animation properties override
  87714. */
  87715. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87716. /**
  87717. * Creates a new MorphTarget
  87718. * @param name defines the name of the target
  87719. * @param influence defines the influence to use
  87720. * @param scene defines the scene the morphtarget belongs to
  87721. */
  87722. constructor(
  87723. /** defines the name of the target */
  87724. name: string, influence?: number, scene?: Nullable<Scene>);
  87725. /**
  87726. * Gets a boolean defining if the target contains position data
  87727. */
  87728. readonly hasPositions: boolean;
  87729. /**
  87730. * Gets a boolean defining if the target contains normal data
  87731. */
  87732. readonly hasNormals: boolean;
  87733. /**
  87734. * Gets a boolean defining if the target contains tangent data
  87735. */
  87736. readonly hasTangents: boolean;
  87737. /**
  87738. * Gets a boolean defining if the target contains texture coordinates data
  87739. */
  87740. readonly hasUVs: boolean;
  87741. /**
  87742. * Affects position data to this target
  87743. * @param data defines the position data to use
  87744. */
  87745. setPositions(data: Nullable<FloatArray>): void;
  87746. /**
  87747. * Gets the position data stored in this target
  87748. * @returns a FloatArray containing the position data (or null if not present)
  87749. */
  87750. getPositions(): Nullable<FloatArray>;
  87751. /**
  87752. * Affects normal data to this target
  87753. * @param data defines the normal data to use
  87754. */
  87755. setNormals(data: Nullable<FloatArray>): void;
  87756. /**
  87757. * Gets the normal data stored in this target
  87758. * @returns a FloatArray containing the normal data (or null if not present)
  87759. */
  87760. getNormals(): Nullable<FloatArray>;
  87761. /**
  87762. * Affects tangent data to this target
  87763. * @param data defines the tangent data to use
  87764. */
  87765. setTangents(data: Nullable<FloatArray>): void;
  87766. /**
  87767. * Gets the tangent data stored in this target
  87768. * @returns a FloatArray containing the tangent data (or null if not present)
  87769. */
  87770. getTangents(): Nullable<FloatArray>;
  87771. /**
  87772. * Affects texture coordinates data to this target
  87773. * @param data defines the texture coordinates data to use
  87774. */
  87775. setUVs(data: Nullable<FloatArray>): void;
  87776. /**
  87777. * Gets the texture coordinates data stored in this target
  87778. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  87779. */
  87780. getUVs(): Nullable<FloatArray>;
  87781. /**
  87782. * Serializes the current target into a Serialization object
  87783. * @returns the serialized object
  87784. */
  87785. serialize(): any;
  87786. /**
  87787. * Returns the string "MorphTarget"
  87788. * @returns "MorphTarget"
  87789. */
  87790. getClassName(): string;
  87791. /**
  87792. * Creates a new target from serialized data
  87793. * @param serializationObject defines the serialized data to use
  87794. * @returns a new MorphTarget
  87795. */
  87796. static Parse(serializationObject: any): MorphTarget;
  87797. /**
  87798. * Creates a MorphTarget from mesh data
  87799. * @param mesh defines the source mesh
  87800. * @param name defines the name to use for the new target
  87801. * @param influence defines the influence to attach to the target
  87802. * @returns a new MorphTarget
  87803. */
  87804. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  87805. }
  87806. }
  87807. declare module BABYLON {
  87808. /**
  87809. * This class is used to deform meshes using morphing between different targets
  87810. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87811. */
  87812. export class MorphTargetManager {
  87813. private _targets;
  87814. private _targetInfluenceChangedObservers;
  87815. private _targetDataLayoutChangedObservers;
  87816. private _activeTargets;
  87817. private _scene;
  87818. private _influences;
  87819. private _supportsNormals;
  87820. private _supportsTangents;
  87821. private _supportsUVs;
  87822. private _vertexCount;
  87823. private _uniqueId;
  87824. private _tempInfluences;
  87825. /**
  87826. * Gets or sets a boolean indicating if normals must be morphed
  87827. */
  87828. enableNormalMorphing: boolean;
  87829. /**
  87830. * Gets or sets a boolean indicating if tangents must be morphed
  87831. */
  87832. enableTangentMorphing: boolean;
  87833. /**
  87834. * Gets or sets a boolean indicating if UV must be morphed
  87835. */
  87836. enableUVMorphing: boolean;
  87837. /**
  87838. * Creates a new MorphTargetManager
  87839. * @param scene defines the current scene
  87840. */
  87841. constructor(scene?: Nullable<Scene>);
  87842. /**
  87843. * Gets the unique ID of this manager
  87844. */
  87845. readonly uniqueId: number;
  87846. /**
  87847. * Gets the number of vertices handled by this manager
  87848. */
  87849. readonly vertexCount: number;
  87850. /**
  87851. * Gets a boolean indicating if this manager supports morphing of normals
  87852. */
  87853. readonly supportsNormals: boolean;
  87854. /**
  87855. * Gets a boolean indicating if this manager supports morphing of tangents
  87856. */
  87857. readonly supportsTangents: boolean;
  87858. /**
  87859. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  87860. */
  87861. readonly supportsUVs: boolean;
  87862. /**
  87863. * Gets the number of targets stored in this manager
  87864. */
  87865. readonly numTargets: number;
  87866. /**
  87867. * Gets the number of influencers (ie. the number of targets with influences > 0)
  87868. */
  87869. readonly numInfluencers: number;
  87870. /**
  87871. * Gets the list of influences (one per target)
  87872. */
  87873. readonly influences: Float32Array;
  87874. /**
  87875. * Gets the active target at specified index. An active target is a target with an influence > 0
  87876. * @param index defines the index to check
  87877. * @returns the requested target
  87878. */
  87879. getActiveTarget(index: number): MorphTarget;
  87880. /**
  87881. * Gets the target at specified index
  87882. * @param index defines the index to check
  87883. * @returns the requested target
  87884. */
  87885. getTarget(index: number): MorphTarget;
  87886. /**
  87887. * Add a new target to this manager
  87888. * @param target defines the target to add
  87889. */
  87890. addTarget(target: MorphTarget): void;
  87891. /**
  87892. * Removes a target from the manager
  87893. * @param target defines the target to remove
  87894. */
  87895. removeTarget(target: MorphTarget): void;
  87896. /**
  87897. * Serializes the current manager into a Serialization object
  87898. * @returns the serialized object
  87899. */
  87900. serialize(): any;
  87901. private _syncActiveTargets;
  87902. /**
  87903. * Syncrhonize the targets with all the meshes using this morph target manager
  87904. */
  87905. synchronize(): void;
  87906. /**
  87907. * Creates a new MorphTargetManager from serialized data
  87908. * @param serializationObject defines the serialized data
  87909. * @param scene defines the hosting scene
  87910. * @returns the new MorphTargetManager
  87911. */
  87912. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  87913. }
  87914. }
  87915. declare module BABYLON {
  87916. /**
  87917. * Class used to represent a specific level of detail of a mesh
  87918. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87919. */
  87920. export class MeshLODLevel {
  87921. /** Defines the distance where this level should start being displayed */
  87922. distance: number;
  87923. /** Defines the mesh to use to render this level */
  87924. mesh: Nullable<Mesh>;
  87925. /**
  87926. * Creates a new LOD level
  87927. * @param distance defines the distance where this level should star being displayed
  87928. * @param mesh defines the mesh to use to render this level
  87929. */
  87930. constructor(
  87931. /** Defines the distance where this level should start being displayed */
  87932. distance: number,
  87933. /** Defines the mesh to use to render this level */
  87934. mesh: Nullable<Mesh>);
  87935. }
  87936. }
  87937. declare module BABYLON {
  87938. /**
  87939. * Mesh representing the gorund
  87940. */
  87941. export class GroundMesh extends Mesh {
  87942. /** If octree should be generated */
  87943. generateOctree: boolean;
  87944. private _heightQuads;
  87945. /** @hidden */
  87946. _subdivisionsX: number;
  87947. /** @hidden */
  87948. _subdivisionsY: number;
  87949. /** @hidden */
  87950. _width: number;
  87951. /** @hidden */
  87952. _height: number;
  87953. /** @hidden */
  87954. _minX: number;
  87955. /** @hidden */
  87956. _maxX: number;
  87957. /** @hidden */
  87958. _minZ: number;
  87959. /** @hidden */
  87960. _maxZ: number;
  87961. constructor(name: string, scene: Scene);
  87962. /**
  87963. * "GroundMesh"
  87964. * @returns "GroundMesh"
  87965. */
  87966. getClassName(): string;
  87967. /**
  87968. * The minimum of x and y subdivisions
  87969. */
  87970. readonly subdivisions: number;
  87971. /**
  87972. * X subdivisions
  87973. */
  87974. readonly subdivisionsX: number;
  87975. /**
  87976. * Y subdivisions
  87977. */
  87978. readonly subdivisionsY: number;
  87979. /**
  87980. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  87981. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  87982. * @param chunksCount the number of subdivisions for x and y
  87983. * @param octreeBlocksSize (Default: 32)
  87984. */
  87985. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  87986. /**
  87987. * Returns a height (y) value in the Worl system :
  87988. * the ground altitude at the coordinates (x, z) expressed in the World system.
  87989. * @param x x coordinate
  87990. * @param z z coordinate
  87991. * @returns the ground y position if (x, z) are outside the ground surface.
  87992. */
  87993. getHeightAtCoordinates(x: number, z: number): number;
  87994. /**
  87995. * Returns a normalized vector (Vector3) orthogonal to the ground
  87996. * at the ground coordinates (x, z) expressed in the World system.
  87997. * @param x x coordinate
  87998. * @param z z coordinate
  87999. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  88000. */
  88001. getNormalAtCoordinates(x: number, z: number): Vector3;
  88002. /**
  88003. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  88004. * at the ground coordinates (x, z) expressed in the World system.
  88005. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  88006. * @param x x coordinate
  88007. * @param z z coordinate
  88008. * @param ref vector to store the result
  88009. * @returns the GroundMesh.
  88010. */
  88011. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  88012. /**
  88013. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  88014. * if the ground has been updated.
  88015. * This can be used in the render loop.
  88016. * @returns the GroundMesh.
  88017. */
  88018. updateCoordinateHeights(): GroundMesh;
  88019. private _getFacetAt;
  88020. private _initHeightQuads;
  88021. private _computeHeightQuads;
  88022. /**
  88023. * Serializes this ground mesh
  88024. * @param serializationObject object to write serialization to
  88025. */
  88026. serialize(serializationObject: any): void;
  88027. /**
  88028. * Parses a serialized ground mesh
  88029. * @param parsedMesh the serialized mesh
  88030. * @param scene the scene to create the ground mesh in
  88031. * @returns the created ground mesh
  88032. */
  88033. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  88034. }
  88035. }
  88036. declare module BABYLON {
  88037. /**
  88038. * Interface for Physics-Joint data
  88039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88040. */
  88041. export interface PhysicsJointData {
  88042. /**
  88043. * The main pivot of the joint
  88044. */
  88045. mainPivot?: Vector3;
  88046. /**
  88047. * The connected pivot of the joint
  88048. */
  88049. connectedPivot?: Vector3;
  88050. /**
  88051. * The main axis of the joint
  88052. */
  88053. mainAxis?: Vector3;
  88054. /**
  88055. * The connected axis of the joint
  88056. */
  88057. connectedAxis?: Vector3;
  88058. /**
  88059. * The collision of the joint
  88060. */
  88061. collision?: boolean;
  88062. /**
  88063. * Native Oimo/Cannon/Energy data
  88064. */
  88065. nativeParams?: any;
  88066. }
  88067. /**
  88068. * This is a holder class for the physics joint created by the physics plugin
  88069. * It holds a set of functions to control the underlying joint
  88070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88071. */
  88072. export class PhysicsJoint {
  88073. /**
  88074. * The type of the physics joint
  88075. */
  88076. type: number;
  88077. /**
  88078. * The data for the physics joint
  88079. */
  88080. jointData: PhysicsJointData;
  88081. private _physicsJoint;
  88082. protected _physicsPlugin: IPhysicsEnginePlugin;
  88083. /**
  88084. * Initializes the physics joint
  88085. * @param type The type of the physics joint
  88086. * @param jointData The data for the physics joint
  88087. */
  88088. constructor(
  88089. /**
  88090. * The type of the physics joint
  88091. */
  88092. type: number,
  88093. /**
  88094. * The data for the physics joint
  88095. */
  88096. jointData: PhysicsJointData);
  88097. /**
  88098. * Gets the physics joint
  88099. */
  88100. /**
  88101. * Sets the physics joint
  88102. */
  88103. physicsJoint: any;
  88104. /**
  88105. * Sets the physics plugin
  88106. */
  88107. physicsPlugin: IPhysicsEnginePlugin;
  88108. /**
  88109. * Execute a function that is physics-plugin specific.
  88110. * @param {Function} func the function that will be executed.
  88111. * It accepts two parameters: the physics world and the physics joint
  88112. */
  88113. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  88114. /**
  88115. * Distance-Joint type
  88116. */
  88117. static DistanceJoint: number;
  88118. /**
  88119. * Hinge-Joint type
  88120. */
  88121. static HingeJoint: number;
  88122. /**
  88123. * Ball-and-Socket joint type
  88124. */
  88125. static BallAndSocketJoint: number;
  88126. /**
  88127. * Wheel-Joint type
  88128. */
  88129. static WheelJoint: number;
  88130. /**
  88131. * Slider-Joint type
  88132. */
  88133. static SliderJoint: number;
  88134. /**
  88135. * Prismatic-Joint type
  88136. */
  88137. static PrismaticJoint: number;
  88138. /**
  88139. * Universal-Joint type
  88140. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  88141. */
  88142. static UniversalJoint: number;
  88143. /**
  88144. * Hinge-Joint 2 type
  88145. */
  88146. static Hinge2Joint: number;
  88147. /**
  88148. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  88149. */
  88150. static PointToPointJoint: number;
  88151. /**
  88152. * Spring-Joint type
  88153. */
  88154. static SpringJoint: number;
  88155. /**
  88156. * Lock-Joint type
  88157. */
  88158. static LockJoint: number;
  88159. }
  88160. /**
  88161. * A class representing a physics distance joint
  88162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88163. */
  88164. export class DistanceJoint extends PhysicsJoint {
  88165. /**
  88166. *
  88167. * @param jointData The data for the Distance-Joint
  88168. */
  88169. constructor(jointData: DistanceJointData);
  88170. /**
  88171. * Update the predefined distance.
  88172. * @param maxDistance The maximum preferred distance
  88173. * @param minDistance The minimum preferred distance
  88174. */
  88175. updateDistance(maxDistance: number, minDistance?: number): void;
  88176. }
  88177. /**
  88178. * Represents a Motor-Enabled Joint
  88179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88180. */
  88181. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  88182. /**
  88183. * Initializes the Motor-Enabled Joint
  88184. * @param type The type of the joint
  88185. * @param jointData The physica joint data for the joint
  88186. */
  88187. constructor(type: number, jointData: PhysicsJointData);
  88188. /**
  88189. * Set the motor values.
  88190. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88191. * @param force the force to apply
  88192. * @param maxForce max force for this motor.
  88193. */
  88194. setMotor(force?: number, maxForce?: number): void;
  88195. /**
  88196. * Set the motor's limits.
  88197. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88198. * @param upperLimit The upper limit of the motor
  88199. * @param lowerLimit The lower limit of the motor
  88200. */
  88201. setLimit(upperLimit: number, lowerLimit?: number): void;
  88202. }
  88203. /**
  88204. * This class represents a single physics Hinge-Joint
  88205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88206. */
  88207. export class HingeJoint extends MotorEnabledJoint {
  88208. /**
  88209. * Initializes the Hinge-Joint
  88210. * @param jointData The joint data for the Hinge-Joint
  88211. */
  88212. constructor(jointData: PhysicsJointData);
  88213. /**
  88214. * Set the motor values.
  88215. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88216. * @param {number} force the force to apply
  88217. * @param {number} maxForce max force for this motor.
  88218. */
  88219. setMotor(force?: number, maxForce?: number): void;
  88220. /**
  88221. * Set the motor's limits.
  88222. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88223. * @param upperLimit The upper limit of the motor
  88224. * @param lowerLimit The lower limit of the motor
  88225. */
  88226. setLimit(upperLimit: number, lowerLimit?: number): void;
  88227. }
  88228. /**
  88229. * This class represents a dual hinge physics joint (same as wheel joint)
  88230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88231. */
  88232. export class Hinge2Joint extends MotorEnabledJoint {
  88233. /**
  88234. * Initializes the Hinge2-Joint
  88235. * @param jointData The joint data for the Hinge2-Joint
  88236. */
  88237. constructor(jointData: PhysicsJointData);
  88238. /**
  88239. * Set the motor values.
  88240. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88241. * @param {number} targetSpeed the speed the motor is to reach
  88242. * @param {number} maxForce max force for this motor.
  88243. * @param {motorIndex} the motor's index, 0 or 1.
  88244. */
  88245. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  88246. /**
  88247. * Set the motor limits.
  88248. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88249. * @param {number} upperLimit the upper limit
  88250. * @param {number} lowerLimit lower limit
  88251. * @param {motorIndex} the motor's index, 0 or 1.
  88252. */
  88253. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88254. }
  88255. /**
  88256. * Interface for a motor enabled joint
  88257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88258. */
  88259. export interface IMotorEnabledJoint {
  88260. /**
  88261. * Physics joint
  88262. */
  88263. physicsJoint: any;
  88264. /**
  88265. * Sets the motor of the motor-enabled joint
  88266. * @param force The force of the motor
  88267. * @param maxForce The maximum force of the motor
  88268. * @param motorIndex The index of the motor
  88269. */
  88270. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  88271. /**
  88272. * Sets the limit of the motor
  88273. * @param upperLimit The upper limit of the motor
  88274. * @param lowerLimit The lower limit of the motor
  88275. * @param motorIndex The index of the motor
  88276. */
  88277. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88278. }
  88279. /**
  88280. * Joint data for a Distance-Joint
  88281. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88282. */
  88283. export interface DistanceJointData extends PhysicsJointData {
  88284. /**
  88285. * Max distance the 2 joint objects can be apart
  88286. */
  88287. maxDistance: number;
  88288. }
  88289. /**
  88290. * Joint data from a spring joint
  88291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88292. */
  88293. export interface SpringJointData extends PhysicsJointData {
  88294. /**
  88295. * Length of the spring
  88296. */
  88297. length: number;
  88298. /**
  88299. * Stiffness of the spring
  88300. */
  88301. stiffness: number;
  88302. /**
  88303. * Damping of the spring
  88304. */
  88305. damping: number;
  88306. /** this callback will be called when applying the force to the impostors. */
  88307. forceApplicationCallback: () => void;
  88308. }
  88309. }
  88310. declare module BABYLON {
  88311. /**
  88312. * Holds the data for the raycast result
  88313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88314. */
  88315. export class PhysicsRaycastResult {
  88316. private _hasHit;
  88317. private _hitDistance;
  88318. private _hitNormalWorld;
  88319. private _hitPointWorld;
  88320. private _rayFromWorld;
  88321. private _rayToWorld;
  88322. /**
  88323. * Gets if there was a hit
  88324. */
  88325. readonly hasHit: boolean;
  88326. /**
  88327. * Gets the distance from the hit
  88328. */
  88329. readonly hitDistance: number;
  88330. /**
  88331. * Gets the hit normal/direction in the world
  88332. */
  88333. readonly hitNormalWorld: Vector3;
  88334. /**
  88335. * Gets the hit point in the world
  88336. */
  88337. readonly hitPointWorld: Vector3;
  88338. /**
  88339. * Gets the ray "start point" of the ray in the world
  88340. */
  88341. readonly rayFromWorld: Vector3;
  88342. /**
  88343. * Gets the ray "end point" of the ray in the world
  88344. */
  88345. readonly rayToWorld: Vector3;
  88346. /**
  88347. * Sets the hit data (normal & point in world space)
  88348. * @param hitNormalWorld defines the normal in world space
  88349. * @param hitPointWorld defines the point in world space
  88350. */
  88351. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  88352. /**
  88353. * Sets the distance from the start point to the hit point
  88354. * @param distance
  88355. */
  88356. setHitDistance(distance: number): void;
  88357. /**
  88358. * Calculates the distance manually
  88359. */
  88360. calculateHitDistance(): void;
  88361. /**
  88362. * Resets all the values to default
  88363. * @param from The from point on world space
  88364. * @param to The to point on world space
  88365. */
  88366. reset(from?: Vector3, to?: Vector3): void;
  88367. }
  88368. /**
  88369. * Interface for the size containing width and height
  88370. */
  88371. interface IXYZ {
  88372. /**
  88373. * X
  88374. */
  88375. x: number;
  88376. /**
  88377. * Y
  88378. */
  88379. y: number;
  88380. /**
  88381. * Z
  88382. */
  88383. z: number;
  88384. }
  88385. }
  88386. declare module BABYLON {
  88387. /**
  88388. * Interface used to describe a physics joint
  88389. */
  88390. export interface PhysicsImpostorJoint {
  88391. /** Defines the main impostor to which the joint is linked */
  88392. mainImpostor: PhysicsImpostor;
  88393. /** Defines the impostor that is connected to the main impostor using this joint */
  88394. connectedImpostor: PhysicsImpostor;
  88395. /** Defines the joint itself */
  88396. joint: PhysicsJoint;
  88397. }
  88398. /** @hidden */
  88399. export interface IPhysicsEnginePlugin {
  88400. world: any;
  88401. name: string;
  88402. setGravity(gravity: Vector3): void;
  88403. setTimeStep(timeStep: number): void;
  88404. getTimeStep(): number;
  88405. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  88406. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88407. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88408. generatePhysicsBody(impostor: PhysicsImpostor): void;
  88409. removePhysicsBody(impostor: PhysicsImpostor): void;
  88410. generateJoint(joint: PhysicsImpostorJoint): void;
  88411. removeJoint(joint: PhysicsImpostorJoint): void;
  88412. isSupported(): boolean;
  88413. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  88414. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  88415. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88416. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88417. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88418. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88419. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  88420. getBodyMass(impostor: PhysicsImpostor): number;
  88421. getBodyFriction(impostor: PhysicsImpostor): number;
  88422. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  88423. getBodyRestitution(impostor: PhysicsImpostor): number;
  88424. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  88425. getBodyPressure?(impostor: PhysicsImpostor): number;
  88426. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  88427. getBodyStiffness?(impostor: PhysicsImpostor): number;
  88428. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  88429. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  88430. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  88431. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  88432. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  88433. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88434. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88435. sleepBody(impostor: PhysicsImpostor): void;
  88436. wakeUpBody(impostor: PhysicsImpostor): void;
  88437. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88438. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  88439. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  88440. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88441. getRadius(impostor: PhysicsImpostor): number;
  88442. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  88443. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  88444. dispose(): void;
  88445. }
  88446. /**
  88447. * Interface used to define a physics engine
  88448. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  88449. */
  88450. export interface IPhysicsEngine {
  88451. /**
  88452. * Gets the gravity vector used by the simulation
  88453. */
  88454. gravity: Vector3;
  88455. /**
  88456. * Sets the gravity vector used by the simulation
  88457. * @param gravity defines the gravity vector to use
  88458. */
  88459. setGravity(gravity: Vector3): void;
  88460. /**
  88461. * Set the time step of the physics engine.
  88462. * Default is 1/60.
  88463. * To slow it down, enter 1/600 for example.
  88464. * To speed it up, 1/30
  88465. * @param newTimeStep the new timestep to apply to this world.
  88466. */
  88467. setTimeStep(newTimeStep: number): void;
  88468. /**
  88469. * Get the time step of the physics engine.
  88470. * @returns the current time step
  88471. */
  88472. getTimeStep(): number;
  88473. /**
  88474. * Release all resources
  88475. */
  88476. dispose(): void;
  88477. /**
  88478. * Gets the name of the current physics plugin
  88479. * @returns the name of the plugin
  88480. */
  88481. getPhysicsPluginName(): string;
  88482. /**
  88483. * Adding a new impostor for the impostor tracking.
  88484. * This will be done by the impostor itself.
  88485. * @param impostor the impostor to add
  88486. */
  88487. addImpostor(impostor: PhysicsImpostor): void;
  88488. /**
  88489. * Remove an impostor from the engine.
  88490. * This impostor and its mesh will not longer be updated by the physics engine.
  88491. * @param impostor the impostor to remove
  88492. */
  88493. removeImpostor(impostor: PhysicsImpostor): void;
  88494. /**
  88495. * Add a joint to the physics engine
  88496. * @param mainImpostor defines the main impostor to which the joint is added.
  88497. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  88498. * @param joint defines the joint that will connect both impostors.
  88499. */
  88500. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88501. /**
  88502. * Removes a joint from the simulation
  88503. * @param mainImpostor defines the impostor used with the joint
  88504. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  88505. * @param joint defines the joint to remove
  88506. */
  88507. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88508. /**
  88509. * Gets the current plugin used to run the simulation
  88510. * @returns current plugin
  88511. */
  88512. getPhysicsPlugin(): IPhysicsEnginePlugin;
  88513. /**
  88514. * Gets the list of physic impostors
  88515. * @returns an array of PhysicsImpostor
  88516. */
  88517. getImpostors(): Array<PhysicsImpostor>;
  88518. /**
  88519. * Gets the impostor for a physics enabled object
  88520. * @param object defines the object impersonated by the impostor
  88521. * @returns the PhysicsImpostor or null if not found
  88522. */
  88523. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88524. /**
  88525. * Gets the impostor for a physics body object
  88526. * @param body defines physics body used by the impostor
  88527. * @returns the PhysicsImpostor or null if not found
  88528. */
  88529. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  88530. /**
  88531. * Does a raycast in the physics world
  88532. * @param from when should the ray start?
  88533. * @param to when should the ray end?
  88534. * @returns PhysicsRaycastResult
  88535. */
  88536. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88537. /**
  88538. * Called by the scene. No need to call it.
  88539. * @param delta defines the timespam between frames
  88540. */
  88541. _step(delta: number): void;
  88542. }
  88543. }
  88544. declare module BABYLON {
  88545. /**
  88546. * The interface for the physics imposter parameters
  88547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88548. */
  88549. export interface PhysicsImpostorParameters {
  88550. /**
  88551. * The mass of the physics imposter
  88552. */
  88553. mass: number;
  88554. /**
  88555. * The friction of the physics imposter
  88556. */
  88557. friction?: number;
  88558. /**
  88559. * The coefficient of restitution of the physics imposter
  88560. */
  88561. restitution?: number;
  88562. /**
  88563. * The native options of the physics imposter
  88564. */
  88565. nativeOptions?: any;
  88566. /**
  88567. * Specifies if the parent should be ignored
  88568. */
  88569. ignoreParent?: boolean;
  88570. /**
  88571. * Specifies if bi-directional transformations should be disabled
  88572. */
  88573. disableBidirectionalTransformation?: boolean;
  88574. /**
  88575. * The pressure inside the physics imposter, soft object only
  88576. */
  88577. pressure?: number;
  88578. /**
  88579. * The stiffness the physics imposter, soft object only
  88580. */
  88581. stiffness?: number;
  88582. /**
  88583. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  88584. */
  88585. velocityIterations?: number;
  88586. /**
  88587. * The number of iterations used in maintaining consistent vertex positions, soft object only
  88588. */
  88589. positionIterations?: number;
  88590. /**
  88591. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  88592. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  88593. * Add to fix multiple points
  88594. */
  88595. fixedPoints?: number;
  88596. /**
  88597. * The collision margin around a soft object
  88598. */
  88599. margin?: number;
  88600. /**
  88601. * The collision margin around a soft object
  88602. */
  88603. damping?: number;
  88604. /**
  88605. * The path for a rope based on an extrusion
  88606. */
  88607. path?: any;
  88608. /**
  88609. * The shape of an extrusion used for a rope based on an extrusion
  88610. */
  88611. shape?: any;
  88612. }
  88613. /**
  88614. * Interface for a physics-enabled object
  88615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88616. */
  88617. export interface IPhysicsEnabledObject {
  88618. /**
  88619. * The position of the physics-enabled object
  88620. */
  88621. position: Vector3;
  88622. /**
  88623. * The rotation of the physics-enabled object
  88624. */
  88625. rotationQuaternion: Nullable<Quaternion>;
  88626. /**
  88627. * The scale of the physics-enabled object
  88628. */
  88629. scaling: Vector3;
  88630. /**
  88631. * The rotation of the physics-enabled object
  88632. */
  88633. rotation?: Vector3;
  88634. /**
  88635. * The parent of the physics-enabled object
  88636. */
  88637. parent?: any;
  88638. /**
  88639. * The bounding info of the physics-enabled object
  88640. * @returns The bounding info of the physics-enabled object
  88641. */
  88642. getBoundingInfo(): BoundingInfo;
  88643. /**
  88644. * Computes the world matrix
  88645. * @param force Specifies if the world matrix should be computed by force
  88646. * @returns A world matrix
  88647. */
  88648. computeWorldMatrix(force: boolean): Matrix;
  88649. /**
  88650. * Gets the world matrix
  88651. * @returns A world matrix
  88652. */
  88653. getWorldMatrix?(): Matrix;
  88654. /**
  88655. * Gets the child meshes
  88656. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  88657. * @returns An array of abstract meshes
  88658. */
  88659. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  88660. /**
  88661. * Gets the vertex data
  88662. * @param kind The type of vertex data
  88663. * @returns A nullable array of numbers, or a float32 array
  88664. */
  88665. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  88666. /**
  88667. * Gets the indices from the mesh
  88668. * @returns A nullable array of index arrays
  88669. */
  88670. getIndices?(): Nullable<IndicesArray>;
  88671. /**
  88672. * Gets the scene from the mesh
  88673. * @returns the indices array or null
  88674. */
  88675. getScene?(): Scene;
  88676. /**
  88677. * Gets the absolute position from the mesh
  88678. * @returns the absolute position
  88679. */
  88680. getAbsolutePosition(): Vector3;
  88681. /**
  88682. * Gets the absolute pivot point from the mesh
  88683. * @returns the absolute pivot point
  88684. */
  88685. getAbsolutePivotPoint(): Vector3;
  88686. /**
  88687. * Rotates the mesh
  88688. * @param axis The axis of rotation
  88689. * @param amount The amount of rotation
  88690. * @param space The space of the rotation
  88691. * @returns The rotation transform node
  88692. */
  88693. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88694. /**
  88695. * Translates the mesh
  88696. * @param axis The axis of translation
  88697. * @param distance The distance of translation
  88698. * @param space The space of the translation
  88699. * @returns The transform node
  88700. */
  88701. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88702. /**
  88703. * Sets the absolute position of the mesh
  88704. * @param absolutePosition The absolute position of the mesh
  88705. * @returns The transform node
  88706. */
  88707. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88708. /**
  88709. * Gets the class name of the mesh
  88710. * @returns The class name
  88711. */
  88712. getClassName(): string;
  88713. }
  88714. /**
  88715. * Represents a physics imposter
  88716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88717. */
  88718. export class PhysicsImpostor {
  88719. /**
  88720. * The physics-enabled object used as the physics imposter
  88721. */
  88722. object: IPhysicsEnabledObject;
  88723. /**
  88724. * The type of the physics imposter
  88725. */
  88726. type: number;
  88727. private _options;
  88728. private _scene?;
  88729. /**
  88730. * The default object size of the imposter
  88731. */
  88732. static DEFAULT_OBJECT_SIZE: Vector3;
  88733. /**
  88734. * The identity quaternion of the imposter
  88735. */
  88736. static IDENTITY_QUATERNION: Quaternion;
  88737. /** @hidden */
  88738. _pluginData: any;
  88739. private _physicsEngine;
  88740. private _physicsBody;
  88741. private _bodyUpdateRequired;
  88742. private _onBeforePhysicsStepCallbacks;
  88743. private _onAfterPhysicsStepCallbacks;
  88744. /** @hidden */
  88745. _onPhysicsCollideCallbacks: Array<{
  88746. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  88747. otherImpostors: Array<PhysicsImpostor>;
  88748. }>;
  88749. private _deltaPosition;
  88750. private _deltaRotation;
  88751. private _deltaRotationConjugated;
  88752. /** @hidden */
  88753. _isFromLine: boolean;
  88754. private _parent;
  88755. private _isDisposed;
  88756. private static _tmpVecs;
  88757. private static _tmpQuat;
  88758. /**
  88759. * Specifies if the physics imposter is disposed
  88760. */
  88761. readonly isDisposed: boolean;
  88762. /**
  88763. * Gets the mass of the physics imposter
  88764. */
  88765. mass: number;
  88766. /**
  88767. * Gets the coefficient of friction
  88768. */
  88769. /**
  88770. * Sets the coefficient of friction
  88771. */
  88772. friction: number;
  88773. /**
  88774. * Gets the coefficient of restitution
  88775. */
  88776. /**
  88777. * Sets the coefficient of restitution
  88778. */
  88779. restitution: number;
  88780. /**
  88781. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  88782. */
  88783. /**
  88784. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  88785. */
  88786. pressure: number;
  88787. /**
  88788. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88789. */
  88790. /**
  88791. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88792. */
  88793. stiffness: number;
  88794. /**
  88795. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88796. */
  88797. /**
  88798. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88799. */
  88800. velocityIterations: number;
  88801. /**
  88802. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88803. */
  88804. /**
  88805. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88806. */
  88807. positionIterations: number;
  88808. /**
  88809. * The unique id of the physics imposter
  88810. * set by the physics engine when adding this impostor to the array
  88811. */
  88812. uniqueId: number;
  88813. /**
  88814. * @hidden
  88815. */
  88816. soft: boolean;
  88817. /**
  88818. * @hidden
  88819. */
  88820. segments: number;
  88821. private _joints;
  88822. /**
  88823. * Initializes the physics imposter
  88824. * @param object The physics-enabled object used as the physics imposter
  88825. * @param type The type of the physics imposter
  88826. * @param _options The options for the physics imposter
  88827. * @param _scene The Babylon scene
  88828. */
  88829. constructor(
  88830. /**
  88831. * The physics-enabled object used as the physics imposter
  88832. */
  88833. object: IPhysicsEnabledObject,
  88834. /**
  88835. * The type of the physics imposter
  88836. */
  88837. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  88838. /**
  88839. * This function will completly initialize this impostor.
  88840. * It will create a new body - but only if this mesh has no parent.
  88841. * If it has, this impostor will not be used other than to define the impostor
  88842. * of the child mesh.
  88843. * @hidden
  88844. */
  88845. _init(): void;
  88846. private _getPhysicsParent;
  88847. /**
  88848. * Should a new body be generated.
  88849. * @returns boolean specifying if body initialization is required
  88850. */
  88851. isBodyInitRequired(): boolean;
  88852. /**
  88853. * Sets the updated scaling
  88854. * @param updated Specifies if the scaling is updated
  88855. */
  88856. setScalingUpdated(): void;
  88857. /**
  88858. * Force a regeneration of this or the parent's impostor's body.
  88859. * Use under cautious - This will remove all joints already implemented.
  88860. */
  88861. forceUpdate(): void;
  88862. /**
  88863. * Gets the body that holds this impostor. Either its own, or its parent.
  88864. */
  88865. /**
  88866. * Set the physics body. Used mainly by the physics engine/plugin
  88867. */
  88868. physicsBody: any;
  88869. /**
  88870. * Get the parent of the physics imposter
  88871. * @returns Physics imposter or null
  88872. */
  88873. /**
  88874. * Sets the parent of the physics imposter
  88875. */
  88876. parent: Nullable<PhysicsImpostor>;
  88877. /**
  88878. * Resets the update flags
  88879. */
  88880. resetUpdateFlags(): void;
  88881. /**
  88882. * Gets the object extend size
  88883. * @returns the object extend size
  88884. */
  88885. getObjectExtendSize(): Vector3;
  88886. /**
  88887. * Gets the object center
  88888. * @returns The object center
  88889. */
  88890. getObjectCenter(): Vector3;
  88891. /**
  88892. * Get a specific parametes from the options parameter
  88893. * @param paramName The object parameter name
  88894. * @returns The object parameter
  88895. */
  88896. getParam(paramName: string): any;
  88897. /**
  88898. * Sets a specific parameter in the options given to the physics plugin
  88899. * @param paramName The parameter name
  88900. * @param value The value of the parameter
  88901. */
  88902. setParam(paramName: string, value: number): void;
  88903. /**
  88904. * Specifically change the body's mass option. Won't recreate the physics body object
  88905. * @param mass The mass of the physics imposter
  88906. */
  88907. setMass(mass: number): void;
  88908. /**
  88909. * Gets the linear velocity
  88910. * @returns linear velocity or null
  88911. */
  88912. getLinearVelocity(): Nullable<Vector3>;
  88913. /**
  88914. * Sets the linear velocity
  88915. * @param velocity linear velocity or null
  88916. */
  88917. setLinearVelocity(velocity: Nullable<Vector3>): void;
  88918. /**
  88919. * Gets the angular velocity
  88920. * @returns angular velocity or null
  88921. */
  88922. getAngularVelocity(): Nullable<Vector3>;
  88923. /**
  88924. * Sets the angular velocity
  88925. * @param velocity The velocity or null
  88926. */
  88927. setAngularVelocity(velocity: Nullable<Vector3>): void;
  88928. /**
  88929. * Execute a function with the physics plugin native code
  88930. * Provide a function the will have two variables - the world object and the physics body object
  88931. * @param func The function to execute with the physics plugin native code
  88932. */
  88933. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  88934. /**
  88935. * Register a function that will be executed before the physics world is stepping forward
  88936. * @param func The function to execute before the physics world is stepped forward
  88937. */
  88938. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88939. /**
  88940. * Unregister a function that will be executed before the physics world is stepping forward
  88941. * @param func The function to execute before the physics world is stepped forward
  88942. */
  88943. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88944. /**
  88945. * Register a function that will be executed after the physics step
  88946. * @param func The function to execute after physics step
  88947. */
  88948. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88949. /**
  88950. * Unregisters a function that will be executed after the physics step
  88951. * @param func The function to execute after physics step
  88952. */
  88953. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88954. /**
  88955. * register a function that will be executed when this impostor collides against a different body
  88956. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  88957. * @param func Callback that is executed on collision
  88958. */
  88959. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  88960. /**
  88961. * Unregisters the physics imposter on contact
  88962. * @param collideAgainst The physics object to collide against
  88963. * @param func Callback to execute on collision
  88964. */
  88965. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  88966. private _tmpQuat;
  88967. private _tmpQuat2;
  88968. /**
  88969. * Get the parent rotation
  88970. * @returns The parent rotation
  88971. */
  88972. getParentsRotation(): Quaternion;
  88973. /**
  88974. * this function is executed by the physics engine.
  88975. */
  88976. beforeStep: () => void;
  88977. /**
  88978. * this function is executed by the physics engine
  88979. */
  88980. afterStep: () => void;
  88981. /**
  88982. * Legacy collision detection event support
  88983. */
  88984. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  88985. /**
  88986. * event and body object due to cannon's event-based architecture.
  88987. */
  88988. onCollide: (e: {
  88989. body: any;
  88990. }) => void;
  88991. /**
  88992. * Apply a force
  88993. * @param force The force to apply
  88994. * @param contactPoint The contact point for the force
  88995. * @returns The physics imposter
  88996. */
  88997. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88998. /**
  88999. * Apply an impulse
  89000. * @param force The impulse force
  89001. * @param contactPoint The contact point for the impulse force
  89002. * @returns The physics imposter
  89003. */
  89004. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89005. /**
  89006. * A help function to create a joint
  89007. * @param otherImpostor A physics imposter used to create a joint
  89008. * @param jointType The type of joint
  89009. * @param jointData The data for the joint
  89010. * @returns The physics imposter
  89011. */
  89012. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  89013. /**
  89014. * Add a joint to this impostor with a different impostor
  89015. * @param otherImpostor A physics imposter used to add a joint
  89016. * @param joint The joint to add
  89017. * @returns The physics imposter
  89018. */
  89019. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  89020. /**
  89021. * Add an anchor to a cloth impostor
  89022. * @param otherImpostor rigid impostor to anchor to
  89023. * @param width ratio across width from 0 to 1
  89024. * @param height ratio up height from 0 to 1
  89025. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  89026. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  89027. * @returns impostor the soft imposter
  89028. */
  89029. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89030. /**
  89031. * Add a hook to a rope impostor
  89032. * @param otherImpostor rigid impostor to anchor to
  89033. * @param length ratio across rope from 0 to 1
  89034. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  89035. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  89036. * @returns impostor the rope imposter
  89037. */
  89038. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89039. /**
  89040. * Will keep this body still, in a sleep mode.
  89041. * @returns the physics imposter
  89042. */
  89043. sleep(): PhysicsImpostor;
  89044. /**
  89045. * Wake the body up.
  89046. * @returns The physics imposter
  89047. */
  89048. wakeUp(): PhysicsImpostor;
  89049. /**
  89050. * Clones the physics imposter
  89051. * @param newObject The physics imposter clones to this physics-enabled object
  89052. * @returns A nullable physics imposter
  89053. */
  89054. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89055. /**
  89056. * Disposes the physics imposter
  89057. */
  89058. dispose(): void;
  89059. /**
  89060. * Sets the delta position
  89061. * @param position The delta position amount
  89062. */
  89063. setDeltaPosition(position: Vector3): void;
  89064. /**
  89065. * Sets the delta rotation
  89066. * @param rotation The delta rotation amount
  89067. */
  89068. setDeltaRotation(rotation: Quaternion): void;
  89069. /**
  89070. * Gets the box size of the physics imposter and stores the result in the input parameter
  89071. * @param result Stores the box size
  89072. * @returns The physics imposter
  89073. */
  89074. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  89075. /**
  89076. * Gets the radius of the physics imposter
  89077. * @returns Radius of the physics imposter
  89078. */
  89079. getRadius(): number;
  89080. /**
  89081. * Sync a bone with this impostor
  89082. * @param bone The bone to sync to the impostor.
  89083. * @param boneMesh The mesh that the bone is influencing.
  89084. * @param jointPivot The pivot of the joint / bone in local space.
  89085. * @param distToJoint Optional distance from the impostor to the joint.
  89086. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89087. */
  89088. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  89089. /**
  89090. * Sync impostor to a bone
  89091. * @param bone The bone that the impostor will be synced to.
  89092. * @param boneMesh The mesh that the bone is influencing.
  89093. * @param jointPivot The pivot of the joint / bone in local space.
  89094. * @param distToJoint Optional distance from the impostor to the joint.
  89095. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89096. * @param boneAxis Optional vector3 axis the bone is aligned with
  89097. */
  89098. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  89099. /**
  89100. * No-Imposter type
  89101. */
  89102. static NoImpostor: number;
  89103. /**
  89104. * Sphere-Imposter type
  89105. */
  89106. static SphereImpostor: number;
  89107. /**
  89108. * Box-Imposter type
  89109. */
  89110. static BoxImpostor: number;
  89111. /**
  89112. * Plane-Imposter type
  89113. */
  89114. static PlaneImpostor: number;
  89115. /**
  89116. * Mesh-imposter type
  89117. */
  89118. static MeshImpostor: number;
  89119. /**
  89120. * Capsule-Impostor type (Ammo.js plugin only)
  89121. */
  89122. static CapsuleImpostor: number;
  89123. /**
  89124. * Cylinder-Imposter type
  89125. */
  89126. static CylinderImpostor: number;
  89127. /**
  89128. * Particle-Imposter type
  89129. */
  89130. static ParticleImpostor: number;
  89131. /**
  89132. * Heightmap-Imposter type
  89133. */
  89134. static HeightmapImpostor: number;
  89135. /**
  89136. * ConvexHull-Impostor type (Ammo.js plugin only)
  89137. */
  89138. static ConvexHullImpostor: number;
  89139. /**
  89140. * Rope-Imposter type
  89141. */
  89142. static RopeImpostor: number;
  89143. /**
  89144. * Cloth-Imposter type
  89145. */
  89146. static ClothImpostor: number;
  89147. /**
  89148. * Softbody-Imposter type
  89149. */
  89150. static SoftbodyImpostor: number;
  89151. }
  89152. }
  89153. declare module BABYLON {
  89154. /**
  89155. * @hidden
  89156. **/
  89157. export class _CreationDataStorage {
  89158. closePath?: boolean;
  89159. closeArray?: boolean;
  89160. idx: number[];
  89161. dashSize: number;
  89162. gapSize: number;
  89163. path3D: Path3D;
  89164. pathArray: Vector3[][];
  89165. arc: number;
  89166. radius: number;
  89167. cap: number;
  89168. tessellation: number;
  89169. }
  89170. /**
  89171. * @hidden
  89172. **/
  89173. class _InstanceDataStorage {
  89174. visibleInstances: any;
  89175. batchCache: _InstancesBatch;
  89176. instancesBufferSize: number;
  89177. instancesBuffer: Nullable<Buffer>;
  89178. instancesData: Float32Array;
  89179. overridenInstanceCount: number;
  89180. isFrozen: boolean;
  89181. previousBatch: Nullable<_InstancesBatch>;
  89182. hardwareInstancedRendering: boolean;
  89183. sideOrientation: number;
  89184. }
  89185. /**
  89186. * @hidden
  89187. **/
  89188. export class _InstancesBatch {
  89189. mustReturn: boolean;
  89190. visibleInstances: Nullable<InstancedMesh[]>[];
  89191. renderSelf: boolean[];
  89192. hardwareInstancedRendering: boolean[];
  89193. }
  89194. /**
  89195. * Class used to represent renderable models
  89196. */
  89197. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  89198. /**
  89199. * Mesh side orientation : usually the external or front surface
  89200. */
  89201. static readonly FRONTSIDE: number;
  89202. /**
  89203. * Mesh side orientation : usually the internal or back surface
  89204. */
  89205. static readonly BACKSIDE: number;
  89206. /**
  89207. * Mesh side orientation : both internal and external or front and back surfaces
  89208. */
  89209. static readonly DOUBLESIDE: number;
  89210. /**
  89211. * Mesh side orientation : by default, `FRONTSIDE`
  89212. */
  89213. static readonly DEFAULTSIDE: number;
  89214. /**
  89215. * Mesh cap setting : no cap
  89216. */
  89217. static readonly NO_CAP: number;
  89218. /**
  89219. * Mesh cap setting : one cap at the beginning of the mesh
  89220. */
  89221. static readonly CAP_START: number;
  89222. /**
  89223. * Mesh cap setting : one cap at the end of the mesh
  89224. */
  89225. static readonly CAP_END: number;
  89226. /**
  89227. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  89228. */
  89229. static readonly CAP_ALL: number;
  89230. /**
  89231. * Mesh pattern setting : no flip or rotate
  89232. */
  89233. static readonly NO_FLIP: number;
  89234. /**
  89235. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  89236. */
  89237. static readonly FLIP_TILE: number;
  89238. /**
  89239. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  89240. */
  89241. static readonly ROTATE_TILE: number;
  89242. /**
  89243. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  89244. */
  89245. static readonly FLIP_ROW: number;
  89246. /**
  89247. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  89248. */
  89249. static readonly ROTATE_ROW: number;
  89250. /**
  89251. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  89252. */
  89253. static readonly FLIP_N_ROTATE_TILE: number;
  89254. /**
  89255. * Mesh pattern setting : rotate pattern and rotate
  89256. */
  89257. static readonly FLIP_N_ROTATE_ROW: number;
  89258. /**
  89259. * Mesh tile positioning : part tiles same on left/right or top/bottom
  89260. */
  89261. static readonly CENTER: number;
  89262. /**
  89263. * Mesh tile positioning : part tiles on left
  89264. */
  89265. static readonly LEFT: number;
  89266. /**
  89267. * Mesh tile positioning : part tiles on right
  89268. */
  89269. static readonly RIGHT: number;
  89270. /**
  89271. * Mesh tile positioning : part tiles on top
  89272. */
  89273. static readonly TOP: number;
  89274. /**
  89275. * Mesh tile positioning : part tiles on bottom
  89276. */
  89277. static readonly BOTTOM: number;
  89278. /**
  89279. * Gets the default side orientation.
  89280. * @param orientation the orientation to value to attempt to get
  89281. * @returns the default orientation
  89282. * @hidden
  89283. */
  89284. static _GetDefaultSideOrientation(orientation?: number): number;
  89285. private _internalMeshDataInfo;
  89286. /**
  89287. * An event triggered before rendering the mesh
  89288. */
  89289. readonly onBeforeRenderObservable: Observable<Mesh>;
  89290. /**
  89291. * An event triggered before binding the mesh
  89292. */
  89293. readonly onBeforeBindObservable: Observable<Mesh>;
  89294. /**
  89295. * An event triggered after rendering the mesh
  89296. */
  89297. readonly onAfterRenderObservable: Observable<Mesh>;
  89298. /**
  89299. * An event triggered before drawing the mesh
  89300. */
  89301. readonly onBeforeDrawObservable: Observable<Mesh>;
  89302. private _onBeforeDrawObserver;
  89303. /**
  89304. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  89305. */
  89306. onBeforeDraw: () => void;
  89307. readonly hasInstances: boolean;
  89308. /**
  89309. * Gets the delay loading state of the mesh (when delay loading is turned on)
  89310. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  89311. */
  89312. delayLoadState: number;
  89313. /**
  89314. * Gets the list of instances created from this mesh
  89315. * it is not supposed to be modified manually.
  89316. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  89317. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89318. */
  89319. instances: InstancedMesh[];
  89320. /**
  89321. * Gets the file containing delay loading data for this mesh
  89322. */
  89323. delayLoadingFile: string;
  89324. /** @hidden */
  89325. _binaryInfo: any;
  89326. /**
  89327. * User defined function used to change how LOD level selection is done
  89328. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89329. */
  89330. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  89331. /**
  89332. * Gets or sets the morph target manager
  89333. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89334. */
  89335. morphTargetManager: Nullable<MorphTargetManager>;
  89336. /** @hidden */
  89337. _creationDataStorage: Nullable<_CreationDataStorage>;
  89338. /** @hidden */
  89339. _geometry: Nullable<Geometry>;
  89340. /** @hidden */
  89341. _delayInfo: Array<string>;
  89342. /** @hidden */
  89343. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  89344. /** @hidden */
  89345. _instanceDataStorage: _InstanceDataStorage;
  89346. private _effectiveMaterial;
  89347. /** @hidden */
  89348. _shouldGenerateFlatShading: boolean;
  89349. /** @hidden */
  89350. _originalBuilderSideOrientation: number;
  89351. /**
  89352. * Use this property to change the original side orientation defined at construction time
  89353. */
  89354. overrideMaterialSideOrientation: Nullable<number>;
  89355. /**
  89356. * Gets the source mesh (the one used to clone this one from)
  89357. */
  89358. readonly source: Nullable<Mesh>;
  89359. /**
  89360. * Gets or sets a boolean indicating that this mesh does not use index buffer
  89361. */
  89362. isUnIndexed: boolean;
  89363. /**
  89364. * @constructor
  89365. * @param name The value used by scene.getMeshByName() to do a lookup.
  89366. * @param scene The scene to add this mesh to.
  89367. * @param parent The parent of this mesh, if it has one
  89368. * @param source An optional Mesh from which geometry is shared, cloned.
  89369. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89370. * When false, achieved by calling a clone(), also passing False.
  89371. * This will make creation of children, recursive.
  89372. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  89373. */
  89374. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  89375. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  89376. /**
  89377. * Gets the class name
  89378. * @returns the string "Mesh".
  89379. */
  89380. getClassName(): string;
  89381. /** @hidden */
  89382. readonly _isMesh: boolean;
  89383. /**
  89384. * Returns a description of this mesh
  89385. * @param fullDetails define if full details about this mesh must be used
  89386. * @returns a descriptive string representing this mesh
  89387. */
  89388. toString(fullDetails?: boolean): string;
  89389. /** @hidden */
  89390. _unBindEffect(): void;
  89391. /**
  89392. * Gets a boolean indicating if this mesh has LOD
  89393. */
  89394. readonly hasLODLevels: boolean;
  89395. /**
  89396. * Gets the list of MeshLODLevel associated with the current mesh
  89397. * @returns an array of MeshLODLevel
  89398. */
  89399. getLODLevels(): MeshLODLevel[];
  89400. private _sortLODLevels;
  89401. /**
  89402. * Add a mesh as LOD level triggered at the given distance.
  89403. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89404. * @param distance The distance from the center of the object to show this level
  89405. * @param mesh The mesh to be added as LOD level (can be null)
  89406. * @return This mesh (for chaining)
  89407. */
  89408. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  89409. /**
  89410. * Returns the LOD level mesh at the passed distance or null if not found.
  89411. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89412. * @param distance The distance from the center of the object to show this level
  89413. * @returns a Mesh or `null`
  89414. */
  89415. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  89416. /**
  89417. * Remove a mesh from the LOD array
  89418. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89419. * @param mesh defines the mesh to be removed
  89420. * @return This mesh (for chaining)
  89421. */
  89422. removeLODLevel(mesh: Mesh): Mesh;
  89423. /**
  89424. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  89425. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89426. * @param camera defines the camera to use to compute distance
  89427. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  89428. * @return This mesh (for chaining)
  89429. */
  89430. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  89431. /**
  89432. * Gets the mesh internal Geometry object
  89433. */
  89434. readonly geometry: Nullable<Geometry>;
  89435. /**
  89436. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  89437. * @returns the total number of vertices
  89438. */
  89439. getTotalVertices(): number;
  89440. /**
  89441. * Returns the content of an associated vertex buffer
  89442. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89443. * - VertexBuffer.PositionKind
  89444. * - VertexBuffer.UVKind
  89445. * - VertexBuffer.UV2Kind
  89446. * - VertexBuffer.UV3Kind
  89447. * - VertexBuffer.UV4Kind
  89448. * - VertexBuffer.UV5Kind
  89449. * - VertexBuffer.UV6Kind
  89450. * - VertexBuffer.ColorKind
  89451. * - VertexBuffer.MatricesIndicesKind
  89452. * - VertexBuffer.MatricesIndicesExtraKind
  89453. * - VertexBuffer.MatricesWeightsKind
  89454. * - VertexBuffer.MatricesWeightsExtraKind
  89455. * @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
  89456. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  89457. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  89458. */
  89459. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89460. /**
  89461. * Returns the mesh VertexBuffer object from the requested `kind`
  89462. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89463. * - VertexBuffer.PositionKind
  89464. * - VertexBuffer.NormalKind
  89465. * - VertexBuffer.UVKind
  89466. * - VertexBuffer.UV2Kind
  89467. * - VertexBuffer.UV3Kind
  89468. * - VertexBuffer.UV4Kind
  89469. * - VertexBuffer.UV5Kind
  89470. * - VertexBuffer.UV6Kind
  89471. * - VertexBuffer.ColorKind
  89472. * - VertexBuffer.MatricesIndicesKind
  89473. * - VertexBuffer.MatricesIndicesExtraKind
  89474. * - VertexBuffer.MatricesWeightsKind
  89475. * - VertexBuffer.MatricesWeightsExtraKind
  89476. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  89477. */
  89478. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89479. /**
  89480. * Tests if a specific vertex buffer is associated with this mesh
  89481. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89482. * - VertexBuffer.PositionKind
  89483. * - VertexBuffer.NormalKind
  89484. * - VertexBuffer.UVKind
  89485. * - VertexBuffer.UV2Kind
  89486. * - VertexBuffer.UV3Kind
  89487. * - VertexBuffer.UV4Kind
  89488. * - VertexBuffer.UV5Kind
  89489. * - VertexBuffer.UV6Kind
  89490. * - VertexBuffer.ColorKind
  89491. * - VertexBuffer.MatricesIndicesKind
  89492. * - VertexBuffer.MatricesIndicesExtraKind
  89493. * - VertexBuffer.MatricesWeightsKind
  89494. * - VertexBuffer.MatricesWeightsExtraKind
  89495. * @returns a boolean
  89496. */
  89497. isVerticesDataPresent(kind: string): boolean;
  89498. /**
  89499. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  89500. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89501. * - VertexBuffer.PositionKind
  89502. * - VertexBuffer.UVKind
  89503. * - VertexBuffer.UV2Kind
  89504. * - VertexBuffer.UV3Kind
  89505. * - VertexBuffer.UV4Kind
  89506. * - VertexBuffer.UV5Kind
  89507. * - VertexBuffer.UV6Kind
  89508. * - VertexBuffer.ColorKind
  89509. * - VertexBuffer.MatricesIndicesKind
  89510. * - VertexBuffer.MatricesIndicesExtraKind
  89511. * - VertexBuffer.MatricesWeightsKind
  89512. * - VertexBuffer.MatricesWeightsExtraKind
  89513. * @returns a boolean
  89514. */
  89515. isVertexBufferUpdatable(kind: string): boolean;
  89516. /**
  89517. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  89518. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89519. * - VertexBuffer.PositionKind
  89520. * - VertexBuffer.NormalKind
  89521. * - VertexBuffer.UVKind
  89522. * - VertexBuffer.UV2Kind
  89523. * - VertexBuffer.UV3Kind
  89524. * - VertexBuffer.UV4Kind
  89525. * - VertexBuffer.UV5Kind
  89526. * - VertexBuffer.UV6Kind
  89527. * - VertexBuffer.ColorKind
  89528. * - VertexBuffer.MatricesIndicesKind
  89529. * - VertexBuffer.MatricesIndicesExtraKind
  89530. * - VertexBuffer.MatricesWeightsKind
  89531. * - VertexBuffer.MatricesWeightsExtraKind
  89532. * @returns an array of strings
  89533. */
  89534. getVerticesDataKinds(): string[];
  89535. /**
  89536. * Returns a positive integer : the total number of indices in this mesh geometry.
  89537. * @returns the numner of indices or zero if the mesh has no geometry.
  89538. */
  89539. getTotalIndices(): number;
  89540. /**
  89541. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89542. * @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.
  89543. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89544. * @returns the indices array or an empty array if the mesh has no geometry
  89545. */
  89546. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89547. readonly isBlocked: boolean;
  89548. /**
  89549. * Determine if the current mesh is ready to be rendered
  89550. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89551. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  89552. * @returns true if all associated assets are ready (material, textures, shaders)
  89553. */
  89554. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  89555. /**
  89556. * 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.
  89557. */
  89558. readonly areNormalsFrozen: boolean;
  89559. /**
  89560. * 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.
  89561. * @returns the current mesh
  89562. */
  89563. freezeNormals(): Mesh;
  89564. /**
  89565. * 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
  89566. * @returns the current mesh
  89567. */
  89568. unfreezeNormals(): Mesh;
  89569. /**
  89570. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  89571. */
  89572. overridenInstanceCount: number;
  89573. /** @hidden */
  89574. _preActivate(): Mesh;
  89575. /** @hidden */
  89576. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89577. /** @hidden */
  89578. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  89579. /**
  89580. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89581. * This means the mesh underlying bounding box and sphere are recomputed.
  89582. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89583. * @returns the current mesh
  89584. */
  89585. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  89586. /** @hidden */
  89587. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  89588. /**
  89589. * This function will subdivide the mesh into multiple submeshes
  89590. * @param count defines the expected number of submeshes
  89591. */
  89592. subdivide(count: number): void;
  89593. /**
  89594. * Copy a FloatArray into a specific associated vertex buffer
  89595. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89596. * - VertexBuffer.PositionKind
  89597. * - VertexBuffer.UVKind
  89598. * - VertexBuffer.UV2Kind
  89599. * - VertexBuffer.UV3Kind
  89600. * - VertexBuffer.UV4Kind
  89601. * - VertexBuffer.UV5Kind
  89602. * - VertexBuffer.UV6Kind
  89603. * - VertexBuffer.ColorKind
  89604. * - VertexBuffer.MatricesIndicesKind
  89605. * - VertexBuffer.MatricesIndicesExtraKind
  89606. * - VertexBuffer.MatricesWeightsKind
  89607. * - VertexBuffer.MatricesWeightsExtraKind
  89608. * @param data defines the data source
  89609. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89610. * @param stride defines the data stride size (can be null)
  89611. * @returns the current mesh
  89612. */
  89613. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89614. /**
  89615. * Flags an associated vertex buffer as updatable
  89616. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  89617. * - VertexBuffer.PositionKind
  89618. * - VertexBuffer.UVKind
  89619. * - VertexBuffer.UV2Kind
  89620. * - VertexBuffer.UV3Kind
  89621. * - VertexBuffer.UV4Kind
  89622. * - VertexBuffer.UV5Kind
  89623. * - VertexBuffer.UV6Kind
  89624. * - VertexBuffer.ColorKind
  89625. * - VertexBuffer.MatricesIndicesKind
  89626. * - VertexBuffer.MatricesIndicesExtraKind
  89627. * - VertexBuffer.MatricesWeightsKind
  89628. * - VertexBuffer.MatricesWeightsExtraKind
  89629. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89630. */
  89631. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  89632. /**
  89633. * Sets the mesh global Vertex Buffer
  89634. * @param buffer defines the buffer to use
  89635. * @returns the current mesh
  89636. */
  89637. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  89638. /**
  89639. * Update a specific associated vertex buffer
  89640. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89641. * - VertexBuffer.PositionKind
  89642. * - VertexBuffer.UVKind
  89643. * - VertexBuffer.UV2Kind
  89644. * - VertexBuffer.UV3Kind
  89645. * - VertexBuffer.UV4Kind
  89646. * - VertexBuffer.UV5Kind
  89647. * - VertexBuffer.UV6Kind
  89648. * - VertexBuffer.ColorKind
  89649. * - VertexBuffer.MatricesIndicesKind
  89650. * - VertexBuffer.MatricesIndicesExtraKind
  89651. * - VertexBuffer.MatricesWeightsKind
  89652. * - VertexBuffer.MatricesWeightsExtraKind
  89653. * @param data defines the data source
  89654. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89655. * @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)
  89656. * @returns the current mesh
  89657. */
  89658. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89659. /**
  89660. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  89661. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  89662. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  89663. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  89664. * @returns the current mesh
  89665. */
  89666. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  89667. /**
  89668. * Creates a un-shared specific occurence of the geometry for the mesh.
  89669. * @returns the current mesh
  89670. */
  89671. makeGeometryUnique(): Mesh;
  89672. /**
  89673. * Set the index buffer of this mesh
  89674. * @param indices defines the source data
  89675. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  89676. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  89677. * @returns the current mesh
  89678. */
  89679. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  89680. /**
  89681. * Update the current index buffer
  89682. * @param indices defines the source data
  89683. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89684. * @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)
  89685. * @returns the current mesh
  89686. */
  89687. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89688. /**
  89689. * Invert the geometry to move from a right handed system to a left handed one.
  89690. * @returns the current mesh
  89691. */
  89692. toLeftHanded(): Mesh;
  89693. /** @hidden */
  89694. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89695. /** @hidden */
  89696. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89697. /**
  89698. * Registers for this mesh a javascript function called just before the rendering process
  89699. * @param func defines the function to call before rendering this mesh
  89700. * @returns the current mesh
  89701. */
  89702. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89703. /**
  89704. * Disposes a previously registered javascript function called before the rendering
  89705. * @param func defines the function to remove
  89706. * @returns the current mesh
  89707. */
  89708. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89709. /**
  89710. * Registers for this mesh a javascript function called just after the rendering is complete
  89711. * @param func defines the function to call after rendering this mesh
  89712. * @returns the current mesh
  89713. */
  89714. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89715. /**
  89716. * Disposes a previously registered javascript function called after the rendering.
  89717. * @param func defines the function to remove
  89718. * @returns the current mesh
  89719. */
  89720. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89721. /** @hidden */
  89722. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  89723. /** @hidden */
  89724. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  89725. /** @hidden */
  89726. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  89727. /** @hidden */
  89728. _rebuild(): void;
  89729. /** @hidden */
  89730. _freeze(): void;
  89731. /** @hidden */
  89732. _unFreeze(): void;
  89733. /**
  89734. * 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
  89735. * @param subMesh defines the subMesh to render
  89736. * @param enableAlphaMode defines if alpha mode can be changed
  89737. * @returns the current mesh
  89738. */
  89739. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  89740. private _onBeforeDraw;
  89741. /**
  89742. * Renormalize the mesh and patch it up if there are no weights
  89743. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  89744. * However in the case of zero weights then we set just a single influence to 1.
  89745. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  89746. */
  89747. cleanMatrixWeights(): void;
  89748. private normalizeSkinFourWeights;
  89749. private normalizeSkinWeightsAndExtra;
  89750. /**
  89751. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  89752. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  89753. * the user know there was an issue with importing the mesh
  89754. * @returns a validation object with skinned, valid and report string
  89755. */
  89756. validateSkinning(): {
  89757. skinned: boolean;
  89758. valid: boolean;
  89759. report: string;
  89760. };
  89761. /** @hidden */
  89762. _checkDelayState(): Mesh;
  89763. private _queueLoad;
  89764. /**
  89765. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89766. * A mesh is in the frustum if its bounding box intersects the frustum
  89767. * @param frustumPlanes defines the frustum to test
  89768. * @returns true if the mesh is in the frustum planes
  89769. */
  89770. isInFrustum(frustumPlanes: Plane[]): boolean;
  89771. /**
  89772. * Sets the mesh material by the material or multiMaterial `id` property
  89773. * @param id is a string identifying the material or the multiMaterial
  89774. * @returns the current mesh
  89775. */
  89776. setMaterialByID(id: string): Mesh;
  89777. /**
  89778. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  89779. * @returns an array of IAnimatable
  89780. */
  89781. getAnimatables(): IAnimatable[];
  89782. /**
  89783. * Modifies the mesh geometry according to the passed transformation matrix.
  89784. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  89785. * The mesh normals are modified using the same transformation.
  89786. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89787. * @param transform defines the transform matrix to use
  89788. * @see http://doc.babylonjs.com/resources/baking_transformations
  89789. * @returns the current mesh
  89790. */
  89791. bakeTransformIntoVertices(transform: Matrix): Mesh;
  89792. /**
  89793. * Modifies the mesh geometry according to its own current World Matrix.
  89794. * The mesh World Matrix is then reset.
  89795. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  89796. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89797. * @see http://doc.babylonjs.com/resources/baking_transformations
  89798. * @returns the current mesh
  89799. */
  89800. bakeCurrentTransformIntoVertices(): Mesh;
  89801. /** @hidden */
  89802. readonly _positions: Nullable<Vector3[]>;
  89803. /** @hidden */
  89804. _resetPointsArrayCache(): Mesh;
  89805. /** @hidden */
  89806. _generatePointsArray(): boolean;
  89807. /**
  89808. * Returns a new Mesh object generated from the current mesh properties.
  89809. * This method must not get confused with createInstance()
  89810. * @param name is a string, the name given to the new mesh
  89811. * @param newParent can be any Node object (default `null`)
  89812. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  89813. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  89814. * @returns a new mesh
  89815. */
  89816. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  89817. /**
  89818. * Releases resources associated with this mesh.
  89819. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89820. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89821. */
  89822. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89823. /**
  89824. * Modifies the mesh geometry according to a displacement map.
  89825. * 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.
  89826. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89827. * @param url is a string, the URL from the image file is to be downloaded.
  89828. * @param minHeight is the lower limit of the displacement.
  89829. * @param maxHeight is the upper limit of the displacement.
  89830. * @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.
  89831. * @param uvOffset is an optional vector2 used to offset UV.
  89832. * @param uvScale is an optional vector2 used to scale UV.
  89833. * @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.
  89834. * @returns the Mesh.
  89835. */
  89836. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89837. /**
  89838. * Modifies the mesh geometry according to a displacementMap buffer.
  89839. * 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.
  89840. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89841. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89842. * @param heightMapWidth is the width of the buffer image.
  89843. * @param heightMapHeight is the height of the buffer image.
  89844. * @param minHeight is the lower limit of the displacement.
  89845. * @param maxHeight is the upper limit of the displacement.
  89846. * @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.
  89847. * @param uvOffset is an optional vector2 used to offset UV.
  89848. * @param uvScale is an optional vector2 used to scale UV.
  89849. * @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.
  89850. * @returns the Mesh.
  89851. */
  89852. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89853. /**
  89854. * Modify the mesh to get a flat shading rendering.
  89855. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89856. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89857. * @returns current mesh
  89858. */
  89859. convertToFlatShadedMesh(): Mesh;
  89860. /**
  89861. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89862. * In other words, more vertices, no more indices and a single bigger VBO.
  89863. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  89864. * @returns current mesh
  89865. */
  89866. convertToUnIndexedMesh(): Mesh;
  89867. /**
  89868. * Inverses facet orientations.
  89869. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89870. * @param flipNormals will also inverts the normals
  89871. * @returns current mesh
  89872. */
  89873. flipFaces(flipNormals?: boolean): Mesh;
  89874. /**
  89875. * Increase the number of facets and hence vertices in a mesh
  89876. * Vertex normals are interpolated from existing vertex normals
  89877. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89878. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  89879. */
  89880. increaseVertices(numberPerEdge: number): void;
  89881. /**
  89882. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  89883. * This will undo any application of covertToFlatShadedMesh
  89884. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89885. */
  89886. forceSharedVertices(): void;
  89887. /** @hidden */
  89888. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  89889. /** @hidden */
  89890. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  89891. /**
  89892. * Creates a new InstancedMesh object from the mesh model.
  89893. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89894. * @param name defines the name of the new instance
  89895. * @returns a new InstancedMesh
  89896. */
  89897. createInstance(name: string): InstancedMesh;
  89898. /**
  89899. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  89900. * After this call, all the mesh instances have the same submeshes than the current mesh.
  89901. * @returns the current mesh
  89902. */
  89903. synchronizeInstances(): Mesh;
  89904. /**
  89905. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  89906. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  89907. * This should be used together with the simplification to avoid disappearing triangles.
  89908. * @param successCallback an optional success callback to be called after the optimization finished.
  89909. * @returns the current mesh
  89910. */
  89911. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  89912. /**
  89913. * Serialize current mesh
  89914. * @param serializationObject defines the object which will receive the serialization data
  89915. */
  89916. serialize(serializationObject: any): void;
  89917. /** @hidden */
  89918. _syncGeometryWithMorphTargetManager(): void;
  89919. /** @hidden */
  89920. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  89921. /**
  89922. * Returns a new Mesh object parsed from the source provided.
  89923. * @param parsedMesh is the source
  89924. * @param scene defines the hosting scene
  89925. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  89926. * @returns a new Mesh
  89927. */
  89928. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  89929. /**
  89930. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  89931. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89932. * @param name defines the name of the mesh to create
  89933. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  89934. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  89935. * @param closePath creates a seam between the first and the last points of each path of the path array
  89936. * @param offset is taken in account only if the `pathArray` is containing a single path
  89937. * @param scene defines the hosting scene
  89938. * @param updatable defines if the mesh must be flagged as updatable
  89939. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89940. * @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)
  89941. * @returns a new Mesh
  89942. */
  89943. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89944. /**
  89945. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  89946. * @param name defines the name of the mesh to create
  89947. * @param radius sets the radius size (float) of the polygon (default 0.5)
  89948. * @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
  89949. * @param scene defines the hosting scene
  89950. * @param updatable defines if the mesh must be flagged as updatable
  89951. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89952. * @returns a new Mesh
  89953. */
  89954. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89955. /**
  89956. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  89957. * @param name defines the name of the mesh to create
  89958. * @param size sets the size (float) of each box side (default 1)
  89959. * @param scene defines the hosting scene
  89960. * @param updatable defines if the mesh must be flagged as updatable
  89961. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89962. * @returns a new Mesh
  89963. */
  89964. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89965. /**
  89966. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  89967. * @param name defines the name of the mesh to create
  89968. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89969. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89970. * @param scene defines the hosting scene
  89971. * @param updatable defines if the mesh must be flagged as updatable
  89972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89973. * @returns a new Mesh
  89974. */
  89975. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89976. /**
  89977. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  89978. * @param name defines the name of the mesh to create
  89979. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89980. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89981. * @param scene defines the hosting scene
  89982. * @returns a new Mesh
  89983. */
  89984. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  89985. /**
  89986. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  89987. * @param name defines the name of the mesh to create
  89988. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  89989. * @param diameterTop set the top cap diameter (floats, default 1)
  89990. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  89991. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  89992. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  89993. * @param scene defines the hosting scene
  89994. * @param updatable defines if the mesh must be flagged as updatable
  89995. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89996. * @returns a new Mesh
  89997. */
  89998. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  89999. /**
  90000. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  90001. * @param name defines the name of the mesh to create
  90002. * @param diameter sets the diameter size (float) of the torus (default 1)
  90003. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  90004. * @param tessellation sets the number of torus sides (postive integer, default 16)
  90005. * @param scene defines the hosting scene
  90006. * @param updatable defines if the mesh must be flagged as updatable
  90007. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90008. * @returns a new Mesh
  90009. */
  90010. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90011. /**
  90012. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  90013. * @param name defines the name of the mesh to create
  90014. * @param radius sets the global radius size (float) of the torus knot (default 2)
  90015. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  90016. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  90017. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  90018. * @param p the number of windings on X axis (positive integers, default 2)
  90019. * @param q the number of windings on Y axis (positive integers, default 3)
  90020. * @param scene defines the hosting scene
  90021. * @param updatable defines if the mesh must be flagged as updatable
  90022. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90023. * @returns a new Mesh
  90024. */
  90025. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90026. /**
  90027. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  90028. * @param name defines the name of the mesh to create
  90029. * @param points is an array successive Vector3
  90030. * @param scene defines the hosting scene
  90031. * @param updatable defines if the mesh must be flagged as updatable
  90032. * @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).
  90033. * @returns a new Mesh
  90034. */
  90035. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  90036. /**
  90037. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  90038. * @param name defines the name of the mesh to create
  90039. * @param points is an array successive Vector3
  90040. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  90041. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90042. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  90043. * @param scene defines the hosting scene
  90044. * @param updatable defines if the mesh must be flagged as updatable
  90045. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  90046. * @returns a new Mesh
  90047. */
  90048. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  90049. /**
  90050. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  90051. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  90052. * 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.
  90053. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90054. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90055. * Remember you can only change the shape positions, not their number when updating a polygon.
  90056. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  90057. * @param name defines the name of the mesh to create
  90058. * @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
  90059. * @param scene defines the hosting scene
  90060. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90061. * @param updatable defines if the mesh must be flagged as updatable
  90062. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90063. * @param earcutInjection can be used to inject your own earcut reference
  90064. * @returns a new Mesh
  90065. */
  90066. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90067. /**
  90068. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  90069. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  90070. * @param name defines the name of the mesh to create
  90071. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  90072. * @param depth defines the height of extrusion
  90073. * @param scene defines the hosting scene
  90074. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90075. * @param updatable defines if the mesh must be flagged as updatable
  90076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90077. * @param earcutInjection can be used to inject your own earcut reference
  90078. * @returns a new Mesh
  90079. */
  90080. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90081. /**
  90082. * Creates an extruded shape mesh.
  90083. * 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
  90084. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90085. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90086. * @param name defines the name of the mesh to create
  90087. * @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
  90088. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90089. * @param scale is the value to scale the shape
  90090. * @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
  90091. * @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
  90092. * @param scene defines the hosting scene
  90093. * @param updatable defines if the mesh must be flagged as updatable
  90094. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90095. * @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)
  90096. * @returns a new Mesh
  90097. */
  90098. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90099. /**
  90100. * Creates an custom extruded shape mesh.
  90101. * The custom extrusion is a parametric shape.
  90102. * It has no predefined shape. Its final shape will depend on the input parameters.
  90103. * Please consider using the same method from the MeshBuilder class instead
  90104. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90105. * @param name defines the name of the mesh to create
  90106. * @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
  90107. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90108. * @param scaleFunction is a custom Javascript function called on each path point
  90109. * @param rotationFunction is a custom Javascript function called on each path point
  90110. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90111. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90112. * @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
  90113. * @param scene defines the hosting scene
  90114. * @param updatable defines if the mesh must be flagged as updatable
  90115. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90116. * @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)
  90117. * @returns a new Mesh
  90118. */
  90119. 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;
  90120. /**
  90121. * Creates lathe mesh.
  90122. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90123. * Please consider using the same method from the MeshBuilder class instead
  90124. * @param name defines the name of the mesh to create
  90125. * @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
  90126. * @param radius is the radius value of the lathe
  90127. * @param tessellation is the side number of the lathe.
  90128. * @param scene defines the hosting scene
  90129. * @param updatable defines if the mesh must be flagged as updatable
  90130. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90131. * @returns a new Mesh
  90132. */
  90133. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90134. /**
  90135. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90136. * @param name defines the name of the mesh to create
  90137. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90138. * @param scene defines the hosting scene
  90139. * @param updatable defines if the mesh must be flagged as updatable
  90140. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90141. * @returns a new Mesh
  90142. */
  90143. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90144. /**
  90145. * Creates a ground mesh.
  90146. * Please consider using the same method from the MeshBuilder class instead
  90147. * @param name defines the name of the mesh to create
  90148. * @param width set the width of the ground
  90149. * @param height set the height of the ground
  90150. * @param subdivisions sets the number of subdivisions per side
  90151. * @param scene defines the hosting scene
  90152. * @param updatable defines if the mesh must be flagged as updatable
  90153. * @returns a new Mesh
  90154. */
  90155. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  90156. /**
  90157. * Creates a tiled ground mesh.
  90158. * Please consider using the same method from the MeshBuilder class instead
  90159. * @param name defines the name of the mesh to create
  90160. * @param xmin set the ground minimum X coordinate
  90161. * @param zmin set the ground minimum Y coordinate
  90162. * @param xmax set the ground maximum X coordinate
  90163. * @param zmax set the ground maximum Z coordinate
  90164. * @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
  90165. * @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
  90166. * @param scene defines the hosting scene
  90167. * @param updatable defines if the mesh must be flagged as updatable
  90168. * @returns a new Mesh
  90169. */
  90170. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  90171. w: number;
  90172. h: number;
  90173. }, precision: {
  90174. w: number;
  90175. h: number;
  90176. }, scene: Scene, updatable?: boolean): Mesh;
  90177. /**
  90178. * Creates a ground mesh from a height map.
  90179. * Please consider using the same method from the MeshBuilder class instead
  90180. * @see http://doc.babylonjs.com/babylon101/height_map
  90181. * @param name defines the name of the mesh to create
  90182. * @param url sets the URL of the height map image resource
  90183. * @param width set the ground width size
  90184. * @param height set the ground height size
  90185. * @param subdivisions sets the number of subdivision per side
  90186. * @param minHeight is the minimum altitude on the ground
  90187. * @param maxHeight is the maximum altitude on the ground
  90188. * @param scene defines the hosting scene
  90189. * @param updatable defines if the mesh must be flagged as updatable
  90190. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90191. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90192. * @returns a new Mesh
  90193. */
  90194. 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;
  90195. /**
  90196. * Creates a tube mesh.
  90197. * The tube is a parametric shape.
  90198. * It has no predefined shape. Its final shape will depend on the input parameters.
  90199. * Please consider using the same method from the MeshBuilder class instead
  90200. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90201. * @param name defines the name of the mesh to create
  90202. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90203. * @param radius sets the tube radius size
  90204. * @param tessellation is the number of sides on the tubular surface
  90205. * @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
  90206. * @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
  90207. * @param scene defines the hosting scene
  90208. * @param updatable defines if the mesh must be flagged as updatable
  90209. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90210. * @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)
  90211. * @returns a new Mesh
  90212. */
  90213. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  90214. (i: number, distance: number): number;
  90215. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90216. /**
  90217. * Creates a polyhedron mesh.
  90218. * Please consider using the same method from the MeshBuilder class instead.
  90219. * * 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
  90220. * * The parameter `size` (positive float, default 1) sets the polygon size
  90221. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90222. * * 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`
  90223. * * 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
  90224. * * 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)`)
  90225. * * 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
  90226. * * 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
  90227. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90228. * * If you create a double-sided mesh, you can choose what parts of 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
  90229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90230. * @param name defines the name of the mesh to create
  90231. * @param options defines the options used to create the mesh
  90232. * @param scene defines the hosting scene
  90233. * @returns a new Mesh
  90234. */
  90235. static CreatePolyhedron(name: string, options: {
  90236. type?: number;
  90237. size?: number;
  90238. sizeX?: number;
  90239. sizeY?: number;
  90240. sizeZ?: number;
  90241. custom?: any;
  90242. faceUV?: Vector4[];
  90243. faceColors?: Color4[];
  90244. updatable?: boolean;
  90245. sideOrientation?: number;
  90246. }, scene: Scene): Mesh;
  90247. /**
  90248. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90249. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90250. * * 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`)
  90251. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90252. * * 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
  90253. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90254. * * If you create a double-sided mesh, you can choose what parts of 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
  90255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90256. * @param name defines the name of the mesh
  90257. * @param options defines the options used to create the mesh
  90258. * @param scene defines the hosting scene
  90259. * @returns a new Mesh
  90260. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90261. */
  90262. static CreateIcoSphere(name: string, options: {
  90263. radius?: number;
  90264. flat?: boolean;
  90265. subdivisions?: number;
  90266. sideOrientation?: number;
  90267. updatable?: boolean;
  90268. }, scene: Scene): Mesh;
  90269. /**
  90270. * Creates a decal mesh.
  90271. * Please consider using the same method from the MeshBuilder class instead.
  90272. * A decal is a mesh usually applied as a model onto the surface of another mesh
  90273. * @param name defines the name of the mesh
  90274. * @param sourceMesh defines the mesh receiving the decal
  90275. * @param position sets the position of the decal in world coordinates
  90276. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  90277. * @param size sets the decal scaling
  90278. * @param angle sets the angle to rotate the decal
  90279. * @returns a new Mesh
  90280. */
  90281. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  90282. /**
  90283. * Prepare internal position array for software CPU skinning
  90284. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  90285. */
  90286. setPositionsForCPUSkinning(): Float32Array;
  90287. /**
  90288. * Prepare internal normal array for software CPU skinning
  90289. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  90290. */
  90291. setNormalsForCPUSkinning(): Float32Array;
  90292. /**
  90293. * Updates the vertex buffer by applying transformation from the bones
  90294. * @param skeleton defines the skeleton to apply to current mesh
  90295. * @returns the current mesh
  90296. */
  90297. applySkeleton(skeleton: Skeleton): Mesh;
  90298. /**
  90299. * 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
  90300. * @param meshes defines the list of meshes to scan
  90301. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  90302. */
  90303. static MinMax(meshes: AbstractMesh[]): {
  90304. min: Vector3;
  90305. max: Vector3;
  90306. };
  90307. /**
  90308. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  90309. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  90310. * @returns a vector3
  90311. */
  90312. static Center(meshesOrMinMaxVector: {
  90313. min: Vector3;
  90314. max: Vector3;
  90315. } | AbstractMesh[]): Vector3;
  90316. /**
  90317. * Merge the array of meshes into a single mesh for performance reasons.
  90318. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  90319. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  90320. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  90321. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  90322. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  90323. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  90324. * @returns a new mesh
  90325. */
  90326. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  90327. /** @hidden */
  90328. addInstance(instance: InstancedMesh): void;
  90329. /** @hidden */
  90330. removeInstance(instance: InstancedMesh): void;
  90331. }
  90332. }
  90333. declare module BABYLON {
  90334. /**
  90335. * This is the base class of all the camera used in the application.
  90336. * @see http://doc.babylonjs.com/features/cameras
  90337. */
  90338. export class Camera extends Node {
  90339. /** @hidden */
  90340. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90341. /**
  90342. * This is the default projection mode used by the cameras.
  90343. * It helps recreating a feeling of perspective and better appreciate depth.
  90344. * This is the best way to simulate real life cameras.
  90345. */
  90346. static readonly PERSPECTIVE_CAMERA: number;
  90347. /**
  90348. * This helps creating camera with an orthographic mode.
  90349. * 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.
  90350. */
  90351. static readonly ORTHOGRAPHIC_CAMERA: number;
  90352. /**
  90353. * This is the default FOV mode for perspective cameras.
  90354. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90355. */
  90356. static readonly FOVMODE_VERTICAL_FIXED: number;
  90357. /**
  90358. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90359. */
  90360. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90361. /**
  90362. * This specifies ther is no need for a camera rig.
  90363. * Basically only one eye is rendered corresponding to the camera.
  90364. */
  90365. static readonly RIG_MODE_NONE: number;
  90366. /**
  90367. * Simulates a camera Rig with one blue eye and one red eye.
  90368. * This can be use with 3d blue and red glasses.
  90369. */
  90370. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90371. /**
  90372. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90373. */
  90374. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90375. /**
  90376. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90377. */
  90378. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90379. /**
  90380. * Defines that both eyes of the camera will be rendered over under each other.
  90381. */
  90382. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90383. /**
  90384. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90385. */
  90386. static readonly RIG_MODE_VR: number;
  90387. /**
  90388. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90389. */
  90390. static readonly RIG_MODE_WEBVR: number;
  90391. /**
  90392. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90393. */
  90394. static readonly RIG_MODE_CUSTOM: number;
  90395. /**
  90396. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90397. */
  90398. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90399. /**
  90400. * Define the input manager associated with the camera.
  90401. */
  90402. inputs: CameraInputsManager<Camera>;
  90403. /** @hidden */
  90404. _position: Vector3;
  90405. /**
  90406. * Define the current local position of the camera in the scene
  90407. */
  90408. position: Vector3;
  90409. /**
  90410. * The vector the camera should consider as up.
  90411. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90412. */
  90413. upVector: Vector3;
  90414. /**
  90415. * Define the current limit on the left side for an orthographic camera
  90416. * In scene unit
  90417. */
  90418. orthoLeft: Nullable<number>;
  90419. /**
  90420. * Define the current limit on the right side for an orthographic camera
  90421. * In scene unit
  90422. */
  90423. orthoRight: Nullable<number>;
  90424. /**
  90425. * Define the current limit on the bottom side for an orthographic camera
  90426. * In scene unit
  90427. */
  90428. orthoBottom: Nullable<number>;
  90429. /**
  90430. * Define the current limit on the top side for an orthographic camera
  90431. * In scene unit
  90432. */
  90433. orthoTop: Nullable<number>;
  90434. /**
  90435. * Field Of View is set in Radians. (default is 0.8)
  90436. */
  90437. fov: number;
  90438. /**
  90439. * Define the minimum distance the camera can see from.
  90440. * This is important to note that the depth buffer are not infinite and the closer it starts
  90441. * the more your scene might encounter depth fighting issue.
  90442. */
  90443. minZ: number;
  90444. /**
  90445. * Define the maximum distance the camera can see to.
  90446. * This is important to note that the depth buffer are not infinite and the further it end
  90447. * the more your scene might encounter depth fighting issue.
  90448. */
  90449. maxZ: number;
  90450. /**
  90451. * Define the default inertia of the camera.
  90452. * This helps giving a smooth feeling to the camera movement.
  90453. */
  90454. inertia: number;
  90455. /**
  90456. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  90457. */
  90458. mode: number;
  90459. /**
  90460. * Define wether the camera is intermediate.
  90461. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90462. */
  90463. isIntermediate: boolean;
  90464. /**
  90465. * Define the viewport of the camera.
  90466. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90467. */
  90468. viewport: Viewport;
  90469. /**
  90470. * Restricts the camera to viewing objects with the same layerMask.
  90471. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90472. */
  90473. layerMask: number;
  90474. /**
  90475. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90476. */
  90477. fovMode: number;
  90478. /**
  90479. * Rig mode of the camera.
  90480. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90481. * This is normally controlled byt the camera themselves as internal use.
  90482. */
  90483. cameraRigMode: number;
  90484. /**
  90485. * Defines the distance between both "eyes" in case of a RIG
  90486. */
  90487. interaxialDistance: number;
  90488. /**
  90489. * Defines if stereoscopic rendering is done side by side or over under.
  90490. */
  90491. isStereoscopicSideBySide: boolean;
  90492. /**
  90493. * 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
  90494. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90495. * else in the scene. (Eg. security camera)
  90496. *
  90497. * 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)
  90498. */
  90499. customRenderTargets: RenderTargetTexture[];
  90500. /**
  90501. * When set, the camera will render to this render target instead of the default canvas
  90502. *
  90503. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  90504. */
  90505. outputRenderTarget: Nullable<RenderTargetTexture>;
  90506. /**
  90507. * Observable triggered when the camera view matrix has changed.
  90508. */
  90509. onViewMatrixChangedObservable: Observable<Camera>;
  90510. /**
  90511. * Observable triggered when the camera Projection matrix has changed.
  90512. */
  90513. onProjectionMatrixChangedObservable: Observable<Camera>;
  90514. /**
  90515. * Observable triggered when the inputs have been processed.
  90516. */
  90517. onAfterCheckInputsObservable: Observable<Camera>;
  90518. /**
  90519. * Observable triggered when reset has been called and applied to the camera.
  90520. */
  90521. onRestoreStateObservable: Observable<Camera>;
  90522. /** @hidden */
  90523. _cameraRigParams: any;
  90524. /** @hidden */
  90525. _rigCameras: Camera[];
  90526. /** @hidden */
  90527. _rigPostProcess: Nullable<PostProcess>;
  90528. protected _webvrViewMatrix: Matrix;
  90529. /** @hidden */
  90530. _skipRendering: boolean;
  90531. /** @hidden */
  90532. _projectionMatrix: Matrix;
  90533. /** @hidden */
  90534. _postProcesses: Nullable<PostProcess>[];
  90535. /** @hidden */
  90536. _activeMeshes: SmartArray<AbstractMesh>;
  90537. protected _globalPosition: Vector3;
  90538. /** @hidden */
  90539. _computedViewMatrix: Matrix;
  90540. private _doNotComputeProjectionMatrix;
  90541. private _transformMatrix;
  90542. private _frustumPlanes;
  90543. private _refreshFrustumPlanes;
  90544. private _storedFov;
  90545. private _stateStored;
  90546. /**
  90547. * Instantiates a new camera object.
  90548. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90549. * @see http://doc.babylonjs.com/features/cameras
  90550. * @param name Defines the name of the camera in the scene
  90551. * @param position Defines the position of the camera
  90552. * @param scene Defines the scene the camera belongs too
  90553. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90554. */
  90555. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90556. /**
  90557. * Store current camera state (fov, position, etc..)
  90558. * @returns the camera
  90559. */
  90560. storeState(): Camera;
  90561. /**
  90562. * Restores the camera state values if it has been stored. You must call storeState() first
  90563. */
  90564. protected _restoreStateValues(): boolean;
  90565. /**
  90566. * Restored camera state. You must call storeState() first.
  90567. * @returns true if restored and false otherwise
  90568. */
  90569. restoreState(): boolean;
  90570. /**
  90571. * Gets the class name of the camera.
  90572. * @returns the class name
  90573. */
  90574. getClassName(): string;
  90575. /** @hidden */
  90576. readonly _isCamera: boolean;
  90577. /**
  90578. * Gets a string representation of the camera useful for debug purpose.
  90579. * @param fullDetails Defines that a more verboe level of logging is required
  90580. * @returns the string representation
  90581. */
  90582. toString(fullDetails?: boolean): string;
  90583. /**
  90584. * Gets the current world space position of the camera.
  90585. */
  90586. readonly globalPosition: Vector3;
  90587. /**
  90588. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90589. * @returns the active meshe list
  90590. */
  90591. getActiveMeshes(): SmartArray<AbstractMesh>;
  90592. /**
  90593. * Check wether a mesh is part of the current active mesh list of the camera
  90594. * @param mesh Defines the mesh to check
  90595. * @returns true if active, false otherwise
  90596. */
  90597. isActiveMesh(mesh: Mesh): boolean;
  90598. /**
  90599. * Is this camera ready to be used/rendered
  90600. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90601. * @return true if the camera is ready
  90602. */
  90603. isReady(completeCheck?: boolean): boolean;
  90604. /** @hidden */
  90605. _initCache(): void;
  90606. /** @hidden */
  90607. _updateCache(ignoreParentClass?: boolean): void;
  90608. /** @hidden */
  90609. _isSynchronized(): boolean;
  90610. /** @hidden */
  90611. _isSynchronizedViewMatrix(): boolean;
  90612. /** @hidden */
  90613. _isSynchronizedProjectionMatrix(): boolean;
  90614. /**
  90615. * Attach the input controls to a specific dom element to get the input from.
  90616. * @param element Defines the element the controls should be listened from
  90617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90618. */
  90619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90620. /**
  90621. * Detach the current controls from the specified dom element.
  90622. * @param element Defines the element to stop listening the inputs from
  90623. */
  90624. detachControl(element: HTMLElement): void;
  90625. /**
  90626. * Update the camera state according to the different inputs gathered during the frame.
  90627. */
  90628. update(): void;
  90629. /** @hidden */
  90630. _checkInputs(): void;
  90631. /** @hidden */
  90632. readonly rigCameras: Camera[];
  90633. /**
  90634. * Gets the post process used by the rig cameras
  90635. */
  90636. readonly rigPostProcess: Nullable<PostProcess>;
  90637. /**
  90638. * Internal, gets the first post proces.
  90639. * @returns the first post process to be run on this camera.
  90640. */
  90641. _getFirstPostProcess(): Nullable<PostProcess>;
  90642. private _cascadePostProcessesToRigCams;
  90643. /**
  90644. * Attach a post process to the camera.
  90645. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90646. * @param postProcess The post process to attach to the camera
  90647. * @param insertAt The position of the post process in case several of them are in use in the scene
  90648. * @returns the position the post process has been inserted at
  90649. */
  90650. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90651. /**
  90652. * Detach a post process to the camera.
  90653. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90654. * @param postProcess The post process to detach from the camera
  90655. */
  90656. detachPostProcess(postProcess: PostProcess): void;
  90657. /**
  90658. * Gets the current world matrix of the camera
  90659. */
  90660. getWorldMatrix(): Matrix;
  90661. /** @hidden */
  90662. _getViewMatrix(): Matrix;
  90663. /**
  90664. * Gets the current view matrix of the camera.
  90665. * @param force forces the camera to recompute the matrix without looking at the cached state
  90666. * @returns the view matrix
  90667. */
  90668. getViewMatrix(force?: boolean): Matrix;
  90669. /**
  90670. * Freeze the projection matrix.
  90671. * It will prevent the cache check of the camera projection compute and can speed up perf
  90672. * if no parameter of the camera are meant to change
  90673. * @param projection Defines manually a projection if necessary
  90674. */
  90675. freezeProjectionMatrix(projection?: Matrix): void;
  90676. /**
  90677. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90678. */
  90679. unfreezeProjectionMatrix(): void;
  90680. /**
  90681. * Gets the current projection matrix of the camera.
  90682. * @param force forces the camera to recompute the matrix without looking at the cached state
  90683. * @returns the projection matrix
  90684. */
  90685. getProjectionMatrix(force?: boolean): Matrix;
  90686. /**
  90687. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90688. * @returns a Matrix
  90689. */
  90690. getTransformationMatrix(): Matrix;
  90691. private _updateFrustumPlanes;
  90692. /**
  90693. * Checks if a cullable object (mesh...) is in the camera frustum
  90694. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90695. * @param target The object to check
  90696. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90697. * @returns true if the object is in frustum otherwise false
  90698. */
  90699. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90700. /**
  90701. * Checks if a cullable object (mesh...) is in the camera frustum
  90702. * Unlike isInFrustum this cheks the full bounding box
  90703. * @param target The object to check
  90704. * @returns true if the object is in frustum otherwise false
  90705. */
  90706. isCompletelyInFrustum(target: ICullable): boolean;
  90707. /**
  90708. * Gets a ray in the forward direction from the camera.
  90709. * @param length Defines the length of the ray to create
  90710. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90711. * @param origin Defines the start point of the ray which defaults to the camera position
  90712. * @returns the forward ray
  90713. */
  90714. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90715. /**
  90716. * Releases resources associated with this node.
  90717. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90718. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90719. */
  90720. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90721. /** @hidden */
  90722. _isLeftCamera: boolean;
  90723. /**
  90724. * Gets the left camera of a rig setup in case of Rigged Camera
  90725. */
  90726. readonly isLeftCamera: boolean;
  90727. /** @hidden */
  90728. _isRightCamera: boolean;
  90729. /**
  90730. * Gets the right camera of a rig setup in case of Rigged Camera
  90731. */
  90732. readonly isRightCamera: boolean;
  90733. /**
  90734. * Gets the left camera of a rig setup in case of Rigged Camera
  90735. */
  90736. readonly leftCamera: Nullable<FreeCamera>;
  90737. /**
  90738. * Gets the right camera of a rig setup in case of Rigged Camera
  90739. */
  90740. readonly rightCamera: Nullable<FreeCamera>;
  90741. /**
  90742. * Gets the left camera target of a rig setup in case of Rigged Camera
  90743. * @returns the target position
  90744. */
  90745. getLeftTarget(): Nullable<Vector3>;
  90746. /**
  90747. * Gets the right camera target of a rig setup in case of Rigged Camera
  90748. * @returns the target position
  90749. */
  90750. getRightTarget(): Nullable<Vector3>;
  90751. /**
  90752. * @hidden
  90753. */
  90754. setCameraRigMode(mode: number, rigParams: any): void;
  90755. /** @hidden */
  90756. static _setStereoscopicRigMode(camera: Camera): void;
  90757. /** @hidden */
  90758. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90759. /** @hidden */
  90760. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90761. /** @hidden */
  90762. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90763. /** @hidden */
  90764. _getVRProjectionMatrix(): Matrix;
  90765. protected _updateCameraRotationMatrix(): void;
  90766. protected _updateWebVRCameraRotationMatrix(): void;
  90767. /**
  90768. * This function MUST be overwritten by the different WebVR cameras available.
  90769. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90770. * @hidden
  90771. */
  90772. _getWebVRProjectionMatrix(): Matrix;
  90773. /**
  90774. * This function MUST be overwritten by the different WebVR cameras available.
  90775. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90776. * @hidden
  90777. */
  90778. _getWebVRViewMatrix(): Matrix;
  90779. /** @hidden */
  90780. setCameraRigParameter(name: string, value: any): void;
  90781. /**
  90782. * needs to be overridden by children so sub has required properties to be copied
  90783. * @hidden
  90784. */
  90785. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90786. /**
  90787. * May need to be overridden by children
  90788. * @hidden
  90789. */
  90790. _updateRigCameras(): void;
  90791. /** @hidden */
  90792. _setupInputs(): void;
  90793. /**
  90794. * Serialiaze the camera setup to a json represention
  90795. * @returns the JSON representation
  90796. */
  90797. serialize(): any;
  90798. /**
  90799. * Clones the current camera.
  90800. * @param name The cloned camera name
  90801. * @returns the cloned camera
  90802. */
  90803. clone(name: string): Camera;
  90804. /**
  90805. * Gets the direction of the camera relative to a given local axis.
  90806. * @param localAxis Defines the reference axis to provide a relative direction.
  90807. * @return the direction
  90808. */
  90809. getDirection(localAxis: Vector3): Vector3;
  90810. /**
  90811. * Returns the current camera absolute rotation
  90812. */
  90813. readonly absoluteRotation: Quaternion;
  90814. /**
  90815. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90816. * @param localAxis Defines the reference axis to provide a relative direction.
  90817. * @param result Defines the vector to store the result in
  90818. */
  90819. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90820. /**
  90821. * Gets a camera constructor for a given camera type
  90822. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90823. * @param name The name of the camera the result will be able to instantiate
  90824. * @param scene The scene the result will construct the camera in
  90825. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90826. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90827. * @returns a factory method to construc the camera
  90828. */
  90829. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90830. /**
  90831. * Compute the world matrix of the camera.
  90832. * @returns the camera workd matrix
  90833. */
  90834. computeWorldMatrix(): Matrix;
  90835. /**
  90836. * Parse a JSON and creates the camera from the parsed information
  90837. * @param parsedCamera The JSON to parse
  90838. * @param scene The scene to instantiate the camera in
  90839. * @returns the newly constructed camera
  90840. */
  90841. static Parse(parsedCamera: any, scene: Scene): Camera;
  90842. }
  90843. }
  90844. declare module BABYLON {
  90845. /**
  90846. * Class containing static functions to help procedurally build meshes
  90847. */
  90848. export class DiscBuilder {
  90849. /**
  90850. * Creates a plane polygonal mesh. By default, this is a disc
  90851. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90852. * * 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
  90853. * * 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
  90854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90857. * @param name defines the name of the mesh
  90858. * @param options defines the options used to create the mesh
  90859. * @param scene defines the hosting scene
  90860. * @returns the plane polygonal mesh
  90861. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90862. */
  90863. static CreateDisc(name: string, options: {
  90864. radius?: number;
  90865. tessellation?: number;
  90866. arc?: number;
  90867. updatable?: boolean;
  90868. sideOrientation?: number;
  90869. frontUVs?: Vector4;
  90870. backUVs?: Vector4;
  90871. }, scene?: Nullable<Scene>): Mesh;
  90872. }
  90873. }
  90874. declare module BABYLON {
  90875. /**
  90876. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  90877. *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.
  90878. * The SPS is also a particle system. It provides some methods to manage the particles.
  90879. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  90880. *
  90881. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  90882. */
  90883. export class SolidParticleSystem implements IDisposable {
  90884. /**
  90885. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  90886. * Example : var p = SPS.particles[i];
  90887. */
  90888. particles: SolidParticle[];
  90889. /**
  90890. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  90891. */
  90892. nbParticles: number;
  90893. /**
  90894. * If the particles must ever face the camera (default false). Useful for planar particles.
  90895. */
  90896. billboard: boolean;
  90897. /**
  90898. * Recompute normals when adding a shape
  90899. */
  90900. recomputeNormals: boolean;
  90901. /**
  90902. * This a counter ofr your own usage. It's not set by any SPS functions.
  90903. */
  90904. counter: number;
  90905. /**
  90906. * The SPS name. This name is also given to the underlying mesh.
  90907. */
  90908. name: string;
  90909. /**
  90910. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  90911. */
  90912. mesh: Mesh;
  90913. /**
  90914. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  90915. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  90916. */
  90917. vars: any;
  90918. /**
  90919. * This array is populated when the SPS is set as 'pickable'.
  90920. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  90921. * Each element of this array is an object `{idx: int, faceId: int}`.
  90922. * `idx` is the picked particle index in the `SPS.particles` array
  90923. * `faceId` is the picked face index counted within this particle.
  90924. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  90925. */
  90926. pickedParticles: {
  90927. idx: number;
  90928. faceId: number;
  90929. }[];
  90930. /**
  90931. * This array is populated when `enableDepthSort` is set to true.
  90932. * Each element of this array is an instance of the class DepthSortedParticle.
  90933. */
  90934. depthSortedParticles: DepthSortedParticle[];
  90935. /**
  90936. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  90937. * @hidden
  90938. */
  90939. _bSphereOnly: boolean;
  90940. /**
  90941. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  90942. * @hidden
  90943. */
  90944. _bSphereRadiusFactor: number;
  90945. private _scene;
  90946. private _positions;
  90947. private _indices;
  90948. private _normals;
  90949. private _colors;
  90950. private _uvs;
  90951. private _indices32;
  90952. private _positions32;
  90953. private _normals32;
  90954. private _fixedNormal32;
  90955. private _colors32;
  90956. private _uvs32;
  90957. private _index;
  90958. private _updatable;
  90959. private _pickable;
  90960. private _isVisibilityBoxLocked;
  90961. private _alwaysVisible;
  90962. private _depthSort;
  90963. private _shapeCounter;
  90964. private _copy;
  90965. private _color;
  90966. private _computeParticleColor;
  90967. private _computeParticleTexture;
  90968. private _computeParticleRotation;
  90969. private _computeParticleVertex;
  90970. private _computeBoundingBox;
  90971. private _depthSortParticles;
  90972. private _camera;
  90973. private _mustUnrotateFixedNormals;
  90974. private _particlesIntersect;
  90975. private _needs32Bits;
  90976. /**
  90977. * Creates a SPS (Solid Particle System) object.
  90978. * @param name (String) is the SPS name, this will be the underlying mesh name.
  90979. * @param scene (Scene) is the scene in which the SPS is added.
  90980. * @param options defines the options of the sps e.g.
  90981. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  90982. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  90983. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  90984. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  90985. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  90986. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  90987. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  90988. */
  90989. constructor(name: string, scene: Scene, options?: {
  90990. updatable?: boolean;
  90991. isPickable?: boolean;
  90992. enableDepthSort?: boolean;
  90993. particleIntersection?: boolean;
  90994. boundingSphereOnly?: boolean;
  90995. bSphereRadiusFactor?: number;
  90996. });
  90997. /**
  90998. * Builds the SPS underlying mesh. Returns a standard Mesh.
  90999. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  91000. * @returns the created mesh
  91001. */
  91002. buildMesh(): Mesh;
  91003. /**
  91004. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  91005. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  91006. * Thus the particles generated from `digest()` have their property `position` set yet.
  91007. * @param mesh ( Mesh ) is the mesh to be digested
  91008. * @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
  91009. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  91010. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  91011. * @returns the current SPS
  91012. */
  91013. digest(mesh: Mesh, options?: {
  91014. facetNb?: number;
  91015. number?: number;
  91016. delta?: number;
  91017. }): SolidParticleSystem;
  91018. private _unrotateFixedNormals;
  91019. private _resetCopy;
  91020. private _meshBuilder;
  91021. private _posToShape;
  91022. private _uvsToShapeUV;
  91023. private _addParticle;
  91024. /**
  91025. * Adds some particles to the SPS from the model shape. Returns the shape id.
  91026. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  91027. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  91028. * @param nb (positive integer) the number of particles to be created from this model
  91029. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  91030. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  91031. * @returns the number of shapes in the system
  91032. */
  91033. addShape(mesh: Mesh, nb: number, options?: {
  91034. positionFunction?: any;
  91035. vertexFunction?: any;
  91036. }): number;
  91037. private _rebuildParticle;
  91038. /**
  91039. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  91040. * @returns the SPS.
  91041. */
  91042. rebuildMesh(): SolidParticleSystem;
  91043. /**
  91044. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  91045. * This method calls `updateParticle()` for each particle of the SPS.
  91046. * For an animated SPS, it is usually called within the render loop.
  91047. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  91048. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  91049. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  91050. * @returns the SPS.
  91051. */
  91052. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  91053. /**
  91054. * Disposes the SPS.
  91055. */
  91056. dispose(): void;
  91057. /**
  91058. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  91059. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91060. * @returns the SPS.
  91061. */
  91062. refreshVisibleSize(): SolidParticleSystem;
  91063. /**
  91064. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  91065. * @param size the size (float) of the visibility box
  91066. * note : this doesn't lock the SPS mesh bounding box.
  91067. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91068. */
  91069. setVisibilityBox(size: number): void;
  91070. /**
  91071. * Gets whether the SPS as always visible or not
  91072. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91073. */
  91074. /**
  91075. * Sets the SPS as always visible or not
  91076. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91077. */
  91078. isAlwaysVisible: boolean;
  91079. /**
  91080. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91081. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91082. */
  91083. /**
  91084. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91085. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91086. */
  91087. isVisibilityBoxLocked: boolean;
  91088. /**
  91089. * Tells to `setParticles()` to compute the particle rotations or not.
  91090. * Default value : true. The SPS is faster when it's set to false.
  91091. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91092. */
  91093. /**
  91094. * Gets if `setParticles()` computes the particle rotations or not.
  91095. * Default value : true. The SPS is faster when it's set to false.
  91096. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91097. */
  91098. computeParticleRotation: boolean;
  91099. /**
  91100. * Tells to `setParticles()` to compute the particle colors or not.
  91101. * Default value : true. The SPS is faster when it's set to false.
  91102. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91103. */
  91104. /**
  91105. * Gets if `setParticles()` computes the particle colors or not.
  91106. * Default value : true. The SPS is faster when it's set to false.
  91107. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91108. */
  91109. computeParticleColor: boolean;
  91110. /**
  91111. * Gets if `setParticles()` computes the particle textures or not.
  91112. * Default value : true. The SPS is faster when it's set to false.
  91113. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  91114. */
  91115. computeParticleTexture: boolean;
  91116. /**
  91117. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  91118. * Default value : false. The SPS is faster when it's set to false.
  91119. * Note : the particle custom vertex positions aren't stored values.
  91120. */
  91121. /**
  91122. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  91123. * Default value : false. The SPS is faster when it's set to false.
  91124. * Note : the particle custom vertex positions aren't stored values.
  91125. */
  91126. computeParticleVertex: boolean;
  91127. /**
  91128. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  91129. */
  91130. /**
  91131. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  91132. */
  91133. computeBoundingBox: boolean;
  91134. /**
  91135. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  91136. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91137. * Default : `true`
  91138. */
  91139. /**
  91140. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  91141. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91142. * Default : `true`
  91143. */
  91144. depthSortParticles: boolean;
  91145. /**
  91146. * This function does nothing. It may be overwritten to set all the particle first values.
  91147. * The SPS doesn't call this function, you may have to call it by your own.
  91148. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91149. */
  91150. initParticles(): void;
  91151. /**
  91152. * This function does nothing. It may be overwritten to recycle a particle.
  91153. * The SPS doesn't call this function, you may have to call it by your own.
  91154. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91155. * @param particle The particle to recycle
  91156. * @returns the recycled particle
  91157. */
  91158. recycleParticle(particle: SolidParticle): SolidParticle;
  91159. /**
  91160. * Updates a particle : this function should be overwritten by the user.
  91161. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  91162. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91163. * @example : just set a particle position or velocity and recycle conditions
  91164. * @param particle The particle to update
  91165. * @returns the updated particle
  91166. */
  91167. updateParticle(particle: SolidParticle): SolidParticle;
  91168. /**
  91169. * Updates a vertex of a particle : it can be overwritten by the user.
  91170. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  91171. * @param particle the current particle
  91172. * @param vertex the current index of the current particle
  91173. * @param pt the index of the current vertex in the particle shape
  91174. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  91175. * @example : just set a vertex particle position
  91176. * @returns the updated vertex
  91177. */
  91178. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  91179. /**
  91180. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  91181. * This does nothing and may be overwritten by the user.
  91182. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91183. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91184. * @param update the boolean update value actually passed to setParticles()
  91185. */
  91186. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91187. /**
  91188. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  91189. * This will be passed three parameters.
  91190. * This does nothing and may be overwritten by the user.
  91191. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91192. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91193. * @param update the boolean update value actually passed to setParticles()
  91194. */
  91195. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91196. }
  91197. }
  91198. declare module BABYLON {
  91199. /**
  91200. * Represents one particle of a solid particle system.
  91201. */
  91202. export class SolidParticle {
  91203. /**
  91204. * particle global index
  91205. */
  91206. idx: number;
  91207. /**
  91208. * The color of the particle
  91209. */
  91210. color: Nullable<Color4>;
  91211. /**
  91212. * The world space position of the particle.
  91213. */
  91214. position: Vector3;
  91215. /**
  91216. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  91217. */
  91218. rotation: Vector3;
  91219. /**
  91220. * The world space rotation quaternion of the particle.
  91221. */
  91222. rotationQuaternion: Nullable<Quaternion>;
  91223. /**
  91224. * The scaling of the particle.
  91225. */
  91226. scaling: Vector3;
  91227. /**
  91228. * The uvs of the particle.
  91229. */
  91230. uvs: Vector4;
  91231. /**
  91232. * The current speed of the particle.
  91233. */
  91234. velocity: Vector3;
  91235. /**
  91236. * The pivot point in the particle local space.
  91237. */
  91238. pivot: Vector3;
  91239. /**
  91240. * Must the particle be translated from its pivot point in its local space ?
  91241. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  91242. * Default : false
  91243. */
  91244. translateFromPivot: boolean;
  91245. /**
  91246. * Is the particle active or not ?
  91247. */
  91248. alive: boolean;
  91249. /**
  91250. * Is the particle visible or not ?
  91251. */
  91252. isVisible: boolean;
  91253. /**
  91254. * Index of this particle in the global "positions" array (Internal use)
  91255. * @hidden
  91256. */
  91257. _pos: number;
  91258. /**
  91259. * @hidden Index of this particle in the global "indices" array (Internal use)
  91260. */
  91261. _ind: number;
  91262. /**
  91263. * @hidden ModelShape of this particle (Internal use)
  91264. */
  91265. _model: ModelShape;
  91266. /**
  91267. * ModelShape id of this particle
  91268. */
  91269. shapeId: number;
  91270. /**
  91271. * Index of the particle in its shape id
  91272. */
  91273. idxInShape: number;
  91274. /**
  91275. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  91276. */
  91277. _modelBoundingInfo: BoundingInfo;
  91278. /**
  91279. * @hidden Particle BoundingInfo object (Internal use)
  91280. */
  91281. _boundingInfo: BoundingInfo;
  91282. /**
  91283. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  91284. */
  91285. _sps: SolidParticleSystem;
  91286. /**
  91287. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  91288. */
  91289. _stillInvisible: boolean;
  91290. /**
  91291. * @hidden Last computed particle rotation matrix
  91292. */
  91293. _rotationMatrix: number[];
  91294. /**
  91295. * Parent particle Id, if any.
  91296. * Default null.
  91297. */
  91298. parentId: Nullable<number>;
  91299. /**
  91300. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  91301. * The possible values are :
  91302. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91303. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91304. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91305. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91306. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91307. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  91308. * */
  91309. cullingStrategy: number;
  91310. /**
  91311. * @hidden Internal global position in the SPS.
  91312. */
  91313. _globalPosition: Vector3;
  91314. /**
  91315. * Creates a Solid Particle object.
  91316. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  91317. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  91318. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  91319. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  91320. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  91321. * @param shapeId (integer) is the model shape identifier in the SPS.
  91322. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  91323. * @param sps defines the sps it is associated to
  91324. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  91325. */
  91326. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  91327. /**
  91328. * Legacy support, changed scale to scaling
  91329. */
  91330. /**
  91331. * Legacy support, changed scale to scaling
  91332. */
  91333. scale: Vector3;
  91334. /**
  91335. * Legacy support, changed quaternion to rotationQuaternion
  91336. */
  91337. /**
  91338. * Legacy support, changed quaternion to rotationQuaternion
  91339. */
  91340. quaternion: Nullable<Quaternion>;
  91341. /**
  91342. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  91343. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  91344. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  91345. * @returns true if it intersects
  91346. */
  91347. intersectsMesh(target: Mesh | SolidParticle): boolean;
  91348. /**
  91349. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  91350. * A particle is in the frustum if its bounding box intersects the frustum
  91351. * @param frustumPlanes defines the frustum to test
  91352. * @returns true if the particle is in the frustum planes
  91353. */
  91354. isInFrustum(frustumPlanes: Plane[]): boolean;
  91355. /**
  91356. * get the rotation matrix of the particle
  91357. * @hidden
  91358. */
  91359. getRotationMatrix(m: Matrix): void;
  91360. }
  91361. /**
  91362. * Represents the shape of the model used by one particle of a solid particle system.
  91363. * SPS internal tool, don't use it manually.
  91364. */
  91365. export class ModelShape {
  91366. /**
  91367. * The shape id
  91368. * @hidden
  91369. */
  91370. shapeID: number;
  91371. /**
  91372. * flat array of model positions (internal use)
  91373. * @hidden
  91374. */
  91375. _shape: Vector3[];
  91376. /**
  91377. * flat array of model UVs (internal use)
  91378. * @hidden
  91379. */
  91380. _shapeUV: number[];
  91381. /**
  91382. * length of the shape in the model indices array (internal use)
  91383. * @hidden
  91384. */
  91385. _indicesLength: number;
  91386. /**
  91387. * Custom position function (internal use)
  91388. * @hidden
  91389. */
  91390. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  91391. /**
  91392. * Custom vertex function (internal use)
  91393. * @hidden
  91394. */
  91395. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  91396. /**
  91397. * 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.
  91398. * SPS internal tool, don't use it manually.
  91399. * @hidden
  91400. */
  91401. 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>);
  91402. }
  91403. /**
  91404. * Represents a Depth Sorted Particle in the solid particle system.
  91405. */
  91406. export class DepthSortedParticle {
  91407. /**
  91408. * Index of the particle in the "indices" array
  91409. */
  91410. ind: number;
  91411. /**
  91412. * Length of the particle shape in the "indices" array
  91413. */
  91414. indicesLength: number;
  91415. /**
  91416. * Squared distance from the particle to the camera
  91417. */
  91418. sqDistance: number;
  91419. }
  91420. }
  91421. declare module BABYLON {
  91422. /**
  91423. * @hidden
  91424. */
  91425. export class _MeshCollisionData {
  91426. _checkCollisions: boolean;
  91427. _collisionMask: number;
  91428. _collisionGroup: number;
  91429. _collider: Nullable<Collider>;
  91430. _oldPositionForCollisions: Vector3;
  91431. _diffPositionForCollisions: Vector3;
  91432. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  91433. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  91434. }
  91435. }
  91436. declare module BABYLON {
  91437. /** @hidden */
  91438. class _FacetDataStorage {
  91439. facetPositions: Vector3[];
  91440. facetNormals: Vector3[];
  91441. facetPartitioning: number[][];
  91442. facetNb: number;
  91443. partitioningSubdivisions: number;
  91444. partitioningBBoxRatio: number;
  91445. facetDataEnabled: boolean;
  91446. facetParameters: any;
  91447. bbSize: Vector3;
  91448. subDiv: {
  91449. max: number;
  91450. X: number;
  91451. Y: number;
  91452. Z: number;
  91453. };
  91454. facetDepthSort: boolean;
  91455. facetDepthSortEnabled: boolean;
  91456. depthSortedIndices: IndicesArray;
  91457. depthSortedFacets: {
  91458. ind: number;
  91459. sqDistance: number;
  91460. }[];
  91461. facetDepthSortFunction: (f1: {
  91462. ind: number;
  91463. sqDistance: number;
  91464. }, f2: {
  91465. ind: number;
  91466. sqDistance: number;
  91467. }) => number;
  91468. facetDepthSortFrom: Vector3;
  91469. facetDepthSortOrigin: Vector3;
  91470. invertedMatrix: Matrix;
  91471. }
  91472. /**
  91473. * @hidden
  91474. **/
  91475. class _InternalAbstractMeshDataInfo {
  91476. _hasVertexAlpha: boolean;
  91477. _useVertexColors: boolean;
  91478. _numBoneInfluencers: number;
  91479. _applyFog: boolean;
  91480. _receiveShadows: boolean;
  91481. _facetData: _FacetDataStorage;
  91482. _visibility: number;
  91483. _skeleton: Nullable<Skeleton>;
  91484. _layerMask: number;
  91485. _computeBonesUsingShaders: boolean;
  91486. _isActive: boolean;
  91487. _onlyForInstances: boolean;
  91488. _isActiveIntermediate: boolean;
  91489. _onlyForInstancesIntermediate: boolean;
  91490. }
  91491. /**
  91492. * Class used to store all common mesh properties
  91493. */
  91494. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  91495. /** No occlusion */
  91496. static OCCLUSION_TYPE_NONE: number;
  91497. /** Occlusion set to optimisitic */
  91498. static OCCLUSION_TYPE_OPTIMISTIC: number;
  91499. /** Occlusion set to strict */
  91500. static OCCLUSION_TYPE_STRICT: number;
  91501. /** Use an accurante occlusion algorithm */
  91502. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  91503. /** Use a conservative occlusion algorithm */
  91504. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  91505. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  91506. * Test order :
  91507. * Is the bounding sphere outside the frustum ?
  91508. * If not, are the bounding box vertices outside the frustum ?
  91509. * It not, then the cullable object is in the frustum.
  91510. */
  91511. static readonly CULLINGSTRATEGY_STANDARD: number;
  91512. /** Culling strategy : Bounding Sphere Only.
  91513. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  91514. * It's also less accurate than the standard because some not visible objects can still be selected.
  91515. * Test : is the bounding sphere outside the frustum ?
  91516. * If not, then the cullable object is in the frustum.
  91517. */
  91518. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  91519. /** Culling strategy : Optimistic Inclusion.
  91520. * This in an inclusion test first, then the standard exclusion test.
  91521. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  91522. * 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.
  91523. * Anyway, it's as accurate as the standard strategy.
  91524. * Test :
  91525. * Is the cullable object bounding sphere center in the frustum ?
  91526. * If not, apply the default culling strategy.
  91527. */
  91528. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  91529. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  91530. * This in an inclusion test first, then the bounding sphere only exclusion test.
  91531. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  91532. * 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.
  91533. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  91534. * Test :
  91535. * Is the cullable object bounding sphere center in the frustum ?
  91536. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  91537. */
  91538. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  91539. /**
  91540. * No billboard
  91541. */
  91542. static readonly BILLBOARDMODE_NONE: number;
  91543. /** Billboard on X axis */
  91544. static readonly BILLBOARDMODE_X: number;
  91545. /** Billboard on Y axis */
  91546. static readonly BILLBOARDMODE_Y: number;
  91547. /** Billboard on Z axis */
  91548. static readonly BILLBOARDMODE_Z: number;
  91549. /** Billboard on all axes */
  91550. static readonly BILLBOARDMODE_ALL: number;
  91551. /** Billboard on using position instead of orientation */
  91552. static readonly BILLBOARDMODE_USE_POSITION: number;
  91553. /** @hidden */
  91554. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  91555. /**
  91556. * The culling strategy to use to check whether the mesh must be rendered or not.
  91557. * This value can be changed at any time and will be used on the next render mesh selection.
  91558. * The possible values are :
  91559. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91560. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91561. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91562. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91563. * Please read each static variable documentation to get details about the culling process.
  91564. * */
  91565. cullingStrategy: number;
  91566. /**
  91567. * Gets the number of facets in the mesh
  91568. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91569. */
  91570. readonly facetNb: number;
  91571. /**
  91572. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  91573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91574. */
  91575. partitioningSubdivisions: number;
  91576. /**
  91577. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  91578. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  91579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91580. */
  91581. partitioningBBoxRatio: number;
  91582. /**
  91583. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  91584. * Works only for updatable meshes.
  91585. * Doesn't work with multi-materials
  91586. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91587. */
  91588. mustDepthSortFacets: boolean;
  91589. /**
  91590. * The location (Vector3) where the facet depth sort must be computed from.
  91591. * By default, the active camera position.
  91592. * Used only when facet depth sort is enabled
  91593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91594. */
  91595. facetDepthSortFrom: Vector3;
  91596. /**
  91597. * gets a boolean indicating if facetData is enabled
  91598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91599. */
  91600. readonly isFacetDataEnabled: boolean;
  91601. /** @hidden */
  91602. _updateNonUniformScalingState(value: boolean): boolean;
  91603. /**
  91604. * An event triggered when this mesh collides with another one
  91605. */
  91606. onCollideObservable: Observable<AbstractMesh>;
  91607. /** Set a function to call when this mesh collides with another one */
  91608. onCollide: () => void;
  91609. /**
  91610. * An event triggered when the collision's position changes
  91611. */
  91612. onCollisionPositionChangeObservable: Observable<Vector3>;
  91613. /** Set a function to call when the collision's position changes */
  91614. onCollisionPositionChange: () => void;
  91615. /**
  91616. * An event triggered when material is changed
  91617. */
  91618. onMaterialChangedObservable: Observable<AbstractMesh>;
  91619. /**
  91620. * Gets or sets the orientation for POV movement & rotation
  91621. */
  91622. definedFacingForward: boolean;
  91623. /** @hidden */
  91624. _occlusionQuery: Nullable<WebGLQuery>;
  91625. /** @hidden */
  91626. _renderingGroup: Nullable<RenderingGroup>;
  91627. /**
  91628. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91629. */
  91630. /**
  91631. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91632. */
  91633. visibility: number;
  91634. /** Gets or sets the alpha index used to sort transparent meshes
  91635. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  91636. */
  91637. alphaIndex: number;
  91638. /**
  91639. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  91640. */
  91641. isVisible: boolean;
  91642. /**
  91643. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91644. */
  91645. isPickable: boolean;
  91646. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  91647. showSubMeshesBoundingBox: boolean;
  91648. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  91649. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  91650. */
  91651. isBlocker: boolean;
  91652. /**
  91653. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  91654. */
  91655. enablePointerMoveEvents: boolean;
  91656. /**
  91657. * Specifies the rendering group id for this mesh (0 by default)
  91658. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91659. */
  91660. renderingGroupId: number;
  91661. private _material;
  91662. /** Gets or sets current material */
  91663. material: Nullable<Material>;
  91664. /**
  91665. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  91666. * @see http://doc.babylonjs.com/babylon101/shadows
  91667. */
  91668. receiveShadows: boolean;
  91669. /** Defines color to use when rendering outline */
  91670. outlineColor: Color3;
  91671. /** Define width to use when rendering outline */
  91672. outlineWidth: number;
  91673. /** Defines color to use when rendering overlay */
  91674. overlayColor: Color3;
  91675. /** Defines alpha to use when rendering overlay */
  91676. overlayAlpha: number;
  91677. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  91678. hasVertexAlpha: boolean;
  91679. /** 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) */
  91680. useVertexColors: boolean;
  91681. /**
  91682. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  91683. */
  91684. computeBonesUsingShaders: boolean;
  91685. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  91686. numBoneInfluencers: number;
  91687. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  91688. applyFog: boolean;
  91689. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  91690. useOctreeForRenderingSelection: boolean;
  91691. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  91692. useOctreeForPicking: boolean;
  91693. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  91694. useOctreeForCollisions: boolean;
  91695. /**
  91696. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  91697. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  91698. */
  91699. layerMask: number;
  91700. /**
  91701. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  91702. */
  91703. alwaysSelectAsActiveMesh: boolean;
  91704. /**
  91705. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  91706. */
  91707. doNotSyncBoundingInfo: boolean;
  91708. /**
  91709. * Gets or sets the current action manager
  91710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91711. */
  91712. actionManager: Nullable<AbstractActionManager>;
  91713. private _meshCollisionData;
  91714. /**
  91715. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  91716. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91717. */
  91718. ellipsoid: Vector3;
  91719. /**
  91720. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  91721. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91722. */
  91723. ellipsoidOffset: Vector3;
  91724. /**
  91725. * Gets or sets a collision mask used to mask collisions (default is -1).
  91726. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91727. */
  91728. collisionMask: number;
  91729. /**
  91730. * Gets or sets the current collision group mask (-1 by default).
  91731. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91732. */
  91733. collisionGroup: number;
  91734. /**
  91735. * Defines edge width used when edgesRenderer is enabled
  91736. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91737. */
  91738. edgesWidth: number;
  91739. /**
  91740. * Defines edge color used when edgesRenderer is enabled
  91741. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91742. */
  91743. edgesColor: Color4;
  91744. /** @hidden */
  91745. _edgesRenderer: Nullable<IEdgesRenderer>;
  91746. /** @hidden */
  91747. _masterMesh: Nullable<AbstractMesh>;
  91748. /** @hidden */
  91749. _boundingInfo: Nullable<BoundingInfo>;
  91750. /** @hidden */
  91751. _renderId: number;
  91752. /**
  91753. * Gets or sets the list of subMeshes
  91754. * @see http://doc.babylonjs.com/how_to/multi_materials
  91755. */
  91756. subMeshes: SubMesh[];
  91757. /** @hidden */
  91758. _intersectionsInProgress: AbstractMesh[];
  91759. /** @hidden */
  91760. _unIndexed: boolean;
  91761. /** @hidden */
  91762. _lightSources: Light[];
  91763. /** Gets the list of lights affecting that mesh */
  91764. readonly lightSources: Light[];
  91765. /** @hidden */
  91766. readonly _positions: Nullable<Vector3[]>;
  91767. /** @hidden */
  91768. _waitingData: {
  91769. lods: Nullable<any>;
  91770. actions: Nullable<any>;
  91771. freezeWorldMatrix: Nullable<boolean>;
  91772. };
  91773. /** @hidden */
  91774. _bonesTransformMatrices: Nullable<Float32Array>;
  91775. /** @hidden */
  91776. _transformMatrixTexture: Nullable<RawTexture>;
  91777. /**
  91778. * Gets or sets a skeleton to apply skining transformations
  91779. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91780. */
  91781. skeleton: Nullable<Skeleton>;
  91782. /**
  91783. * An event triggered when the mesh is rebuilt.
  91784. */
  91785. onRebuildObservable: Observable<AbstractMesh>;
  91786. /**
  91787. * Creates a new AbstractMesh
  91788. * @param name defines the name of the mesh
  91789. * @param scene defines the hosting scene
  91790. */
  91791. constructor(name: string, scene?: Nullable<Scene>);
  91792. /**
  91793. * Returns the string "AbstractMesh"
  91794. * @returns "AbstractMesh"
  91795. */
  91796. getClassName(): string;
  91797. /**
  91798. * Gets a string representation of the current mesh
  91799. * @param fullDetails defines a boolean indicating if full details must be included
  91800. * @returns a string representation of the current mesh
  91801. */
  91802. toString(fullDetails?: boolean): string;
  91803. /**
  91804. * @hidden
  91805. */
  91806. protected _getEffectiveParent(): Nullable<Node>;
  91807. /** @hidden */
  91808. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91809. /** @hidden */
  91810. _rebuild(): void;
  91811. /** @hidden */
  91812. _resyncLightSources(): void;
  91813. /** @hidden */
  91814. _resyncLighSource(light: Light): void;
  91815. /** @hidden */
  91816. _unBindEffect(): void;
  91817. /** @hidden */
  91818. _removeLightSource(light: Light, dispose: boolean): void;
  91819. private _markSubMeshesAsDirty;
  91820. /** @hidden */
  91821. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  91822. /** @hidden */
  91823. _markSubMeshesAsAttributesDirty(): void;
  91824. /** @hidden */
  91825. _markSubMeshesAsMiscDirty(): void;
  91826. /**
  91827. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  91828. */
  91829. scaling: Vector3;
  91830. /**
  91831. * Returns true if the mesh is blocked. Implemented by child classes
  91832. */
  91833. readonly isBlocked: boolean;
  91834. /**
  91835. * Returns the mesh itself by default. Implemented by child classes
  91836. * @param camera defines the camera to use to pick the right LOD level
  91837. * @returns the currentAbstractMesh
  91838. */
  91839. getLOD(camera: Camera): Nullable<AbstractMesh>;
  91840. /**
  91841. * Returns 0 by default. Implemented by child classes
  91842. * @returns an integer
  91843. */
  91844. getTotalVertices(): number;
  91845. /**
  91846. * Returns a positive integer : the total number of indices in this mesh geometry.
  91847. * @returns the numner of indices or zero if the mesh has no geometry.
  91848. */
  91849. getTotalIndices(): number;
  91850. /**
  91851. * Returns null by default. Implemented by child classes
  91852. * @returns null
  91853. */
  91854. getIndices(): Nullable<IndicesArray>;
  91855. /**
  91856. * Returns the array of the requested vertex data kind. Implemented by child classes
  91857. * @param kind defines the vertex data kind to use
  91858. * @returns null
  91859. */
  91860. getVerticesData(kind: string): Nullable<FloatArray>;
  91861. /**
  91862. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91863. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91864. * Note that a new underlying VertexBuffer object is created each call.
  91865. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91866. * @param kind defines vertex data kind:
  91867. * * VertexBuffer.PositionKind
  91868. * * VertexBuffer.UVKind
  91869. * * VertexBuffer.UV2Kind
  91870. * * VertexBuffer.UV3Kind
  91871. * * VertexBuffer.UV4Kind
  91872. * * VertexBuffer.UV5Kind
  91873. * * VertexBuffer.UV6Kind
  91874. * * VertexBuffer.ColorKind
  91875. * * VertexBuffer.MatricesIndicesKind
  91876. * * VertexBuffer.MatricesIndicesExtraKind
  91877. * * VertexBuffer.MatricesWeightsKind
  91878. * * VertexBuffer.MatricesWeightsExtraKind
  91879. * @param data defines the data source
  91880. * @param updatable defines if the data must be flagged as updatable (or static)
  91881. * @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
  91882. * @returns the current mesh
  91883. */
  91884. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91885. /**
  91886. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91887. * If the mesh has no geometry, it is simply returned as it is.
  91888. * @param kind defines vertex data kind:
  91889. * * VertexBuffer.PositionKind
  91890. * * VertexBuffer.UVKind
  91891. * * VertexBuffer.UV2Kind
  91892. * * VertexBuffer.UV3Kind
  91893. * * VertexBuffer.UV4Kind
  91894. * * VertexBuffer.UV5Kind
  91895. * * VertexBuffer.UV6Kind
  91896. * * VertexBuffer.ColorKind
  91897. * * VertexBuffer.MatricesIndicesKind
  91898. * * VertexBuffer.MatricesIndicesExtraKind
  91899. * * VertexBuffer.MatricesWeightsKind
  91900. * * VertexBuffer.MatricesWeightsExtraKind
  91901. * @param data defines the data source
  91902. * @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
  91903. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  91904. * @returns the current mesh
  91905. */
  91906. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91907. /**
  91908. * Sets the mesh indices,
  91909. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91910. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  91911. * @param totalVertices Defines the total number of vertices
  91912. * @returns the current mesh
  91913. */
  91914. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  91915. /**
  91916. * Gets a boolean indicating if specific vertex data is present
  91917. * @param kind defines the vertex data kind to use
  91918. * @returns true is data kind is present
  91919. */
  91920. isVerticesDataPresent(kind: string): boolean;
  91921. /**
  91922. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  91923. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  91924. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  91925. * @returns a BoundingInfo
  91926. */
  91927. getBoundingInfo(): BoundingInfo;
  91928. /**
  91929. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  91930. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  91931. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  91932. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  91933. * @returns the current mesh
  91934. */
  91935. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  91936. /**
  91937. * Overwrite the current bounding info
  91938. * @param boundingInfo defines the new bounding info
  91939. * @returns the current mesh
  91940. */
  91941. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  91942. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  91943. readonly useBones: boolean;
  91944. /** @hidden */
  91945. _preActivate(): void;
  91946. /** @hidden */
  91947. _preActivateForIntermediateRendering(renderId: number): void;
  91948. /** @hidden */
  91949. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91950. /** @hidden */
  91951. _postActivate(): void;
  91952. /** @hidden */
  91953. _freeze(): void;
  91954. /** @hidden */
  91955. _unFreeze(): void;
  91956. /**
  91957. * Gets the current world matrix
  91958. * @returns a Matrix
  91959. */
  91960. getWorldMatrix(): Matrix;
  91961. /** @hidden */
  91962. _getWorldMatrixDeterminant(): number;
  91963. /**
  91964. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  91965. */
  91966. readonly isAnInstance: boolean;
  91967. /**
  91968. * Gets a boolean indicating if this mesh has instances
  91969. */
  91970. readonly hasInstances: boolean;
  91971. /**
  91972. * Perform relative position change from the point of view of behind the front of the mesh.
  91973. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91974. * Supports definition of mesh facing forward or backward
  91975. * @param amountRight defines the distance on the right axis
  91976. * @param amountUp defines the distance on the up axis
  91977. * @param amountForward defines the distance on the forward axis
  91978. * @returns the current mesh
  91979. */
  91980. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  91981. /**
  91982. * Calculate relative position change from the point of view of behind the front of the mesh.
  91983. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91984. * Supports definition of mesh facing forward or backward
  91985. * @param amountRight defines the distance on the right axis
  91986. * @param amountUp defines the distance on the up axis
  91987. * @param amountForward defines the distance on the forward axis
  91988. * @returns the new displacement vector
  91989. */
  91990. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  91991. /**
  91992. * Perform relative rotation change from the point of view of behind the front of the mesh.
  91993. * Supports definition of mesh facing forward or backward
  91994. * @param flipBack defines the flip
  91995. * @param twirlClockwise defines the twirl
  91996. * @param tiltRight defines the tilt
  91997. * @returns the current mesh
  91998. */
  91999. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  92000. /**
  92001. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  92002. * Supports definition of mesh facing forward or backward.
  92003. * @param flipBack defines the flip
  92004. * @param twirlClockwise defines the twirl
  92005. * @param tiltRight defines the tilt
  92006. * @returns the new rotation vector
  92007. */
  92008. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  92009. /**
  92010. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92011. * This means the mesh underlying bounding box and sphere are recomputed.
  92012. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92013. * @returns the current mesh
  92014. */
  92015. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  92016. /** @hidden */
  92017. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  92018. /** @hidden */
  92019. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  92020. /** @hidden */
  92021. _updateBoundingInfo(): AbstractMesh;
  92022. /** @hidden */
  92023. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  92024. /** @hidden */
  92025. protected _afterComputeWorldMatrix(): void;
  92026. /** @hidden */
  92027. readonly _effectiveMesh: AbstractMesh;
  92028. /**
  92029. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92030. * A mesh is in the frustum if its bounding box intersects the frustum
  92031. * @param frustumPlanes defines the frustum to test
  92032. * @returns true if the mesh is in the frustum planes
  92033. */
  92034. isInFrustum(frustumPlanes: Plane[]): boolean;
  92035. /**
  92036. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  92037. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  92038. * @param frustumPlanes defines the frustum to test
  92039. * @returns true if the mesh is completely in the frustum planes
  92040. */
  92041. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92042. /**
  92043. * True if the mesh intersects another mesh or a SolidParticle object
  92044. * @param mesh defines a target mesh or SolidParticle to test
  92045. * @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)
  92046. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  92047. * @returns true if there is an intersection
  92048. */
  92049. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  92050. /**
  92051. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  92052. * @param point defines the point to test
  92053. * @returns true if there is an intersection
  92054. */
  92055. intersectsPoint(point: Vector3): boolean;
  92056. /**
  92057. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  92058. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92059. */
  92060. checkCollisions: boolean;
  92061. /**
  92062. * Gets Collider object used to compute collisions (not physics)
  92063. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92064. */
  92065. readonly collider: Nullable<Collider>;
  92066. /**
  92067. * Move the mesh using collision engine
  92068. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92069. * @param displacement defines the requested displacement vector
  92070. * @returns the current mesh
  92071. */
  92072. moveWithCollisions(displacement: Vector3): AbstractMesh;
  92073. private _onCollisionPositionChange;
  92074. /** @hidden */
  92075. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  92076. /** @hidden */
  92077. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  92078. /** @hidden */
  92079. _checkCollision(collider: Collider): AbstractMesh;
  92080. /** @hidden */
  92081. _generatePointsArray(): boolean;
  92082. /**
  92083. * Checks if the passed Ray intersects with the mesh
  92084. * @param ray defines the ray to use
  92085. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  92086. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92087. * @returns the picking info
  92088. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92089. */
  92090. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  92091. /**
  92092. * Clones the current mesh
  92093. * @param name defines the mesh name
  92094. * @param newParent defines the new mesh parent
  92095. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  92096. * @returns the new mesh
  92097. */
  92098. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  92099. /**
  92100. * Disposes all the submeshes of the current meshnp
  92101. * @returns the current mesh
  92102. */
  92103. releaseSubMeshes(): AbstractMesh;
  92104. /**
  92105. * Releases resources associated with this abstract mesh.
  92106. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92107. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92108. */
  92109. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92110. /**
  92111. * Adds the passed mesh as a child to the current mesh
  92112. * @param mesh defines the child mesh
  92113. * @returns the current mesh
  92114. */
  92115. addChild(mesh: AbstractMesh): AbstractMesh;
  92116. /**
  92117. * Removes the passed mesh from the current mesh children list
  92118. * @param mesh defines the child mesh
  92119. * @returns the current mesh
  92120. */
  92121. removeChild(mesh: AbstractMesh): AbstractMesh;
  92122. /** @hidden */
  92123. private _initFacetData;
  92124. /**
  92125. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  92126. * This method can be called within the render loop.
  92127. * 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
  92128. * @returns the current mesh
  92129. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92130. */
  92131. updateFacetData(): AbstractMesh;
  92132. /**
  92133. * Returns the facetLocalNormals array.
  92134. * The normals are expressed in the mesh local spac
  92135. * @returns an array of Vector3
  92136. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92137. */
  92138. getFacetLocalNormals(): Vector3[];
  92139. /**
  92140. * Returns the facetLocalPositions array.
  92141. * The facet positions are expressed in the mesh local space
  92142. * @returns an array of Vector3
  92143. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92144. */
  92145. getFacetLocalPositions(): Vector3[];
  92146. /**
  92147. * Returns the facetLocalPartioning array
  92148. * @returns an array of array of numbers
  92149. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92150. */
  92151. getFacetLocalPartitioning(): number[][];
  92152. /**
  92153. * Returns the i-th facet position in the world system.
  92154. * This method allocates a new Vector3 per call
  92155. * @param i defines the facet index
  92156. * @returns a new Vector3
  92157. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92158. */
  92159. getFacetPosition(i: number): Vector3;
  92160. /**
  92161. * Sets the reference Vector3 with the i-th facet position in the world system
  92162. * @param i defines the facet index
  92163. * @param ref defines the target vector
  92164. * @returns the current mesh
  92165. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92166. */
  92167. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  92168. /**
  92169. * Returns the i-th facet normal in the world system.
  92170. * This method allocates a new Vector3 per call
  92171. * @param i defines the facet index
  92172. * @returns a new Vector3
  92173. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92174. */
  92175. getFacetNormal(i: number): Vector3;
  92176. /**
  92177. * Sets the reference Vector3 with the i-th facet normal in the world system
  92178. * @param i defines the facet index
  92179. * @param ref defines the target vector
  92180. * @returns the current mesh
  92181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92182. */
  92183. getFacetNormalToRef(i: number, ref: Vector3): this;
  92184. /**
  92185. * 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)
  92186. * @param x defines x coordinate
  92187. * @param y defines y coordinate
  92188. * @param z defines z coordinate
  92189. * @returns the array of facet indexes
  92190. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92191. */
  92192. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  92193. /**
  92194. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  92195. * @param projected sets as the (x,y,z) world projection on the facet
  92196. * @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
  92197. * @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
  92198. * @param x defines x coordinate
  92199. * @param y defines y coordinate
  92200. * @param z defines z coordinate
  92201. * @returns the face index if found (or null instead)
  92202. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92203. */
  92204. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92205. /**
  92206. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  92207. * @param projected sets as the (x,y,z) local projection on the facet
  92208. * @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
  92209. * @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
  92210. * @param x defines x coordinate
  92211. * @param y defines y coordinate
  92212. * @param z defines z coordinate
  92213. * @returns the face index if found (or null instead)
  92214. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92215. */
  92216. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92217. /**
  92218. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  92219. * @returns the parameters
  92220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92221. */
  92222. getFacetDataParameters(): any;
  92223. /**
  92224. * Disables the feature FacetData and frees the related memory
  92225. * @returns the current mesh
  92226. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92227. */
  92228. disableFacetData(): AbstractMesh;
  92229. /**
  92230. * Updates the AbstractMesh indices array
  92231. * @param indices defines the data source
  92232. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92233. * @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)
  92234. * @returns the current mesh
  92235. */
  92236. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92237. /**
  92238. * Creates new normals data for the mesh
  92239. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  92240. * @returns the current mesh
  92241. */
  92242. createNormals(updatable: boolean): AbstractMesh;
  92243. /**
  92244. * Align the mesh with a normal
  92245. * @param normal defines the normal to use
  92246. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  92247. * @returns the current mesh
  92248. */
  92249. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  92250. /** @hidden */
  92251. _checkOcclusionQuery(): boolean;
  92252. /**
  92253. * Disables the mesh edge rendering mode
  92254. * @returns the currentAbstractMesh
  92255. */
  92256. disableEdgesRendering(): AbstractMesh;
  92257. /**
  92258. * Enables the edge rendering mode on the mesh.
  92259. * This mode makes the mesh edges visible
  92260. * @param epsilon defines the maximal distance between two angles to detect a face
  92261. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92262. * @returns the currentAbstractMesh
  92263. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92264. */
  92265. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92266. }
  92267. }
  92268. declare module BABYLON {
  92269. /**
  92270. * Interface used to define ActionEvent
  92271. */
  92272. export interface IActionEvent {
  92273. /** The mesh or sprite that triggered the action */
  92274. source: any;
  92275. /** The X mouse cursor position at the time of the event */
  92276. pointerX: number;
  92277. /** The Y mouse cursor position at the time of the event */
  92278. pointerY: number;
  92279. /** The mesh that is currently pointed at (can be null) */
  92280. meshUnderPointer: Nullable<AbstractMesh>;
  92281. /** the original (browser) event that triggered the ActionEvent */
  92282. sourceEvent?: any;
  92283. /** additional data for the event */
  92284. additionalData?: any;
  92285. }
  92286. /**
  92287. * ActionEvent is the event being sent when an action is triggered.
  92288. */
  92289. export class ActionEvent implements IActionEvent {
  92290. /** The mesh or sprite that triggered the action */
  92291. source: any;
  92292. /** The X mouse cursor position at the time of the event */
  92293. pointerX: number;
  92294. /** The Y mouse cursor position at the time of the event */
  92295. pointerY: number;
  92296. /** The mesh that is currently pointed at (can be null) */
  92297. meshUnderPointer: Nullable<AbstractMesh>;
  92298. /** the original (browser) event that triggered the ActionEvent */
  92299. sourceEvent?: any;
  92300. /** additional data for the event */
  92301. additionalData?: any;
  92302. /**
  92303. * Creates a new ActionEvent
  92304. * @param source The mesh or sprite that triggered the action
  92305. * @param pointerX The X mouse cursor position at the time of the event
  92306. * @param pointerY The Y mouse cursor position at the time of the event
  92307. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  92308. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  92309. * @param additionalData additional data for the event
  92310. */
  92311. constructor(
  92312. /** The mesh or sprite that triggered the action */
  92313. source: any,
  92314. /** The X mouse cursor position at the time of the event */
  92315. pointerX: number,
  92316. /** The Y mouse cursor position at the time of the event */
  92317. pointerY: number,
  92318. /** The mesh that is currently pointed at (can be null) */
  92319. meshUnderPointer: Nullable<AbstractMesh>,
  92320. /** the original (browser) event that triggered the ActionEvent */
  92321. sourceEvent?: any,
  92322. /** additional data for the event */
  92323. additionalData?: any);
  92324. /**
  92325. * Helper function to auto-create an ActionEvent from a source mesh.
  92326. * @param source The source mesh that triggered the event
  92327. * @param evt The original (browser) event
  92328. * @param additionalData additional data for the event
  92329. * @returns the new ActionEvent
  92330. */
  92331. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  92332. /**
  92333. * Helper function to auto-create an ActionEvent from a source sprite
  92334. * @param source The source sprite that triggered the event
  92335. * @param scene Scene associated with the sprite
  92336. * @param evt The original (browser) event
  92337. * @param additionalData additional data for the event
  92338. * @returns the new ActionEvent
  92339. */
  92340. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  92341. /**
  92342. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  92343. * @param scene the scene where the event occurred
  92344. * @param evt The original (browser) event
  92345. * @returns the new ActionEvent
  92346. */
  92347. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  92348. /**
  92349. * Helper function to auto-create an ActionEvent from a primitive
  92350. * @param prim defines the target primitive
  92351. * @param pointerPos defines the pointer position
  92352. * @param evt The original (browser) event
  92353. * @param additionalData additional data for the event
  92354. * @returns the new ActionEvent
  92355. */
  92356. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  92357. }
  92358. }
  92359. declare module BABYLON {
  92360. /**
  92361. * Abstract class used to decouple action Manager from scene and meshes.
  92362. * Do not instantiate.
  92363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92364. */
  92365. export abstract class AbstractActionManager implements IDisposable {
  92366. /** Gets the list of active triggers */
  92367. static Triggers: {
  92368. [key: string]: number;
  92369. };
  92370. /** Gets the cursor to use when hovering items */
  92371. hoverCursor: string;
  92372. /** Gets the list of actions */
  92373. actions: IAction[];
  92374. /**
  92375. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  92376. */
  92377. isRecursive: boolean;
  92378. /**
  92379. * Releases all associated resources
  92380. */
  92381. abstract dispose(): void;
  92382. /**
  92383. * Does this action manager has pointer triggers
  92384. */
  92385. abstract readonly hasPointerTriggers: boolean;
  92386. /**
  92387. * Does this action manager has pick triggers
  92388. */
  92389. abstract readonly hasPickTriggers: boolean;
  92390. /**
  92391. * Process a specific trigger
  92392. * @param trigger defines the trigger to process
  92393. * @param evt defines the event details to be processed
  92394. */
  92395. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  92396. /**
  92397. * Does this action manager handles actions of any of the given triggers
  92398. * @param triggers defines the triggers to be tested
  92399. * @return a boolean indicating whether one (or more) of the triggers is handled
  92400. */
  92401. abstract hasSpecificTriggers(triggers: number[]): boolean;
  92402. /**
  92403. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92404. * speed.
  92405. * @param triggerA defines the trigger to be tested
  92406. * @param triggerB defines the trigger to be tested
  92407. * @return a boolean indicating whether one (or more) of the triggers is handled
  92408. */
  92409. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92410. /**
  92411. * Does this action manager handles actions of a given trigger
  92412. * @param trigger defines the trigger to be tested
  92413. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92414. * @return whether the trigger is handled
  92415. */
  92416. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92417. /**
  92418. * Serialize this manager to a JSON object
  92419. * @param name defines the property name to store this manager
  92420. * @returns a JSON representation of this manager
  92421. */
  92422. abstract serialize(name: string): any;
  92423. /**
  92424. * Registers an action to this action manager
  92425. * @param action defines the action to be registered
  92426. * @return the action amended (prepared) after registration
  92427. */
  92428. abstract registerAction(action: IAction): Nullable<IAction>;
  92429. /**
  92430. * Unregisters an action to this action manager
  92431. * @param action defines the action to be unregistered
  92432. * @return a boolean indicating whether the action has been unregistered
  92433. */
  92434. abstract unregisterAction(action: IAction): Boolean;
  92435. /**
  92436. * Does exist one action manager with at least one trigger
  92437. **/
  92438. static readonly HasTriggers: boolean;
  92439. /**
  92440. * Does exist one action manager with at least one pick trigger
  92441. **/
  92442. static readonly HasPickTriggers: boolean;
  92443. /**
  92444. * Does exist one action manager that handles actions of a given trigger
  92445. * @param trigger defines the trigger to be tested
  92446. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  92447. **/
  92448. static HasSpecificTrigger(trigger: number): boolean;
  92449. }
  92450. }
  92451. declare module BABYLON {
  92452. /**
  92453. * Defines how a node can be built from a string name.
  92454. */
  92455. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  92456. /**
  92457. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  92458. */
  92459. export class Node implements IBehaviorAware<Node> {
  92460. /** @hidden */
  92461. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  92462. private static _NodeConstructors;
  92463. /**
  92464. * Add a new node constructor
  92465. * @param type defines the type name of the node to construct
  92466. * @param constructorFunc defines the constructor function
  92467. */
  92468. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  92469. /**
  92470. * Returns a node constructor based on type name
  92471. * @param type defines the type name
  92472. * @param name defines the new node name
  92473. * @param scene defines the hosting scene
  92474. * @param options defines optional options to transmit to constructors
  92475. * @returns the new constructor or null
  92476. */
  92477. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  92478. /**
  92479. * Gets or sets the name of the node
  92480. */
  92481. name: string;
  92482. /**
  92483. * Gets or sets the id of the node
  92484. */
  92485. id: string;
  92486. /**
  92487. * Gets or sets the unique id of the node
  92488. */
  92489. uniqueId: number;
  92490. /**
  92491. * Gets or sets a string used to store user defined state for the node
  92492. */
  92493. state: string;
  92494. /**
  92495. * Gets or sets an object used to store user defined information for the node
  92496. */
  92497. metadata: any;
  92498. /**
  92499. * For internal use only. Please do not use.
  92500. */
  92501. reservedDataStore: any;
  92502. /**
  92503. * List of inspectable custom properties (used by the Inspector)
  92504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92505. */
  92506. inspectableCustomProperties: IInspectable[];
  92507. /**
  92508. * Gets or sets a boolean used to define if the node must be serialized
  92509. */
  92510. doNotSerialize: boolean;
  92511. /** @hidden */
  92512. _isDisposed: boolean;
  92513. /**
  92514. * Gets a list of Animations associated with the node
  92515. */
  92516. animations: Animation[];
  92517. protected _ranges: {
  92518. [name: string]: Nullable<AnimationRange>;
  92519. };
  92520. /**
  92521. * Callback raised when the node is ready to be used
  92522. */
  92523. onReady: Nullable<(node: Node) => void>;
  92524. private _isEnabled;
  92525. private _isParentEnabled;
  92526. private _isReady;
  92527. /** @hidden */
  92528. _currentRenderId: number;
  92529. private _parentUpdateId;
  92530. /** @hidden */
  92531. _childUpdateId: number;
  92532. /** @hidden */
  92533. _waitingParentId: Nullable<string>;
  92534. /** @hidden */
  92535. _scene: Scene;
  92536. /** @hidden */
  92537. _cache: any;
  92538. private _parentNode;
  92539. private _children;
  92540. /** @hidden */
  92541. _worldMatrix: Matrix;
  92542. /** @hidden */
  92543. _worldMatrixDeterminant: number;
  92544. /** @hidden */
  92545. _worldMatrixDeterminantIsDirty: boolean;
  92546. /** @hidden */
  92547. private _sceneRootNodesIndex;
  92548. /**
  92549. * Gets a boolean indicating if the node has been disposed
  92550. * @returns true if the node was disposed
  92551. */
  92552. isDisposed(): boolean;
  92553. /**
  92554. * Gets or sets the parent of the node (without keeping the current position in the scene)
  92555. * @see https://doc.babylonjs.com/how_to/parenting
  92556. */
  92557. parent: Nullable<Node>;
  92558. private addToSceneRootNodes;
  92559. private removeFromSceneRootNodes;
  92560. private _animationPropertiesOverride;
  92561. /**
  92562. * Gets or sets the animation properties override
  92563. */
  92564. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92565. /**
  92566. * Gets a string idenfifying the name of the class
  92567. * @returns "Node" string
  92568. */
  92569. getClassName(): string;
  92570. /** @hidden */
  92571. readonly _isNode: boolean;
  92572. /**
  92573. * An event triggered when the mesh is disposed
  92574. */
  92575. onDisposeObservable: Observable<Node>;
  92576. private _onDisposeObserver;
  92577. /**
  92578. * Sets a callback that will be raised when the node will be disposed
  92579. */
  92580. onDispose: () => void;
  92581. /**
  92582. * Creates a new Node
  92583. * @param name the name and id to be given to this node
  92584. * @param scene the scene this node will be added to
  92585. * @param addToRootNodes the node will be added to scene.rootNodes
  92586. */
  92587. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  92588. /**
  92589. * Gets the scene of the node
  92590. * @returns a scene
  92591. */
  92592. getScene(): Scene;
  92593. /**
  92594. * Gets the engine of the node
  92595. * @returns a Engine
  92596. */
  92597. getEngine(): Engine;
  92598. private _behaviors;
  92599. /**
  92600. * Attach a behavior to the node
  92601. * @see http://doc.babylonjs.com/features/behaviour
  92602. * @param behavior defines the behavior to attach
  92603. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  92604. * @returns the current Node
  92605. */
  92606. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  92607. /**
  92608. * Remove an attached behavior
  92609. * @see http://doc.babylonjs.com/features/behaviour
  92610. * @param behavior defines the behavior to attach
  92611. * @returns the current Node
  92612. */
  92613. removeBehavior(behavior: Behavior<Node>): Node;
  92614. /**
  92615. * Gets the list of attached behaviors
  92616. * @see http://doc.babylonjs.com/features/behaviour
  92617. */
  92618. readonly behaviors: Behavior<Node>[];
  92619. /**
  92620. * Gets an attached behavior by name
  92621. * @param name defines the name of the behavior to look for
  92622. * @see http://doc.babylonjs.com/features/behaviour
  92623. * @returns null if behavior was not found else the requested behavior
  92624. */
  92625. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  92626. /**
  92627. * Returns the latest update of the World matrix
  92628. * @returns a Matrix
  92629. */
  92630. getWorldMatrix(): Matrix;
  92631. /** @hidden */
  92632. _getWorldMatrixDeterminant(): number;
  92633. /**
  92634. * Returns directly the latest state of the mesh World matrix.
  92635. * A Matrix is returned.
  92636. */
  92637. readonly worldMatrixFromCache: Matrix;
  92638. /** @hidden */
  92639. _initCache(): void;
  92640. /** @hidden */
  92641. updateCache(force?: boolean): void;
  92642. /** @hidden */
  92643. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92644. /** @hidden */
  92645. _updateCache(ignoreParentClass?: boolean): void;
  92646. /** @hidden */
  92647. _isSynchronized(): boolean;
  92648. /** @hidden */
  92649. _markSyncedWithParent(): void;
  92650. /** @hidden */
  92651. isSynchronizedWithParent(): boolean;
  92652. /** @hidden */
  92653. isSynchronized(): boolean;
  92654. /**
  92655. * Is this node ready to be used/rendered
  92656. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92657. * @return true if the node is ready
  92658. */
  92659. isReady(completeCheck?: boolean): boolean;
  92660. /**
  92661. * Is this node enabled?
  92662. * 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
  92663. * @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
  92664. * @return whether this node (and its parent) is enabled
  92665. */
  92666. isEnabled(checkAncestors?: boolean): boolean;
  92667. /** @hidden */
  92668. protected _syncParentEnabledState(): void;
  92669. /**
  92670. * Set the enabled state of this node
  92671. * @param value defines the new enabled state
  92672. */
  92673. setEnabled(value: boolean): void;
  92674. /**
  92675. * Is this node a descendant of the given node?
  92676. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  92677. * @param ancestor defines the parent node to inspect
  92678. * @returns a boolean indicating if this node is a descendant of the given node
  92679. */
  92680. isDescendantOf(ancestor: Node): boolean;
  92681. /** @hidden */
  92682. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  92683. /**
  92684. * Will return all nodes that have this node as ascendant
  92685. * @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
  92686. * @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
  92687. * @return all children nodes of all types
  92688. */
  92689. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  92690. /**
  92691. * Get all child-meshes of this node
  92692. * @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)
  92693. * @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
  92694. * @returns an array of AbstractMesh
  92695. */
  92696. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  92697. /**
  92698. * Get all direct children of this node
  92699. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  92700. * @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)
  92701. * @returns an array of Node
  92702. */
  92703. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  92704. /** @hidden */
  92705. _setReady(state: boolean): void;
  92706. /**
  92707. * Get an animation by name
  92708. * @param name defines the name of the animation to look for
  92709. * @returns null if not found else the requested animation
  92710. */
  92711. getAnimationByName(name: string): Nullable<Animation>;
  92712. /**
  92713. * Creates an animation range for this node
  92714. * @param name defines the name of the range
  92715. * @param from defines the starting key
  92716. * @param to defines the end key
  92717. */
  92718. createAnimationRange(name: string, from: number, to: number): void;
  92719. /**
  92720. * Delete a specific animation range
  92721. * @param name defines the name of the range to delete
  92722. * @param deleteFrames defines if animation frames from the range must be deleted as well
  92723. */
  92724. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  92725. /**
  92726. * Get an animation range by name
  92727. * @param name defines the name of the animation range to look for
  92728. * @returns null if not found else the requested animation range
  92729. */
  92730. getAnimationRange(name: string): Nullable<AnimationRange>;
  92731. /**
  92732. * Gets the list of all animation ranges defined on this node
  92733. * @returns an array
  92734. */
  92735. getAnimationRanges(): Nullable<AnimationRange>[];
  92736. /**
  92737. * Will start the animation sequence
  92738. * @param name defines the range frames for animation sequence
  92739. * @param loop defines if the animation should loop (false by default)
  92740. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  92741. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  92742. * @returns the object created for this animation. If range does not exist, it will return null
  92743. */
  92744. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  92745. /**
  92746. * Serialize animation ranges into a JSON compatible object
  92747. * @returns serialization object
  92748. */
  92749. serializeAnimationRanges(): any;
  92750. /**
  92751. * Computes the world matrix of the node
  92752. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92753. * @returns the world matrix
  92754. */
  92755. computeWorldMatrix(force?: boolean): Matrix;
  92756. /**
  92757. * Releases resources associated with this node.
  92758. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92759. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92760. */
  92761. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92762. /**
  92763. * Parse animation range data from a serialization object and store them into a given node
  92764. * @param node defines where to store the animation ranges
  92765. * @param parsedNode defines the serialization object to read data from
  92766. * @param scene defines the hosting scene
  92767. */
  92768. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  92769. /**
  92770. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  92771. * @param includeDescendants Include bounding info from descendants as well (true by default)
  92772. * @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
  92773. * @returns the new bounding vectors
  92774. */
  92775. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  92776. min: Vector3;
  92777. max: Vector3;
  92778. };
  92779. }
  92780. }
  92781. declare module BABYLON {
  92782. /**
  92783. * @hidden
  92784. */
  92785. export class _IAnimationState {
  92786. key: number;
  92787. repeatCount: number;
  92788. workValue?: any;
  92789. loopMode?: number;
  92790. offsetValue?: any;
  92791. highLimitValue?: any;
  92792. }
  92793. /**
  92794. * Class used to store any kind of animation
  92795. */
  92796. export class Animation {
  92797. /**Name of the animation */
  92798. name: string;
  92799. /**Property to animate */
  92800. targetProperty: string;
  92801. /**The frames per second of the animation */
  92802. framePerSecond: number;
  92803. /**The data type of the animation */
  92804. dataType: number;
  92805. /**The loop mode of the animation */
  92806. loopMode?: number | undefined;
  92807. /**Specifies if blending should be enabled */
  92808. enableBlending?: boolean | undefined;
  92809. /**
  92810. * Use matrix interpolation instead of using direct key value when animating matrices
  92811. */
  92812. static AllowMatricesInterpolation: boolean;
  92813. /**
  92814. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  92815. */
  92816. static AllowMatrixDecomposeForInterpolation: boolean;
  92817. /**
  92818. * Stores the key frames of the animation
  92819. */
  92820. private _keys;
  92821. /**
  92822. * Stores the easing function of the animation
  92823. */
  92824. private _easingFunction;
  92825. /**
  92826. * @hidden Internal use only
  92827. */
  92828. _runtimeAnimations: RuntimeAnimation[];
  92829. /**
  92830. * The set of event that will be linked to this animation
  92831. */
  92832. private _events;
  92833. /**
  92834. * Stores an array of target property paths
  92835. */
  92836. targetPropertyPath: string[];
  92837. /**
  92838. * Stores the blending speed of the animation
  92839. */
  92840. blendingSpeed: number;
  92841. /**
  92842. * Stores the animation ranges for the animation
  92843. */
  92844. private _ranges;
  92845. /**
  92846. * @hidden Internal use
  92847. */
  92848. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  92849. /**
  92850. * Sets up an animation
  92851. * @param property The property to animate
  92852. * @param animationType The animation type to apply
  92853. * @param framePerSecond The frames per second of the animation
  92854. * @param easingFunction The easing function used in the animation
  92855. * @returns The created animation
  92856. */
  92857. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  92858. /**
  92859. * Create and start an animation on a node
  92860. * @param name defines the name of the global animation that will be run on all nodes
  92861. * @param node defines the root node where the animation will take place
  92862. * @param targetProperty defines property to animate
  92863. * @param framePerSecond defines the number of frame per second yo use
  92864. * @param totalFrame defines the number of frames in total
  92865. * @param from defines the initial value
  92866. * @param to defines the final value
  92867. * @param loopMode defines which loop mode you want to use (off by default)
  92868. * @param easingFunction defines the easing function to use (linear by default)
  92869. * @param onAnimationEnd defines the callback to call when animation end
  92870. * @returns the animatable created for this animation
  92871. */
  92872. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92873. /**
  92874. * Create and start an animation on a node and its descendants
  92875. * @param name defines the name of the global animation that will be run on all nodes
  92876. * @param node defines the root node where the animation will take place
  92877. * @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
  92878. * @param targetProperty defines property to animate
  92879. * @param framePerSecond defines the number of frame per second to use
  92880. * @param totalFrame defines the number of frames in total
  92881. * @param from defines the initial value
  92882. * @param to defines the final value
  92883. * @param loopMode defines which loop mode you want to use (off by default)
  92884. * @param easingFunction defines the easing function to use (linear by default)
  92885. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92886. * @returns the list of animatables created for all nodes
  92887. * @example https://www.babylonjs-playground.com/#MH0VLI
  92888. */
  92889. 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[]>;
  92890. /**
  92891. * Creates a new animation, merges it with the existing animations and starts it
  92892. * @param name Name of the animation
  92893. * @param node Node which contains the scene that begins the animations
  92894. * @param targetProperty Specifies which property to animate
  92895. * @param framePerSecond The frames per second of the animation
  92896. * @param totalFrame The total number of frames
  92897. * @param from The frame at the beginning of the animation
  92898. * @param to The frame at the end of the animation
  92899. * @param loopMode Specifies the loop mode of the animation
  92900. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  92901. * @param onAnimationEnd Callback to run once the animation is complete
  92902. * @returns Nullable animation
  92903. */
  92904. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92905. /**
  92906. * Transition property of an host to the target Value
  92907. * @param property The property to transition
  92908. * @param targetValue The target Value of the property
  92909. * @param host The object where the property to animate belongs
  92910. * @param scene Scene used to run the animation
  92911. * @param frameRate Framerate (in frame/s) to use
  92912. * @param transition The transition type we want to use
  92913. * @param duration The duration of the animation, in milliseconds
  92914. * @param onAnimationEnd Callback trigger at the end of the animation
  92915. * @returns Nullable animation
  92916. */
  92917. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  92918. /**
  92919. * Return the array of runtime animations currently using this animation
  92920. */
  92921. readonly runtimeAnimations: RuntimeAnimation[];
  92922. /**
  92923. * Specifies if any of the runtime animations are currently running
  92924. */
  92925. readonly hasRunningRuntimeAnimations: boolean;
  92926. /**
  92927. * Initializes the animation
  92928. * @param name Name of the animation
  92929. * @param targetProperty Property to animate
  92930. * @param framePerSecond The frames per second of the animation
  92931. * @param dataType The data type of the animation
  92932. * @param loopMode The loop mode of the animation
  92933. * @param enableBlending Specifies if blending should be enabled
  92934. */
  92935. constructor(
  92936. /**Name of the animation */
  92937. name: string,
  92938. /**Property to animate */
  92939. targetProperty: string,
  92940. /**The frames per second of the animation */
  92941. framePerSecond: number,
  92942. /**The data type of the animation */
  92943. dataType: number,
  92944. /**The loop mode of the animation */
  92945. loopMode?: number | undefined,
  92946. /**Specifies if blending should be enabled */
  92947. enableBlending?: boolean | undefined);
  92948. /**
  92949. * Converts the animation to a string
  92950. * @param fullDetails support for multiple levels of logging within scene loading
  92951. * @returns String form of the animation
  92952. */
  92953. toString(fullDetails?: boolean): string;
  92954. /**
  92955. * Add an event to this animation
  92956. * @param event Event to add
  92957. */
  92958. addEvent(event: AnimationEvent): void;
  92959. /**
  92960. * Remove all events found at the given frame
  92961. * @param frame The frame to remove events from
  92962. */
  92963. removeEvents(frame: number): void;
  92964. /**
  92965. * Retrieves all the events from the animation
  92966. * @returns Events from the animation
  92967. */
  92968. getEvents(): AnimationEvent[];
  92969. /**
  92970. * Creates an animation range
  92971. * @param name Name of the animation range
  92972. * @param from Starting frame of the animation range
  92973. * @param to Ending frame of the animation
  92974. */
  92975. createRange(name: string, from: number, to: number): void;
  92976. /**
  92977. * Deletes an animation range by name
  92978. * @param name Name of the animation range to delete
  92979. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  92980. */
  92981. deleteRange(name: string, deleteFrames?: boolean): void;
  92982. /**
  92983. * Gets the animation range by name, or null if not defined
  92984. * @param name Name of the animation range
  92985. * @returns Nullable animation range
  92986. */
  92987. getRange(name: string): Nullable<AnimationRange>;
  92988. /**
  92989. * Gets the key frames from the animation
  92990. * @returns The key frames of the animation
  92991. */
  92992. getKeys(): Array<IAnimationKey>;
  92993. /**
  92994. * Gets the highest frame rate of the animation
  92995. * @returns Highest frame rate of the animation
  92996. */
  92997. getHighestFrame(): number;
  92998. /**
  92999. * Gets the easing function of the animation
  93000. * @returns Easing function of the animation
  93001. */
  93002. getEasingFunction(): IEasingFunction;
  93003. /**
  93004. * Sets the easing function of the animation
  93005. * @param easingFunction A custom mathematical formula for animation
  93006. */
  93007. setEasingFunction(easingFunction: EasingFunction): void;
  93008. /**
  93009. * Interpolates a scalar linearly
  93010. * @param startValue Start value of the animation curve
  93011. * @param endValue End value of the animation curve
  93012. * @param gradient Scalar amount to interpolate
  93013. * @returns Interpolated scalar value
  93014. */
  93015. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  93016. /**
  93017. * Interpolates a scalar cubically
  93018. * @param startValue Start value of the animation curve
  93019. * @param outTangent End tangent of the animation
  93020. * @param endValue End value of the animation curve
  93021. * @param inTangent Start tangent of the animation curve
  93022. * @param gradient Scalar amount to interpolate
  93023. * @returns Interpolated scalar value
  93024. */
  93025. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  93026. /**
  93027. * Interpolates a quaternion using a spherical linear interpolation
  93028. * @param startValue Start value of the animation curve
  93029. * @param endValue End value of the animation curve
  93030. * @param gradient Scalar amount to interpolate
  93031. * @returns Interpolated quaternion value
  93032. */
  93033. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  93034. /**
  93035. * Interpolates a quaternion cubically
  93036. * @param startValue Start value of the animation curve
  93037. * @param outTangent End tangent of the animation curve
  93038. * @param endValue End value of the animation curve
  93039. * @param inTangent Start tangent of the animation curve
  93040. * @param gradient Scalar amount to interpolate
  93041. * @returns Interpolated quaternion value
  93042. */
  93043. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  93044. /**
  93045. * Interpolates a Vector3 linearl
  93046. * @param startValue Start value of the animation curve
  93047. * @param endValue End value of the animation curve
  93048. * @param gradient Scalar amount to interpolate
  93049. * @returns Interpolated scalar value
  93050. */
  93051. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  93052. /**
  93053. * Interpolates a Vector3 cubically
  93054. * @param startValue Start value of the animation curve
  93055. * @param outTangent End tangent of the animation
  93056. * @param endValue End value of the animation curve
  93057. * @param inTangent Start tangent of the animation curve
  93058. * @param gradient Scalar amount to interpolate
  93059. * @returns InterpolatedVector3 value
  93060. */
  93061. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  93062. /**
  93063. * Interpolates a Vector2 linearly
  93064. * @param startValue Start value of the animation curve
  93065. * @param endValue End value of the animation curve
  93066. * @param gradient Scalar amount to interpolate
  93067. * @returns Interpolated Vector2 value
  93068. */
  93069. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  93070. /**
  93071. * Interpolates a Vector2 cubically
  93072. * @param startValue Start value of the animation curve
  93073. * @param outTangent End tangent of the animation
  93074. * @param endValue End value of the animation curve
  93075. * @param inTangent Start tangent of the animation curve
  93076. * @param gradient Scalar amount to interpolate
  93077. * @returns Interpolated Vector2 value
  93078. */
  93079. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  93080. /**
  93081. * Interpolates a size linearly
  93082. * @param startValue Start value of the animation curve
  93083. * @param endValue End value of the animation curve
  93084. * @param gradient Scalar amount to interpolate
  93085. * @returns Interpolated Size value
  93086. */
  93087. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  93088. /**
  93089. * Interpolates a Color3 linearly
  93090. * @param startValue Start value of the animation curve
  93091. * @param endValue End value of the animation curve
  93092. * @param gradient Scalar amount to interpolate
  93093. * @returns Interpolated Color3 value
  93094. */
  93095. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  93096. /**
  93097. * @hidden Internal use only
  93098. */
  93099. _getKeyValue(value: any): any;
  93100. /**
  93101. * @hidden Internal use only
  93102. */
  93103. _interpolate(currentFrame: number, state: _IAnimationState): any;
  93104. /**
  93105. * Defines the function to use to interpolate matrices
  93106. * @param startValue defines the start matrix
  93107. * @param endValue defines the end matrix
  93108. * @param gradient defines the gradient between both matrices
  93109. * @param result defines an optional target matrix where to store the interpolation
  93110. * @returns the interpolated matrix
  93111. */
  93112. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  93113. /**
  93114. * Makes a copy of the animation
  93115. * @returns Cloned animation
  93116. */
  93117. clone(): Animation;
  93118. /**
  93119. * Sets the key frames of the animation
  93120. * @param values The animation key frames to set
  93121. */
  93122. setKeys(values: Array<IAnimationKey>): void;
  93123. /**
  93124. * Serializes the animation to an object
  93125. * @returns Serialized object
  93126. */
  93127. serialize(): any;
  93128. /**
  93129. * Float animation type
  93130. */
  93131. private static _ANIMATIONTYPE_FLOAT;
  93132. /**
  93133. * Vector3 animation type
  93134. */
  93135. private static _ANIMATIONTYPE_VECTOR3;
  93136. /**
  93137. * Quaternion animation type
  93138. */
  93139. private static _ANIMATIONTYPE_QUATERNION;
  93140. /**
  93141. * Matrix animation type
  93142. */
  93143. private static _ANIMATIONTYPE_MATRIX;
  93144. /**
  93145. * Color3 animation type
  93146. */
  93147. private static _ANIMATIONTYPE_COLOR3;
  93148. /**
  93149. * Vector2 animation type
  93150. */
  93151. private static _ANIMATIONTYPE_VECTOR2;
  93152. /**
  93153. * Size animation type
  93154. */
  93155. private static _ANIMATIONTYPE_SIZE;
  93156. /**
  93157. * Relative Loop Mode
  93158. */
  93159. private static _ANIMATIONLOOPMODE_RELATIVE;
  93160. /**
  93161. * Cycle Loop Mode
  93162. */
  93163. private static _ANIMATIONLOOPMODE_CYCLE;
  93164. /**
  93165. * Constant Loop Mode
  93166. */
  93167. private static _ANIMATIONLOOPMODE_CONSTANT;
  93168. /**
  93169. * Get the float animation type
  93170. */
  93171. static readonly ANIMATIONTYPE_FLOAT: number;
  93172. /**
  93173. * Get the Vector3 animation type
  93174. */
  93175. static readonly ANIMATIONTYPE_VECTOR3: number;
  93176. /**
  93177. * Get the Vector2 animation type
  93178. */
  93179. static readonly ANIMATIONTYPE_VECTOR2: number;
  93180. /**
  93181. * Get the Size animation type
  93182. */
  93183. static readonly ANIMATIONTYPE_SIZE: number;
  93184. /**
  93185. * Get the Quaternion animation type
  93186. */
  93187. static readonly ANIMATIONTYPE_QUATERNION: number;
  93188. /**
  93189. * Get the Matrix animation type
  93190. */
  93191. static readonly ANIMATIONTYPE_MATRIX: number;
  93192. /**
  93193. * Get the Color3 animation type
  93194. */
  93195. static readonly ANIMATIONTYPE_COLOR3: number;
  93196. /**
  93197. * Get the Relative Loop Mode
  93198. */
  93199. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  93200. /**
  93201. * Get the Cycle Loop Mode
  93202. */
  93203. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  93204. /**
  93205. * Get the Constant Loop Mode
  93206. */
  93207. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  93208. /** @hidden */
  93209. static _UniversalLerp(left: any, right: any, amount: number): any;
  93210. /**
  93211. * Parses an animation object and creates an animation
  93212. * @param parsedAnimation Parsed animation object
  93213. * @returns Animation object
  93214. */
  93215. static Parse(parsedAnimation: any): Animation;
  93216. /**
  93217. * Appends the serialized animations from the source animations
  93218. * @param source Source containing the animations
  93219. * @param destination Target to store the animations
  93220. */
  93221. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93222. }
  93223. }
  93224. declare module BABYLON {
  93225. /**
  93226. * Interface containing an array of animations
  93227. */
  93228. export interface IAnimatable {
  93229. /**
  93230. * Array of animations
  93231. */
  93232. animations: Nullable<Array<Animation>>;
  93233. }
  93234. }
  93235. declare module BABYLON {
  93236. /**
  93237. * This represents all the required information to add a fresnel effect on a material:
  93238. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93239. */
  93240. export class FresnelParameters {
  93241. private _isEnabled;
  93242. /**
  93243. * Define if the fresnel effect is enable or not.
  93244. */
  93245. isEnabled: boolean;
  93246. /**
  93247. * Define the color used on edges (grazing angle)
  93248. */
  93249. leftColor: Color3;
  93250. /**
  93251. * Define the color used on center
  93252. */
  93253. rightColor: Color3;
  93254. /**
  93255. * Define bias applied to computed fresnel term
  93256. */
  93257. bias: number;
  93258. /**
  93259. * Defined the power exponent applied to fresnel term
  93260. */
  93261. power: number;
  93262. /**
  93263. * Clones the current fresnel and its valuues
  93264. * @returns a clone fresnel configuration
  93265. */
  93266. clone(): FresnelParameters;
  93267. /**
  93268. * Serializes the current fresnel parameters to a JSON representation.
  93269. * @return the JSON serialization
  93270. */
  93271. serialize(): any;
  93272. /**
  93273. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93274. * @param parsedFresnelParameters Define the JSON representation
  93275. * @returns the parsed parameters
  93276. */
  93277. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93278. }
  93279. }
  93280. declare module BABYLON {
  93281. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93282. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93283. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93284. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93285. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93286. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93287. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93288. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93289. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93290. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93291. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93292. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93293. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93294. /**
  93295. * Decorator used to define property that can be serialized as reference to a camera
  93296. * @param sourceName defines the name of the property to decorate
  93297. */
  93298. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93299. /**
  93300. * Class used to help serialization objects
  93301. */
  93302. export class SerializationHelper {
  93303. /** @hidden */
  93304. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93305. /** @hidden */
  93306. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93307. /** @hidden */
  93308. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93309. /** @hidden */
  93310. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93311. /**
  93312. * Appends the serialized animations from the source animations
  93313. * @param source Source containing the animations
  93314. * @param destination Target to store the animations
  93315. */
  93316. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93317. /**
  93318. * Static function used to serialized a specific entity
  93319. * @param entity defines the entity to serialize
  93320. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93321. * @returns a JSON compatible object representing the serialization of the entity
  93322. */
  93323. static Serialize<T>(entity: T, serializationObject?: any): any;
  93324. /**
  93325. * Creates a new entity from a serialization data object
  93326. * @param creationFunction defines a function used to instanciated the new entity
  93327. * @param source defines the source serialization data
  93328. * @param scene defines the hosting scene
  93329. * @param rootUrl defines the root url for resources
  93330. * @returns a new entity
  93331. */
  93332. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93333. /**
  93334. * Clones an object
  93335. * @param creationFunction defines the function used to instanciate the new object
  93336. * @param source defines the source object
  93337. * @returns the cloned object
  93338. */
  93339. static Clone<T>(creationFunction: () => T, source: T): T;
  93340. /**
  93341. * Instanciates a new object based on a source one (some data will be shared between both object)
  93342. * @param creationFunction defines the function used to instanciate the new object
  93343. * @param source defines the source object
  93344. * @returns the new object
  93345. */
  93346. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93347. }
  93348. }
  93349. declare module BABYLON {
  93350. /**
  93351. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  93352. */
  93353. export interface CubeMapInfo {
  93354. /**
  93355. * The pixel array for the front face.
  93356. * This is stored in format, left to right, up to down format.
  93357. */
  93358. front: Nullable<ArrayBufferView>;
  93359. /**
  93360. * The pixel array for the back face.
  93361. * This is stored in format, left to right, up to down format.
  93362. */
  93363. back: Nullable<ArrayBufferView>;
  93364. /**
  93365. * The pixel array for the left face.
  93366. * This is stored in format, left to right, up to down format.
  93367. */
  93368. left: Nullable<ArrayBufferView>;
  93369. /**
  93370. * The pixel array for the right face.
  93371. * This is stored in format, left to right, up to down format.
  93372. */
  93373. right: Nullable<ArrayBufferView>;
  93374. /**
  93375. * The pixel array for the up face.
  93376. * This is stored in format, left to right, up to down format.
  93377. */
  93378. up: Nullable<ArrayBufferView>;
  93379. /**
  93380. * The pixel array for the down face.
  93381. * This is stored in format, left to right, up to down format.
  93382. */
  93383. down: Nullable<ArrayBufferView>;
  93384. /**
  93385. * The size of the cubemap stored.
  93386. *
  93387. * Each faces will be size * size pixels.
  93388. */
  93389. size: number;
  93390. /**
  93391. * The format of the texture.
  93392. *
  93393. * RGBA, RGB.
  93394. */
  93395. format: number;
  93396. /**
  93397. * The type of the texture data.
  93398. *
  93399. * UNSIGNED_INT, FLOAT.
  93400. */
  93401. type: number;
  93402. /**
  93403. * Specifies whether the texture is in gamma space.
  93404. */
  93405. gammaSpace: boolean;
  93406. }
  93407. /**
  93408. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93409. */
  93410. export class PanoramaToCubeMapTools {
  93411. private static FACE_FRONT;
  93412. private static FACE_BACK;
  93413. private static FACE_RIGHT;
  93414. private static FACE_LEFT;
  93415. private static FACE_DOWN;
  93416. private static FACE_UP;
  93417. /**
  93418. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93419. *
  93420. * @param float32Array The source data.
  93421. * @param inputWidth The width of the input panorama.
  93422. * @param inputHeight The height of the input panorama.
  93423. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93424. * @return The cubemap data
  93425. */
  93426. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  93427. private static CreateCubemapTexture;
  93428. private static CalcProjectionSpherical;
  93429. }
  93430. }
  93431. declare module BABYLON {
  93432. /**
  93433. * Helper class dealing with the extraction of spherical polynomial dataArray
  93434. * from a cube map.
  93435. */
  93436. export class CubeMapToSphericalPolynomialTools {
  93437. private static FileFaces;
  93438. /**
  93439. * Converts a texture to the according Spherical Polynomial data.
  93440. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93441. *
  93442. * @param texture The texture to extract the information from.
  93443. * @return The Spherical Polynomial data.
  93444. */
  93445. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  93446. /**
  93447. * Converts a cubemap to the according Spherical Polynomial data.
  93448. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93449. *
  93450. * @param cubeInfo The Cube map to extract the information from.
  93451. * @return The Spherical Polynomial data.
  93452. */
  93453. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  93454. }
  93455. }
  93456. declare module BABYLON {
  93457. /**
  93458. * Class used to manipulate GUIDs
  93459. */
  93460. export class GUID {
  93461. /**
  93462. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93463. * Be aware Math.random() could cause collisions, but:
  93464. * "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"
  93465. * @returns a pseudo random id
  93466. */
  93467. static RandomId(): string;
  93468. }
  93469. }
  93470. declare module BABYLON {
  93471. /**
  93472. * Base class of all the textures in babylon.
  93473. * It groups all the common properties the materials, post process, lights... might need
  93474. * in order to make a correct use of the texture.
  93475. */
  93476. export class BaseTexture implements IAnimatable {
  93477. /**
  93478. * Default anisotropic filtering level for the application.
  93479. * It is set to 4 as a good tradeoff between perf and quality.
  93480. */
  93481. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  93482. /**
  93483. * Gets or sets the unique id of the texture
  93484. */
  93485. uniqueId: number;
  93486. /**
  93487. * Define the name of the texture.
  93488. */
  93489. name: string;
  93490. /**
  93491. * Gets or sets an object used to store user defined information.
  93492. */
  93493. metadata: any;
  93494. /**
  93495. * For internal use only. Please do not use.
  93496. */
  93497. reservedDataStore: any;
  93498. private _hasAlpha;
  93499. /**
  93500. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  93501. */
  93502. hasAlpha: boolean;
  93503. /**
  93504. * Defines if the alpha value should be determined via the rgb values.
  93505. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  93506. */
  93507. getAlphaFromRGB: boolean;
  93508. /**
  93509. * Intensity or strength of the texture.
  93510. * It is commonly used by materials to fine tune the intensity of the texture
  93511. */
  93512. level: number;
  93513. /**
  93514. * Define the UV chanel to use starting from 0 and defaulting to 0.
  93515. * This is part of the texture as textures usually maps to one uv set.
  93516. */
  93517. coordinatesIndex: number;
  93518. private _coordinatesMode;
  93519. /**
  93520. * How a texture is mapped.
  93521. *
  93522. * | Value | Type | Description |
  93523. * | ----- | ----------------------------------- | ----------- |
  93524. * | 0 | EXPLICIT_MODE | |
  93525. * | 1 | SPHERICAL_MODE | |
  93526. * | 2 | PLANAR_MODE | |
  93527. * | 3 | CUBIC_MODE | |
  93528. * | 4 | PROJECTION_MODE | |
  93529. * | 5 | SKYBOX_MODE | |
  93530. * | 6 | INVCUBIC_MODE | |
  93531. * | 7 | EQUIRECTANGULAR_MODE | |
  93532. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  93533. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  93534. */
  93535. coordinatesMode: number;
  93536. /**
  93537. * | Value | Type | Description |
  93538. * | ----- | ------------------ | ----------- |
  93539. * | 0 | CLAMP_ADDRESSMODE | |
  93540. * | 1 | WRAP_ADDRESSMODE | |
  93541. * | 2 | MIRROR_ADDRESSMODE | |
  93542. */
  93543. wrapU: number;
  93544. /**
  93545. * | Value | Type | Description |
  93546. * | ----- | ------------------ | ----------- |
  93547. * | 0 | CLAMP_ADDRESSMODE | |
  93548. * | 1 | WRAP_ADDRESSMODE | |
  93549. * | 2 | MIRROR_ADDRESSMODE | |
  93550. */
  93551. wrapV: number;
  93552. /**
  93553. * | Value | Type | Description |
  93554. * | ----- | ------------------ | ----------- |
  93555. * | 0 | CLAMP_ADDRESSMODE | |
  93556. * | 1 | WRAP_ADDRESSMODE | |
  93557. * | 2 | MIRROR_ADDRESSMODE | |
  93558. */
  93559. wrapR: number;
  93560. /**
  93561. * With compliant hardware and browser (supporting anisotropic filtering)
  93562. * this defines the level of anisotropic filtering in the texture.
  93563. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  93564. */
  93565. anisotropicFilteringLevel: number;
  93566. /**
  93567. * Define if the texture is a cube texture or if false a 2d texture.
  93568. */
  93569. isCube: boolean;
  93570. /**
  93571. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  93572. */
  93573. is3D: boolean;
  93574. /**
  93575. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  93576. * HDR texture are usually stored in linear space.
  93577. * This only impacts the PBR and Background materials
  93578. */
  93579. gammaSpace: boolean;
  93580. /**
  93581. * Gets or sets whether or not the texture contains RGBD data.
  93582. */
  93583. isRGBD: boolean;
  93584. /**
  93585. * Is Z inverted in the texture (useful in a cube texture).
  93586. */
  93587. invertZ: boolean;
  93588. /**
  93589. * Are mip maps generated for this texture or not.
  93590. */
  93591. readonly noMipmap: boolean;
  93592. /**
  93593. * @hidden
  93594. */
  93595. lodLevelInAlpha: boolean;
  93596. /**
  93597. * With prefiltered texture, defined the offset used during the prefiltering steps.
  93598. */
  93599. lodGenerationOffset: number;
  93600. /**
  93601. * With prefiltered texture, defined the scale used during the prefiltering steps.
  93602. */
  93603. lodGenerationScale: number;
  93604. /**
  93605. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  93606. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  93607. * average roughness values.
  93608. */
  93609. linearSpecularLOD: boolean;
  93610. /**
  93611. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  93612. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  93613. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  93614. */
  93615. irradianceTexture: Nullable<BaseTexture>;
  93616. /**
  93617. * Define if the texture is a render target.
  93618. */
  93619. isRenderTarget: boolean;
  93620. /**
  93621. * Define the unique id of the texture in the scene.
  93622. */
  93623. readonly uid: string;
  93624. /**
  93625. * Return a string representation of the texture.
  93626. * @returns the texture as a string
  93627. */
  93628. toString(): string;
  93629. /**
  93630. * Get the class name of the texture.
  93631. * @returns "BaseTexture"
  93632. */
  93633. getClassName(): string;
  93634. /**
  93635. * Define the list of animation attached to the texture.
  93636. */
  93637. animations: Animation[];
  93638. /**
  93639. * An event triggered when the texture is disposed.
  93640. */
  93641. onDisposeObservable: Observable<BaseTexture>;
  93642. private _onDisposeObserver;
  93643. /**
  93644. * Callback triggered when the texture has been disposed.
  93645. * Kept for back compatibility, you can use the onDisposeObservable instead.
  93646. */
  93647. onDispose: () => void;
  93648. /**
  93649. * Define the current state of the loading sequence when in delayed load mode.
  93650. */
  93651. delayLoadState: number;
  93652. private _scene;
  93653. /** @hidden */
  93654. _texture: Nullable<InternalTexture>;
  93655. private _uid;
  93656. /**
  93657. * Define if the texture is preventinga material to render or not.
  93658. * If not and the texture is not ready, the engine will use a default black texture instead.
  93659. */
  93660. readonly isBlocking: boolean;
  93661. /**
  93662. * Instantiates a new BaseTexture.
  93663. * Base class of all the textures in babylon.
  93664. * It groups all the common properties the materials, post process, lights... might need
  93665. * in order to make a correct use of the texture.
  93666. * @param scene Define the scene the texture blongs to
  93667. */
  93668. constructor(scene: Nullable<Scene>);
  93669. /**
  93670. * Get the scene the texture belongs to.
  93671. * @returns the scene or null if undefined
  93672. */
  93673. getScene(): Nullable<Scene>;
  93674. /**
  93675. * Get the texture transform matrix used to offset tile the texture for istance.
  93676. * @returns the transformation matrix
  93677. */
  93678. getTextureMatrix(): Matrix;
  93679. /**
  93680. * Get the texture reflection matrix used to rotate/transform the reflection.
  93681. * @returns the reflection matrix
  93682. */
  93683. getReflectionTextureMatrix(): Matrix;
  93684. /**
  93685. * Get the underlying lower level texture from Babylon.
  93686. * @returns the insternal texture
  93687. */
  93688. getInternalTexture(): Nullable<InternalTexture>;
  93689. /**
  93690. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  93691. * @returns true if ready or not blocking
  93692. */
  93693. isReadyOrNotBlocking(): boolean;
  93694. /**
  93695. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  93696. * @returns true if fully ready
  93697. */
  93698. isReady(): boolean;
  93699. private _cachedSize;
  93700. /**
  93701. * Get the size of the texture.
  93702. * @returns the texture size.
  93703. */
  93704. getSize(): ISize;
  93705. /**
  93706. * Get the base size of the texture.
  93707. * It can be different from the size if the texture has been resized for POT for instance
  93708. * @returns the base size
  93709. */
  93710. getBaseSize(): ISize;
  93711. /**
  93712. * Update the sampling mode of the texture.
  93713. * Default is Trilinear mode.
  93714. *
  93715. * | Value | Type | Description |
  93716. * | ----- | ------------------ | ----------- |
  93717. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  93718. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  93719. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  93720. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  93721. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  93722. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  93723. * | 7 | NEAREST_LINEAR | |
  93724. * | 8 | NEAREST_NEAREST | |
  93725. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  93726. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  93727. * | 11 | LINEAR_LINEAR | |
  93728. * | 12 | LINEAR_NEAREST | |
  93729. *
  93730. * > _mag_: magnification filter (close to the viewer)
  93731. * > _min_: minification filter (far from the viewer)
  93732. * > _mip_: filter used between mip map levels
  93733. *@param samplingMode Define the new sampling mode of the texture
  93734. */
  93735. updateSamplingMode(samplingMode: number): void;
  93736. /**
  93737. * Scales the texture if is `canRescale()`
  93738. * @param ratio the resize factor we want to use to rescale
  93739. */
  93740. scale(ratio: number): void;
  93741. /**
  93742. * Get if the texture can rescale.
  93743. */
  93744. readonly canRescale: boolean;
  93745. /** @hidden */
  93746. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  93747. /** @hidden */
  93748. _rebuild(): void;
  93749. /**
  93750. * Triggers the load sequence in delayed load mode.
  93751. */
  93752. delayLoad(): void;
  93753. /**
  93754. * Clones the texture.
  93755. * @returns the cloned texture
  93756. */
  93757. clone(): Nullable<BaseTexture>;
  93758. /**
  93759. * Get the texture underlying type (INT, FLOAT...)
  93760. */
  93761. readonly textureType: number;
  93762. /**
  93763. * Get the texture underlying format (RGB, RGBA...)
  93764. */
  93765. readonly textureFormat: number;
  93766. /**
  93767. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  93768. * This will returns an RGBA array buffer containing either in values (0-255) or
  93769. * float values (0-1) depending of the underlying buffer type.
  93770. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  93771. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  93772. * @param buffer defines a user defined buffer to fill with data (can be null)
  93773. * @returns The Array buffer containing the pixels data.
  93774. */
  93775. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  93776. /**
  93777. * Release and destroy the underlying lower level texture aka internalTexture.
  93778. */
  93779. releaseInternalTexture(): void;
  93780. /**
  93781. * Get the polynomial representation of the texture data.
  93782. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  93783. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  93784. */
  93785. sphericalPolynomial: Nullable<SphericalPolynomial>;
  93786. /** @hidden */
  93787. readonly _lodTextureHigh: Nullable<BaseTexture>;
  93788. /** @hidden */
  93789. readonly _lodTextureMid: Nullable<BaseTexture>;
  93790. /** @hidden */
  93791. readonly _lodTextureLow: Nullable<BaseTexture>;
  93792. /**
  93793. * Dispose the texture and release its associated resources.
  93794. */
  93795. dispose(): void;
  93796. /**
  93797. * Serialize the texture into a JSON representation that can be parsed later on.
  93798. * @returns the JSON representation of the texture
  93799. */
  93800. serialize(): any;
  93801. /**
  93802. * Helper function to be called back once a list of texture contains only ready textures.
  93803. * @param textures Define the list of textures to wait for
  93804. * @param callback Define the callback triggered once the entire list will be ready
  93805. */
  93806. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  93807. }
  93808. }
  93809. declare module BABYLON {
  93810. /**
  93811. * Class used to store data associated with WebGL texture data for the engine
  93812. * This class should not be used directly
  93813. */
  93814. export class InternalTexture {
  93815. /** @hidden */
  93816. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  93817. /**
  93818. * The source of the texture data is unknown
  93819. */
  93820. static DATASOURCE_UNKNOWN: number;
  93821. /**
  93822. * Texture data comes from an URL
  93823. */
  93824. static DATASOURCE_URL: number;
  93825. /**
  93826. * Texture data is only used for temporary storage
  93827. */
  93828. static DATASOURCE_TEMP: number;
  93829. /**
  93830. * Texture data comes from raw data (ArrayBuffer)
  93831. */
  93832. static DATASOURCE_RAW: number;
  93833. /**
  93834. * Texture content is dynamic (video or dynamic texture)
  93835. */
  93836. static DATASOURCE_DYNAMIC: number;
  93837. /**
  93838. * Texture content is generated by rendering to it
  93839. */
  93840. static DATASOURCE_RENDERTARGET: number;
  93841. /**
  93842. * Texture content is part of a multi render target process
  93843. */
  93844. static DATASOURCE_MULTIRENDERTARGET: number;
  93845. /**
  93846. * Texture data comes from a cube data file
  93847. */
  93848. static DATASOURCE_CUBE: number;
  93849. /**
  93850. * Texture data comes from a raw cube data
  93851. */
  93852. static DATASOURCE_CUBERAW: number;
  93853. /**
  93854. * Texture data come from a prefiltered cube data file
  93855. */
  93856. static DATASOURCE_CUBEPREFILTERED: number;
  93857. /**
  93858. * Texture content is raw 3D data
  93859. */
  93860. static DATASOURCE_RAW3D: number;
  93861. /**
  93862. * Texture content is a depth texture
  93863. */
  93864. static DATASOURCE_DEPTHTEXTURE: number;
  93865. /**
  93866. * Texture data comes from a raw cube data encoded with RGBD
  93867. */
  93868. static DATASOURCE_CUBERAW_RGBD: number;
  93869. /**
  93870. * Defines if the texture is ready
  93871. */
  93872. isReady: boolean;
  93873. /**
  93874. * Defines if the texture is a cube texture
  93875. */
  93876. isCube: boolean;
  93877. /**
  93878. * Defines if the texture contains 3D data
  93879. */
  93880. is3D: boolean;
  93881. /**
  93882. * Defines if the texture contains multiview data
  93883. */
  93884. isMultiview: boolean;
  93885. /**
  93886. * Gets the URL used to load this texture
  93887. */
  93888. url: string;
  93889. /**
  93890. * Gets the sampling mode of the texture
  93891. */
  93892. samplingMode: number;
  93893. /**
  93894. * Gets a boolean indicating if the texture needs mipmaps generation
  93895. */
  93896. generateMipMaps: boolean;
  93897. /**
  93898. * Gets the number of samples used by the texture (WebGL2+ only)
  93899. */
  93900. samples: number;
  93901. /**
  93902. * Gets the type of the texture (int, float...)
  93903. */
  93904. type: number;
  93905. /**
  93906. * Gets the format of the texture (RGB, RGBA...)
  93907. */
  93908. format: number;
  93909. /**
  93910. * Observable called when the texture is loaded
  93911. */
  93912. onLoadedObservable: Observable<InternalTexture>;
  93913. /**
  93914. * Gets the width of the texture
  93915. */
  93916. width: number;
  93917. /**
  93918. * Gets the height of the texture
  93919. */
  93920. height: number;
  93921. /**
  93922. * Gets the depth of the texture
  93923. */
  93924. depth: number;
  93925. /**
  93926. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  93927. */
  93928. baseWidth: number;
  93929. /**
  93930. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  93931. */
  93932. baseHeight: number;
  93933. /**
  93934. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  93935. */
  93936. baseDepth: number;
  93937. /**
  93938. * Gets a boolean indicating if the texture is inverted on Y axis
  93939. */
  93940. invertY: boolean;
  93941. /** @hidden */
  93942. _invertVScale: boolean;
  93943. /** @hidden */
  93944. _associatedChannel: number;
  93945. /** @hidden */
  93946. _dataSource: number;
  93947. /** @hidden */
  93948. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  93949. /** @hidden */
  93950. _bufferView: Nullable<ArrayBufferView>;
  93951. /** @hidden */
  93952. _bufferViewArray: Nullable<ArrayBufferView[]>;
  93953. /** @hidden */
  93954. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  93955. /** @hidden */
  93956. _size: number;
  93957. /** @hidden */
  93958. _extension: string;
  93959. /** @hidden */
  93960. _files: Nullable<string[]>;
  93961. /** @hidden */
  93962. _workingCanvas: Nullable<HTMLCanvasElement>;
  93963. /** @hidden */
  93964. _workingContext: Nullable<CanvasRenderingContext2D>;
  93965. /** @hidden */
  93966. _framebuffer: Nullable<WebGLFramebuffer>;
  93967. /** @hidden */
  93968. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  93969. /** @hidden */
  93970. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  93971. /** @hidden */
  93972. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  93973. /** @hidden */
  93974. _attachments: Nullable<number[]>;
  93975. /** @hidden */
  93976. _cachedCoordinatesMode: Nullable<number>;
  93977. /** @hidden */
  93978. _cachedWrapU: Nullable<number>;
  93979. /** @hidden */
  93980. _cachedWrapV: Nullable<number>;
  93981. /** @hidden */
  93982. _cachedWrapR: Nullable<number>;
  93983. /** @hidden */
  93984. _cachedAnisotropicFilteringLevel: Nullable<number>;
  93985. /** @hidden */
  93986. _isDisabled: boolean;
  93987. /** @hidden */
  93988. _compression: Nullable<string>;
  93989. /** @hidden */
  93990. _generateStencilBuffer: boolean;
  93991. /** @hidden */
  93992. _generateDepthBuffer: boolean;
  93993. /** @hidden */
  93994. _comparisonFunction: number;
  93995. /** @hidden */
  93996. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  93997. /** @hidden */
  93998. _lodGenerationScale: number;
  93999. /** @hidden */
  94000. _lodGenerationOffset: number;
  94001. /** @hidden */
  94002. _colorTextureArray: Nullable<WebGLTexture>;
  94003. /** @hidden */
  94004. _depthStencilTextureArray: Nullable<WebGLTexture>;
  94005. /** @hidden */
  94006. _lodTextureHigh: Nullable<BaseTexture>;
  94007. /** @hidden */
  94008. _lodTextureMid: Nullable<BaseTexture>;
  94009. /** @hidden */
  94010. _lodTextureLow: Nullable<BaseTexture>;
  94011. /** @hidden */
  94012. _isRGBD: boolean;
  94013. /** @hidden */
  94014. _linearSpecularLOD: boolean;
  94015. /** @hidden */
  94016. _irradianceTexture: Nullable<BaseTexture>;
  94017. /** @hidden */
  94018. _webGLTexture: Nullable<WebGLTexture>;
  94019. /** @hidden */
  94020. _references: number;
  94021. private _engine;
  94022. /**
  94023. * Gets the Engine the texture belongs to.
  94024. * @returns The babylon engine
  94025. */
  94026. getEngine(): Engine;
  94027. /**
  94028. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  94029. */
  94030. readonly dataSource: number;
  94031. /**
  94032. * Creates a new InternalTexture
  94033. * @param engine defines the engine to use
  94034. * @param dataSource defines the type of data that will be used
  94035. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94036. */
  94037. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  94038. /**
  94039. * Increments the number of references (ie. the number of Texture that point to it)
  94040. */
  94041. incrementReferences(): void;
  94042. /**
  94043. * Change the size of the texture (not the size of the content)
  94044. * @param width defines the new width
  94045. * @param height defines the new height
  94046. * @param depth defines the new depth (1 by default)
  94047. */
  94048. updateSize(width: int, height: int, depth?: int): void;
  94049. /** @hidden */
  94050. _rebuild(): void;
  94051. /** @hidden */
  94052. _swapAndDie(target: InternalTexture): void;
  94053. /**
  94054. * Dispose the current allocated resources
  94055. */
  94056. dispose(): void;
  94057. }
  94058. }
  94059. declare module BABYLON {
  94060. /**
  94061. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  94062. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  94063. */
  94064. export class EffectFallbacks {
  94065. private _defines;
  94066. private _currentRank;
  94067. private _maxRank;
  94068. private _mesh;
  94069. /**
  94070. * Removes the fallback from the bound mesh.
  94071. */
  94072. unBindMesh(): void;
  94073. /**
  94074. * Adds a fallback on the specified property.
  94075. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94076. * @param define The name of the define in the shader
  94077. */
  94078. addFallback(rank: number, define: string): void;
  94079. /**
  94080. * Sets the mesh to use CPU skinning when needing to fallback.
  94081. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94082. * @param mesh The mesh to use the fallbacks.
  94083. */
  94084. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  94085. /**
  94086. * Checks to see if more fallbacks are still availible.
  94087. */
  94088. readonly hasMoreFallbacks: boolean;
  94089. /**
  94090. * Removes the defines that should be removed when falling back.
  94091. * @param currentDefines defines the current define statements for the shader.
  94092. * @param effect defines the current effect we try to compile
  94093. * @returns The resulting defines with defines of the current rank removed.
  94094. */
  94095. reduce(currentDefines: string, effect: Effect): string;
  94096. }
  94097. /**
  94098. * Options to be used when creating an effect.
  94099. */
  94100. export class EffectCreationOptions {
  94101. /**
  94102. * Atrributes that will be used in the shader.
  94103. */
  94104. attributes: string[];
  94105. /**
  94106. * Uniform varible names that will be set in the shader.
  94107. */
  94108. uniformsNames: string[];
  94109. /**
  94110. * Uniform buffer varible names that will be set in the shader.
  94111. */
  94112. uniformBuffersNames: string[];
  94113. /**
  94114. * Sampler texture variable names that will be set in the shader.
  94115. */
  94116. samplers: string[];
  94117. /**
  94118. * Define statements that will be set in the shader.
  94119. */
  94120. defines: any;
  94121. /**
  94122. * Possible fallbacks for this effect to improve performance when needed.
  94123. */
  94124. fallbacks: Nullable<EffectFallbacks>;
  94125. /**
  94126. * Callback that will be called when the shader is compiled.
  94127. */
  94128. onCompiled: Nullable<(effect: Effect) => void>;
  94129. /**
  94130. * Callback that will be called if an error occurs during shader compilation.
  94131. */
  94132. onError: Nullable<(effect: Effect, errors: string) => void>;
  94133. /**
  94134. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94135. */
  94136. indexParameters: any;
  94137. /**
  94138. * Max number of lights that can be used in the shader.
  94139. */
  94140. maxSimultaneousLights: number;
  94141. /**
  94142. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94143. */
  94144. transformFeedbackVaryings: Nullable<string[]>;
  94145. }
  94146. /**
  94147. * Effect containing vertex and fragment shader that can be executed on an object.
  94148. */
  94149. export class Effect implements IDisposable {
  94150. /**
  94151. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94152. */
  94153. static ShadersRepository: string;
  94154. /**
  94155. * Name of the effect.
  94156. */
  94157. name: any;
  94158. /**
  94159. * String container all the define statements that should be set on the shader.
  94160. */
  94161. defines: string;
  94162. /**
  94163. * Callback that will be called when the shader is compiled.
  94164. */
  94165. onCompiled: Nullable<(effect: Effect) => void>;
  94166. /**
  94167. * Callback that will be called if an error occurs during shader compilation.
  94168. */
  94169. onError: Nullable<(effect: Effect, errors: string) => void>;
  94170. /**
  94171. * Callback that will be called when effect is bound.
  94172. */
  94173. onBind: Nullable<(effect: Effect) => void>;
  94174. /**
  94175. * Unique ID of the effect.
  94176. */
  94177. uniqueId: number;
  94178. /**
  94179. * Observable that will be called when the shader is compiled.
  94180. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94181. */
  94182. onCompileObservable: Observable<Effect>;
  94183. /**
  94184. * Observable that will be called if an error occurs during shader compilation.
  94185. */
  94186. onErrorObservable: Observable<Effect>;
  94187. /** @hidden */
  94188. _onBindObservable: Nullable<Observable<Effect>>;
  94189. /**
  94190. * Observable that will be called when effect is bound.
  94191. */
  94192. readonly onBindObservable: Observable<Effect>;
  94193. /** @hidden */
  94194. _bonesComputationForcedToCPU: boolean;
  94195. private static _uniqueIdSeed;
  94196. private _engine;
  94197. private _uniformBuffersNames;
  94198. private _uniformsNames;
  94199. private _samplerList;
  94200. private _samplers;
  94201. private _isReady;
  94202. private _compilationError;
  94203. private _attributesNames;
  94204. private _attributes;
  94205. private _uniforms;
  94206. /**
  94207. * Key for the effect.
  94208. * @hidden
  94209. */
  94210. _key: string;
  94211. private _indexParameters;
  94212. private _fallbacks;
  94213. private _vertexSourceCode;
  94214. private _fragmentSourceCode;
  94215. private _vertexSourceCodeOverride;
  94216. private _fragmentSourceCodeOverride;
  94217. private _transformFeedbackVaryings;
  94218. /**
  94219. * Compiled shader to webGL program.
  94220. * @hidden
  94221. */
  94222. _pipelineContext: Nullable<IPipelineContext>;
  94223. private _valueCache;
  94224. private static _baseCache;
  94225. /**
  94226. * Instantiates an effect.
  94227. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94228. * @param baseName Name of the effect.
  94229. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94230. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94231. * @param samplers List of sampler variables that will be passed to the shader.
  94232. * @param engine Engine to be used to render the effect
  94233. * @param defines Define statements to be added to the shader.
  94234. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94235. * @param onCompiled Callback that will be called when the shader is compiled.
  94236. * @param onError Callback that will be called if an error occurs during shader compilation.
  94237. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94238. */
  94239. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  94240. private _useFinalCode;
  94241. /**
  94242. * Unique key for this effect
  94243. */
  94244. readonly key: string;
  94245. /**
  94246. * If the effect has been compiled and prepared.
  94247. * @returns if the effect is compiled and prepared.
  94248. */
  94249. isReady(): boolean;
  94250. private _isReadyInternal;
  94251. /**
  94252. * The engine the effect was initialized with.
  94253. * @returns the engine.
  94254. */
  94255. getEngine(): Engine;
  94256. /**
  94257. * The pipeline context for this effect
  94258. * @returns the associated pipeline context
  94259. */
  94260. getPipelineContext(): Nullable<IPipelineContext>;
  94261. /**
  94262. * The set of names of attribute variables for the shader.
  94263. * @returns An array of attribute names.
  94264. */
  94265. getAttributesNames(): string[];
  94266. /**
  94267. * Returns the attribute at the given index.
  94268. * @param index The index of the attribute.
  94269. * @returns The location of the attribute.
  94270. */
  94271. getAttributeLocation(index: number): number;
  94272. /**
  94273. * Returns the attribute based on the name of the variable.
  94274. * @param name of the attribute to look up.
  94275. * @returns the attribute location.
  94276. */
  94277. getAttributeLocationByName(name: string): number;
  94278. /**
  94279. * The number of attributes.
  94280. * @returns the numnber of attributes.
  94281. */
  94282. getAttributesCount(): number;
  94283. /**
  94284. * Gets the index of a uniform variable.
  94285. * @param uniformName of the uniform to look up.
  94286. * @returns the index.
  94287. */
  94288. getUniformIndex(uniformName: string): number;
  94289. /**
  94290. * Returns the attribute based on the name of the variable.
  94291. * @param uniformName of the uniform to look up.
  94292. * @returns the location of the uniform.
  94293. */
  94294. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94295. /**
  94296. * Returns an array of sampler variable names
  94297. * @returns The array of sampler variable neames.
  94298. */
  94299. getSamplers(): string[];
  94300. /**
  94301. * The error from the last compilation.
  94302. * @returns the error string.
  94303. */
  94304. getCompilationError(): string;
  94305. /**
  94306. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94307. * @param func The callback to be used.
  94308. */
  94309. executeWhenCompiled(func: (effect: Effect) => void): void;
  94310. private _checkIsReady;
  94311. /** @hidden */
  94312. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  94313. /** @hidden */
  94314. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  94315. /** @hidden */
  94316. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  94317. /**
  94318. * Recompiles the webGL program
  94319. * @param vertexSourceCode The source code for the vertex shader.
  94320. * @param fragmentSourceCode The source code for the fragment shader.
  94321. * @param onCompiled Callback called when completed.
  94322. * @param onError Callback called on error.
  94323. * @hidden
  94324. */
  94325. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94326. /**
  94327. * Prepares the effect
  94328. * @hidden
  94329. */
  94330. _prepareEffect(): void;
  94331. private _processCompilationErrors;
  94332. /**
  94333. * Checks if the effect is supported. (Must be called after compilation)
  94334. */
  94335. readonly isSupported: boolean;
  94336. /**
  94337. * Binds a texture to the engine to be used as output of the shader.
  94338. * @param channel Name of the output variable.
  94339. * @param texture Texture to bind.
  94340. * @hidden
  94341. */
  94342. _bindTexture(channel: string, texture: InternalTexture): void;
  94343. /**
  94344. * Sets a texture on the engine to be used in the shader.
  94345. * @param channel Name of the sampler variable.
  94346. * @param texture Texture to set.
  94347. */
  94348. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  94349. /**
  94350. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  94351. * @param channel Name of the sampler variable.
  94352. * @param texture Texture to set.
  94353. */
  94354. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  94355. /**
  94356. * Sets an array of textures on the engine to be used in the shader.
  94357. * @param channel Name of the variable.
  94358. * @param textures Textures to set.
  94359. */
  94360. setTextureArray(channel: string, textures: BaseTexture[]): void;
  94361. /**
  94362. * 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)
  94363. * @param channel Name of the sampler variable.
  94364. * @param postProcess Post process to get the input texture from.
  94365. */
  94366. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  94367. /**
  94368. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  94369. * 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)
  94370. * @param channel Name of the sampler variable.
  94371. * @param postProcess Post process to get the output texture from.
  94372. */
  94373. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  94374. /** @hidden */
  94375. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  94376. /** @hidden */
  94377. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  94378. /** @hidden */
  94379. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  94380. /** @hidden */
  94381. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  94382. /**
  94383. * Binds a buffer to a uniform.
  94384. * @param buffer Buffer to bind.
  94385. * @param name Name of the uniform variable to bind to.
  94386. */
  94387. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  94388. /**
  94389. * Binds block to a uniform.
  94390. * @param blockName Name of the block to bind.
  94391. * @param index Index to bind.
  94392. */
  94393. bindUniformBlock(blockName: string, index: number): void;
  94394. /**
  94395. * Sets an interger value on a uniform variable.
  94396. * @param uniformName Name of the variable.
  94397. * @param value Value to be set.
  94398. * @returns this effect.
  94399. */
  94400. setInt(uniformName: string, value: number): Effect;
  94401. /**
  94402. * Sets an int array on a uniform variable.
  94403. * @param uniformName Name of the variable.
  94404. * @param array array to be set.
  94405. * @returns this effect.
  94406. */
  94407. setIntArray(uniformName: string, array: Int32Array): Effect;
  94408. /**
  94409. * 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)
  94410. * @param uniformName Name of the variable.
  94411. * @param array array to be set.
  94412. * @returns this effect.
  94413. */
  94414. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94415. /**
  94416. * 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)
  94417. * @param uniformName Name of the variable.
  94418. * @param array array to be set.
  94419. * @returns this effect.
  94420. */
  94421. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94422. /**
  94423. * 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)
  94424. * @param uniformName Name of the variable.
  94425. * @param array array to be set.
  94426. * @returns this effect.
  94427. */
  94428. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94429. /**
  94430. * Sets an float array on a uniform variable.
  94431. * @param uniformName Name of the variable.
  94432. * @param array array to be set.
  94433. * @returns this effect.
  94434. */
  94435. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94436. /**
  94437. * 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)
  94438. * @param uniformName Name of the variable.
  94439. * @param array array to be set.
  94440. * @returns this effect.
  94441. */
  94442. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94443. /**
  94444. * 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)
  94445. * @param uniformName Name of the variable.
  94446. * @param array array to be set.
  94447. * @returns this effect.
  94448. */
  94449. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94450. /**
  94451. * 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)
  94452. * @param uniformName Name of the variable.
  94453. * @param array array to be set.
  94454. * @returns this effect.
  94455. */
  94456. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94457. /**
  94458. * Sets an array on a uniform variable.
  94459. * @param uniformName Name of the variable.
  94460. * @param array array to be set.
  94461. * @returns this effect.
  94462. */
  94463. setArray(uniformName: string, array: number[]): Effect;
  94464. /**
  94465. * 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)
  94466. * @param uniformName Name of the variable.
  94467. * @param array array to be set.
  94468. * @returns this effect.
  94469. */
  94470. setArray2(uniformName: string, array: number[]): Effect;
  94471. /**
  94472. * 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)
  94473. * @param uniformName Name of the variable.
  94474. * @param array array to be set.
  94475. * @returns this effect.
  94476. */
  94477. setArray3(uniformName: string, array: number[]): Effect;
  94478. /**
  94479. * 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)
  94480. * @param uniformName Name of the variable.
  94481. * @param array array to be set.
  94482. * @returns this effect.
  94483. */
  94484. setArray4(uniformName: string, array: number[]): Effect;
  94485. /**
  94486. * Sets matrices on a uniform variable.
  94487. * @param uniformName Name of the variable.
  94488. * @param matrices matrices to be set.
  94489. * @returns this effect.
  94490. */
  94491. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94492. /**
  94493. * Sets matrix on a uniform variable.
  94494. * @param uniformName Name of the variable.
  94495. * @param matrix matrix to be set.
  94496. * @returns this effect.
  94497. */
  94498. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94499. /**
  94500. * 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)
  94501. * @param uniformName Name of the variable.
  94502. * @param matrix matrix to be set.
  94503. * @returns this effect.
  94504. */
  94505. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94506. /**
  94507. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94508. * @param uniformName Name of the variable.
  94509. * @param matrix matrix to be set.
  94510. * @returns this effect.
  94511. */
  94512. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94513. /**
  94514. * Sets a float on a uniform variable.
  94515. * @param uniformName Name of the variable.
  94516. * @param value value to be set.
  94517. * @returns this effect.
  94518. */
  94519. setFloat(uniformName: string, value: number): Effect;
  94520. /**
  94521. * Sets a boolean on a uniform variable.
  94522. * @param uniformName Name of the variable.
  94523. * @param bool value to be set.
  94524. * @returns this effect.
  94525. */
  94526. setBool(uniformName: string, bool: boolean): Effect;
  94527. /**
  94528. * Sets a Vector2 on a uniform variable.
  94529. * @param uniformName Name of the variable.
  94530. * @param vector2 vector2 to be set.
  94531. * @returns this effect.
  94532. */
  94533. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  94534. /**
  94535. * Sets a float2 on a uniform variable.
  94536. * @param uniformName Name of the variable.
  94537. * @param x First float in float2.
  94538. * @param y Second float in float2.
  94539. * @returns this effect.
  94540. */
  94541. setFloat2(uniformName: string, x: number, y: number): Effect;
  94542. /**
  94543. * Sets a Vector3 on a uniform variable.
  94544. * @param uniformName Name of the variable.
  94545. * @param vector3 Value to be set.
  94546. * @returns this effect.
  94547. */
  94548. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  94549. /**
  94550. * Sets a float3 on a uniform variable.
  94551. * @param uniformName Name of the variable.
  94552. * @param x First float in float3.
  94553. * @param y Second float in float3.
  94554. * @param z Third float in float3.
  94555. * @returns this effect.
  94556. */
  94557. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  94558. /**
  94559. * Sets a Vector4 on a uniform variable.
  94560. * @param uniformName Name of the variable.
  94561. * @param vector4 Value to be set.
  94562. * @returns this effect.
  94563. */
  94564. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  94565. /**
  94566. * Sets a float4 on a uniform variable.
  94567. * @param uniformName Name of the variable.
  94568. * @param x First float in float4.
  94569. * @param y Second float in float4.
  94570. * @param z Third float in float4.
  94571. * @param w Fourth float in float4.
  94572. * @returns this effect.
  94573. */
  94574. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  94575. /**
  94576. * Sets a Color3 on a uniform variable.
  94577. * @param uniformName Name of the variable.
  94578. * @param color3 Value to be set.
  94579. * @returns this effect.
  94580. */
  94581. setColor3(uniformName: string, color3: IColor3Like): Effect;
  94582. /**
  94583. * Sets a Color4 on a uniform variable.
  94584. * @param uniformName Name of the variable.
  94585. * @param color3 Value to be set.
  94586. * @param alpha Alpha value to be set.
  94587. * @returns this effect.
  94588. */
  94589. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  94590. /**
  94591. * Sets a Color4 on a uniform variable
  94592. * @param uniformName defines the name of the variable
  94593. * @param color4 defines the value to be set
  94594. * @returns this effect.
  94595. */
  94596. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  94597. /** Release all associated resources */
  94598. dispose(): void;
  94599. /**
  94600. * This function will add a new shader to the shader store
  94601. * @param name the name of the shader
  94602. * @param pixelShader optional pixel shader content
  94603. * @param vertexShader optional vertex shader content
  94604. */
  94605. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  94606. /**
  94607. * Store of each shader (The can be looked up using effect.key)
  94608. */
  94609. static ShadersStore: {
  94610. [key: string]: string;
  94611. };
  94612. /**
  94613. * Store of each included file for a shader (The can be looked up using effect.key)
  94614. */
  94615. static IncludesShadersStore: {
  94616. [key: string]: string;
  94617. };
  94618. /**
  94619. * Resets the cache of effects.
  94620. */
  94621. static ResetCache(): void;
  94622. }
  94623. }
  94624. declare module BABYLON {
  94625. /**
  94626. * Uniform buffer objects.
  94627. *
  94628. * Handles blocks of uniform on the GPU.
  94629. *
  94630. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94631. *
  94632. * For more information, please refer to :
  94633. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94634. */
  94635. export class UniformBuffer {
  94636. private _engine;
  94637. private _buffer;
  94638. private _data;
  94639. private _bufferData;
  94640. private _dynamic?;
  94641. private _uniformLocations;
  94642. private _uniformSizes;
  94643. private _uniformLocationPointer;
  94644. private _needSync;
  94645. private _noUBO;
  94646. private _currentEffect;
  94647. private static _MAX_UNIFORM_SIZE;
  94648. private static _tempBuffer;
  94649. /**
  94650. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  94651. * This is dynamic to allow compat with webgl 1 and 2.
  94652. * You will need to pass the name of the uniform as well as the value.
  94653. */
  94654. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  94655. /**
  94656. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  94657. * This is dynamic to allow compat with webgl 1 and 2.
  94658. * You will need to pass the name of the uniform as well as the value.
  94659. */
  94660. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  94661. /**
  94662. * Lambda to Update a single float in a uniform buffer.
  94663. * This is dynamic to allow compat with webgl 1 and 2.
  94664. * You will need to pass the name of the uniform as well as the value.
  94665. */
  94666. updateFloat: (name: string, x: number) => void;
  94667. /**
  94668. * Lambda to Update a vec2 of float in a uniform buffer.
  94669. * This is dynamic to allow compat with webgl 1 and 2.
  94670. * You will need to pass the name of the uniform as well as the value.
  94671. */
  94672. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  94673. /**
  94674. * Lambda to Update a vec3 of float in a uniform buffer.
  94675. * This is dynamic to allow compat with webgl 1 and 2.
  94676. * You will need to pass the name of the uniform as well as the value.
  94677. */
  94678. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  94679. /**
  94680. * Lambda to Update a vec4 of float in a uniform buffer.
  94681. * This is dynamic to allow compat with webgl 1 and 2.
  94682. * You will need to pass the name of the uniform as well as the value.
  94683. */
  94684. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  94685. /**
  94686. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  94687. * This is dynamic to allow compat with webgl 1 and 2.
  94688. * You will need to pass the name of the uniform as well as the value.
  94689. */
  94690. updateMatrix: (name: string, mat: Matrix) => void;
  94691. /**
  94692. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  94693. * This is dynamic to allow compat with webgl 1 and 2.
  94694. * You will need to pass the name of the uniform as well as the value.
  94695. */
  94696. updateVector3: (name: string, vector: Vector3) => void;
  94697. /**
  94698. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  94699. * This is dynamic to allow compat with webgl 1 and 2.
  94700. * You will need to pass the name of the uniform as well as the value.
  94701. */
  94702. updateVector4: (name: string, vector: Vector4) => void;
  94703. /**
  94704. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  94705. * This is dynamic to allow compat with webgl 1 and 2.
  94706. * You will need to pass the name of the uniform as well as the value.
  94707. */
  94708. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  94709. /**
  94710. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  94711. * This is dynamic to allow compat with webgl 1 and 2.
  94712. * You will need to pass the name of the uniform as well as the value.
  94713. */
  94714. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  94715. /**
  94716. * Instantiates a new Uniform buffer objects.
  94717. *
  94718. * Handles blocks of uniform on the GPU.
  94719. *
  94720. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94721. *
  94722. * For more information, please refer to :
  94723. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94724. * @param engine Define the engine the buffer is associated with
  94725. * @param data Define the data contained in the buffer
  94726. * @param dynamic Define if the buffer is updatable
  94727. */
  94728. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  94729. /**
  94730. * Indicates if the buffer is using the WebGL2 UBO implementation,
  94731. * or just falling back on setUniformXXX calls.
  94732. */
  94733. readonly useUbo: boolean;
  94734. /**
  94735. * Indicates if the WebGL underlying uniform buffer is in sync
  94736. * with the javascript cache data.
  94737. */
  94738. readonly isSync: boolean;
  94739. /**
  94740. * Indicates if the WebGL underlying uniform buffer is dynamic.
  94741. * Also, a dynamic UniformBuffer will disable cache verification and always
  94742. * update the underlying WebGL uniform buffer to the GPU.
  94743. * @returns if Dynamic, otherwise false
  94744. */
  94745. isDynamic(): boolean;
  94746. /**
  94747. * The data cache on JS side.
  94748. * @returns the underlying data as a float array
  94749. */
  94750. getData(): Float32Array;
  94751. /**
  94752. * The underlying WebGL Uniform buffer.
  94753. * @returns the webgl buffer
  94754. */
  94755. getBuffer(): Nullable<DataBuffer>;
  94756. /**
  94757. * std140 layout specifies how to align data within an UBO structure.
  94758. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  94759. * for specs.
  94760. */
  94761. private _fillAlignment;
  94762. /**
  94763. * Adds an uniform in the buffer.
  94764. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  94765. * for the layout to be correct !
  94766. * @param name Name of the uniform, as used in the uniform block in the shader.
  94767. * @param size Data size, or data directly.
  94768. */
  94769. addUniform(name: string, size: number | number[]): void;
  94770. /**
  94771. * Adds a Matrix 4x4 to the uniform buffer.
  94772. * @param name Name of the uniform, as used in the uniform block in the shader.
  94773. * @param mat A 4x4 matrix.
  94774. */
  94775. addMatrix(name: string, mat: Matrix): void;
  94776. /**
  94777. * Adds a vec2 to the uniform buffer.
  94778. * @param name Name of the uniform, as used in the uniform block in the shader.
  94779. * @param x Define the x component value of the vec2
  94780. * @param y Define the y component value of the vec2
  94781. */
  94782. addFloat2(name: string, x: number, y: number): void;
  94783. /**
  94784. * Adds a vec3 to the uniform buffer.
  94785. * @param name Name of the uniform, as used in the uniform block in the shader.
  94786. * @param x Define the x component value of the vec3
  94787. * @param y Define the y component value of the vec3
  94788. * @param z Define the z component value of the vec3
  94789. */
  94790. addFloat3(name: string, x: number, y: number, z: number): void;
  94791. /**
  94792. * Adds a vec3 to the uniform buffer.
  94793. * @param name Name of the uniform, as used in the uniform block in the shader.
  94794. * @param color Define the vec3 from a Color
  94795. */
  94796. addColor3(name: string, color: Color3): void;
  94797. /**
  94798. * Adds a vec4 to the uniform buffer.
  94799. * @param name Name of the uniform, as used in the uniform block in the shader.
  94800. * @param color Define the rgb components from a Color
  94801. * @param alpha Define the a component of the vec4
  94802. */
  94803. addColor4(name: string, color: Color3, alpha: number): void;
  94804. /**
  94805. * Adds a vec3 to the uniform buffer.
  94806. * @param name Name of the uniform, as used in the uniform block in the shader.
  94807. * @param vector Define the vec3 components from a Vector
  94808. */
  94809. addVector3(name: string, vector: Vector3): void;
  94810. /**
  94811. * Adds a Matrix 3x3 to the uniform buffer.
  94812. * @param name Name of the uniform, as used in the uniform block in the shader.
  94813. */
  94814. addMatrix3x3(name: string): void;
  94815. /**
  94816. * Adds a Matrix 2x2 to the uniform buffer.
  94817. * @param name Name of the uniform, as used in the uniform block in the shader.
  94818. */
  94819. addMatrix2x2(name: string): void;
  94820. /**
  94821. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  94822. */
  94823. create(): void;
  94824. /** @hidden */
  94825. _rebuild(): void;
  94826. /**
  94827. * Updates the WebGL Uniform Buffer on the GPU.
  94828. * If the `dynamic` flag is set to true, no cache comparison is done.
  94829. * Otherwise, the buffer will be updated only if the cache differs.
  94830. */
  94831. update(): void;
  94832. /**
  94833. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94834. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94835. * @param data Define the flattened data
  94836. * @param size Define the size of the data.
  94837. */
  94838. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  94839. private _valueCache;
  94840. private _cacheMatrix;
  94841. private _updateMatrix3x3ForUniform;
  94842. private _updateMatrix3x3ForEffect;
  94843. private _updateMatrix2x2ForEffect;
  94844. private _updateMatrix2x2ForUniform;
  94845. private _updateFloatForEffect;
  94846. private _updateFloatForUniform;
  94847. private _updateFloat2ForEffect;
  94848. private _updateFloat2ForUniform;
  94849. private _updateFloat3ForEffect;
  94850. private _updateFloat3ForUniform;
  94851. private _updateFloat4ForEffect;
  94852. private _updateFloat4ForUniform;
  94853. private _updateMatrixForEffect;
  94854. private _updateMatrixForUniform;
  94855. private _updateVector3ForEffect;
  94856. private _updateVector3ForUniform;
  94857. private _updateVector4ForEffect;
  94858. private _updateVector4ForUniform;
  94859. private _updateColor3ForEffect;
  94860. private _updateColor3ForUniform;
  94861. private _updateColor4ForEffect;
  94862. private _updateColor4ForUniform;
  94863. /**
  94864. * Sets a sampler uniform on the effect.
  94865. * @param name Define the name of the sampler.
  94866. * @param texture Define the texture to set in the sampler
  94867. */
  94868. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  94869. /**
  94870. * Directly updates the value of the uniform in the cache AND on the GPU.
  94871. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94872. * @param data Define the flattened data
  94873. */
  94874. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  94875. /**
  94876. * Binds this uniform buffer to an effect.
  94877. * @param effect Define the effect to bind the buffer to
  94878. * @param name Name of the uniform block in the shader.
  94879. */
  94880. bindToEffect(effect: Effect, name: string): void;
  94881. /**
  94882. * Disposes the uniform buffer.
  94883. */
  94884. dispose(): void;
  94885. }
  94886. }
  94887. declare module BABYLON {
  94888. /**
  94889. * Class used to work with sound analyzer using fast fourier transform (FFT)
  94890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94891. */
  94892. export class Analyser {
  94893. /**
  94894. * Gets or sets the smoothing
  94895. * @ignorenaming
  94896. */
  94897. SMOOTHING: number;
  94898. /**
  94899. * Gets or sets the FFT table size
  94900. * @ignorenaming
  94901. */
  94902. FFT_SIZE: number;
  94903. /**
  94904. * Gets or sets the bar graph amplitude
  94905. * @ignorenaming
  94906. */
  94907. BARGRAPHAMPLITUDE: number;
  94908. /**
  94909. * Gets or sets the position of the debug canvas
  94910. * @ignorenaming
  94911. */
  94912. DEBUGCANVASPOS: {
  94913. x: number;
  94914. y: number;
  94915. };
  94916. /**
  94917. * Gets or sets the debug canvas size
  94918. * @ignorenaming
  94919. */
  94920. DEBUGCANVASSIZE: {
  94921. width: number;
  94922. height: number;
  94923. };
  94924. private _byteFreqs;
  94925. private _byteTime;
  94926. private _floatFreqs;
  94927. private _webAudioAnalyser;
  94928. private _debugCanvas;
  94929. private _debugCanvasContext;
  94930. private _scene;
  94931. private _registerFunc;
  94932. private _audioEngine;
  94933. /**
  94934. * Creates a new analyser
  94935. * @param scene defines hosting scene
  94936. */
  94937. constructor(scene: Scene);
  94938. /**
  94939. * Get the number of data values you will have to play with for the visualization
  94940. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  94941. * @returns a number
  94942. */
  94943. getFrequencyBinCount(): number;
  94944. /**
  94945. * Gets the current frequency data as a byte array
  94946. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94947. * @returns a Uint8Array
  94948. */
  94949. getByteFrequencyData(): Uint8Array;
  94950. /**
  94951. * Gets the current waveform as a byte array
  94952. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  94953. * @returns a Uint8Array
  94954. */
  94955. getByteTimeDomainData(): Uint8Array;
  94956. /**
  94957. * Gets the current frequency data as a float array
  94958. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94959. * @returns a Float32Array
  94960. */
  94961. getFloatFrequencyData(): Float32Array;
  94962. /**
  94963. * Renders the debug canvas
  94964. */
  94965. drawDebugCanvas(): void;
  94966. /**
  94967. * Stops rendering the debug canvas and removes it
  94968. */
  94969. stopDebugCanvas(): void;
  94970. /**
  94971. * Connects two audio nodes
  94972. * @param inputAudioNode defines first node to connect
  94973. * @param outputAudioNode defines second node to connect
  94974. */
  94975. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  94976. /**
  94977. * Releases all associated resources
  94978. */
  94979. dispose(): void;
  94980. }
  94981. }
  94982. declare module BABYLON {
  94983. /**
  94984. * This represents an audio engine and it is responsible
  94985. * to play, synchronize and analyse sounds throughout the application.
  94986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94987. */
  94988. export interface IAudioEngine extends IDisposable {
  94989. /**
  94990. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94991. */
  94992. readonly canUseWebAudio: boolean;
  94993. /**
  94994. * Gets the current AudioContext if available.
  94995. */
  94996. readonly audioContext: Nullable<AudioContext>;
  94997. /**
  94998. * The master gain node defines the global audio volume of your audio engine.
  94999. */
  95000. readonly masterGain: GainNode;
  95001. /**
  95002. * Gets whether or not mp3 are supported by your browser.
  95003. */
  95004. readonly isMP3supported: boolean;
  95005. /**
  95006. * Gets whether or not ogg are supported by your browser.
  95007. */
  95008. readonly isOGGsupported: boolean;
  95009. /**
  95010. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95011. * @ignoreNaming
  95012. */
  95013. WarnedWebAudioUnsupported: boolean;
  95014. /**
  95015. * Defines if the audio engine relies on a custom unlocked button.
  95016. * In this case, the embedded button will not be displayed.
  95017. */
  95018. useCustomUnlockedButton: boolean;
  95019. /**
  95020. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  95021. */
  95022. readonly unlocked: boolean;
  95023. /**
  95024. * Event raised when audio has been unlocked on the browser.
  95025. */
  95026. onAudioUnlockedObservable: Observable<AudioEngine>;
  95027. /**
  95028. * Event raised when audio has been locked on the browser.
  95029. */
  95030. onAudioLockedObservable: Observable<AudioEngine>;
  95031. /**
  95032. * Flags the audio engine in Locked state.
  95033. * This happens due to new browser policies preventing audio to autoplay.
  95034. */
  95035. lock(): void;
  95036. /**
  95037. * Unlocks the audio engine once a user action has been done on the dom.
  95038. * This is helpful to resume play once browser policies have been satisfied.
  95039. */
  95040. unlock(): void;
  95041. }
  95042. /**
  95043. * This represents the default audio engine used in babylon.
  95044. * It is responsible to play, synchronize and analyse sounds throughout the application.
  95045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95046. */
  95047. export class AudioEngine implements IAudioEngine {
  95048. private _audioContext;
  95049. private _audioContextInitialized;
  95050. private _muteButton;
  95051. private _hostElement;
  95052. /**
  95053. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  95054. */
  95055. canUseWebAudio: boolean;
  95056. /**
  95057. * The master gain node defines the global audio volume of your audio engine.
  95058. */
  95059. masterGain: GainNode;
  95060. /**
  95061. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95062. * @ignoreNaming
  95063. */
  95064. WarnedWebAudioUnsupported: boolean;
  95065. /**
  95066. * Gets whether or not mp3 are supported by your browser.
  95067. */
  95068. isMP3supported: boolean;
  95069. /**
  95070. * Gets whether or not ogg are supported by your browser.
  95071. */
  95072. isOGGsupported: boolean;
  95073. /**
  95074. * Gets whether audio has been unlocked on the device.
  95075. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  95076. * a user interaction has happened.
  95077. */
  95078. unlocked: boolean;
  95079. /**
  95080. * Defines if the audio engine relies on a custom unlocked button.
  95081. * In this case, the embedded button will not be displayed.
  95082. */
  95083. useCustomUnlockedButton: boolean;
  95084. /**
  95085. * Event raised when audio has been unlocked on the browser.
  95086. */
  95087. onAudioUnlockedObservable: Observable<AudioEngine>;
  95088. /**
  95089. * Event raised when audio has been locked on the browser.
  95090. */
  95091. onAudioLockedObservable: Observable<AudioEngine>;
  95092. /**
  95093. * Gets the current AudioContext if available.
  95094. */
  95095. readonly audioContext: Nullable<AudioContext>;
  95096. private _connectedAnalyser;
  95097. /**
  95098. * Instantiates a new audio engine.
  95099. *
  95100. * There should be only one per page as some browsers restrict the number
  95101. * of audio contexts you can create.
  95102. * @param hostElement defines the host element where to display the mute icon if necessary
  95103. */
  95104. constructor(hostElement?: Nullable<HTMLElement>);
  95105. /**
  95106. * Flags the audio engine in Locked state.
  95107. * This happens due to new browser policies preventing audio to autoplay.
  95108. */
  95109. lock(): void;
  95110. /**
  95111. * Unlocks the audio engine once a user action has been done on the dom.
  95112. * This is helpful to resume play once browser policies have been satisfied.
  95113. */
  95114. unlock(): void;
  95115. private _resumeAudioContext;
  95116. private _initializeAudioContext;
  95117. private _tryToRun;
  95118. private _triggerRunningState;
  95119. private _triggerSuspendedState;
  95120. private _displayMuteButton;
  95121. private _moveButtonToTopLeft;
  95122. private _onResize;
  95123. private _hideMuteButton;
  95124. /**
  95125. * Destroy and release the resources associated with the audio ccontext.
  95126. */
  95127. dispose(): void;
  95128. /**
  95129. * Gets the global volume sets on the master gain.
  95130. * @returns the global volume if set or -1 otherwise
  95131. */
  95132. getGlobalVolume(): number;
  95133. /**
  95134. * Sets the global volume of your experience (sets on the master gain).
  95135. * @param newVolume Defines the new global volume of the application
  95136. */
  95137. setGlobalVolume(newVolume: number): void;
  95138. /**
  95139. * Connect the audio engine to an audio analyser allowing some amazing
  95140. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  95141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  95142. * @param analyser The analyser to connect to the engine
  95143. */
  95144. connectToAnalyser(analyser: Analyser): void;
  95145. }
  95146. }
  95147. declare module BABYLON {
  95148. /**
  95149. * Interface used to present a loading screen while loading a scene
  95150. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95151. */
  95152. export interface ILoadingScreen {
  95153. /**
  95154. * Function called to display the loading screen
  95155. */
  95156. displayLoadingUI: () => void;
  95157. /**
  95158. * Function called to hide the loading screen
  95159. */
  95160. hideLoadingUI: () => void;
  95161. /**
  95162. * Gets or sets the color to use for the background
  95163. */
  95164. loadingUIBackgroundColor: string;
  95165. /**
  95166. * Gets or sets the text to display while loading
  95167. */
  95168. loadingUIText: string;
  95169. }
  95170. /**
  95171. * Class used for the default loading screen
  95172. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95173. */
  95174. export class DefaultLoadingScreen implements ILoadingScreen {
  95175. private _renderingCanvas;
  95176. private _loadingText;
  95177. private _loadingDivBackgroundColor;
  95178. private _loadingDiv;
  95179. private _loadingTextDiv;
  95180. /** Gets or sets the logo url to use for the default loading screen */
  95181. static DefaultLogoUrl: string;
  95182. /** Gets or sets the spinner url to use for the default loading screen */
  95183. static DefaultSpinnerUrl: string;
  95184. /**
  95185. * Creates a new default loading screen
  95186. * @param _renderingCanvas defines the canvas used to render the scene
  95187. * @param _loadingText defines the default text to display
  95188. * @param _loadingDivBackgroundColor defines the default background color
  95189. */
  95190. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  95191. /**
  95192. * Function called to display the loading screen
  95193. */
  95194. displayLoadingUI(): void;
  95195. /**
  95196. * Function called to hide the loading screen
  95197. */
  95198. hideLoadingUI(): void;
  95199. /**
  95200. * Gets or sets the text to display while loading
  95201. */
  95202. loadingUIText: string;
  95203. /**
  95204. * Gets or sets the color to use for the background
  95205. */
  95206. loadingUIBackgroundColor: string;
  95207. private _resizeLoadingUI;
  95208. }
  95209. }
  95210. declare module BABYLON {
  95211. /** @hidden */
  95212. export class WebGLPipelineContext implements IPipelineContext {
  95213. engine: Engine;
  95214. program: Nullable<WebGLProgram>;
  95215. context?: WebGLRenderingContext;
  95216. vertexShader?: WebGLShader;
  95217. fragmentShader?: WebGLShader;
  95218. isParallelCompiled: boolean;
  95219. onCompiled?: () => void;
  95220. transformFeedback?: WebGLTransformFeedback | null;
  95221. readonly isAsync: boolean;
  95222. readonly isReady: boolean;
  95223. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  95224. }
  95225. }
  95226. declare module BABYLON {
  95227. /** @hidden */
  95228. export class WebGLDataBuffer extends DataBuffer {
  95229. private _buffer;
  95230. constructor(resource: WebGLBuffer);
  95231. readonly underlyingResource: any;
  95232. }
  95233. }
  95234. declare module BABYLON {
  95235. /** @hidden */
  95236. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95237. attributeProcessor(attribute: string): string;
  95238. varyingProcessor(varying: string, isFragment: boolean): string;
  95239. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95240. }
  95241. }
  95242. declare module BABYLON {
  95243. /**
  95244. * This class is used to track a performance counter which is number based.
  95245. * The user has access to many properties which give statistics of different nature.
  95246. *
  95247. * The implementer can track two kinds of Performance Counter: time and count.
  95248. * 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.
  95249. * 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.
  95250. */
  95251. export class PerfCounter {
  95252. /**
  95253. * Gets or sets a global boolean to turn on and off all the counters
  95254. */
  95255. static Enabled: boolean;
  95256. /**
  95257. * Returns the smallest value ever
  95258. */
  95259. readonly min: number;
  95260. /**
  95261. * Returns the biggest value ever
  95262. */
  95263. readonly max: number;
  95264. /**
  95265. * Returns the average value since the performance counter is running
  95266. */
  95267. readonly average: number;
  95268. /**
  95269. * Returns the average value of the last second the counter was monitored
  95270. */
  95271. readonly lastSecAverage: number;
  95272. /**
  95273. * Returns the current value
  95274. */
  95275. readonly current: number;
  95276. /**
  95277. * Gets the accumulated total
  95278. */
  95279. readonly total: number;
  95280. /**
  95281. * Gets the total value count
  95282. */
  95283. readonly count: number;
  95284. /**
  95285. * Creates a new counter
  95286. */
  95287. constructor();
  95288. /**
  95289. * Call this method to start monitoring a new frame.
  95290. * 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.
  95291. */
  95292. fetchNewFrame(): void;
  95293. /**
  95294. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95295. * @param newCount the count value to add to the monitored count
  95296. * @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.
  95297. */
  95298. addCount(newCount: number, fetchResult: boolean): void;
  95299. /**
  95300. * Start monitoring this performance counter
  95301. */
  95302. beginMonitoring(): void;
  95303. /**
  95304. * Compute the time lapsed since the previous beginMonitoring() call.
  95305. * @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
  95306. */
  95307. endMonitoring(newFrame?: boolean): void;
  95308. private _fetchResult;
  95309. private _startMonitoringTime;
  95310. private _min;
  95311. private _max;
  95312. private _average;
  95313. private _current;
  95314. private _totalValueCount;
  95315. private _totalAccumulated;
  95316. private _lastSecAverage;
  95317. private _lastSecAccumulated;
  95318. private _lastSecTime;
  95319. private _lastSecValueCount;
  95320. }
  95321. }
  95322. declare module BABYLON {
  95323. /**
  95324. * Interface for any object that can request an animation frame
  95325. */
  95326. export interface ICustomAnimationFrameRequester {
  95327. /**
  95328. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  95329. */
  95330. renderFunction?: Function;
  95331. /**
  95332. * Called to request the next frame to render to
  95333. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  95334. */
  95335. requestAnimationFrame: Function;
  95336. /**
  95337. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  95338. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  95339. */
  95340. requestID?: number;
  95341. }
  95342. }
  95343. declare module BABYLON {
  95344. /**
  95345. * Settings for finer control over video usage
  95346. */
  95347. export interface VideoTextureSettings {
  95348. /**
  95349. * Applies `autoplay` to video, if specified
  95350. */
  95351. autoPlay?: boolean;
  95352. /**
  95353. * Applies `loop` to video, if specified
  95354. */
  95355. loop?: boolean;
  95356. /**
  95357. * Automatically updates internal texture from video at every frame in the render loop
  95358. */
  95359. autoUpdateTexture: boolean;
  95360. /**
  95361. * Image src displayed during the video loading or until the user interacts with the video.
  95362. */
  95363. poster?: string;
  95364. }
  95365. /**
  95366. * If you want to display a video in your scene, this is the special texture for that.
  95367. * This special texture works similar to other textures, with the exception of a few parameters.
  95368. * @see https://doc.babylonjs.com/how_to/video_texture
  95369. */
  95370. export class VideoTexture extends Texture {
  95371. /**
  95372. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95373. */
  95374. readonly autoUpdateTexture: boolean;
  95375. /**
  95376. * The video instance used by the texture internally
  95377. */
  95378. readonly video: HTMLVideoElement;
  95379. private _onUserActionRequestedObservable;
  95380. /**
  95381. * Event triggerd when a dom action is required by the user to play the video.
  95382. * This happens due to recent changes in browser policies preventing video to auto start.
  95383. */
  95384. readonly onUserActionRequestedObservable: Observable<Texture>;
  95385. private _generateMipMaps;
  95386. private _engine;
  95387. private _stillImageCaptured;
  95388. private _displayingPosterTexture;
  95389. private _settings;
  95390. private _createInternalTextureOnEvent;
  95391. private _frameId;
  95392. /**
  95393. * Creates a video texture.
  95394. * If you want to display a video in your scene, this is the special texture for that.
  95395. * This special texture works similar to other textures, with the exception of a few parameters.
  95396. * @see https://doc.babylonjs.com/how_to/video_texture
  95397. * @param name optional name, will detect from video source, if not defined
  95398. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95399. * @param scene is obviously the current scene.
  95400. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95401. * @param invertY is false by default but can be used to invert video on Y axis
  95402. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95403. * @param settings allows finer control over video usage
  95404. */
  95405. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95406. private _getName;
  95407. private _getVideo;
  95408. private _createInternalTexture;
  95409. private reset;
  95410. /**
  95411. * @hidden Internal method to initiate `update`.
  95412. */
  95413. _rebuild(): void;
  95414. /**
  95415. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95416. */
  95417. update(): void;
  95418. /**
  95419. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95420. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95421. */
  95422. updateTexture(isVisible: boolean): void;
  95423. protected _updateInternalTexture: () => void;
  95424. /**
  95425. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95426. * @param url New url.
  95427. */
  95428. updateURL(url: string): void;
  95429. /**
  95430. * Dispose the texture and release its associated resources.
  95431. */
  95432. dispose(): void;
  95433. /**
  95434. * Creates a video texture straight from a stream.
  95435. * @param scene Define the scene the texture should be created in
  95436. * @param stream Define the stream the texture should be created from
  95437. * @returns The created video texture as a promise
  95438. */
  95439. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95440. /**
  95441. * Creates a video texture straight from your WebCam video feed.
  95442. * @param scene Define the scene the texture should be created in
  95443. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95444. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95445. * @returns The created video texture as a promise
  95446. */
  95447. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95448. minWidth: number;
  95449. maxWidth: number;
  95450. minHeight: number;
  95451. maxHeight: number;
  95452. deviceId: string;
  95453. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95454. /**
  95455. * Creates a video texture straight from your WebCam video feed.
  95456. * @param scene Define the scene the texture should be created in
  95457. * @param onReady Define a callback to triggered once the texture will be ready
  95458. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95459. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95460. */
  95461. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95462. minWidth: number;
  95463. maxWidth: number;
  95464. minHeight: number;
  95465. maxHeight: number;
  95466. deviceId: string;
  95467. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95468. }
  95469. }
  95470. declare module BABYLON {
  95471. /**
  95472. * Defines the interface used by objects containing a viewport (like a camera)
  95473. */
  95474. interface IViewportOwnerLike {
  95475. /**
  95476. * Gets or sets the viewport
  95477. */
  95478. viewport: IViewportLike;
  95479. }
  95480. /**
  95481. * Interface for attribute information associated with buffer instanciation
  95482. */
  95483. export class InstancingAttributeInfo {
  95484. /**
  95485. * Index/offset of the attribute in the vertex shader
  95486. */
  95487. index: number;
  95488. /**
  95489. * size of the attribute, 1, 2, 3 or 4
  95490. */
  95491. attributeSize: number;
  95492. /**
  95493. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95494. * default is FLOAT
  95495. */
  95496. attribyteType: number;
  95497. /**
  95498. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95499. */
  95500. normalized: boolean;
  95501. /**
  95502. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95503. */
  95504. offset: number;
  95505. /**
  95506. * Name of the GLSL attribute, for debugging purpose only
  95507. */
  95508. attributeName: string;
  95509. }
  95510. /**
  95511. * Define options used to create a depth texture
  95512. */
  95513. export class DepthTextureCreationOptions {
  95514. /** Specifies whether or not a stencil should be allocated in the texture */
  95515. generateStencil?: boolean;
  95516. /** Specifies whether or not bilinear filtering is enable on the texture */
  95517. bilinearFiltering?: boolean;
  95518. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  95519. comparisonFunction?: number;
  95520. /** Specifies if the created texture is a cube texture */
  95521. isCube?: boolean;
  95522. }
  95523. /**
  95524. * Class used to describe the capabilities of the engine relatively to the current browser
  95525. */
  95526. export class EngineCapabilities {
  95527. /** Maximum textures units per fragment shader */
  95528. maxTexturesImageUnits: number;
  95529. /** Maximum texture units per vertex shader */
  95530. maxVertexTextureImageUnits: number;
  95531. /** Maximum textures units in the entire pipeline */
  95532. maxCombinedTexturesImageUnits: number;
  95533. /** Maximum texture size */
  95534. maxTextureSize: number;
  95535. /** Maximum cube texture size */
  95536. maxCubemapTextureSize: number;
  95537. /** Maximum render texture size */
  95538. maxRenderTextureSize: number;
  95539. /** Maximum number of vertex attributes */
  95540. maxVertexAttribs: number;
  95541. /** Maximum number of varyings */
  95542. maxVaryingVectors: number;
  95543. /** Maximum number of uniforms per vertex shader */
  95544. maxVertexUniformVectors: number;
  95545. /** Maximum number of uniforms per fragment shader */
  95546. maxFragmentUniformVectors: number;
  95547. /** Defines if standard derivates (dx/dy) are supported */
  95548. standardDerivatives: boolean;
  95549. /** Defines if s3tc texture compression is supported */
  95550. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95551. /** Defines if pvrtc texture compression is supported */
  95552. pvrtc: any;
  95553. /** Defines if etc1 texture compression is supported */
  95554. etc1: any;
  95555. /** Defines if etc2 texture compression is supported */
  95556. etc2: any;
  95557. /** Defines if astc texture compression is supported */
  95558. astc: any;
  95559. /** Defines if float textures are supported */
  95560. textureFloat: boolean;
  95561. /** Defines if vertex array objects are supported */
  95562. vertexArrayObject: boolean;
  95563. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95564. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95565. /** Gets the maximum level of anisotropy supported */
  95566. maxAnisotropy: number;
  95567. /** Defines if instancing is supported */
  95568. instancedArrays: boolean;
  95569. /** Defines if 32 bits indices are supported */
  95570. uintIndices: boolean;
  95571. /** Defines if high precision shaders are supported */
  95572. highPrecisionShaderSupported: boolean;
  95573. /** Defines if depth reading in the fragment shader is supported */
  95574. fragmentDepthSupported: boolean;
  95575. /** Defines if float texture linear filtering is supported*/
  95576. textureFloatLinearFiltering: boolean;
  95577. /** Defines if rendering to float textures is supported */
  95578. textureFloatRender: boolean;
  95579. /** Defines if half float textures are supported*/
  95580. textureHalfFloat: boolean;
  95581. /** Defines if half float texture linear filtering is supported*/
  95582. textureHalfFloatLinearFiltering: boolean;
  95583. /** Defines if rendering to half float textures is supported */
  95584. textureHalfFloatRender: boolean;
  95585. /** Defines if textureLOD shader command is supported */
  95586. textureLOD: boolean;
  95587. /** Defines if draw buffers extension is supported */
  95588. drawBuffersExtension: boolean;
  95589. /** Defines if depth textures are supported */
  95590. depthTextureExtension: boolean;
  95591. /** Defines if float color buffer are supported */
  95592. colorBufferFloat: boolean;
  95593. /** Gets disjoint timer query extension (null if not supported) */
  95594. timerQuery: EXT_disjoint_timer_query;
  95595. /** Defines if timestamp can be used with timer query */
  95596. canUseTimestampForTimerQuery: boolean;
  95597. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95598. multiview: any;
  95599. /** Function used to let the system compiles shaders in background */
  95600. parallelShaderCompile: {
  95601. COMPLETION_STATUS_KHR: number;
  95602. };
  95603. /** Max number of texture samples for MSAA */
  95604. maxMSAASamples: number;
  95605. }
  95606. /** Interface defining initialization parameters for Engine class */
  95607. export interface EngineOptions extends WebGLContextAttributes {
  95608. /**
  95609. * Defines if the engine should no exceed a specified device ratio
  95610. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95611. */
  95612. limitDeviceRatio?: number;
  95613. /**
  95614. * Defines if webvr should be enabled automatically
  95615. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95616. */
  95617. autoEnableWebVR?: boolean;
  95618. /**
  95619. * Defines if webgl2 should be turned off even if supported
  95620. * @see http://doc.babylonjs.com/features/webgl2
  95621. */
  95622. disableWebGL2Support?: boolean;
  95623. /**
  95624. * Defines if webaudio should be initialized as well
  95625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95626. */
  95627. audioEngine?: boolean;
  95628. /**
  95629. * Defines if animations should run using a deterministic lock step
  95630. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95631. */
  95632. deterministicLockstep?: boolean;
  95633. /** Defines the maximum steps to use with deterministic lock step mode */
  95634. lockstepMaxSteps?: number;
  95635. /**
  95636. * Defines that engine should ignore context lost events
  95637. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95638. */
  95639. doNotHandleContextLost?: boolean;
  95640. /**
  95641. * Defines that engine should ignore modifying touch action attribute and style
  95642. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95643. */
  95644. doNotHandleTouchAction?: boolean;
  95645. /**
  95646. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95647. */
  95648. useHighPrecisionFloats?: boolean;
  95649. }
  95650. /**
  95651. * Defines the interface used by display changed events
  95652. */
  95653. export interface IDisplayChangedEventArgs {
  95654. /** Gets the vrDisplay object (if any) */
  95655. vrDisplay: Nullable<any>;
  95656. /** Gets a boolean indicating if webVR is supported */
  95657. vrSupported: boolean;
  95658. }
  95659. /**
  95660. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  95661. */
  95662. export class Engine {
  95663. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95664. static ExceptionList: ({
  95665. key: string;
  95666. capture: string;
  95667. captureConstraint: number;
  95668. targets: string[];
  95669. } | {
  95670. key: string;
  95671. capture: null;
  95672. captureConstraint: null;
  95673. targets: string[];
  95674. })[];
  95675. /** Gets the list of created engines */
  95676. static readonly Instances: Engine[];
  95677. /**
  95678. * Gets the latest created engine
  95679. */
  95680. static readonly LastCreatedEngine: Nullable<Engine>;
  95681. /**
  95682. * Gets the latest created scene
  95683. */
  95684. static readonly LastCreatedScene: Nullable<Scene>;
  95685. /**
  95686. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  95687. * @param flag defines which part of the materials must be marked as dirty
  95688. * @param predicate defines a predicate used to filter which materials should be affected
  95689. */
  95690. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  95691. /** @hidden */
  95692. static _TextureLoaders: IInternalTextureLoader[];
  95693. /** Defines that alpha blending is disabled */
  95694. static readonly ALPHA_DISABLE: number;
  95695. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  95696. static readonly ALPHA_ADD: number;
  95697. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  95698. static readonly ALPHA_COMBINE: number;
  95699. /** Defines that alpha blending to DEST - SRC * DEST */
  95700. static readonly ALPHA_SUBTRACT: number;
  95701. /** Defines that alpha blending to SRC * DEST */
  95702. static readonly ALPHA_MULTIPLY: number;
  95703. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  95704. static readonly ALPHA_MAXIMIZED: number;
  95705. /** Defines that alpha blending to SRC + DEST */
  95706. static readonly ALPHA_ONEONE: number;
  95707. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  95708. static readonly ALPHA_PREMULTIPLIED: number;
  95709. /**
  95710. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  95711. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  95712. */
  95713. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  95714. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  95715. static readonly ALPHA_INTERPOLATE: number;
  95716. /**
  95717. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  95718. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  95719. */
  95720. static readonly ALPHA_SCREENMODE: number;
  95721. /** Defines that the ressource is not delayed*/
  95722. static readonly DELAYLOADSTATE_NONE: number;
  95723. /** Defines that the ressource was successfully delay loaded */
  95724. static readonly DELAYLOADSTATE_LOADED: number;
  95725. /** Defines that the ressource is currently delay loading */
  95726. static readonly DELAYLOADSTATE_LOADING: number;
  95727. /** Defines that the ressource is delayed and has not started loading */
  95728. static readonly DELAYLOADSTATE_NOTLOADED: number;
  95729. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  95730. static readonly NEVER: number;
  95731. /** 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 */
  95732. static readonly ALWAYS: number;
  95733. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  95734. static readonly LESS: number;
  95735. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  95736. static readonly EQUAL: number;
  95737. /** 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 */
  95738. static readonly LEQUAL: number;
  95739. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  95740. static readonly GREATER: number;
  95741. /** 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 */
  95742. static readonly GEQUAL: number;
  95743. /** 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 */
  95744. static readonly NOTEQUAL: number;
  95745. /** Passed to stencilOperation to specify that stencil value must be kept */
  95746. static readonly KEEP: number;
  95747. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95748. static readonly REPLACE: number;
  95749. /** Passed to stencilOperation to specify that stencil value must be incremented */
  95750. static readonly INCR: number;
  95751. /** Passed to stencilOperation to specify that stencil value must be decremented */
  95752. static readonly DECR: number;
  95753. /** Passed to stencilOperation to specify that stencil value must be inverted */
  95754. static readonly INVERT: number;
  95755. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  95756. static readonly INCR_WRAP: number;
  95757. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  95758. static readonly DECR_WRAP: number;
  95759. /** Texture is not repeating outside of 0..1 UVs */
  95760. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  95761. /** Texture is repeating outside of 0..1 UVs */
  95762. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  95763. /** Texture is repeating and mirrored */
  95764. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  95765. /** ALPHA */
  95766. static readonly TEXTUREFORMAT_ALPHA: number;
  95767. /** LUMINANCE */
  95768. static readonly TEXTUREFORMAT_LUMINANCE: number;
  95769. /** LUMINANCE_ALPHA */
  95770. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  95771. /** RGB */
  95772. static readonly TEXTUREFORMAT_RGB: number;
  95773. /** RGBA */
  95774. static readonly TEXTUREFORMAT_RGBA: number;
  95775. /** RED */
  95776. static readonly TEXTUREFORMAT_RED: number;
  95777. /** RED (2nd reference) */
  95778. static readonly TEXTUREFORMAT_R: number;
  95779. /** RG */
  95780. static readonly TEXTUREFORMAT_RG: number;
  95781. /** RED_INTEGER */
  95782. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  95783. /** RED_INTEGER (2nd reference) */
  95784. static readonly TEXTUREFORMAT_R_INTEGER: number;
  95785. /** RG_INTEGER */
  95786. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  95787. /** RGB_INTEGER */
  95788. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  95789. /** RGBA_INTEGER */
  95790. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  95791. /** UNSIGNED_BYTE */
  95792. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  95793. /** UNSIGNED_BYTE (2nd reference) */
  95794. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  95795. /** FLOAT */
  95796. static readonly TEXTURETYPE_FLOAT: number;
  95797. /** HALF_FLOAT */
  95798. static readonly TEXTURETYPE_HALF_FLOAT: number;
  95799. /** BYTE */
  95800. static readonly TEXTURETYPE_BYTE: number;
  95801. /** SHORT */
  95802. static readonly TEXTURETYPE_SHORT: number;
  95803. /** UNSIGNED_SHORT */
  95804. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  95805. /** INT */
  95806. static readonly TEXTURETYPE_INT: number;
  95807. /** UNSIGNED_INT */
  95808. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  95809. /** UNSIGNED_SHORT_4_4_4_4 */
  95810. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  95811. /** UNSIGNED_SHORT_5_5_5_1 */
  95812. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  95813. /** UNSIGNED_SHORT_5_6_5 */
  95814. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  95815. /** UNSIGNED_INT_2_10_10_10_REV */
  95816. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  95817. /** UNSIGNED_INT_24_8 */
  95818. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  95819. /** UNSIGNED_INT_10F_11F_11F_REV */
  95820. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  95821. /** UNSIGNED_INT_5_9_9_9_REV */
  95822. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  95823. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  95824. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  95825. /** nearest is mag = nearest and min = nearest and mip = linear */
  95826. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  95827. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95828. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  95829. /** Trilinear is mag = linear and min = linear and mip = linear */
  95830. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  95831. /** nearest is mag = nearest and min = nearest and mip = linear */
  95832. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  95833. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95834. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  95835. /** Trilinear is mag = linear and min = linear and mip = linear */
  95836. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  95837. /** mag = nearest and min = nearest and mip = nearest */
  95838. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  95839. /** mag = nearest and min = linear and mip = nearest */
  95840. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  95841. /** mag = nearest and min = linear and mip = linear */
  95842. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  95843. /** mag = nearest and min = linear and mip = none */
  95844. static readonly TEXTURE_NEAREST_LINEAR: number;
  95845. /** mag = nearest and min = nearest and mip = none */
  95846. static readonly TEXTURE_NEAREST_NEAREST: number;
  95847. /** mag = linear and min = nearest and mip = nearest */
  95848. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  95849. /** mag = linear and min = nearest and mip = linear */
  95850. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  95851. /** mag = linear and min = linear and mip = none */
  95852. static readonly TEXTURE_LINEAR_LINEAR: number;
  95853. /** mag = linear and min = nearest and mip = none */
  95854. static readonly TEXTURE_LINEAR_NEAREST: number;
  95855. /** Explicit coordinates mode */
  95856. static readonly TEXTURE_EXPLICIT_MODE: number;
  95857. /** Spherical coordinates mode */
  95858. static readonly TEXTURE_SPHERICAL_MODE: number;
  95859. /** Planar coordinates mode */
  95860. static readonly TEXTURE_PLANAR_MODE: number;
  95861. /** Cubic coordinates mode */
  95862. static readonly TEXTURE_CUBIC_MODE: number;
  95863. /** Projection coordinates mode */
  95864. static readonly TEXTURE_PROJECTION_MODE: number;
  95865. /** Skybox coordinates mode */
  95866. static readonly TEXTURE_SKYBOX_MODE: number;
  95867. /** Inverse Cubic coordinates mode */
  95868. static readonly TEXTURE_INVCUBIC_MODE: number;
  95869. /** Equirectangular coordinates mode */
  95870. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  95871. /** Equirectangular Fixed coordinates mode */
  95872. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  95873. /** Equirectangular Fixed Mirrored coordinates mode */
  95874. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  95875. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  95876. static readonly SCALEMODE_FLOOR: number;
  95877. /** Defines that texture rescaling will look for the nearest power of 2 size */
  95878. static readonly SCALEMODE_NEAREST: number;
  95879. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  95880. static readonly SCALEMODE_CEILING: number;
  95881. /**
  95882. * Returns the current npm package of the sdk
  95883. */
  95884. static readonly NpmPackage: string;
  95885. /**
  95886. * Returns the current version of the framework
  95887. */
  95888. static readonly Version: string;
  95889. /**
  95890. * Returns a string describing the current engine
  95891. */
  95892. readonly description: string;
  95893. /**
  95894. * Gets or sets the epsilon value used by collision engine
  95895. */
  95896. static CollisionsEpsilon: number;
  95897. /**
  95898. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95899. */
  95900. static ShadersRepository: string;
  95901. /**
  95902. * Method called to create the default loading screen.
  95903. * This can be overriden in your own app.
  95904. * @param canvas The rendering canvas element
  95905. * @returns The loading screen
  95906. */
  95907. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  95908. /**
  95909. * Method called to create the default rescale post process on each engine.
  95910. */
  95911. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  95912. /** @hidden */
  95913. _shaderProcessor: IShaderProcessor;
  95914. /**
  95915. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95916. */
  95917. forcePOTTextures: boolean;
  95918. /**
  95919. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95920. */
  95921. isFullscreen: boolean;
  95922. /**
  95923. * Gets a boolean indicating if the pointer is currently locked
  95924. */
  95925. isPointerLock: boolean;
  95926. /**
  95927. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95928. */
  95929. cullBackFaces: boolean;
  95930. /**
  95931. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95932. */
  95933. renderEvenInBackground: boolean;
  95934. /**
  95935. * Gets or sets a boolean indicating that cache can be kept between frames
  95936. */
  95937. preventCacheWipeBetweenFrames: boolean;
  95938. /**
  95939. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  95940. **/
  95941. enableOfflineSupport: boolean;
  95942. /**
  95943. * 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)
  95944. **/
  95945. disableManifestCheck: boolean;
  95946. /**
  95947. * Gets the list of created scenes
  95948. */
  95949. scenes: Scene[];
  95950. /**
  95951. * Event raised when a new scene is created
  95952. */
  95953. onNewSceneAddedObservable: Observable<Scene>;
  95954. /**
  95955. * Gets the list of created postprocesses
  95956. */
  95957. postProcesses: PostProcess[];
  95958. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95959. validateShaderPrograms: boolean;
  95960. /**
  95961. * Observable event triggered each time the rendering canvas is resized
  95962. */
  95963. onResizeObservable: Observable<Engine>;
  95964. /**
  95965. * Observable event triggered each time the canvas loses focus
  95966. */
  95967. onCanvasBlurObservable: Observable<Engine>;
  95968. /**
  95969. * Observable event triggered each time the canvas gains focus
  95970. */
  95971. onCanvasFocusObservable: Observable<Engine>;
  95972. /**
  95973. * Observable event triggered each time the canvas receives pointerout event
  95974. */
  95975. onCanvasPointerOutObservable: Observable<PointerEvent>;
  95976. /**
  95977. * Observable event triggered before each texture is initialized
  95978. */
  95979. onBeforeTextureInitObservable: Observable<Texture>;
  95980. /**
  95981. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95982. */
  95983. disableUniformBuffers: boolean;
  95984. /** @hidden */
  95985. _uniformBuffers: UniformBuffer[];
  95986. /**
  95987. * Gets a boolean indicating that the engine supports uniform buffers
  95988. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95989. */
  95990. readonly supportsUniformBuffers: boolean;
  95991. /**
  95992. * Observable raised when the engine begins a new frame
  95993. */
  95994. onBeginFrameObservable: Observable<Engine>;
  95995. /**
  95996. * If set, will be used to request the next animation frame for the render loop
  95997. */
  95998. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  95999. /**
  96000. * Observable raised when the engine ends the current frame
  96001. */
  96002. onEndFrameObservable: Observable<Engine>;
  96003. /**
  96004. * Observable raised when the engine is about to compile a shader
  96005. */
  96006. onBeforeShaderCompilationObservable: Observable<Engine>;
  96007. /**
  96008. * Observable raised when the engine has jsut compiled a shader
  96009. */
  96010. onAfterShaderCompilationObservable: Observable<Engine>;
  96011. /** @hidden */
  96012. _gl: WebGLRenderingContext;
  96013. private _renderingCanvas;
  96014. private _windowIsBackground;
  96015. protected _webGLVersion: number;
  96016. protected _highPrecisionShadersAllowed: boolean;
  96017. /** @hidden */
  96018. readonly _shouldUseHighPrecisionShader: boolean;
  96019. /**
  96020. * Gets a boolean indicating that only power of 2 textures are supported
  96021. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96022. */
  96023. readonly needPOTTextures: boolean;
  96024. /** @hidden */
  96025. _badOS: boolean;
  96026. /** @hidden */
  96027. _badDesktopOS: boolean;
  96028. /**
  96029. * Gets the audio engine
  96030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96031. * @ignorenaming
  96032. */
  96033. static audioEngine: IAudioEngine;
  96034. /**
  96035. * Default AudioEngine factory responsible of creating the Audio Engine.
  96036. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  96037. */
  96038. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  96039. /**
  96040. * Default offline support factory responsible of creating a tool used to store data locally.
  96041. * By default, this will create a Database object if the workload has been embedded.
  96042. */
  96043. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  96044. private _onFocus;
  96045. private _onBlur;
  96046. private _onCanvasPointerOut;
  96047. private _onCanvasBlur;
  96048. private _onCanvasFocus;
  96049. private _onFullscreenChange;
  96050. private _onPointerLockChange;
  96051. private _hardwareScalingLevel;
  96052. /** @hidden */
  96053. _caps: EngineCapabilities;
  96054. private _pointerLockRequested;
  96055. private _isStencilEnable;
  96056. protected _colorWrite: boolean;
  96057. private _loadingScreen;
  96058. /** @hidden */
  96059. _drawCalls: PerfCounter;
  96060. private _glVersion;
  96061. private _glRenderer;
  96062. private _glVendor;
  96063. private _videoTextureSupported;
  96064. private _renderingQueueLaunched;
  96065. private _activeRenderLoops;
  96066. private _deterministicLockstep;
  96067. private _lockstepMaxSteps;
  96068. /**
  96069. * Observable signaled when a context lost event is raised
  96070. */
  96071. onContextLostObservable: Observable<Engine>;
  96072. /**
  96073. * Observable signaled when a context restored event is raised
  96074. */
  96075. onContextRestoredObservable: Observable<Engine>;
  96076. private _onContextLost;
  96077. private _onContextRestored;
  96078. private _contextWasLost;
  96079. /** @hidden */
  96080. _doNotHandleContextLost: boolean;
  96081. /**
  96082. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96083. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96084. */
  96085. doNotHandleContextLost: boolean;
  96086. private _performanceMonitor;
  96087. private _fps;
  96088. private _deltaTime;
  96089. /**
  96090. * Turn this value on if you want to pause FPS computation when in background
  96091. */
  96092. disablePerformanceMonitorInBackground: boolean;
  96093. /**
  96094. * Gets the performance monitor attached to this engine
  96095. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  96096. */
  96097. readonly performanceMonitor: PerformanceMonitor;
  96098. /**
  96099. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96100. */
  96101. disableVertexArrayObjects: boolean;
  96102. /** @hidden */
  96103. protected _depthCullingState: _DepthCullingState;
  96104. /** @hidden */
  96105. protected _stencilState: _StencilState;
  96106. /** @hidden */
  96107. protected _alphaState: _AlphaState;
  96108. /** @hidden */
  96109. protected _alphaMode: number;
  96110. /** @hidden */
  96111. _internalTexturesCache: InternalTexture[];
  96112. /** @hidden */
  96113. protected _activeChannel: number;
  96114. private _currentTextureChannel;
  96115. /** @hidden */
  96116. protected _boundTexturesCache: {
  96117. [key: string]: Nullable<InternalTexture>;
  96118. };
  96119. /** @hidden */
  96120. protected _currentEffect: Nullable<Effect>;
  96121. /** @hidden */
  96122. protected _currentProgram: Nullable<WebGLProgram>;
  96123. private _compiledEffects;
  96124. private _vertexAttribArraysEnabled;
  96125. /** @hidden */
  96126. protected _cachedViewport: Nullable<IViewportLike>;
  96127. private _cachedVertexArrayObject;
  96128. /** @hidden */
  96129. protected _cachedVertexBuffers: any;
  96130. /** @hidden */
  96131. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96132. /** @hidden */
  96133. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96134. /** @hidden */
  96135. _currentRenderTarget: Nullable<InternalTexture>;
  96136. private _uintIndicesCurrentlySet;
  96137. private _currentBoundBuffer;
  96138. /** @hidden */
  96139. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96140. private _currentBufferPointers;
  96141. private _currentInstanceLocations;
  96142. private _currentInstanceBuffers;
  96143. private _textureUnits;
  96144. /** @hidden */
  96145. _workingCanvas: Nullable<HTMLCanvasElement>;
  96146. /** @hidden */
  96147. _workingContext: Nullable<CanvasRenderingContext2D>;
  96148. private _rescalePostProcess;
  96149. private _dummyFramebuffer;
  96150. private _externalData;
  96151. /** @hidden */
  96152. _bindedRenderFunction: any;
  96153. private _vaoRecordInProgress;
  96154. private _mustWipeVertexAttributes;
  96155. private _emptyTexture;
  96156. private _emptyCubeTexture;
  96157. private _emptyTexture3D;
  96158. /** @hidden */
  96159. _frameHandler: number;
  96160. private _nextFreeTextureSlots;
  96161. private _maxSimultaneousTextures;
  96162. private _activeRequests;
  96163. private _texturesSupported;
  96164. /** @hidden */
  96165. _textureFormatInUse: Nullable<string>;
  96166. /**
  96167. * Gets the list of texture formats supported
  96168. */
  96169. readonly texturesSupported: Array<string>;
  96170. /**
  96171. * Gets the list of texture formats in use
  96172. */
  96173. readonly textureFormatInUse: Nullable<string>;
  96174. /**
  96175. * Gets the current viewport
  96176. */
  96177. readonly currentViewport: Nullable<IViewportLike>;
  96178. /**
  96179. * Gets the default empty texture
  96180. */
  96181. readonly emptyTexture: InternalTexture;
  96182. /**
  96183. * Gets the default empty 3D texture
  96184. */
  96185. readonly emptyTexture3D: InternalTexture;
  96186. /**
  96187. * Gets the default empty cube texture
  96188. */
  96189. readonly emptyCubeTexture: InternalTexture;
  96190. /**
  96191. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96192. */
  96193. readonly premultipliedAlpha: boolean;
  96194. /**
  96195. * Creates a new engine
  96196. * @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
  96197. * @param antialias defines enable antialiasing (default: false)
  96198. * @param options defines further options to be sent to the getContext() function
  96199. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96200. */
  96201. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96202. /**
  96203. * Initializes a webVR display and starts listening to display change events
  96204. * The onVRDisplayChangedObservable will be notified upon these changes
  96205. * @returns The onVRDisplayChangedObservable
  96206. */
  96207. initWebVR(): Observable<IDisplayChangedEventArgs>;
  96208. /** @hidden */
  96209. _prepareVRComponent(): void;
  96210. /** @hidden */
  96211. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  96212. /** @hidden */
  96213. _submitVRFrame(): void;
  96214. /**
  96215. * Call this function to leave webVR mode
  96216. * Will do nothing if webVR is not supported or if there is no webVR device
  96217. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96218. */
  96219. disableVR(): void;
  96220. /**
  96221. * Gets a boolean indicating that the system is in VR mode and is presenting
  96222. * @returns true if VR mode is engaged
  96223. */
  96224. isVRPresenting(): boolean;
  96225. /** @hidden */
  96226. _requestVRFrame(): void;
  96227. private _disableTouchAction;
  96228. private _rebuildInternalTextures;
  96229. private _rebuildEffects;
  96230. /**
  96231. * Gets a boolean indicating if all created effects are ready
  96232. * @returns true if all effects are ready
  96233. */
  96234. areAllEffectsReady(): boolean;
  96235. private _rebuildBuffers;
  96236. private _initGLContext;
  96237. /**
  96238. * Gets version of the current webGL context
  96239. */
  96240. readonly webGLVersion: number;
  96241. /**
  96242. * Gets a string idenfifying the name of the class
  96243. * @returns "Engine" string
  96244. */
  96245. getClassName(): string;
  96246. /**
  96247. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96248. */
  96249. readonly isStencilEnable: boolean;
  96250. /** @hidden */
  96251. _prepareWorkingCanvas(): void;
  96252. /**
  96253. * Reset the texture cache to empty state
  96254. */
  96255. resetTextureCache(): void;
  96256. /**
  96257. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  96258. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96259. * @returns true if engine is in deterministic lock step mode
  96260. */
  96261. isDeterministicLockStep(): boolean;
  96262. /**
  96263. * Gets the max steps when engine is running in deterministic lock step
  96264. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96265. * @returns the max steps
  96266. */
  96267. getLockstepMaxSteps(): number;
  96268. /**
  96269. * Gets an object containing information about the current webGL context
  96270. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96271. */
  96272. getGlInfo(): {
  96273. vendor: string;
  96274. renderer: string;
  96275. version: string;
  96276. };
  96277. /**
  96278. * Gets current aspect ratio
  96279. * @param viewportOwner defines the camera to use to get the aspect ratio
  96280. * @param useScreen defines if screen size must be used (or the current render target if any)
  96281. * @returns a number defining the aspect ratio
  96282. */
  96283. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  96284. /**
  96285. * Gets current screen aspect ratio
  96286. * @returns a number defining the aspect ratio
  96287. */
  96288. getScreenAspectRatio(): number;
  96289. /**
  96290. * Gets the current render width
  96291. * @param useScreen defines if screen size must be used (or the current render target if any)
  96292. * @returns a number defining the current render width
  96293. */
  96294. getRenderWidth(useScreen?: boolean): number;
  96295. /**
  96296. * Gets the current render height
  96297. * @param useScreen defines if screen size must be used (or the current render target if any)
  96298. * @returns a number defining the current render height
  96299. */
  96300. getRenderHeight(useScreen?: boolean): number;
  96301. /**
  96302. * Gets the HTML canvas attached with the current webGL context
  96303. * @returns a HTML canvas
  96304. */
  96305. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96306. /**
  96307. * Gets host window
  96308. * @returns the host window object
  96309. */
  96310. getHostWindow(): Window;
  96311. /**
  96312. * Gets host document
  96313. * @returns the host document object
  96314. */
  96315. getHostDocument(): Document;
  96316. /**
  96317. * Gets the client rect of the HTML canvas attached with the current webGL context
  96318. * @returns a client rectanglee
  96319. */
  96320. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  96321. /**
  96322. * Defines the hardware scaling level.
  96323. * By default the hardware scaling level is computed from the window device ratio.
  96324. * 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.
  96325. * @param level defines the level to use
  96326. */
  96327. setHardwareScalingLevel(level: number): void;
  96328. /**
  96329. * Gets the current hardware scaling level.
  96330. * By default the hardware scaling level is computed from the window device ratio.
  96331. * 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.
  96332. * @returns a number indicating the current hardware scaling level
  96333. */
  96334. getHardwareScalingLevel(): number;
  96335. /**
  96336. * Gets the list of loaded textures
  96337. * @returns an array containing all loaded textures
  96338. */
  96339. getLoadedTexturesCache(): InternalTexture[];
  96340. /**
  96341. * Gets the object containing all engine capabilities
  96342. * @returns the EngineCapabilities object
  96343. */
  96344. getCaps(): EngineCapabilities;
  96345. /**
  96346. * Gets the current depth function
  96347. * @returns a number defining the depth function
  96348. */
  96349. getDepthFunction(): Nullable<number>;
  96350. /**
  96351. * Sets the current depth function
  96352. * @param depthFunc defines the function to use
  96353. */
  96354. setDepthFunction(depthFunc: number): void;
  96355. /**
  96356. * Sets the current depth function to GREATER
  96357. */
  96358. setDepthFunctionToGreater(): void;
  96359. /**
  96360. * Sets the current depth function to GEQUAL
  96361. */
  96362. setDepthFunctionToGreaterOrEqual(): void;
  96363. /**
  96364. * Sets the current depth function to LESS
  96365. */
  96366. setDepthFunctionToLess(): void;
  96367. private _cachedStencilBuffer;
  96368. private _cachedStencilFunction;
  96369. private _cachedStencilMask;
  96370. private _cachedStencilOperationPass;
  96371. private _cachedStencilOperationFail;
  96372. private _cachedStencilOperationDepthFail;
  96373. private _cachedStencilReference;
  96374. /**
  96375. * Caches the the state of the stencil buffer
  96376. */
  96377. cacheStencilState(): void;
  96378. /**
  96379. * Restores the state of the stencil buffer
  96380. */
  96381. restoreStencilState(): void;
  96382. /**
  96383. * Sets the current depth function to LEQUAL
  96384. */
  96385. setDepthFunctionToLessOrEqual(): void;
  96386. /**
  96387. * Gets a boolean indicating if stencil buffer is enabled
  96388. * @returns the current stencil buffer state
  96389. */
  96390. getStencilBuffer(): boolean;
  96391. /**
  96392. * Enable or disable the stencil buffer
  96393. * @param enable defines if the stencil buffer must be enabled or disabled
  96394. */
  96395. setStencilBuffer(enable: boolean): void;
  96396. /**
  96397. * Gets the current stencil mask
  96398. * @returns a number defining the new stencil mask to use
  96399. */
  96400. getStencilMask(): number;
  96401. /**
  96402. * Sets the current stencil mask
  96403. * @param mask defines the new stencil mask to use
  96404. */
  96405. setStencilMask(mask: number): void;
  96406. /**
  96407. * Gets the current stencil function
  96408. * @returns a number defining the stencil function to use
  96409. */
  96410. getStencilFunction(): number;
  96411. /**
  96412. * Gets the current stencil reference value
  96413. * @returns a number defining the stencil reference value to use
  96414. */
  96415. getStencilFunctionReference(): number;
  96416. /**
  96417. * Gets the current stencil mask
  96418. * @returns a number defining the stencil mask to use
  96419. */
  96420. getStencilFunctionMask(): number;
  96421. /**
  96422. * Sets the current stencil function
  96423. * @param stencilFunc defines the new stencil function to use
  96424. */
  96425. setStencilFunction(stencilFunc: number): void;
  96426. /**
  96427. * Sets the current stencil reference
  96428. * @param reference defines the new stencil reference to use
  96429. */
  96430. setStencilFunctionReference(reference: number): void;
  96431. /**
  96432. * Sets the current stencil mask
  96433. * @param mask defines the new stencil mask to use
  96434. */
  96435. setStencilFunctionMask(mask: number): void;
  96436. /**
  96437. * Gets the current stencil operation when stencil fails
  96438. * @returns a number defining stencil operation to use when stencil fails
  96439. */
  96440. getStencilOperationFail(): number;
  96441. /**
  96442. * Gets the current stencil operation when depth fails
  96443. * @returns a number defining stencil operation to use when depth fails
  96444. */
  96445. getStencilOperationDepthFail(): number;
  96446. /**
  96447. * Gets the current stencil operation when stencil passes
  96448. * @returns a number defining stencil operation to use when stencil passes
  96449. */
  96450. getStencilOperationPass(): number;
  96451. /**
  96452. * Sets the stencil operation to use when stencil fails
  96453. * @param operation defines the stencil operation to use when stencil fails
  96454. */
  96455. setStencilOperationFail(operation: number): void;
  96456. /**
  96457. * Sets the stencil operation to use when depth fails
  96458. * @param operation defines the stencil operation to use when depth fails
  96459. */
  96460. setStencilOperationDepthFail(operation: number): void;
  96461. /**
  96462. * Sets the stencil operation to use when stencil passes
  96463. * @param operation defines the stencil operation to use when stencil passes
  96464. */
  96465. setStencilOperationPass(operation: number): void;
  96466. /**
  96467. * Sets a boolean indicating if the dithering state is enabled or disabled
  96468. * @param value defines the dithering state
  96469. */
  96470. setDitheringState(value: boolean): void;
  96471. /**
  96472. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  96473. * @param value defines the rasterizer state
  96474. */
  96475. setRasterizerState(value: boolean): void;
  96476. /**
  96477. * stop executing a render loop function and remove it from the execution array
  96478. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96479. */
  96480. stopRenderLoop(renderFunction?: () => void): void;
  96481. /** @hidden */
  96482. _renderLoop(): void;
  96483. /**
  96484. * Can be used to override the current requestAnimationFrame requester.
  96485. * @hidden
  96486. */
  96487. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96488. /**
  96489. * Register and execute a render loop. The engine can have more than one render function
  96490. * @param renderFunction defines the function to continuously execute
  96491. */
  96492. runRenderLoop(renderFunction: () => void): void;
  96493. /**
  96494. * Toggle full screen mode
  96495. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96496. */
  96497. switchFullscreen(requestPointerLock: boolean): void;
  96498. /**
  96499. * Enters full screen mode
  96500. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96501. */
  96502. enterFullscreen(requestPointerLock: boolean): void;
  96503. /**
  96504. * Exits full screen mode
  96505. */
  96506. exitFullscreen(): void;
  96507. /**
  96508. * Enters Pointerlock mode
  96509. */
  96510. enterPointerlock(): void;
  96511. /**
  96512. * Exits Pointerlock mode
  96513. */
  96514. exitPointerlock(): void;
  96515. /**
  96516. * Clear the current render buffer or the current render target (if any is set up)
  96517. * @param color defines the color to use
  96518. * @param backBuffer defines if the back buffer must be cleared
  96519. * @param depth defines if the depth buffer must be cleared
  96520. * @param stencil defines if the stencil buffer must be cleared
  96521. */
  96522. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96523. /**
  96524. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  96525. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96526. * @param y defines the y-coordinate of the corner of the clear rectangle
  96527. * @param width defines the width of the clear rectangle
  96528. * @param height defines the height of the clear rectangle
  96529. * @param clearColor defines the clear color
  96530. */
  96531. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  96532. /**
  96533. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  96534. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96535. * @param y defines the y-coordinate of the corner of the clear rectangle
  96536. * @param width defines the width of the clear rectangle
  96537. * @param height defines the height of the clear rectangle
  96538. */
  96539. enableScissor(x: number, y: number, width: number, height: number): void;
  96540. /**
  96541. * Disable previously set scissor test rectangle
  96542. */
  96543. disableScissor(): void;
  96544. private _viewportCached;
  96545. /** @hidden */
  96546. _viewport(x: number, y: number, width: number, height: number): void;
  96547. /**
  96548. * Set the WebGL's viewport
  96549. * @param viewport defines the viewport element to be used
  96550. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96551. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96552. */
  96553. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96554. /**
  96555. * Directly set the WebGL Viewport
  96556. * @param x defines the x coordinate of the viewport (in screen space)
  96557. * @param y defines the y coordinate of the viewport (in screen space)
  96558. * @param width defines the width of the viewport (in screen space)
  96559. * @param height defines the height of the viewport (in screen space)
  96560. * @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
  96561. */
  96562. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  96563. /**
  96564. * Begin a new frame
  96565. */
  96566. beginFrame(): void;
  96567. /**
  96568. * Enf the current frame
  96569. */
  96570. endFrame(): void;
  96571. /**
  96572. * Resize the view according to the canvas' size
  96573. */
  96574. resize(): void;
  96575. /**
  96576. * Force a specific size of the canvas
  96577. * @param width defines the new canvas' width
  96578. * @param height defines the new canvas' height
  96579. */
  96580. setSize(width: number, height: number): void;
  96581. /**
  96582. * Binds the frame buffer to the specified texture.
  96583. * @param texture The texture to render to or null for the default canvas
  96584. * @param faceIndex The face of the texture to render to in case of cube texture
  96585. * @param requiredWidth The width of the target to render to
  96586. * @param requiredHeight The height of the target to render to
  96587. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96588. * @param depthStencilTexture The depth stencil texture to use to render
  96589. * @param lodLevel defines le lod level to bind to the frame buffer
  96590. */
  96591. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96592. /** @hidden */
  96593. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96594. /**
  96595. * Unbind the current render target texture from the webGL context
  96596. * @param texture defines the render target texture to unbind
  96597. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96598. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96599. */
  96600. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96601. /**
  96602. * Force the mipmap generation for the given render target texture
  96603. * @param texture defines the render target texture to use
  96604. */
  96605. generateMipMapsForCubemap(texture: InternalTexture): void;
  96606. /**
  96607. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96608. */
  96609. flushFramebuffer(): void;
  96610. /**
  96611. * Unbind the current render target and bind the default framebuffer
  96612. */
  96613. restoreDefaultFramebuffer(): void;
  96614. /**
  96615. * Create an uniform buffer
  96616. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96617. * @param elements defines the content of the uniform buffer
  96618. * @returns the webGL uniform buffer
  96619. */
  96620. createUniformBuffer(elements: FloatArray): DataBuffer;
  96621. /**
  96622. * Create a dynamic uniform buffer
  96623. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96624. * @param elements defines the content of the uniform buffer
  96625. * @returns the webGL uniform buffer
  96626. */
  96627. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  96628. /**
  96629. * Update an existing uniform buffer
  96630. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96631. * @param uniformBuffer defines the target uniform buffer
  96632. * @param elements defines the content to update
  96633. * @param offset defines the offset in the uniform buffer where update should start
  96634. * @param count defines the size of the data to update
  96635. */
  96636. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  96637. private _resetVertexBufferBinding;
  96638. /**
  96639. * Creates a vertex buffer
  96640. * @param data the data for the vertex buffer
  96641. * @returns the new WebGL static buffer
  96642. */
  96643. createVertexBuffer(data: DataArray): DataBuffer;
  96644. /**
  96645. * Creates a dynamic vertex buffer
  96646. * @param data the data for the dynamic vertex buffer
  96647. * @returns the new WebGL dynamic buffer
  96648. */
  96649. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96650. /**
  96651. * Update a dynamic index buffer
  96652. * @param indexBuffer defines the target index buffer
  96653. * @param indices defines the data to update
  96654. * @param offset defines the offset in the target index buffer where update should start
  96655. */
  96656. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96657. /**
  96658. * Updates a dynamic vertex buffer.
  96659. * @param vertexBuffer the vertex buffer to update
  96660. * @param data the data used to update the vertex buffer
  96661. * @param byteOffset the byte offset of the data
  96662. * @param byteLength the byte length of the data
  96663. */
  96664. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96665. private _resetIndexBufferBinding;
  96666. /**
  96667. * Creates a new index buffer
  96668. * @param indices defines the content of the index buffer
  96669. * @param updatable defines if the index buffer must be updatable
  96670. * @returns a new webGL buffer
  96671. */
  96672. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96673. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96674. /**
  96675. * Bind a webGL buffer to the webGL context
  96676. * @param buffer defines the buffer to bind
  96677. */
  96678. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96679. /**
  96680. * Bind an uniform buffer to the current webGL context
  96681. * @param buffer defines the buffer to bind
  96682. */
  96683. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  96684. /**
  96685. * Bind a buffer to the current webGL context at a given location
  96686. * @param buffer defines the buffer to bind
  96687. * @param location defines the index where to bind the buffer
  96688. */
  96689. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  96690. /**
  96691. * Bind a specific block at a given index in a specific shader program
  96692. * @param pipelineContext defines the pipeline context to use
  96693. * @param blockName defines the block name
  96694. * @param index defines the index where to bind the block
  96695. */
  96696. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  96697. private bindIndexBuffer;
  96698. private bindBuffer;
  96699. /**
  96700. * update the bound buffer with the given data
  96701. * @param data defines the data to update
  96702. */
  96703. updateArrayBuffer(data: Float32Array): void;
  96704. private _vertexAttribPointer;
  96705. private _bindIndexBufferWithCache;
  96706. private _bindVertexBuffersAttributes;
  96707. /**
  96708. * Records a vertex array object
  96709. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96710. * @param vertexBuffers defines the list of vertex buffers to store
  96711. * @param indexBuffer defines the index buffer to store
  96712. * @param effect defines the effect to store
  96713. * @returns the new vertex array object
  96714. */
  96715. recordVertexArrayObject(vertexBuffers: {
  96716. [key: string]: VertexBuffer;
  96717. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96718. /**
  96719. * Bind a specific vertex array object
  96720. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96721. * @param vertexArrayObject defines the vertex array object to bind
  96722. * @param indexBuffer defines the index buffer to bind
  96723. */
  96724. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96725. /**
  96726. * Bind webGl buffers directly to the webGL context
  96727. * @param vertexBuffer defines the vertex buffer to bind
  96728. * @param indexBuffer defines the index buffer to bind
  96729. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96730. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96731. * @param effect defines the effect associated with the vertex buffer
  96732. */
  96733. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96734. private _unbindVertexArrayObject;
  96735. /**
  96736. * Bind a list of vertex buffers to the webGL context
  96737. * @param vertexBuffers defines the list of vertex buffers to bind
  96738. * @param indexBuffer defines the index buffer to bind
  96739. * @param effect defines the effect associated with the vertex buffers
  96740. */
  96741. bindBuffers(vertexBuffers: {
  96742. [key: string]: Nullable<VertexBuffer>;
  96743. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96744. /**
  96745. * Unbind all instance attributes
  96746. */
  96747. unbindInstanceAttributes(): void;
  96748. /**
  96749. * Release and free the memory of a vertex array object
  96750. * @param vao defines the vertex array object to delete
  96751. */
  96752. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96753. /** @hidden */
  96754. _releaseBuffer(buffer: DataBuffer): boolean;
  96755. protected _deleteBuffer(buffer: DataBuffer): void;
  96756. /**
  96757. * Creates a webGL buffer to use with instanciation
  96758. * @param capacity defines the size of the buffer
  96759. * @returns the webGL buffer
  96760. */
  96761. createInstancesBuffer(capacity: number): DataBuffer;
  96762. /**
  96763. * Delete a webGL buffer used with instanciation
  96764. * @param buffer defines the webGL buffer to delete
  96765. */
  96766. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96767. /**
  96768. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96769. * @param instancesBuffer defines the webGL buffer to update and bind
  96770. * @param data defines the data to store in the buffer
  96771. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96772. */
  96773. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96774. /**
  96775. * Apply all cached states (depth, culling, stencil and alpha)
  96776. */
  96777. applyStates(): void;
  96778. /**
  96779. * Send a draw order
  96780. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96781. * @param indexStart defines the starting index
  96782. * @param indexCount defines the number of index to draw
  96783. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96784. */
  96785. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96786. /**
  96787. * Draw a list of points
  96788. * @param verticesStart defines the index of first vertex to draw
  96789. * @param verticesCount defines the count of vertices to draw
  96790. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96791. */
  96792. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96793. /**
  96794. * Draw a list of unindexed primitives
  96795. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96796. * @param verticesStart defines the index of first vertex to draw
  96797. * @param verticesCount defines the count of vertices to draw
  96798. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96799. */
  96800. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96801. /**
  96802. * Draw a list of indexed primitives
  96803. * @param fillMode defines the primitive to use
  96804. * @param indexStart defines the starting index
  96805. * @param indexCount defines the number of index to draw
  96806. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96807. */
  96808. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96809. /**
  96810. * Draw a list of unindexed primitives
  96811. * @param fillMode defines the primitive to use
  96812. * @param verticesStart defines the index of first vertex to draw
  96813. * @param verticesCount defines the count of vertices to draw
  96814. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96815. */
  96816. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96817. private _drawMode;
  96818. /** @hidden */
  96819. _releaseEffect(effect: Effect): void;
  96820. /** @hidden */
  96821. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96822. /**
  96823. * Create a new effect (used to store vertex/fragment shaders)
  96824. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96825. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96826. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96827. * @param samplers defines an array of string used to represent textures
  96828. * @param defines defines the string containing the defines to use to compile the shaders
  96829. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96830. * @param onCompiled defines a function to call when the effect creation is successful
  96831. * @param onError defines a function to call when the effect creation has failed
  96832. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96833. * @returns the new Effect
  96834. */
  96835. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96836. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96837. private _compileShader;
  96838. private _compileRawShader;
  96839. /**
  96840. * Directly creates a webGL program
  96841. * @param pipelineContext defines the pipeline context to attach to
  96842. * @param vertexCode defines the vertex shader code to use
  96843. * @param fragmentCode defines the fragment shader code to use
  96844. * @param context defines the webGL context to use (if not set, the current one will be used)
  96845. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96846. * @returns the new webGL program
  96847. */
  96848. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96849. /**
  96850. * Creates a webGL program
  96851. * @param pipelineContext defines the pipeline context to attach to
  96852. * @param vertexCode defines the vertex shader code to use
  96853. * @param fragmentCode defines the fragment shader code to use
  96854. * @param defines defines the string containing the defines to use to compile the shaders
  96855. * @param context defines the webGL context to use (if not set, the current one will be used)
  96856. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96857. * @returns the new webGL program
  96858. */
  96859. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96860. /**
  96861. * Creates a new pipeline context
  96862. * @returns the new pipeline
  96863. */
  96864. createPipelineContext(): IPipelineContext;
  96865. private _createShaderProgram;
  96866. private _finalizePipelineContext;
  96867. /** @hidden */
  96868. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96869. /** @hidden */
  96870. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96871. /** @hidden */
  96872. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96873. /**
  96874. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96875. * @param pipelineContext defines the pipeline context to use
  96876. * @param uniformsNames defines the list of uniform names
  96877. * @returns an array of webGL uniform locations
  96878. */
  96879. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96880. /**
  96881. * Gets the lsit of active attributes for a given webGL program
  96882. * @param pipelineContext defines the pipeline context to use
  96883. * @param attributesNames defines the list of attribute names to get
  96884. * @returns an array of indices indicating the offset of each attribute
  96885. */
  96886. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96887. /**
  96888. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96889. * @param effect defines the effect to activate
  96890. */
  96891. enableEffect(effect: Nullable<Effect>): void;
  96892. /**
  96893. * Set the value of an uniform to an array of int32
  96894. * @param uniform defines the webGL uniform location where to store the value
  96895. * @param array defines the array of int32 to store
  96896. */
  96897. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96898. /**
  96899. * Set the value of an uniform to an array of int32 (stored as vec2)
  96900. * @param uniform defines the webGL uniform location where to store the value
  96901. * @param array defines the array of int32 to store
  96902. */
  96903. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96904. /**
  96905. * Set the value of an uniform to an array of int32 (stored as vec3)
  96906. * @param uniform defines the webGL uniform location where to store the value
  96907. * @param array defines the array of int32 to store
  96908. */
  96909. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96910. /**
  96911. * Set the value of an uniform to an array of int32 (stored as vec4)
  96912. * @param uniform defines the webGL uniform location where to store the value
  96913. * @param array defines the array of int32 to store
  96914. */
  96915. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96916. /**
  96917. * Set the value of an uniform to an array of float32
  96918. * @param uniform defines the webGL uniform location where to store the value
  96919. * @param array defines the array of float32 to store
  96920. */
  96921. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96922. /**
  96923. * Set the value of an uniform to an array of float32 (stored as vec2)
  96924. * @param uniform defines the webGL uniform location where to store the value
  96925. * @param array defines the array of float32 to store
  96926. */
  96927. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96928. /**
  96929. * Set the value of an uniform to an array of float32 (stored as vec3)
  96930. * @param uniform defines the webGL uniform location where to store the value
  96931. * @param array defines the array of float32 to store
  96932. */
  96933. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96934. /**
  96935. * Set the value of an uniform to an array of float32 (stored as vec4)
  96936. * @param uniform defines the webGL uniform location where to store the value
  96937. * @param array defines the array of float32 to store
  96938. */
  96939. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96940. /**
  96941. * Set the value of an uniform to an array of number
  96942. * @param uniform defines the webGL uniform location where to store the value
  96943. * @param array defines the array of number to store
  96944. */
  96945. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96946. /**
  96947. * Set the value of an uniform to an array of number (stored as vec2)
  96948. * @param uniform defines the webGL uniform location where to store the value
  96949. * @param array defines the array of number to store
  96950. */
  96951. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96952. /**
  96953. * Set the value of an uniform to an array of number (stored as vec3)
  96954. * @param uniform defines the webGL uniform location where to store the value
  96955. * @param array defines the array of number to store
  96956. */
  96957. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96958. /**
  96959. * Set the value of an uniform to an array of number (stored as vec4)
  96960. * @param uniform defines the webGL uniform location where to store the value
  96961. * @param array defines the array of number to store
  96962. */
  96963. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96964. /**
  96965. * Set the value of an uniform to an array of float32 (stored as matrices)
  96966. * @param uniform defines the webGL uniform location where to store the value
  96967. * @param matrices defines the array of float32 to store
  96968. */
  96969. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96970. /**
  96971. * Set the value of an uniform to a matrix (3x3)
  96972. * @param uniform defines the webGL uniform location where to store the value
  96973. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96974. */
  96975. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96976. /**
  96977. * Set the value of an uniform to a matrix (2x2)
  96978. * @param uniform defines the webGL uniform location where to store the value
  96979. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96980. */
  96981. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96982. /**
  96983. * Set the value of an uniform to a number (int)
  96984. * @param uniform defines the webGL uniform location where to store the value
  96985. * @param value defines the int number to store
  96986. */
  96987. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96988. /**
  96989. * Set the value of an uniform to a number (float)
  96990. * @param uniform defines the webGL uniform location where to store the value
  96991. * @param value defines the float number to store
  96992. */
  96993. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96994. /**
  96995. * Set the value of an uniform to a vec2
  96996. * @param uniform defines the webGL uniform location where to store the value
  96997. * @param x defines the 1st component of the value
  96998. * @param y defines the 2nd component of the value
  96999. */
  97000. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97001. /**
  97002. * Set the value of an uniform to a vec3
  97003. * @param uniform defines the webGL uniform location where to store the value
  97004. * @param x defines the 1st component of the value
  97005. * @param y defines the 2nd component of the value
  97006. * @param z defines the 3rd component of the value
  97007. */
  97008. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97009. /**
  97010. * Set the value of an uniform to a boolean
  97011. * @param uniform defines the webGL uniform location where to store the value
  97012. * @param bool defines the boolean to store
  97013. */
  97014. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  97015. /**
  97016. * Set the value of an uniform to a vec4
  97017. * @param uniform defines the webGL uniform location where to store the value
  97018. * @param x defines the 1st component of the value
  97019. * @param y defines the 2nd component of the value
  97020. * @param z defines the 3rd component of the value
  97021. * @param w defines the 4th component of the value
  97022. */
  97023. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97024. /**
  97025. * Sets a Color4 on a uniform variable
  97026. * @param uniform defines the uniform location
  97027. * @param color4 defines the value to be set
  97028. */
  97029. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  97030. /**
  97031. * Set various states to the webGL context
  97032. * @param culling defines backface culling state
  97033. * @param zOffset defines the value to apply to zOffset (0 by default)
  97034. * @param force defines if states must be applied even if cache is up to date
  97035. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  97036. */
  97037. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97038. /**
  97039. * Set the z offset to apply to current rendering
  97040. * @param value defines the offset to apply
  97041. */
  97042. setZOffset(value: number): void;
  97043. /**
  97044. * Gets the current value of the zOffset
  97045. * @returns the current zOffset state
  97046. */
  97047. getZOffset(): number;
  97048. /**
  97049. * Enable or disable depth buffering
  97050. * @param enable defines the state to set
  97051. */
  97052. setDepthBuffer(enable: boolean): void;
  97053. /**
  97054. * Gets a boolean indicating if depth writing is enabled
  97055. * @returns the current depth writing state
  97056. */
  97057. getDepthWrite(): boolean;
  97058. /**
  97059. * Enable or disable depth writing
  97060. * @param enable defines the state to set
  97061. */
  97062. setDepthWrite(enable: boolean): void;
  97063. /**
  97064. * Enable or disable color writing
  97065. * @param enable defines the state to set
  97066. */
  97067. setColorWrite(enable: boolean): void;
  97068. /**
  97069. * Gets a boolean indicating if color writing is enabled
  97070. * @returns the current color writing state
  97071. */
  97072. getColorWrite(): boolean;
  97073. /**
  97074. * Sets alpha constants used by some alpha blending modes
  97075. * @param r defines the red component
  97076. * @param g defines the green component
  97077. * @param b defines the blue component
  97078. * @param a defines the alpha component
  97079. */
  97080. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  97081. /**
  97082. * Sets the current alpha mode
  97083. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  97084. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  97085. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97086. */
  97087. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97088. /**
  97089. * Gets the current alpha mode
  97090. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97091. * @returns the current alpha mode
  97092. */
  97093. getAlphaMode(): number;
  97094. /**
  97095. * Clears the list of texture accessible through engine.
  97096. * This can help preventing texture load conflict due to name collision.
  97097. */
  97098. clearInternalTexturesCache(): void;
  97099. /**
  97100. * Force the entire cache to be cleared
  97101. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97102. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97103. */
  97104. wipeCaches(bruteForce?: boolean): void;
  97105. /**
  97106. * Set the compressed texture format to use, based on the formats you have, and the formats
  97107. * supported by the hardware / browser.
  97108. *
  97109. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  97110. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  97111. * to API arguments needed to compressed textures. This puts the burden on the container
  97112. * generator to house the arcane code for determining these for current & future formats.
  97113. *
  97114. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  97115. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  97116. *
  97117. * Note: The result of this call is not taken into account when a texture is base64.
  97118. *
  97119. * @param formatsAvailable defines the list of those format families you have created
  97120. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  97121. *
  97122. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  97123. * @returns The extension selected.
  97124. */
  97125. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  97126. /** @hidden */
  97127. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97128. min: number;
  97129. mag: number;
  97130. };
  97131. /** @hidden */
  97132. _createTexture(): WebGLTexture;
  97133. /**
  97134. * Usually called from Texture.ts.
  97135. * Passed information to create a WebGLTexture
  97136. * @param urlArg defines a value which contains one of the following:
  97137. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97138. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97139. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97140. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97141. * @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)
  97142. * @param scene needed for loading to the correct scene
  97143. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97144. * @param onLoad optional callback to be called upon successful completion
  97145. * @param onError optional callback to be called upon failure
  97146. * @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
  97147. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97148. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97149. * @param forcedExtension defines the extension to use to pick the right loader
  97150. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97151. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97152. */
  97153. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  97154. /**
  97155. * @hidden
  97156. * Rescales a texture
  97157. * @param source input texutre
  97158. * @param destination destination texture
  97159. * @param scene scene to use to render the resize
  97160. * @param internalFormat format to use when resizing
  97161. * @param onComplete callback to be called when resize has completed
  97162. */
  97163. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  97164. private _unpackFlipYCached;
  97165. /**
  97166. * In case you are sharing the context with other applications, it might
  97167. * be interested to not cache the unpack flip y state to ensure a consistent
  97168. * value would be set.
  97169. */
  97170. enableUnpackFlipYCached: boolean;
  97171. /** @hidden */
  97172. _unpackFlipY(value: boolean): void;
  97173. /** @hidden */
  97174. _getUnpackAlignement(): number;
  97175. /**
  97176. * Creates a dynamic texture
  97177. * @param width defines the width of the texture
  97178. * @param height defines the height of the texture
  97179. * @param generateMipMaps defines if the engine should generate the mip levels
  97180. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97181. * @returns the dynamic texture inside an InternalTexture
  97182. */
  97183. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  97184. /**
  97185. * Update the sampling mode of a given texture
  97186. * @param samplingMode defines the required sampling mode
  97187. * @param texture defines the texture to update
  97188. */
  97189. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97190. /**
  97191. * Update the content of a dynamic texture
  97192. * @param texture defines the texture to update
  97193. * @param canvas defines the canvas containing the source
  97194. * @param invertY defines if data must be stored with Y axis inverted
  97195. * @param premulAlpha defines if alpha is stored as premultiplied
  97196. * @param format defines the format of the data
  97197. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  97198. */
  97199. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  97200. /**
  97201. * Update a video texture
  97202. * @param texture defines the texture to update
  97203. * @param video defines the video element to use
  97204. * @param invertY defines if data must be stored with Y axis inverted
  97205. */
  97206. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97207. /**
  97208. * Updates a depth texture Comparison Mode and Function.
  97209. * If the comparison Function is equal to 0, the mode will be set to none.
  97210. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  97211. * @param texture The texture to set the comparison function for
  97212. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  97213. */
  97214. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  97215. /** @hidden */
  97216. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97217. width: number;
  97218. height: number;
  97219. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97220. /**
  97221. * Creates a depth stencil texture.
  97222. * This is only available in WebGL 2 or with the depth texture extension available.
  97223. * @param size The size of face edge in the texture.
  97224. * @param options The options defining the texture.
  97225. * @returns The texture
  97226. */
  97227. createDepthStencilTexture(size: number | {
  97228. width: number;
  97229. height: number;
  97230. }, options: DepthTextureCreationOptions): InternalTexture;
  97231. /**
  97232. * Creates a depth stencil texture.
  97233. * This is only available in WebGL 2 or with the depth texture extension available.
  97234. * @param size The size of face edge in the texture.
  97235. * @param options The options defining the texture.
  97236. * @returns The texture
  97237. */
  97238. private _createDepthStencilTexture;
  97239. /**
  97240. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  97241. * @param renderTarget The render target to set the frame buffer for
  97242. */
  97243. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  97244. /**
  97245. * Creates a new render target texture
  97246. * @param size defines the size of the texture
  97247. * @param options defines the options used to create the texture
  97248. * @returns a new render target texture stored in an InternalTexture
  97249. */
  97250. createRenderTargetTexture(size: number | {
  97251. width: number;
  97252. height: number;
  97253. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97254. /** @hidden */
  97255. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97256. /**
  97257. * Updates the sample count of a render target texture
  97258. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  97259. * @param texture defines the texture to update
  97260. * @param samples defines the sample count to set
  97261. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  97262. */
  97263. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  97264. /** @hidden */
  97265. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97266. /** @hidden */
  97267. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97268. /** @hidden */
  97269. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97270. /** @hidden */
  97271. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97272. /**
  97273. * @hidden
  97274. */
  97275. _setCubeMapTextureParams(loadMipmap: boolean): void;
  97276. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97277. private _prepareWebGLTexture;
  97278. /** @hidden */
  97279. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  97280. /** @hidden */
  97281. _releaseFramebufferObjects(texture: InternalTexture): void;
  97282. /** @hidden */
  97283. _releaseTexture(texture: InternalTexture): void;
  97284. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97285. protected _setProgram(program: WebGLProgram): void;
  97286. protected _boundUniforms: {
  97287. [key: number]: WebGLUniformLocation;
  97288. };
  97289. /**
  97290. * Binds an effect to the webGL context
  97291. * @param effect defines the effect to bind
  97292. */
  97293. bindSamplers(effect: Effect): void;
  97294. private _activateCurrentTexture;
  97295. /** @hidden */
  97296. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97297. /** @hidden */
  97298. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97299. /**
  97300. * Sets a texture to the webGL context from a postprocess
  97301. * @param channel defines the channel to use
  97302. * @param postProcess defines the source postprocess
  97303. */
  97304. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  97305. /**
  97306. * Binds the output of the passed in post process to the texture channel specified
  97307. * @param channel The channel the texture should be bound to
  97308. * @param postProcess The post process which's output should be bound
  97309. */
  97310. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  97311. /**
  97312. * Unbind all textures from the webGL context
  97313. */
  97314. unbindAllTextures(): void;
  97315. /**
  97316. * Sets a texture to the according uniform.
  97317. * @param channel The texture channel
  97318. * @param uniform The uniform to set
  97319. * @param texture The texture to apply
  97320. */
  97321. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97322. /**
  97323. * Sets a depth stencil texture from a render target to the according uniform.
  97324. * @param channel The texture channel
  97325. * @param uniform The uniform to set
  97326. * @param texture The render target texture containing the depth stencil texture to apply
  97327. */
  97328. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  97329. private _bindSamplerUniformToChannel;
  97330. private _getTextureWrapMode;
  97331. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97332. /**
  97333. * Sets an array of texture to the webGL context
  97334. * @param channel defines the channel where the texture array must be set
  97335. * @param uniform defines the associated uniform location
  97336. * @param textures defines the array of textures to bind
  97337. */
  97338. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97339. /** @hidden */
  97340. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97341. private _setTextureParameterFloat;
  97342. private _setTextureParameterInteger;
  97343. /**
  97344. * Reads pixels from the current frame buffer. Please note that this function can be slow
  97345. * @param x defines the x coordinate of the rectangle where pixels must be read
  97346. * @param y defines the y coordinate of the rectangle where pixels must be read
  97347. * @param width defines the width of the rectangle where pixels must be read
  97348. * @param height defines the height of the rectangle where pixels must be read
  97349. * @returns a Uint8Array containing RGBA colors
  97350. */
  97351. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  97352. /**
  97353. * Add an externaly attached data from its key.
  97354. * This method call will fail and return false, if such key already exists.
  97355. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  97356. * @param key the unique key that identifies the data
  97357. * @param data the data object to associate to the key for this Engine instance
  97358. * @return true if no such key were already present and the data was added successfully, false otherwise
  97359. */
  97360. addExternalData<T>(key: string, data: T): boolean;
  97361. /**
  97362. * Get an externaly attached data from its key
  97363. * @param key the unique key that identifies the data
  97364. * @return the associated data, if present (can be null), or undefined if not present
  97365. */
  97366. getExternalData<T>(key: string): T;
  97367. /**
  97368. * Get an externaly attached data from its key, create it using a factory if it's not already present
  97369. * @param key the unique key that identifies the data
  97370. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  97371. * @return the associated data, can be null if the factory returned null.
  97372. */
  97373. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  97374. /**
  97375. * Remove an externaly attached data from the Engine instance
  97376. * @param key the unique key that identifies the data
  97377. * @return true if the data was successfully removed, false if it doesn't exist
  97378. */
  97379. removeExternalData(key: string): boolean;
  97380. /**
  97381. * Unbind all vertex attributes from the webGL context
  97382. */
  97383. unbindAllAttributes(): void;
  97384. /**
  97385. * 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
  97386. */
  97387. releaseEffects(): void;
  97388. /**
  97389. * Dispose and release all associated resources
  97390. */
  97391. dispose(): void;
  97392. /**
  97393. * Display the loading screen
  97394. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97395. */
  97396. displayLoadingUI(): void;
  97397. /**
  97398. * Hide the loading screen
  97399. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97400. */
  97401. hideLoadingUI(): void;
  97402. /**
  97403. * Gets the current loading screen object
  97404. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97405. */
  97406. /**
  97407. * Sets the current loading screen object
  97408. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97409. */
  97410. loadingScreen: ILoadingScreen;
  97411. /**
  97412. * Sets the current loading screen text
  97413. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97414. */
  97415. loadingUIText: string;
  97416. /**
  97417. * Sets the current loading screen background color
  97418. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97419. */
  97420. loadingUIBackgroundColor: string;
  97421. /**
  97422. * Attach a new callback raised when context lost event is fired
  97423. * @param callback defines the callback to call
  97424. */
  97425. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97426. /**
  97427. * Attach a new callback raised when context restored event is fired
  97428. * @param callback defines the callback to call
  97429. */
  97430. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97431. /**
  97432. * Gets the source code of the vertex shader associated with a specific webGL program
  97433. * @param program defines the program to use
  97434. * @returns a string containing the source code of the vertex shader associated with the program
  97435. */
  97436. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  97437. /**
  97438. * Gets the source code of the fragment shader associated with a specific webGL program
  97439. * @param program defines the program to use
  97440. * @returns a string containing the source code of the fragment shader associated with the program
  97441. */
  97442. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  97443. /**
  97444. * Get the current error code of the webGL context
  97445. * @returns the error code
  97446. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97447. */
  97448. getError(): number;
  97449. /**
  97450. * Gets the current framerate
  97451. * @returns a number representing the framerate
  97452. */
  97453. getFps(): number;
  97454. /**
  97455. * Gets the time spent between current and previous frame
  97456. * @returns a number representing the delta time in ms
  97457. */
  97458. getDeltaTime(): number;
  97459. private _measureFps;
  97460. /** @hidden */
  97461. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  97462. private _canRenderToFloatFramebuffer;
  97463. private _canRenderToHalfFloatFramebuffer;
  97464. private _canRenderToFramebuffer;
  97465. /** @hidden */
  97466. _getWebGLTextureType(type: number): number;
  97467. /** @hidden */
  97468. _getInternalFormat(format: number): number;
  97469. /** @hidden */
  97470. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97471. /** @hidden */
  97472. _getRGBAMultiSampleBufferFormat(type: number): number;
  97473. /** @hidden */
  97474. _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;
  97475. /** @hidden */
  97476. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97477. /**
  97478. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97479. * @returns true if the engine can be created
  97480. * @ignorenaming
  97481. */
  97482. static isSupported(): boolean;
  97483. /**
  97484. * Find the next highest power of two.
  97485. * @param x Number to start search from.
  97486. * @return Next highest power of two.
  97487. */
  97488. static CeilingPOT(x: number): number;
  97489. /**
  97490. * Find the next lowest power of two.
  97491. * @param x Number to start search from.
  97492. * @return Next lowest power of two.
  97493. */
  97494. static FloorPOT(x: number): number;
  97495. /**
  97496. * Find the nearest power of two.
  97497. * @param x Number to start search from.
  97498. * @return Next nearest power of two.
  97499. */
  97500. static NearestPOT(x: number): number;
  97501. /**
  97502. * Get the closest exponent of two
  97503. * @param value defines the value to approximate
  97504. * @param max defines the maximum value to return
  97505. * @param mode defines how to define the closest value
  97506. * @returns closest exponent of two of the given value
  97507. */
  97508. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97509. /**
  97510. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97511. * @param func - the function to be called
  97512. * @param requester - the object that will request the next frame. Falls back to window.
  97513. * @returns frame number
  97514. */
  97515. static QueueNewFrame(func: () => void, requester?: any): number;
  97516. /**
  97517. * Ask the browser to promote the current element to pointerlock mode
  97518. * @param element defines the DOM element to promote
  97519. */
  97520. static _RequestPointerlock(element: HTMLElement): void;
  97521. /**
  97522. * Asks the browser to exit pointerlock mode
  97523. */
  97524. static _ExitPointerlock(): void;
  97525. /**
  97526. * Ask the browser to promote the current element to fullscreen rendering mode
  97527. * @param element defines the DOM element to promote
  97528. */
  97529. static _RequestFullscreen(element: HTMLElement): void;
  97530. /**
  97531. * Asks the browser to exit fullscreen mode
  97532. */
  97533. static _ExitFullscreen(): void;
  97534. }
  97535. }
  97536. declare module BABYLON {
  97537. /**
  97538. * The engine store class is responsible to hold all the instances of Engine and Scene created
  97539. * during the life time of the application.
  97540. */
  97541. export class EngineStore {
  97542. /** Gets the list of created engines */
  97543. static Instances: Engine[];
  97544. /** @hidden */
  97545. static _LastCreatedScene: Nullable<Scene>;
  97546. /**
  97547. * Gets the latest created engine
  97548. */
  97549. static readonly LastCreatedEngine: Nullable<Engine>;
  97550. /**
  97551. * Gets the latest created scene
  97552. */
  97553. static readonly LastCreatedScene: Nullable<Scene>;
  97554. /**
  97555. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97556. * @ignorenaming
  97557. */
  97558. static UseFallbackTexture: boolean;
  97559. /**
  97560. * Texture content used if a texture cannot loaded
  97561. * @ignorenaming
  97562. */
  97563. static FallbackTexture: string;
  97564. }
  97565. }
  97566. declare module BABYLON {
  97567. /**
  97568. * Helper class that provides a small promise polyfill
  97569. */
  97570. export class PromisePolyfill {
  97571. /**
  97572. * Static function used to check if the polyfill is required
  97573. * If this is the case then the function will inject the polyfill to window.Promise
  97574. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  97575. */
  97576. static Apply(force?: boolean): void;
  97577. }
  97578. }
  97579. declare module BABYLON {
  97580. /**
  97581. * Interface for screenshot methods with describe argument called `size` as object with options
  97582. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  97583. */
  97584. export interface IScreenshotSize {
  97585. /**
  97586. * number in pixels for canvas height
  97587. */
  97588. height?: number;
  97589. /**
  97590. * multiplier allowing render at a higher or lower resolution
  97591. * If value is defined then height and width will be ignored and taken from camera
  97592. */
  97593. precision?: number;
  97594. /**
  97595. * number in pixels for canvas width
  97596. */
  97597. width?: number;
  97598. }
  97599. }
  97600. declare module BABYLON {
  97601. interface IColor4Like {
  97602. r: float;
  97603. g: float;
  97604. b: float;
  97605. a: float;
  97606. }
  97607. /**
  97608. * Class containing a set of static utilities functions
  97609. */
  97610. export class Tools {
  97611. /**
  97612. * Gets or sets the base URL to use to load assets
  97613. */
  97614. static BaseUrl: string;
  97615. /**
  97616. * Enable/Disable Custom HTTP Request Headers globally.
  97617. * default = false
  97618. * @see CustomRequestHeaders
  97619. */
  97620. static UseCustomRequestHeaders: boolean;
  97621. /**
  97622. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  97623. * i.e. when loading files, where the server/service expects an Authorization header
  97624. */
  97625. static CustomRequestHeaders: {
  97626. [key: string]: string;
  97627. };
  97628. /**
  97629. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  97630. */
  97631. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  97632. /**
  97633. * Default behaviour for cors in the application.
  97634. * It can be a string if the expected behavior is identical in the entire app.
  97635. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  97636. */
  97637. static CorsBehavior: string | ((url: string | string[]) => string);
  97638. /**
  97639. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97640. * @ignorenaming
  97641. */
  97642. static UseFallbackTexture: boolean;
  97643. /**
  97644. * Use this object to register external classes like custom textures or material
  97645. * to allow the laoders to instantiate them
  97646. */
  97647. static RegisteredExternalClasses: {
  97648. [key: string]: Object;
  97649. };
  97650. /**
  97651. * Texture content used if a texture cannot loaded
  97652. * @ignorenaming
  97653. */
  97654. static fallbackTexture: string;
  97655. /**
  97656. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97657. * @param u defines the coordinate on X axis
  97658. * @param v defines the coordinate on Y axis
  97659. * @param width defines the width of the source data
  97660. * @param height defines the height of the source data
  97661. * @param pixels defines the source byte array
  97662. * @param color defines the output color
  97663. */
  97664. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  97665. /**
  97666. * Interpolates between a and b via alpha
  97667. * @param a The lower value (returned when alpha = 0)
  97668. * @param b The upper value (returned when alpha = 1)
  97669. * @param alpha The interpolation-factor
  97670. * @return The mixed value
  97671. */
  97672. static Mix(a: number, b: number, alpha: number): number;
  97673. /**
  97674. * Tries to instantiate a new object from a given class name
  97675. * @param className defines the class name to instantiate
  97676. * @returns the new object or null if the system was not able to do the instantiation
  97677. */
  97678. static Instantiate(className: string): any;
  97679. /**
  97680. * Provides a slice function that will work even on IE
  97681. * @param data defines the array to slice
  97682. * @param start defines the start of the data (optional)
  97683. * @param end defines the end of the data (optional)
  97684. * @returns the new sliced array
  97685. */
  97686. static Slice<T>(data: T, start?: number, end?: number): T;
  97687. /**
  97688. * Polyfill for setImmediate
  97689. * @param action defines the action to execute after the current execution block
  97690. */
  97691. static SetImmediate(action: () => void): void;
  97692. /**
  97693. * Function indicating if a number is an exponent of 2
  97694. * @param value defines the value to test
  97695. * @returns true if the value is an exponent of 2
  97696. */
  97697. static IsExponentOfTwo(value: number): boolean;
  97698. private static _tmpFloatArray;
  97699. /**
  97700. * Returns the nearest 32-bit single precision float representation of a Number
  97701. * @param value A Number. If the parameter is of a different type, it will get converted
  97702. * to a number or to NaN if it cannot be converted
  97703. * @returns number
  97704. */
  97705. static FloatRound(value: number): number;
  97706. /**
  97707. * Extracts the filename from a path
  97708. * @param path defines the path to use
  97709. * @returns the filename
  97710. */
  97711. static GetFilename(path: string): string;
  97712. /**
  97713. * Extracts the "folder" part of a path (everything before the filename).
  97714. * @param uri The URI to extract the info from
  97715. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97716. * @returns The "folder" part of the path
  97717. */
  97718. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  97719. /**
  97720. * Extracts text content from a DOM element hierarchy
  97721. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  97722. */
  97723. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  97724. /**
  97725. * Convert an angle in radians to degrees
  97726. * @param angle defines the angle to convert
  97727. * @returns the angle in degrees
  97728. */
  97729. static ToDegrees(angle: number): number;
  97730. /**
  97731. * Convert an angle in degrees to radians
  97732. * @param angle defines the angle to convert
  97733. * @returns the angle in radians
  97734. */
  97735. static ToRadians(angle: number): number;
  97736. /**
  97737. * Encode a buffer to a base64 string
  97738. * @param buffer defines the buffer to encode
  97739. * @returns the encoded string
  97740. */
  97741. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  97742. /**
  97743. * Returns an array if obj is not an array
  97744. * @param obj defines the object to evaluate as an array
  97745. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97746. * @returns either obj directly if obj is an array or a new array containing obj
  97747. */
  97748. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  97749. /**
  97750. * Gets the pointer prefix to use
  97751. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97752. */
  97753. static GetPointerPrefix(): string;
  97754. /**
  97755. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97756. * @param url define the url we are trying
  97757. * @param element define the dom element where to configure the cors policy
  97758. */
  97759. static SetCorsBehavior(url: string | string[], element: {
  97760. crossOrigin: string | null;
  97761. }): void;
  97762. /**
  97763. * Removes unwanted characters from an url
  97764. * @param url defines the url to clean
  97765. * @returns the cleaned url
  97766. */
  97767. static CleanUrl(url: string): string;
  97768. /**
  97769. * Gets or sets a function used to pre-process url before using them to load assets
  97770. */
  97771. static PreprocessUrl: (url: string) => string;
  97772. /**
  97773. * Loads an image as an HTMLImageElement.
  97774. * @param input url string, ArrayBuffer, or Blob to load
  97775. * @param onLoad callback called when the image successfully loads
  97776. * @param onError callback called when the image fails to load
  97777. * @param offlineProvider offline provider for caching
  97778. * @returns the HTMLImageElement of the loaded image
  97779. */
  97780. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  97781. /**
  97782. * Loads a file
  97783. * @param url url string, ArrayBuffer, or Blob to load
  97784. * @param onSuccess callback called when the file successfully loads
  97785. * @param onProgress callback called while file is loading (if the server supports this mode)
  97786. * @param offlineProvider defines the offline provider for caching
  97787. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97788. * @param onError callback called when the file fails to load
  97789. * @returns a file request object
  97790. */
  97791. 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;
  97792. /**
  97793. * Loads a file from a url
  97794. * @param url the file url to load
  97795. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  97796. */
  97797. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  97798. /**
  97799. * Load a script (identified by an url). When the url returns, the
  97800. * content of this file is added into a new script element, attached to the DOM (body element)
  97801. * @param scriptUrl defines the url of the script to laod
  97802. * @param onSuccess defines the callback called when the script is loaded
  97803. * @param onError defines the callback to call if an error occurs
  97804. * @param scriptId defines the id of the script element
  97805. */
  97806. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  97807. /**
  97808. * Load an asynchronous script (identified by an url). When the url returns, the
  97809. * content of this file is added into a new script element, attached to the DOM (body element)
  97810. * @param scriptUrl defines the url of the script to laod
  97811. * @param scriptId defines the id of the script element
  97812. * @returns a promise request object
  97813. */
  97814. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  97815. /**
  97816. * Loads a file from a blob
  97817. * @param fileToLoad defines the blob to use
  97818. * @param callback defines the callback to call when data is loaded
  97819. * @param progressCallback defines the callback to call during loading process
  97820. * @returns a file request object
  97821. */
  97822. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  97823. /**
  97824. * Loads a file
  97825. * @param fileToLoad defines the file to load
  97826. * @param callback defines the callback to call when data is loaded
  97827. * @param progressCallBack defines the callback to call during loading process
  97828. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97829. * @returns a file request object
  97830. */
  97831. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  97832. /**
  97833. * Creates a data url from a given string content
  97834. * @param content defines the content to convert
  97835. * @returns the new data url link
  97836. */
  97837. static FileAsURL(content: string): string;
  97838. /**
  97839. * Format the given number to a specific decimal format
  97840. * @param value defines the number to format
  97841. * @param decimals defines the number of decimals to use
  97842. * @returns the formatted string
  97843. */
  97844. static Format(value: number, decimals?: number): string;
  97845. /**
  97846. * Tries to copy an object by duplicating every property
  97847. * @param source defines the source object
  97848. * @param destination defines the target object
  97849. * @param doNotCopyList defines a list of properties to avoid
  97850. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  97851. */
  97852. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  97853. /**
  97854. * Gets a boolean indicating if the given object has no own property
  97855. * @param obj defines the object to test
  97856. * @returns true if object has no own property
  97857. */
  97858. static IsEmpty(obj: any): boolean;
  97859. /**
  97860. * Function used to register events at window level
  97861. * @param windowElement defines the Window object to use
  97862. * @param events defines the events to register
  97863. */
  97864. static RegisterTopRootEvents(windowElement: Window, events: {
  97865. name: string;
  97866. handler: Nullable<(e: FocusEvent) => any>;
  97867. }[]): void;
  97868. /**
  97869. * Function used to unregister events from window level
  97870. * @param windowElement defines the Window object to use
  97871. * @param events defines the events to unregister
  97872. */
  97873. static UnregisterTopRootEvents(windowElement: Window, events: {
  97874. name: string;
  97875. handler: Nullable<(e: FocusEvent) => any>;
  97876. }[]): void;
  97877. /**
  97878. * @ignore
  97879. */
  97880. static _ScreenshotCanvas: HTMLCanvasElement;
  97881. /**
  97882. * Dumps the current bound framebuffer
  97883. * @param width defines the rendering width
  97884. * @param height defines the rendering height
  97885. * @param engine defines the hosting engine
  97886. * @param successCallback defines the callback triggered once the data are available
  97887. * @param mimeType defines the mime type of the result
  97888. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  97889. */
  97890. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97891. /**
  97892. * Converts the canvas data to blob.
  97893. * This acts as a polyfill for browsers not supporting the to blob function.
  97894. * @param canvas Defines the canvas to extract the data from
  97895. * @param successCallback Defines the callback triggered once the data are available
  97896. * @param mimeType Defines the mime type of the result
  97897. */
  97898. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  97899. /**
  97900. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  97901. * @param successCallback defines the callback triggered once the data are available
  97902. * @param mimeType defines the mime type of the result
  97903. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  97904. */
  97905. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97906. /**
  97907. * Downloads a blob in the browser
  97908. * @param blob defines the blob to download
  97909. * @param fileName defines the name of the downloaded file
  97910. */
  97911. static Download(blob: Blob, fileName: string): void;
  97912. /**
  97913. * Captures a screenshot of the current rendering
  97914. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97915. * @param engine defines the rendering engine
  97916. * @param camera defines the source camera
  97917. * @param size This parameter can be set to a single number or to an object with the
  97918. * following (optional) properties: precision, width, height. If a single number is passed,
  97919. * it will be used for both width and height. If an object is passed, the screenshot size
  97920. * will be derived from the parameters. The precision property is a multiplier allowing
  97921. * rendering at a higher or lower resolution
  97922. * @param successCallback defines the callback receives a single parameter which contains the
  97923. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97924. * src parameter of an <img> to display it
  97925. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97926. * Check your browser for supported MIME types
  97927. */
  97928. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  97929. /**
  97930. * Captures a screenshot of the current rendering
  97931. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97932. * @param engine defines the rendering engine
  97933. * @param camera defines the source camera
  97934. * @param size This parameter can be set to a single number or to an object with the
  97935. * following (optional) properties: precision, width, height. If a single number is passed,
  97936. * it will be used for both width and height. If an object is passed, the screenshot size
  97937. * will be derived from the parameters. The precision property is a multiplier allowing
  97938. * rendering at a higher or lower resolution
  97939. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97940. * Check your browser for supported MIME types
  97941. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97942. * to the src parameter of an <img> to display it
  97943. */
  97944. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  97945. /**
  97946. * Generates an image screenshot from the specified camera.
  97947. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97948. * @param engine The engine to use for rendering
  97949. * @param camera The camera to use for rendering
  97950. * @param size This parameter can be set to a single number or to an object with the
  97951. * following (optional) properties: precision, width, height. If a single number is passed,
  97952. * it will be used for both width and height. If an object is passed, the screenshot size
  97953. * will be derived from the parameters. The precision property is a multiplier allowing
  97954. * rendering at a higher or lower resolution
  97955. * @param successCallback The callback receives a single parameter which contains the
  97956. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97957. * src parameter of an <img> to display it
  97958. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97959. * Check your browser for supported MIME types
  97960. * @param samples Texture samples (default: 1)
  97961. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97962. * @param fileName A name for for the downloaded file.
  97963. */
  97964. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  97965. /**
  97966. * Generates an image screenshot from the specified camera.
  97967. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97968. * @param engine The engine to use for rendering
  97969. * @param camera The camera to use for rendering
  97970. * @param size This parameter can be set to a single number or to an object with the
  97971. * following (optional) properties: precision, width, height. If a single number is passed,
  97972. * it will be used for both width and height. If an object is passed, the screenshot size
  97973. * will be derived from the parameters. The precision property is a multiplier allowing
  97974. * rendering at a higher or lower resolution
  97975. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97976. * Check your browser for supported MIME types
  97977. * @param samples Texture samples (default: 1)
  97978. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97979. * @param fileName A name for for the downloaded file.
  97980. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97981. * to the src parameter of an <img> to display it
  97982. */
  97983. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  97984. /**
  97985. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97986. * Be aware Math.random() could cause collisions, but:
  97987. * "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"
  97988. * @returns a pseudo random id
  97989. */
  97990. static RandomId(): string;
  97991. /**
  97992. * Test if the given uri is a base64 string
  97993. * @param uri The uri to test
  97994. * @return True if the uri is a base64 string or false otherwise
  97995. */
  97996. static IsBase64(uri: string): boolean;
  97997. /**
  97998. * Decode the given base64 uri.
  97999. * @param uri The uri to decode
  98000. * @return The decoded base64 data.
  98001. */
  98002. static DecodeBase64(uri: string): ArrayBuffer;
  98003. /**
  98004. * Gets the absolute url.
  98005. * @param url the input url
  98006. * @return the absolute url
  98007. */
  98008. static GetAbsoluteUrl(url: string): string;
  98009. /**
  98010. * No log
  98011. */
  98012. static readonly NoneLogLevel: number;
  98013. /**
  98014. * Only message logs
  98015. */
  98016. static readonly MessageLogLevel: number;
  98017. /**
  98018. * Only warning logs
  98019. */
  98020. static readonly WarningLogLevel: number;
  98021. /**
  98022. * Only error logs
  98023. */
  98024. static readonly ErrorLogLevel: number;
  98025. /**
  98026. * All logs
  98027. */
  98028. static readonly AllLogLevel: number;
  98029. /**
  98030. * Gets a value indicating the number of loading errors
  98031. * @ignorenaming
  98032. */
  98033. static readonly errorsCount: number;
  98034. /**
  98035. * Callback called when a new log is added
  98036. */
  98037. static OnNewCacheEntry: (entry: string) => void;
  98038. /**
  98039. * Log a message to the console
  98040. * @param message defines the message to log
  98041. */
  98042. static Log(message: string): void;
  98043. /**
  98044. * Write a warning message to the console
  98045. * @param message defines the message to log
  98046. */
  98047. static Warn(message: string): void;
  98048. /**
  98049. * Write an error message to the console
  98050. * @param message defines the message to log
  98051. */
  98052. static Error(message: string): void;
  98053. /**
  98054. * Gets current log cache (list of logs)
  98055. */
  98056. static readonly LogCache: string;
  98057. /**
  98058. * Clears the log cache
  98059. */
  98060. static ClearLogCache(): void;
  98061. /**
  98062. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98063. */
  98064. static LogLevels: number;
  98065. /**
  98066. * Checks if the window object exists
  98067. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98068. */
  98069. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  98070. /**
  98071. * No performance log
  98072. */
  98073. static readonly PerformanceNoneLogLevel: number;
  98074. /**
  98075. * Use user marks to log performance
  98076. */
  98077. static readonly PerformanceUserMarkLogLevel: number;
  98078. /**
  98079. * Log performance to the console
  98080. */
  98081. static readonly PerformanceConsoleLogLevel: number;
  98082. private static _performance;
  98083. /**
  98084. * Sets the current performance log level
  98085. */
  98086. static PerformanceLogLevel: number;
  98087. private static _StartPerformanceCounterDisabled;
  98088. private static _EndPerformanceCounterDisabled;
  98089. private static _StartUserMark;
  98090. private static _EndUserMark;
  98091. private static _StartPerformanceConsole;
  98092. private static _EndPerformanceConsole;
  98093. /**
  98094. * Starts a performance counter
  98095. */
  98096. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98097. /**
  98098. * Ends a specific performance coutner
  98099. */
  98100. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98101. /**
  98102. * Gets either window.performance.now() if supported or Date.now() else
  98103. */
  98104. static readonly Now: number;
  98105. /**
  98106. * This method will return the name of the class used to create the instance of the given object.
  98107. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98108. * @param object the object to get the class name from
  98109. * @param isType defines if the object is actually a type
  98110. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98111. */
  98112. static GetClassName(object: any, isType?: boolean): string;
  98113. /**
  98114. * Gets the first element of an array satisfying a given predicate
  98115. * @param array defines the array to browse
  98116. * @param predicate defines the predicate to use
  98117. * @returns null if not found or the element
  98118. */
  98119. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  98120. /**
  98121. * This method will return the name of the full name of the class, including its owning module (if any).
  98122. * 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).
  98123. * @param object the object to get the class name from
  98124. * @param isType defines if the object is actually a type
  98125. * @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.
  98126. * @ignorenaming
  98127. */
  98128. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  98129. /**
  98130. * Returns a promise that resolves after the given amount of time.
  98131. * @param delay Number of milliseconds to delay
  98132. * @returns Promise that resolves after the given amount of time
  98133. */
  98134. static DelayAsync(delay: number): Promise<void>;
  98135. }
  98136. /**
  98137. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98138. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98139. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98140. * @param name The name of the class, case should be preserved
  98141. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98142. */
  98143. export function className(name: string, module?: string): (target: Object) => void;
  98144. /**
  98145. * An implementation of a loop for asynchronous functions.
  98146. */
  98147. export class AsyncLoop {
  98148. /**
  98149. * Defines the number of iterations for the loop
  98150. */
  98151. iterations: number;
  98152. /**
  98153. * Defines the current index of the loop.
  98154. */
  98155. index: number;
  98156. private _done;
  98157. private _fn;
  98158. private _successCallback;
  98159. /**
  98160. * Constructor.
  98161. * @param iterations the number of iterations.
  98162. * @param func the function to run each iteration
  98163. * @param successCallback the callback that will be called upon succesful execution
  98164. * @param offset starting offset.
  98165. */
  98166. constructor(
  98167. /**
  98168. * Defines the number of iterations for the loop
  98169. */
  98170. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  98171. /**
  98172. * Execute the next iteration. Must be called after the last iteration was finished.
  98173. */
  98174. executeNext(): void;
  98175. /**
  98176. * Break the loop and run the success callback.
  98177. */
  98178. breakLoop(): void;
  98179. /**
  98180. * Create and run an async loop.
  98181. * @param iterations the number of iterations.
  98182. * @param fn the function to run each iteration
  98183. * @param successCallback the callback that will be called upon succesful execution
  98184. * @param offset starting offset.
  98185. * @returns the created async loop object
  98186. */
  98187. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  98188. /**
  98189. * A for-loop that will run a given number of iterations synchronous and the rest async.
  98190. * @param iterations total number of iterations
  98191. * @param syncedIterations number of synchronous iterations in each async iteration.
  98192. * @param fn the function to call each iteration.
  98193. * @param callback a success call back that will be called when iterating stops.
  98194. * @param breakFunction a break condition (optional)
  98195. * @param timeout timeout settings for the setTimeout function. default - 0.
  98196. * @returns the created async loop object
  98197. */
  98198. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  98199. }
  98200. }
  98201. declare module BABYLON {
  98202. /** @hidden */
  98203. export interface ICollisionCoordinator {
  98204. createCollider(): Collider;
  98205. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98206. init(scene: Scene): void;
  98207. }
  98208. /** @hidden */
  98209. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  98210. private _scene;
  98211. private _scaledPosition;
  98212. private _scaledVelocity;
  98213. private _finalPosition;
  98214. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98215. createCollider(): Collider;
  98216. init(scene: Scene): void;
  98217. private _collideWithWorld;
  98218. }
  98219. }
  98220. declare module BABYLON {
  98221. /**
  98222. * Class used to manage all inputs for the scene.
  98223. */
  98224. export class InputManager {
  98225. /** The distance in pixel that you have to move to prevent some events */
  98226. static DragMovementThreshold: number;
  98227. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  98228. static LongPressDelay: number;
  98229. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  98230. static DoubleClickDelay: number;
  98231. /** If you need to check double click without raising a single click at first click, enable this flag */
  98232. static ExclusiveDoubleClickMode: boolean;
  98233. private _wheelEventName;
  98234. private _onPointerMove;
  98235. private _onPointerDown;
  98236. private _onPointerUp;
  98237. private _initClickEvent;
  98238. private _initActionManager;
  98239. private _delayedSimpleClick;
  98240. private _delayedSimpleClickTimeout;
  98241. private _previousDelayedSimpleClickTimeout;
  98242. private _meshPickProceed;
  98243. private _previousButtonPressed;
  98244. private _currentPickResult;
  98245. private _previousPickResult;
  98246. private _totalPointersPressed;
  98247. private _doubleClickOccured;
  98248. private _pointerOverMesh;
  98249. private _pickedDownMesh;
  98250. private _pickedUpMesh;
  98251. private _pointerX;
  98252. private _pointerY;
  98253. private _unTranslatedPointerX;
  98254. private _unTranslatedPointerY;
  98255. private _startingPointerPosition;
  98256. private _previousStartingPointerPosition;
  98257. private _startingPointerTime;
  98258. private _previousStartingPointerTime;
  98259. private _pointerCaptures;
  98260. private _onKeyDown;
  98261. private _onKeyUp;
  98262. private _onCanvasFocusObserver;
  98263. private _onCanvasBlurObserver;
  98264. private _scene;
  98265. /**
  98266. * Creates a new InputManager
  98267. * @param scene defines the hosting scene
  98268. */
  98269. constructor(scene: Scene);
  98270. /**
  98271. * Gets the mesh that is currently under the pointer
  98272. */
  98273. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98274. /**
  98275. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  98276. */
  98277. readonly unTranslatedPointer: Vector2;
  98278. /**
  98279. * Gets or sets the current on-screen X position of the pointer
  98280. */
  98281. pointerX: number;
  98282. /**
  98283. * Gets or sets the current on-screen Y position of the pointer
  98284. */
  98285. pointerY: number;
  98286. private _updatePointerPosition;
  98287. private _processPointerMove;
  98288. private _setRayOnPointerInfo;
  98289. private _checkPrePointerObservable;
  98290. /**
  98291. * Use this method to simulate a pointer move on a mesh
  98292. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98293. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98294. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98295. */
  98296. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98297. /**
  98298. * Use this method to simulate a pointer down on a mesh
  98299. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98300. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98301. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98302. */
  98303. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98304. private _processPointerDown;
  98305. /** @hidden */
  98306. _isPointerSwiping(): boolean;
  98307. /**
  98308. * Use this method to simulate a pointer up on a mesh
  98309. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98310. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98311. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98312. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98313. */
  98314. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  98315. private _processPointerUp;
  98316. /**
  98317. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98318. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98319. * @returns true if the pointer was captured
  98320. */
  98321. isPointerCaptured(pointerId?: number): boolean;
  98322. /**
  98323. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98324. * @param attachUp defines if you want to attach events to pointerup
  98325. * @param attachDown defines if you want to attach events to pointerdown
  98326. * @param attachMove defines if you want to attach events to pointermove
  98327. */
  98328. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98329. /**
  98330. * Detaches all event handlers
  98331. */
  98332. detachControl(): void;
  98333. /**
  98334. * Force the value of meshUnderPointer
  98335. * @param mesh defines the mesh to use
  98336. */
  98337. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98338. /**
  98339. * Gets the mesh under the pointer
  98340. * @returns a Mesh or null if no mesh is under the pointer
  98341. */
  98342. getPointerOverMesh(): Nullable<AbstractMesh>;
  98343. }
  98344. }
  98345. declare module BABYLON {
  98346. /**
  98347. * Helper class used to generate session unique ID
  98348. */
  98349. export class UniqueIdGenerator {
  98350. private static _UniqueIdCounter;
  98351. /**
  98352. * Gets an unique (relatively to the current scene) Id
  98353. */
  98354. static readonly UniqueId: number;
  98355. }
  98356. }
  98357. declare module BABYLON {
  98358. /**
  98359. * This class defines the direct association between an animation and a target
  98360. */
  98361. export class TargetedAnimation {
  98362. /**
  98363. * Animation to perform
  98364. */
  98365. animation: Animation;
  98366. /**
  98367. * Target to animate
  98368. */
  98369. target: any;
  98370. /**
  98371. * Serialize the object
  98372. * @returns the JSON object representing the current entity
  98373. */
  98374. serialize(): any;
  98375. }
  98376. /**
  98377. * Use this class to create coordinated animations on multiple targets
  98378. */
  98379. export class AnimationGroup implements IDisposable {
  98380. /** The name of the animation group */
  98381. name: string;
  98382. private _scene;
  98383. private _targetedAnimations;
  98384. private _animatables;
  98385. private _from;
  98386. private _to;
  98387. private _isStarted;
  98388. private _isPaused;
  98389. private _speedRatio;
  98390. private _loopAnimation;
  98391. /**
  98392. * Gets or sets the unique id of the node
  98393. */
  98394. uniqueId: number;
  98395. /**
  98396. * This observable will notify when one animation have ended
  98397. */
  98398. onAnimationEndObservable: Observable<TargetedAnimation>;
  98399. /**
  98400. * Observer raised when one animation loops
  98401. */
  98402. onAnimationLoopObservable: Observable<TargetedAnimation>;
  98403. /**
  98404. * This observable will notify when all animations have ended.
  98405. */
  98406. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  98407. /**
  98408. * This observable will notify when all animations have paused.
  98409. */
  98410. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  98411. /**
  98412. * This observable will notify when all animations are playing.
  98413. */
  98414. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  98415. /**
  98416. * Gets the first frame
  98417. */
  98418. readonly from: number;
  98419. /**
  98420. * Gets the last frame
  98421. */
  98422. readonly to: number;
  98423. /**
  98424. * Define if the animations are started
  98425. */
  98426. readonly isStarted: boolean;
  98427. /**
  98428. * Gets a value indicating that the current group is playing
  98429. */
  98430. readonly isPlaying: boolean;
  98431. /**
  98432. * Gets or sets the speed ratio to use for all animations
  98433. */
  98434. /**
  98435. * Gets or sets the speed ratio to use for all animations
  98436. */
  98437. speedRatio: number;
  98438. /**
  98439. * Gets or sets if all animations should loop or not
  98440. */
  98441. loopAnimation: boolean;
  98442. /**
  98443. * Gets the targeted animations for this animation group
  98444. */
  98445. readonly targetedAnimations: Array<TargetedAnimation>;
  98446. /**
  98447. * returning the list of animatables controlled by this animation group.
  98448. */
  98449. readonly animatables: Array<Animatable>;
  98450. /**
  98451. * Instantiates a new Animation Group.
  98452. * This helps managing several animations at once.
  98453. * @see http://doc.babylonjs.com/how_to/group
  98454. * @param name Defines the name of the group
  98455. * @param scene Defines the scene the group belongs to
  98456. */
  98457. constructor(
  98458. /** The name of the animation group */
  98459. name: string, scene?: Nullable<Scene>);
  98460. /**
  98461. * Add an animation (with its target) in the group
  98462. * @param animation defines the animation we want to add
  98463. * @param target defines the target of the animation
  98464. * @returns the TargetedAnimation object
  98465. */
  98466. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  98467. /**
  98468. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  98469. * It can add constant keys at begin or end
  98470. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  98471. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  98472. * @returns the animation group
  98473. */
  98474. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  98475. /**
  98476. * Start all animations on given targets
  98477. * @param loop defines if animations must loop
  98478. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  98479. * @param from defines the from key (optional)
  98480. * @param to defines the to key (optional)
  98481. * @returns the current animation group
  98482. */
  98483. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  98484. /**
  98485. * Pause all animations
  98486. * @returns the animation group
  98487. */
  98488. pause(): AnimationGroup;
  98489. /**
  98490. * Play all animations to initial state
  98491. * This function will start() the animations if they were not started or will restart() them if they were paused
  98492. * @param loop defines if animations must loop
  98493. * @returns the animation group
  98494. */
  98495. play(loop?: boolean): AnimationGroup;
  98496. /**
  98497. * Reset all animations to initial state
  98498. * @returns the animation group
  98499. */
  98500. reset(): AnimationGroup;
  98501. /**
  98502. * Restart animations from key 0
  98503. * @returns the animation group
  98504. */
  98505. restart(): AnimationGroup;
  98506. /**
  98507. * Stop all animations
  98508. * @returns the animation group
  98509. */
  98510. stop(): AnimationGroup;
  98511. /**
  98512. * Set animation weight for all animatables
  98513. * @param weight defines the weight to use
  98514. * @return the animationGroup
  98515. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98516. */
  98517. setWeightForAllAnimatables(weight: number): AnimationGroup;
  98518. /**
  98519. * Synchronize and normalize all animatables with a source animatable
  98520. * @param root defines the root animatable to synchronize with
  98521. * @return the animationGroup
  98522. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98523. */
  98524. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  98525. /**
  98526. * Goes to a specific frame in this animation group
  98527. * @param frame the frame number to go to
  98528. * @return the animationGroup
  98529. */
  98530. goToFrame(frame: number): AnimationGroup;
  98531. /**
  98532. * Dispose all associated resources
  98533. */
  98534. dispose(): void;
  98535. private _checkAnimationGroupEnded;
  98536. /**
  98537. * Clone the current animation group and returns a copy
  98538. * @param newName defines the name of the new group
  98539. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  98540. * @returns the new aniamtion group
  98541. */
  98542. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  98543. /**
  98544. * Serializes the animationGroup to an object
  98545. * @returns Serialized object
  98546. */
  98547. serialize(): any;
  98548. /**
  98549. * Returns a new AnimationGroup object parsed from the source provided.
  98550. * @param parsedAnimationGroup defines the source
  98551. * @param scene defines the scene that will receive the animationGroup
  98552. * @returns a new AnimationGroup
  98553. */
  98554. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  98555. /**
  98556. * Returns the string "AnimationGroup"
  98557. * @returns "AnimationGroup"
  98558. */
  98559. getClassName(): string;
  98560. /**
  98561. * Creates a detailled string about the object
  98562. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  98563. * @returns a string representing the object
  98564. */
  98565. toString(fullDetails?: boolean): string;
  98566. }
  98567. }
  98568. declare module BABYLON {
  98569. /**
  98570. * Define an interface for all classes that will hold resources
  98571. */
  98572. export interface IDisposable {
  98573. /**
  98574. * Releases all held resources
  98575. */
  98576. dispose(): void;
  98577. }
  98578. /** Interface defining initialization parameters for Scene class */
  98579. export interface SceneOptions {
  98580. /**
  98581. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  98582. * It will improve performance when the number of geometries becomes important.
  98583. */
  98584. useGeometryUniqueIdsMap?: boolean;
  98585. /**
  98586. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  98587. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98588. */
  98589. useMaterialMeshMap?: boolean;
  98590. /**
  98591. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  98592. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98593. */
  98594. useClonedMeshhMap?: boolean;
  98595. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  98596. virtual?: boolean;
  98597. }
  98598. /**
  98599. * Represents a scene to be rendered by the engine.
  98600. * @see http://doc.babylonjs.com/features/scene
  98601. */
  98602. export class Scene extends AbstractScene implements IAnimatable {
  98603. /** The fog is deactivated */
  98604. static readonly FOGMODE_NONE: number;
  98605. /** The fog density is following an exponential function */
  98606. static readonly FOGMODE_EXP: number;
  98607. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  98608. static readonly FOGMODE_EXP2: number;
  98609. /** The fog density is following a linear function. */
  98610. static readonly FOGMODE_LINEAR: number;
  98611. /**
  98612. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  98613. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98614. */
  98615. static MinDeltaTime: number;
  98616. /**
  98617. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  98618. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98619. */
  98620. static MaxDeltaTime: number;
  98621. /**
  98622. * Factory used to create the default material.
  98623. * @param name The name of the material to create
  98624. * @param scene The scene to create the material for
  98625. * @returns The default material
  98626. */
  98627. static DefaultMaterialFactory(scene: Scene): Material;
  98628. /**
  98629. * Factory used to create the a collision coordinator.
  98630. * @returns The collision coordinator
  98631. */
  98632. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  98633. /** @hidden */
  98634. _inputManager: InputManager;
  98635. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  98636. cameraToUseForPointers: Nullable<Camera>;
  98637. /** @hidden */
  98638. readonly _isScene: boolean;
  98639. /**
  98640. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  98641. */
  98642. autoClear: boolean;
  98643. /**
  98644. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  98645. */
  98646. autoClearDepthAndStencil: boolean;
  98647. /**
  98648. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  98649. */
  98650. clearColor: Color4;
  98651. /**
  98652. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  98653. */
  98654. ambientColor: Color3;
  98655. /**
  98656. * This is use to store the default BRDF lookup for PBR materials in your scene.
  98657. * It should only be one of the following (if not the default embedded one):
  98658. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  98659. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  98660. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  98661. * The material properties need to be setup according to the type of texture in use.
  98662. */
  98663. environmentBRDFTexture: BaseTexture;
  98664. /** @hidden */
  98665. protected _environmentTexture: Nullable<BaseTexture>;
  98666. /**
  98667. * Texture used in all pbr material as the reflection texture.
  98668. * As in the majority of the scene they are the same (exception for multi room and so on),
  98669. * this is easier to reference from here than from all the materials.
  98670. */
  98671. /**
  98672. * Texture used in all pbr material as the reflection texture.
  98673. * As in the majority of the scene they are the same (exception for multi room and so on),
  98674. * this is easier to set here than in all the materials.
  98675. */
  98676. environmentTexture: Nullable<BaseTexture>;
  98677. /** @hidden */
  98678. protected _environmentIntensity: number;
  98679. /**
  98680. * Intensity of the environment in all pbr material.
  98681. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98682. * As in the majority of the scene they are the same (exception for multi room and so on),
  98683. * this is easier to reference from here than from all the materials.
  98684. */
  98685. /**
  98686. * Intensity of the environment in all pbr material.
  98687. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98688. * As in the majority of the scene they are the same (exception for multi room and so on),
  98689. * this is easier to set here than in all the materials.
  98690. */
  98691. environmentIntensity: number;
  98692. /** @hidden */
  98693. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98694. /**
  98695. * Default image processing configuration used either in the rendering
  98696. * Forward main pass or through the imageProcessingPostProcess if present.
  98697. * As in the majority of the scene they are the same (exception for multi camera),
  98698. * this is easier to reference from here than from all the materials and post process.
  98699. *
  98700. * No setter as we it is a shared configuration, you can set the values instead.
  98701. */
  98702. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  98703. private _forceWireframe;
  98704. /**
  98705. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  98706. */
  98707. forceWireframe: boolean;
  98708. private _forcePointsCloud;
  98709. /**
  98710. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  98711. */
  98712. forcePointsCloud: boolean;
  98713. /**
  98714. * Gets or sets the active clipplane 1
  98715. */
  98716. clipPlane: Nullable<Plane>;
  98717. /**
  98718. * Gets or sets the active clipplane 2
  98719. */
  98720. clipPlane2: Nullable<Plane>;
  98721. /**
  98722. * Gets or sets the active clipplane 3
  98723. */
  98724. clipPlane3: Nullable<Plane>;
  98725. /**
  98726. * Gets or sets the active clipplane 4
  98727. */
  98728. clipPlane4: Nullable<Plane>;
  98729. /**
  98730. * Gets or sets a boolean indicating if animations are enabled
  98731. */
  98732. animationsEnabled: boolean;
  98733. private _animationPropertiesOverride;
  98734. /**
  98735. * Gets or sets the animation properties override
  98736. */
  98737. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  98738. /**
  98739. * Gets or sets a boolean indicating if a constant deltatime has to be used
  98740. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  98741. */
  98742. useConstantAnimationDeltaTime: boolean;
  98743. /**
  98744. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  98745. * Please note that it requires to run a ray cast through the scene on every frame
  98746. */
  98747. constantlyUpdateMeshUnderPointer: boolean;
  98748. /**
  98749. * Defines the HTML cursor to use when hovering over interactive elements
  98750. */
  98751. hoverCursor: string;
  98752. /**
  98753. * Defines the HTML default cursor to use (empty by default)
  98754. */
  98755. defaultCursor: string;
  98756. /**
  98757. * This is used to call preventDefault() on pointer down
  98758. * in order to block unwanted artifacts like system double clicks
  98759. */
  98760. preventDefaultOnPointerDown: boolean;
  98761. /**
  98762. * This is used to call preventDefault() on pointer up
  98763. * in order to block unwanted artifacts like system double clicks
  98764. */
  98765. preventDefaultOnPointerUp: boolean;
  98766. /**
  98767. * Gets or sets user defined metadata
  98768. */
  98769. metadata: any;
  98770. /**
  98771. * For internal use only. Please do not use.
  98772. */
  98773. reservedDataStore: any;
  98774. /**
  98775. * Gets the name of the plugin used to load this scene (null by default)
  98776. */
  98777. loadingPluginName: string;
  98778. /**
  98779. * Use this array to add regular expressions used to disable offline support for specific urls
  98780. */
  98781. disableOfflineSupportExceptionRules: RegExp[];
  98782. /**
  98783. * An event triggered when the scene is disposed.
  98784. */
  98785. onDisposeObservable: Observable<Scene>;
  98786. private _onDisposeObserver;
  98787. /** Sets a function to be executed when this scene is disposed. */
  98788. onDispose: () => void;
  98789. /**
  98790. * An event triggered before rendering the scene (right after animations and physics)
  98791. */
  98792. onBeforeRenderObservable: Observable<Scene>;
  98793. private _onBeforeRenderObserver;
  98794. /** Sets a function to be executed before rendering this scene */
  98795. beforeRender: Nullable<() => void>;
  98796. /**
  98797. * An event triggered after rendering the scene
  98798. */
  98799. onAfterRenderObservable: Observable<Scene>;
  98800. /**
  98801. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  98802. */
  98803. onAfterRenderCameraObservable: Observable<Camera>;
  98804. private _onAfterRenderObserver;
  98805. /** Sets a function to be executed after rendering this scene */
  98806. afterRender: Nullable<() => void>;
  98807. /**
  98808. * An event triggered before animating the scene
  98809. */
  98810. onBeforeAnimationsObservable: Observable<Scene>;
  98811. /**
  98812. * An event triggered after animations processing
  98813. */
  98814. onAfterAnimationsObservable: Observable<Scene>;
  98815. /**
  98816. * An event triggered before draw calls are ready to be sent
  98817. */
  98818. onBeforeDrawPhaseObservable: Observable<Scene>;
  98819. /**
  98820. * An event triggered after draw calls have been sent
  98821. */
  98822. onAfterDrawPhaseObservable: Observable<Scene>;
  98823. /**
  98824. * An event triggered when the scene is ready
  98825. */
  98826. onReadyObservable: Observable<Scene>;
  98827. /**
  98828. * An event triggered before rendering a camera
  98829. */
  98830. onBeforeCameraRenderObservable: Observable<Camera>;
  98831. private _onBeforeCameraRenderObserver;
  98832. /** Sets a function to be executed before rendering a camera*/
  98833. beforeCameraRender: () => void;
  98834. /**
  98835. * An event triggered after rendering a camera
  98836. */
  98837. onAfterCameraRenderObservable: Observable<Camera>;
  98838. private _onAfterCameraRenderObserver;
  98839. /** Sets a function to be executed after rendering a camera*/
  98840. afterCameraRender: () => void;
  98841. /**
  98842. * An event triggered when active meshes evaluation is about to start
  98843. */
  98844. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  98845. /**
  98846. * An event triggered when active meshes evaluation is done
  98847. */
  98848. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  98849. /**
  98850. * An event triggered when particles rendering is about to start
  98851. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98852. */
  98853. onBeforeParticlesRenderingObservable: Observable<Scene>;
  98854. /**
  98855. * An event triggered when particles rendering is done
  98856. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98857. */
  98858. onAfterParticlesRenderingObservable: Observable<Scene>;
  98859. /**
  98860. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  98861. */
  98862. onDataLoadedObservable: Observable<Scene>;
  98863. /**
  98864. * An event triggered when a camera is created
  98865. */
  98866. onNewCameraAddedObservable: Observable<Camera>;
  98867. /**
  98868. * An event triggered when a camera is removed
  98869. */
  98870. onCameraRemovedObservable: Observable<Camera>;
  98871. /**
  98872. * An event triggered when a light is created
  98873. */
  98874. onNewLightAddedObservable: Observable<Light>;
  98875. /**
  98876. * An event triggered when a light is removed
  98877. */
  98878. onLightRemovedObservable: Observable<Light>;
  98879. /**
  98880. * An event triggered when a geometry is created
  98881. */
  98882. onNewGeometryAddedObservable: Observable<Geometry>;
  98883. /**
  98884. * An event triggered when a geometry is removed
  98885. */
  98886. onGeometryRemovedObservable: Observable<Geometry>;
  98887. /**
  98888. * An event triggered when a transform node is created
  98889. */
  98890. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  98891. /**
  98892. * An event triggered when a transform node is removed
  98893. */
  98894. onTransformNodeRemovedObservable: Observable<TransformNode>;
  98895. /**
  98896. * An event triggered when a mesh is created
  98897. */
  98898. onNewMeshAddedObservable: Observable<AbstractMesh>;
  98899. /**
  98900. * An event triggered when a mesh is removed
  98901. */
  98902. onMeshRemovedObservable: Observable<AbstractMesh>;
  98903. /**
  98904. * An event triggered when a skeleton is created
  98905. */
  98906. onNewSkeletonAddedObservable: Observable<Skeleton>;
  98907. /**
  98908. * An event triggered when a skeleton is removed
  98909. */
  98910. onSkeletonRemovedObservable: Observable<Skeleton>;
  98911. /**
  98912. * An event triggered when a material is created
  98913. */
  98914. onNewMaterialAddedObservable: Observable<Material>;
  98915. /**
  98916. * An event triggered when a material is removed
  98917. */
  98918. onMaterialRemovedObservable: Observable<Material>;
  98919. /**
  98920. * An event triggered when a texture is created
  98921. */
  98922. onNewTextureAddedObservable: Observable<BaseTexture>;
  98923. /**
  98924. * An event triggered when a texture is removed
  98925. */
  98926. onTextureRemovedObservable: Observable<BaseTexture>;
  98927. /**
  98928. * An event triggered when render targets are about to be rendered
  98929. * Can happen multiple times per frame.
  98930. */
  98931. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  98932. /**
  98933. * An event triggered when render targets were rendered.
  98934. * Can happen multiple times per frame.
  98935. */
  98936. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  98937. /**
  98938. * An event triggered before calculating deterministic simulation step
  98939. */
  98940. onBeforeStepObservable: Observable<Scene>;
  98941. /**
  98942. * An event triggered after calculating deterministic simulation step
  98943. */
  98944. onAfterStepObservable: Observable<Scene>;
  98945. /**
  98946. * An event triggered when the activeCamera property is updated
  98947. */
  98948. onActiveCameraChanged: Observable<Scene>;
  98949. /**
  98950. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  98951. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98952. * 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)
  98953. */
  98954. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98955. /**
  98956. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  98957. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98958. * 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)
  98959. */
  98960. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98961. /**
  98962. * This Observable will when a mesh has been imported into the scene.
  98963. */
  98964. onMeshImportedObservable: Observable<AbstractMesh>;
  98965. /**
  98966. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  98967. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  98968. */
  98969. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  98970. /** @hidden */
  98971. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  98972. /**
  98973. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  98974. */
  98975. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  98976. /**
  98977. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  98978. */
  98979. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  98980. /**
  98981. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  98982. */
  98983. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  98984. /** Callback called when a pointer move is detected */
  98985. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98986. /** Callback called when a pointer down is detected */
  98987. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98988. /** Callback called when a pointer up is detected */
  98989. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  98990. /** Callback called when a pointer pick is detected */
  98991. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  98992. /**
  98993. * 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).
  98994. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  98995. */
  98996. onPrePointerObservable: Observable<PointerInfoPre>;
  98997. /**
  98998. * Observable event triggered each time an input event is received from the rendering canvas
  98999. */
  99000. onPointerObservable: Observable<PointerInfo>;
  99001. /**
  99002. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  99003. */
  99004. readonly unTranslatedPointer: Vector2;
  99005. /**
  99006. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  99007. */
  99008. static DragMovementThreshold: number;
  99009. /**
  99010. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  99011. */
  99012. static LongPressDelay: number;
  99013. /**
  99014. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  99015. */
  99016. static DoubleClickDelay: number;
  99017. /** If you need to check double click without raising a single click at first click, enable this flag */
  99018. static ExclusiveDoubleClickMode: boolean;
  99019. /** @hidden */
  99020. _mirroredCameraPosition: Nullable<Vector3>;
  99021. /**
  99022. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  99023. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  99024. */
  99025. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  99026. /**
  99027. * Observable event triggered each time an keyboard event is received from the hosting window
  99028. */
  99029. onKeyboardObservable: Observable<KeyboardInfo>;
  99030. private _useRightHandedSystem;
  99031. /**
  99032. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  99033. */
  99034. useRightHandedSystem: boolean;
  99035. private _timeAccumulator;
  99036. private _currentStepId;
  99037. private _currentInternalStep;
  99038. /**
  99039. * Sets the step Id used by deterministic lock step
  99040. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99041. * @param newStepId defines the step Id
  99042. */
  99043. setStepId(newStepId: number): void;
  99044. /**
  99045. * Gets the step Id used by deterministic lock step
  99046. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99047. * @returns the step Id
  99048. */
  99049. getStepId(): number;
  99050. /**
  99051. * Gets the internal step used by deterministic lock step
  99052. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99053. * @returns the internal step
  99054. */
  99055. getInternalStep(): number;
  99056. private _fogEnabled;
  99057. /**
  99058. * Gets or sets a boolean indicating if fog is enabled on this scene
  99059. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99060. * (Default is true)
  99061. */
  99062. fogEnabled: boolean;
  99063. private _fogMode;
  99064. /**
  99065. * Gets or sets the fog mode to use
  99066. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99067. * | mode | value |
  99068. * | --- | --- |
  99069. * | FOGMODE_NONE | 0 |
  99070. * | FOGMODE_EXP | 1 |
  99071. * | FOGMODE_EXP2 | 2 |
  99072. * | FOGMODE_LINEAR | 3 |
  99073. */
  99074. fogMode: number;
  99075. /**
  99076. * Gets or sets the fog color to use
  99077. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99078. * (Default is Color3(0.2, 0.2, 0.3))
  99079. */
  99080. fogColor: Color3;
  99081. /**
  99082. * Gets or sets the fog density to use
  99083. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99084. * (Default is 0.1)
  99085. */
  99086. fogDensity: number;
  99087. /**
  99088. * Gets or sets the fog start distance to use
  99089. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99090. * (Default is 0)
  99091. */
  99092. fogStart: number;
  99093. /**
  99094. * Gets or sets the fog end distance to use
  99095. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99096. * (Default is 1000)
  99097. */
  99098. fogEnd: number;
  99099. private _shadowsEnabled;
  99100. /**
  99101. * Gets or sets a boolean indicating if shadows are enabled on this scene
  99102. */
  99103. shadowsEnabled: boolean;
  99104. private _lightsEnabled;
  99105. /**
  99106. * Gets or sets a boolean indicating if lights are enabled on this scene
  99107. */
  99108. lightsEnabled: boolean;
  99109. /** All of the active cameras added to this scene. */
  99110. activeCameras: Camera[];
  99111. /** @hidden */
  99112. _activeCamera: Nullable<Camera>;
  99113. /** Gets or sets the current active camera */
  99114. activeCamera: Nullable<Camera>;
  99115. private _defaultMaterial;
  99116. /** The default material used on meshes when no material is affected */
  99117. /** The default material used on meshes when no material is affected */
  99118. defaultMaterial: Material;
  99119. private _texturesEnabled;
  99120. /**
  99121. * Gets or sets a boolean indicating if textures are enabled on this scene
  99122. */
  99123. texturesEnabled: boolean;
  99124. /**
  99125. * Gets or sets a boolean indicating if particles are enabled on this scene
  99126. */
  99127. particlesEnabled: boolean;
  99128. /**
  99129. * Gets or sets a boolean indicating if sprites are enabled on this scene
  99130. */
  99131. spritesEnabled: boolean;
  99132. private _skeletonsEnabled;
  99133. /**
  99134. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  99135. */
  99136. skeletonsEnabled: boolean;
  99137. /**
  99138. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  99139. */
  99140. lensFlaresEnabled: boolean;
  99141. /**
  99142. * Gets or sets a boolean indicating if collisions are enabled on this scene
  99143. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99144. */
  99145. collisionsEnabled: boolean;
  99146. private _collisionCoordinator;
  99147. /** @hidden */
  99148. readonly collisionCoordinator: ICollisionCoordinator;
  99149. /**
  99150. * Defines the gravity applied to this scene (used only for collisions)
  99151. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99152. */
  99153. gravity: Vector3;
  99154. /**
  99155. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  99156. */
  99157. postProcessesEnabled: boolean;
  99158. /**
  99159. * The list of postprocesses added to the scene
  99160. */
  99161. postProcesses: PostProcess[];
  99162. /**
  99163. * Gets the current postprocess manager
  99164. */
  99165. postProcessManager: PostProcessManager;
  99166. /**
  99167. * Gets or sets a boolean indicating if render targets are enabled on this scene
  99168. */
  99169. renderTargetsEnabled: boolean;
  99170. /**
  99171. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  99172. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  99173. */
  99174. dumpNextRenderTargets: boolean;
  99175. /**
  99176. * The list of user defined render targets added to the scene
  99177. */
  99178. customRenderTargets: RenderTargetTexture[];
  99179. /**
  99180. * Defines if texture loading must be delayed
  99181. * If true, textures will only be loaded when they need to be rendered
  99182. */
  99183. useDelayedTextureLoading: boolean;
  99184. /**
  99185. * Gets the list of meshes imported to the scene through SceneLoader
  99186. */
  99187. importedMeshesFiles: String[];
  99188. /**
  99189. * Gets or sets a boolean indicating if probes are enabled on this scene
  99190. */
  99191. probesEnabled: boolean;
  99192. /**
  99193. * Gets or sets the current offline provider to use to store scene data
  99194. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  99195. */
  99196. offlineProvider: IOfflineProvider;
  99197. /**
  99198. * Gets or sets the action manager associated with the scene
  99199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99200. */
  99201. actionManager: AbstractActionManager;
  99202. private _meshesForIntersections;
  99203. /**
  99204. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  99205. */
  99206. proceduralTexturesEnabled: boolean;
  99207. private _engine;
  99208. private _totalVertices;
  99209. /** @hidden */
  99210. _activeIndices: PerfCounter;
  99211. /** @hidden */
  99212. _activeParticles: PerfCounter;
  99213. /** @hidden */
  99214. _activeBones: PerfCounter;
  99215. private _animationRatio;
  99216. /** @hidden */
  99217. _animationTimeLast: number;
  99218. /** @hidden */
  99219. _animationTime: number;
  99220. /**
  99221. * Gets or sets a general scale for animation speed
  99222. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  99223. */
  99224. animationTimeScale: number;
  99225. /** @hidden */
  99226. _cachedMaterial: Nullable<Material>;
  99227. /** @hidden */
  99228. _cachedEffect: Nullable<Effect>;
  99229. /** @hidden */
  99230. _cachedVisibility: Nullable<number>;
  99231. private _renderId;
  99232. private _frameId;
  99233. private _executeWhenReadyTimeoutId;
  99234. private _intermediateRendering;
  99235. private _viewUpdateFlag;
  99236. private _projectionUpdateFlag;
  99237. /** @hidden */
  99238. _toBeDisposed: Nullable<IDisposable>[];
  99239. private _activeRequests;
  99240. /** @hidden */
  99241. _pendingData: any[];
  99242. private _isDisposed;
  99243. /**
  99244. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  99245. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  99246. */
  99247. dispatchAllSubMeshesOfActiveMeshes: boolean;
  99248. private _activeMeshes;
  99249. private _processedMaterials;
  99250. private _renderTargets;
  99251. /** @hidden */
  99252. _activeParticleSystems: SmartArray<IParticleSystem>;
  99253. private _activeSkeletons;
  99254. private _softwareSkinnedMeshes;
  99255. private _renderingManager;
  99256. /** @hidden */
  99257. _activeAnimatables: Animatable[];
  99258. private _transformMatrix;
  99259. private _sceneUbo;
  99260. /** @hidden */
  99261. _viewMatrix: Matrix;
  99262. private _projectionMatrix;
  99263. /** @hidden */
  99264. _forcedViewPosition: Nullable<Vector3>;
  99265. /** @hidden */
  99266. _frustumPlanes: Plane[];
  99267. /**
  99268. * Gets the list of frustum planes (built from the active camera)
  99269. */
  99270. readonly frustumPlanes: Plane[];
  99271. /**
  99272. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  99273. * This is useful if there are more lights that the maximum simulteanous authorized
  99274. */
  99275. requireLightSorting: boolean;
  99276. /** @hidden */
  99277. readonly useMaterialMeshMap: boolean;
  99278. /** @hidden */
  99279. readonly useClonedMeshhMap: boolean;
  99280. private _externalData;
  99281. private _uid;
  99282. /**
  99283. * @hidden
  99284. * Backing store of defined scene components.
  99285. */
  99286. _components: ISceneComponent[];
  99287. /**
  99288. * @hidden
  99289. * Backing store of defined scene components.
  99290. */
  99291. _serializableComponents: ISceneSerializableComponent[];
  99292. /**
  99293. * List of components to register on the next registration step.
  99294. */
  99295. private _transientComponents;
  99296. /**
  99297. * Registers the transient components if needed.
  99298. */
  99299. private _registerTransientComponents;
  99300. /**
  99301. * @hidden
  99302. * Add a component to the scene.
  99303. * Note that the ccomponent could be registered on th next frame if this is called after
  99304. * the register component stage.
  99305. * @param component Defines the component to add to the scene
  99306. */
  99307. _addComponent(component: ISceneComponent): void;
  99308. /**
  99309. * @hidden
  99310. * Gets a component from the scene.
  99311. * @param name defines the name of the component to retrieve
  99312. * @returns the component or null if not present
  99313. */
  99314. _getComponent(name: string): Nullable<ISceneComponent>;
  99315. /**
  99316. * @hidden
  99317. * Defines the actions happening before camera updates.
  99318. */
  99319. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  99320. /**
  99321. * @hidden
  99322. * Defines the actions happening before clear the canvas.
  99323. */
  99324. _beforeClearStage: Stage<SimpleStageAction>;
  99325. /**
  99326. * @hidden
  99327. * Defines the actions when collecting render targets for the frame.
  99328. */
  99329. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99330. /**
  99331. * @hidden
  99332. * Defines the actions happening for one camera in the frame.
  99333. */
  99334. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99335. /**
  99336. * @hidden
  99337. * Defines the actions happening during the per mesh ready checks.
  99338. */
  99339. _isReadyForMeshStage: Stage<MeshStageAction>;
  99340. /**
  99341. * @hidden
  99342. * Defines the actions happening before evaluate active mesh checks.
  99343. */
  99344. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  99345. /**
  99346. * @hidden
  99347. * Defines the actions happening during the evaluate sub mesh checks.
  99348. */
  99349. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  99350. /**
  99351. * @hidden
  99352. * Defines the actions happening during the active mesh stage.
  99353. */
  99354. _activeMeshStage: Stage<ActiveMeshStageAction>;
  99355. /**
  99356. * @hidden
  99357. * Defines the actions happening during the per camera render target step.
  99358. */
  99359. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  99360. /**
  99361. * @hidden
  99362. * Defines the actions happening just before the active camera is drawing.
  99363. */
  99364. _beforeCameraDrawStage: Stage<CameraStageAction>;
  99365. /**
  99366. * @hidden
  99367. * Defines the actions happening just before a render target is drawing.
  99368. */
  99369. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99370. /**
  99371. * @hidden
  99372. * Defines the actions happening just before a rendering group is drawing.
  99373. */
  99374. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99375. /**
  99376. * @hidden
  99377. * Defines the actions happening just before a mesh is drawing.
  99378. */
  99379. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99380. /**
  99381. * @hidden
  99382. * Defines the actions happening just after a mesh has been drawn.
  99383. */
  99384. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99385. /**
  99386. * @hidden
  99387. * Defines the actions happening just after a rendering group has been drawn.
  99388. */
  99389. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99390. /**
  99391. * @hidden
  99392. * Defines the actions happening just after the active camera has been drawn.
  99393. */
  99394. _afterCameraDrawStage: Stage<CameraStageAction>;
  99395. /**
  99396. * @hidden
  99397. * Defines the actions happening just after a render target has been drawn.
  99398. */
  99399. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99400. /**
  99401. * @hidden
  99402. * Defines the actions happening just after rendering all cameras and computing intersections.
  99403. */
  99404. _afterRenderStage: Stage<SimpleStageAction>;
  99405. /**
  99406. * @hidden
  99407. * Defines the actions happening when a pointer move event happens.
  99408. */
  99409. _pointerMoveStage: Stage<PointerMoveStageAction>;
  99410. /**
  99411. * @hidden
  99412. * Defines the actions happening when a pointer down event happens.
  99413. */
  99414. _pointerDownStage: Stage<PointerUpDownStageAction>;
  99415. /**
  99416. * @hidden
  99417. * Defines the actions happening when a pointer up event happens.
  99418. */
  99419. _pointerUpStage: Stage<PointerUpDownStageAction>;
  99420. /**
  99421. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  99422. */
  99423. private geometriesByUniqueId;
  99424. /**
  99425. * Creates a new Scene
  99426. * @param engine defines the engine to use to render this scene
  99427. * @param options defines the scene options
  99428. */
  99429. constructor(engine: Engine, options?: SceneOptions);
  99430. /**
  99431. * Gets a string idenfifying the name of the class
  99432. * @returns "Scene" string
  99433. */
  99434. getClassName(): string;
  99435. private _defaultMeshCandidates;
  99436. /**
  99437. * @hidden
  99438. */
  99439. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99440. private _defaultSubMeshCandidates;
  99441. /**
  99442. * @hidden
  99443. */
  99444. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99445. /**
  99446. * Sets the default candidate providers for the scene.
  99447. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  99448. * and getCollidingSubMeshCandidates to their default function
  99449. */
  99450. setDefaultCandidateProviders(): void;
  99451. /**
  99452. * Gets the mesh that is currently under the pointer
  99453. */
  99454. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99455. /**
  99456. * Gets or sets the current on-screen X position of the pointer
  99457. */
  99458. pointerX: number;
  99459. /**
  99460. * Gets or sets the current on-screen Y position of the pointer
  99461. */
  99462. pointerY: number;
  99463. /**
  99464. * Gets the cached material (ie. the latest rendered one)
  99465. * @returns the cached material
  99466. */
  99467. getCachedMaterial(): Nullable<Material>;
  99468. /**
  99469. * Gets the cached effect (ie. the latest rendered one)
  99470. * @returns the cached effect
  99471. */
  99472. getCachedEffect(): Nullable<Effect>;
  99473. /**
  99474. * Gets the cached visibility state (ie. the latest rendered one)
  99475. * @returns the cached visibility state
  99476. */
  99477. getCachedVisibility(): Nullable<number>;
  99478. /**
  99479. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  99480. * @param material defines the current material
  99481. * @param effect defines the current effect
  99482. * @param visibility defines the current visibility state
  99483. * @returns true if one parameter is not cached
  99484. */
  99485. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  99486. /**
  99487. * Gets the engine associated with the scene
  99488. * @returns an Engine
  99489. */
  99490. getEngine(): Engine;
  99491. /**
  99492. * Gets the total number of vertices rendered per frame
  99493. * @returns the total number of vertices rendered per frame
  99494. */
  99495. getTotalVertices(): number;
  99496. /**
  99497. * Gets the performance counter for total vertices
  99498. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99499. */
  99500. readonly totalVerticesPerfCounter: PerfCounter;
  99501. /**
  99502. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  99503. * @returns the total number of active indices rendered per frame
  99504. */
  99505. getActiveIndices(): number;
  99506. /**
  99507. * Gets the performance counter for active indices
  99508. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99509. */
  99510. readonly totalActiveIndicesPerfCounter: PerfCounter;
  99511. /**
  99512. * Gets the total number of active particles rendered per frame
  99513. * @returns the total number of active particles rendered per frame
  99514. */
  99515. getActiveParticles(): number;
  99516. /**
  99517. * Gets the performance counter for active particles
  99518. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99519. */
  99520. readonly activeParticlesPerfCounter: PerfCounter;
  99521. /**
  99522. * Gets the total number of active bones rendered per frame
  99523. * @returns the total number of active bones rendered per frame
  99524. */
  99525. getActiveBones(): number;
  99526. /**
  99527. * Gets the performance counter for active bones
  99528. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99529. */
  99530. readonly activeBonesPerfCounter: PerfCounter;
  99531. /**
  99532. * Gets the array of active meshes
  99533. * @returns an array of AbstractMesh
  99534. */
  99535. getActiveMeshes(): SmartArray<AbstractMesh>;
  99536. /**
  99537. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  99538. * @returns a number
  99539. */
  99540. getAnimationRatio(): number;
  99541. /**
  99542. * Gets an unique Id for the current render phase
  99543. * @returns a number
  99544. */
  99545. getRenderId(): number;
  99546. /**
  99547. * Gets an unique Id for the current frame
  99548. * @returns a number
  99549. */
  99550. getFrameId(): number;
  99551. /** Call this function if you want to manually increment the render Id*/
  99552. incrementRenderId(): void;
  99553. private _createUbo;
  99554. /**
  99555. * Use this method to simulate a pointer move on a mesh
  99556. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99557. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99558. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99559. * @returns the current scene
  99560. */
  99561. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99562. /**
  99563. * Use this method to simulate a pointer down on a mesh
  99564. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99565. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99566. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99567. * @returns the current scene
  99568. */
  99569. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99570. /**
  99571. * Use this method to simulate a pointer up on a mesh
  99572. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99573. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99574. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99575. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99576. * @returns the current scene
  99577. */
  99578. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  99579. /**
  99580. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99581. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99582. * @returns true if the pointer was captured
  99583. */
  99584. isPointerCaptured(pointerId?: number): boolean;
  99585. /**
  99586. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99587. * @param attachUp defines if you want to attach events to pointerup
  99588. * @param attachDown defines if you want to attach events to pointerdown
  99589. * @param attachMove defines if you want to attach events to pointermove
  99590. */
  99591. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99592. /** Detaches all event handlers*/
  99593. detachControl(): void;
  99594. /**
  99595. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  99596. * Delay loaded resources are not taking in account
  99597. * @return true if all required resources are ready
  99598. */
  99599. isReady(): boolean;
  99600. /** Resets all cached information relative to material (including effect and visibility) */
  99601. resetCachedMaterial(): void;
  99602. /**
  99603. * Registers a function to be called before every frame render
  99604. * @param func defines the function to register
  99605. */
  99606. registerBeforeRender(func: () => void): void;
  99607. /**
  99608. * Unregisters a function called before every frame render
  99609. * @param func defines the function to unregister
  99610. */
  99611. unregisterBeforeRender(func: () => void): void;
  99612. /**
  99613. * Registers a function to be called after every frame render
  99614. * @param func defines the function to register
  99615. */
  99616. registerAfterRender(func: () => void): void;
  99617. /**
  99618. * Unregisters a function called after every frame render
  99619. * @param func defines the function to unregister
  99620. */
  99621. unregisterAfterRender(func: () => void): void;
  99622. private _executeOnceBeforeRender;
  99623. /**
  99624. * The provided function will run before render once and will be disposed afterwards.
  99625. * A timeout delay can be provided so that the function will be executed in N ms.
  99626. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  99627. * @param func The function to be executed.
  99628. * @param timeout optional delay in ms
  99629. */
  99630. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  99631. /** @hidden */
  99632. _addPendingData(data: any): void;
  99633. /** @hidden */
  99634. _removePendingData(data: any): void;
  99635. /**
  99636. * Returns the number of items waiting to be loaded
  99637. * @returns the number of items waiting to be loaded
  99638. */
  99639. getWaitingItemsCount(): number;
  99640. /**
  99641. * Returns a boolean indicating if the scene is still loading data
  99642. */
  99643. readonly isLoading: boolean;
  99644. /**
  99645. * Registers a function to be executed when the scene is ready
  99646. * @param {Function} func - the function to be executed
  99647. */
  99648. executeWhenReady(func: () => void): void;
  99649. /**
  99650. * Returns a promise that resolves when the scene is ready
  99651. * @returns A promise that resolves when the scene is ready
  99652. */
  99653. whenReadyAsync(): Promise<void>;
  99654. /** @hidden */
  99655. _checkIsReady(): void;
  99656. /**
  99657. * Gets all animatable attached to the scene
  99658. */
  99659. readonly animatables: Animatable[];
  99660. /**
  99661. * Resets the last animation time frame.
  99662. * Useful to override when animations start running when loading a scene for the first time.
  99663. */
  99664. resetLastAnimationTimeFrame(): void;
  99665. /**
  99666. * Gets the current view matrix
  99667. * @returns a Matrix
  99668. */
  99669. getViewMatrix(): Matrix;
  99670. /**
  99671. * Gets the current projection matrix
  99672. * @returns a Matrix
  99673. */
  99674. getProjectionMatrix(): Matrix;
  99675. /**
  99676. * Gets the current transform matrix
  99677. * @returns a Matrix made of View * Projection
  99678. */
  99679. getTransformMatrix(): Matrix;
  99680. /**
  99681. * Sets the current transform matrix
  99682. * @param viewL defines the View matrix to use
  99683. * @param projectionL defines the Projection matrix to use
  99684. * @param viewR defines the right View matrix to use (if provided)
  99685. * @param projectionR defines the right Projection matrix to use (if provided)
  99686. */
  99687. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  99688. /**
  99689. * Gets the uniform buffer used to store scene data
  99690. * @returns a UniformBuffer
  99691. */
  99692. getSceneUniformBuffer(): UniformBuffer;
  99693. /**
  99694. * Gets an unique (relatively to the current scene) Id
  99695. * @returns an unique number for the scene
  99696. */
  99697. getUniqueId(): number;
  99698. /**
  99699. * Add a mesh to the list of scene's meshes
  99700. * @param newMesh defines the mesh to add
  99701. * @param recursive if all child meshes should also be added to the scene
  99702. */
  99703. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  99704. /**
  99705. * Remove a mesh for the list of scene's meshes
  99706. * @param toRemove defines the mesh to remove
  99707. * @param recursive if all child meshes should also be removed from the scene
  99708. * @returns the index where the mesh was in the mesh list
  99709. */
  99710. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  99711. /**
  99712. * Add a transform node to the list of scene's transform nodes
  99713. * @param newTransformNode defines the transform node to add
  99714. */
  99715. addTransformNode(newTransformNode: TransformNode): void;
  99716. /**
  99717. * Remove a transform node for the list of scene's transform nodes
  99718. * @param toRemove defines the transform node to remove
  99719. * @returns the index where the transform node was in the transform node list
  99720. */
  99721. removeTransformNode(toRemove: TransformNode): number;
  99722. /**
  99723. * Remove a skeleton for the list of scene's skeletons
  99724. * @param toRemove defines the skeleton to remove
  99725. * @returns the index where the skeleton was in the skeleton list
  99726. */
  99727. removeSkeleton(toRemove: Skeleton): number;
  99728. /**
  99729. * Remove a morph target for the list of scene's morph targets
  99730. * @param toRemove defines the morph target to remove
  99731. * @returns the index where the morph target was in the morph target list
  99732. */
  99733. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  99734. /**
  99735. * Remove a light for the list of scene's lights
  99736. * @param toRemove defines the light to remove
  99737. * @returns the index where the light was in the light list
  99738. */
  99739. removeLight(toRemove: Light): number;
  99740. /**
  99741. * Remove a camera for the list of scene's cameras
  99742. * @param toRemove defines the camera to remove
  99743. * @returns the index where the camera was in the camera list
  99744. */
  99745. removeCamera(toRemove: Camera): number;
  99746. /**
  99747. * Remove a particle system for the list of scene's particle systems
  99748. * @param toRemove defines the particle system to remove
  99749. * @returns the index where the particle system was in the particle system list
  99750. */
  99751. removeParticleSystem(toRemove: IParticleSystem): number;
  99752. /**
  99753. * Remove a animation for the list of scene's animations
  99754. * @param toRemove defines the animation to remove
  99755. * @returns the index where the animation was in the animation list
  99756. */
  99757. removeAnimation(toRemove: Animation): number;
  99758. /**
  99759. * Will stop the animation of the given target
  99760. * @param target - the target
  99761. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  99762. * @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)
  99763. */
  99764. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  99765. /**
  99766. * Removes the given animation group from this scene.
  99767. * @param toRemove The animation group to remove
  99768. * @returns The index of the removed animation group
  99769. */
  99770. removeAnimationGroup(toRemove: AnimationGroup): number;
  99771. /**
  99772. * Removes the given multi-material from this scene.
  99773. * @param toRemove The multi-material to remove
  99774. * @returns The index of the removed multi-material
  99775. */
  99776. removeMultiMaterial(toRemove: MultiMaterial): number;
  99777. /**
  99778. * Removes the given material from this scene.
  99779. * @param toRemove The material to remove
  99780. * @returns The index of the removed material
  99781. */
  99782. removeMaterial(toRemove: Material): number;
  99783. /**
  99784. * Removes the given action manager from this scene.
  99785. * @param toRemove The action manager to remove
  99786. * @returns The index of the removed action manager
  99787. */
  99788. removeActionManager(toRemove: AbstractActionManager): number;
  99789. /**
  99790. * Removes the given texture from this scene.
  99791. * @param toRemove The texture to remove
  99792. * @returns The index of the removed texture
  99793. */
  99794. removeTexture(toRemove: BaseTexture): number;
  99795. /**
  99796. * Adds the given light to this scene
  99797. * @param newLight The light to add
  99798. */
  99799. addLight(newLight: Light): void;
  99800. /**
  99801. * Sorts the list list based on light priorities
  99802. */
  99803. sortLightsByPriority(): void;
  99804. /**
  99805. * Adds the given camera to this scene
  99806. * @param newCamera The camera to add
  99807. */
  99808. addCamera(newCamera: Camera): void;
  99809. /**
  99810. * Adds the given skeleton to this scene
  99811. * @param newSkeleton The skeleton to add
  99812. */
  99813. addSkeleton(newSkeleton: Skeleton): void;
  99814. /**
  99815. * Adds the given particle system to this scene
  99816. * @param newParticleSystem The particle system to add
  99817. */
  99818. addParticleSystem(newParticleSystem: IParticleSystem): void;
  99819. /**
  99820. * Adds the given animation to this scene
  99821. * @param newAnimation The animation to add
  99822. */
  99823. addAnimation(newAnimation: Animation): void;
  99824. /**
  99825. * Adds the given animation group to this scene.
  99826. * @param newAnimationGroup The animation group to add
  99827. */
  99828. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  99829. /**
  99830. * Adds the given multi-material to this scene
  99831. * @param newMultiMaterial The multi-material to add
  99832. */
  99833. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  99834. /**
  99835. * Adds the given material to this scene
  99836. * @param newMaterial The material to add
  99837. */
  99838. addMaterial(newMaterial: Material): void;
  99839. /**
  99840. * Adds the given morph target to this scene
  99841. * @param newMorphTargetManager The morph target to add
  99842. */
  99843. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  99844. /**
  99845. * Adds the given geometry to this scene
  99846. * @param newGeometry The geometry to add
  99847. */
  99848. addGeometry(newGeometry: Geometry): void;
  99849. /**
  99850. * Adds the given action manager to this scene
  99851. * @param newActionManager The action manager to add
  99852. */
  99853. addActionManager(newActionManager: AbstractActionManager): void;
  99854. /**
  99855. * Adds the given texture to this scene.
  99856. * @param newTexture The texture to add
  99857. */
  99858. addTexture(newTexture: BaseTexture): void;
  99859. /**
  99860. * Switch active camera
  99861. * @param newCamera defines the new active camera
  99862. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  99863. */
  99864. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  99865. /**
  99866. * sets the active camera of the scene using its ID
  99867. * @param id defines the camera's ID
  99868. * @return the new active camera or null if none found.
  99869. */
  99870. setActiveCameraByID(id: string): Nullable<Camera>;
  99871. /**
  99872. * sets the active camera of the scene using its name
  99873. * @param name defines the camera's name
  99874. * @returns the new active camera or null if none found.
  99875. */
  99876. setActiveCameraByName(name: string): Nullable<Camera>;
  99877. /**
  99878. * get an animation group using its name
  99879. * @param name defines the material's name
  99880. * @return the animation group or null if none found.
  99881. */
  99882. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  99883. /**
  99884. * Get a material using its unique id
  99885. * @param uniqueId defines the material's unique id
  99886. * @return the material or null if none found.
  99887. */
  99888. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  99889. /**
  99890. * get a material using its id
  99891. * @param id defines the material's ID
  99892. * @return the material or null if none found.
  99893. */
  99894. getMaterialByID(id: string): Nullable<Material>;
  99895. /**
  99896. * Gets a the last added material using a given id
  99897. * @param id defines the material's ID
  99898. * @return the last material with the given id or null if none found.
  99899. */
  99900. getLastMaterialByID(id: string): Nullable<Material>;
  99901. /**
  99902. * Gets a material using its name
  99903. * @param name defines the material's name
  99904. * @return the material or null if none found.
  99905. */
  99906. getMaterialByName(name: string): Nullable<Material>;
  99907. /**
  99908. * Get a texture using its unique id
  99909. * @param uniqueId defines the texture's unique id
  99910. * @return the texture or null if none found.
  99911. */
  99912. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  99913. /**
  99914. * Gets a camera using its id
  99915. * @param id defines the id to look for
  99916. * @returns the camera or null if not found
  99917. */
  99918. getCameraByID(id: string): Nullable<Camera>;
  99919. /**
  99920. * Gets a camera using its unique id
  99921. * @param uniqueId defines the unique id to look for
  99922. * @returns the camera or null if not found
  99923. */
  99924. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  99925. /**
  99926. * Gets a camera using its name
  99927. * @param name defines the camera's name
  99928. * @return the camera or null if none found.
  99929. */
  99930. getCameraByName(name: string): Nullable<Camera>;
  99931. /**
  99932. * Gets a bone using its id
  99933. * @param id defines the bone's id
  99934. * @return the bone or null if not found
  99935. */
  99936. getBoneByID(id: string): Nullable<Bone>;
  99937. /**
  99938. * Gets a bone using its id
  99939. * @param name defines the bone's name
  99940. * @return the bone or null if not found
  99941. */
  99942. getBoneByName(name: string): Nullable<Bone>;
  99943. /**
  99944. * Gets a light node using its name
  99945. * @param name defines the the light's name
  99946. * @return the light or null if none found.
  99947. */
  99948. getLightByName(name: string): Nullable<Light>;
  99949. /**
  99950. * Gets a light node using its id
  99951. * @param id defines the light's id
  99952. * @return the light or null if none found.
  99953. */
  99954. getLightByID(id: string): Nullable<Light>;
  99955. /**
  99956. * Gets a light node using its scene-generated unique ID
  99957. * @param uniqueId defines the light's unique id
  99958. * @return the light or null if none found.
  99959. */
  99960. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  99961. /**
  99962. * Gets a particle system by id
  99963. * @param id defines the particle system id
  99964. * @return the corresponding system or null if none found
  99965. */
  99966. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  99967. /**
  99968. * Gets a geometry using its ID
  99969. * @param id defines the geometry's id
  99970. * @return the geometry or null if none found.
  99971. */
  99972. getGeometryByID(id: string): Nullable<Geometry>;
  99973. private _getGeometryByUniqueID;
  99974. /**
  99975. * Add a new geometry to this scene
  99976. * @param geometry defines the geometry to be added to the scene.
  99977. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  99978. * @return a boolean defining if the geometry was added or not
  99979. */
  99980. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  99981. /**
  99982. * Removes an existing geometry
  99983. * @param geometry defines the geometry to be removed from the scene
  99984. * @return a boolean defining if the geometry was removed or not
  99985. */
  99986. removeGeometry(geometry: Geometry): boolean;
  99987. /**
  99988. * Gets the list of geometries attached to the scene
  99989. * @returns an array of Geometry
  99990. */
  99991. getGeometries(): Geometry[];
  99992. /**
  99993. * Gets the first added mesh found of a given ID
  99994. * @param id defines the id to search for
  99995. * @return the mesh found or null if not found at all
  99996. */
  99997. getMeshByID(id: string): Nullable<AbstractMesh>;
  99998. /**
  99999. * Gets a list of meshes using their id
  100000. * @param id defines the id to search for
  100001. * @returns a list of meshes
  100002. */
  100003. getMeshesByID(id: string): Array<AbstractMesh>;
  100004. /**
  100005. * Gets the first added transform node found of a given ID
  100006. * @param id defines the id to search for
  100007. * @return the found transform node or null if not found at all.
  100008. */
  100009. getTransformNodeByID(id: string): Nullable<TransformNode>;
  100010. /**
  100011. * Gets a transform node with its auto-generated unique id
  100012. * @param uniqueId efines the unique id to search for
  100013. * @return the found transform node or null if not found at all.
  100014. */
  100015. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  100016. /**
  100017. * Gets a list of transform nodes using their id
  100018. * @param id defines the id to search for
  100019. * @returns a list of transform nodes
  100020. */
  100021. getTransformNodesByID(id: string): Array<TransformNode>;
  100022. /**
  100023. * Gets a mesh with its auto-generated unique id
  100024. * @param uniqueId defines the unique id to search for
  100025. * @return the found mesh or null if not found at all.
  100026. */
  100027. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  100028. /**
  100029. * Gets a the last added mesh using a given id
  100030. * @param id defines the id to search for
  100031. * @return the found mesh or null if not found at all.
  100032. */
  100033. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  100034. /**
  100035. * Gets a the last added node (Mesh, Camera, Light) using a given id
  100036. * @param id defines the id to search for
  100037. * @return the found node or null if not found at all
  100038. */
  100039. getLastEntryByID(id: string): Nullable<Node>;
  100040. /**
  100041. * Gets a node (Mesh, Camera, Light) using a given id
  100042. * @param id defines the id to search for
  100043. * @return the found node or null if not found at all
  100044. */
  100045. getNodeByID(id: string): Nullable<Node>;
  100046. /**
  100047. * Gets a node (Mesh, Camera, Light) using a given name
  100048. * @param name defines the name to search for
  100049. * @return the found node or null if not found at all.
  100050. */
  100051. getNodeByName(name: string): Nullable<Node>;
  100052. /**
  100053. * Gets a mesh using a given name
  100054. * @param name defines the name to search for
  100055. * @return the found mesh or null if not found at all.
  100056. */
  100057. getMeshByName(name: string): Nullable<AbstractMesh>;
  100058. /**
  100059. * Gets a transform node using a given name
  100060. * @param name defines the name to search for
  100061. * @return the found transform node or null if not found at all.
  100062. */
  100063. getTransformNodeByName(name: string): Nullable<TransformNode>;
  100064. /**
  100065. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  100066. * @param id defines the id to search for
  100067. * @return the found skeleton or null if not found at all.
  100068. */
  100069. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  100070. /**
  100071. * Gets a skeleton using a given auto generated unique id
  100072. * @param uniqueId defines the unique id to search for
  100073. * @return the found skeleton or null if not found at all.
  100074. */
  100075. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  100076. /**
  100077. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  100078. * @param id defines the id to search for
  100079. * @return the found skeleton or null if not found at all.
  100080. */
  100081. getSkeletonById(id: string): Nullable<Skeleton>;
  100082. /**
  100083. * Gets a skeleton using a given name
  100084. * @param name defines the name to search for
  100085. * @return the found skeleton or null if not found at all.
  100086. */
  100087. getSkeletonByName(name: string): Nullable<Skeleton>;
  100088. /**
  100089. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  100090. * @param id defines the id to search for
  100091. * @return the found morph target manager or null if not found at all.
  100092. */
  100093. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  100094. /**
  100095. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  100096. * @param id defines the id to search for
  100097. * @return the found morph target or null if not found at all.
  100098. */
  100099. getMorphTargetById(id: string): Nullable<MorphTarget>;
  100100. /**
  100101. * Gets a boolean indicating if the given mesh is active
  100102. * @param mesh defines the mesh to look for
  100103. * @returns true if the mesh is in the active list
  100104. */
  100105. isActiveMesh(mesh: AbstractMesh): boolean;
  100106. /**
  100107. * Return a unique id as a string which can serve as an identifier for the scene
  100108. */
  100109. readonly uid: string;
  100110. /**
  100111. * Add an externaly attached data from its key.
  100112. * This method call will fail and return false, if such key already exists.
  100113. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  100114. * @param key the unique key that identifies the data
  100115. * @param data the data object to associate to the key for this Engine instance
  100116. * @return true if no such key were already present and the data was added successfully, false otherwise
  100117. */
  100118. addExternalData<T>(key: string, data: T): boolean;
  100119. /**
  100120. * Get an externaly attached data from its key
  100121. * @param key the unique key that identifies the data
  100122. * @return the associated data, if present (can be null), or undefined if not present
  100123. */
  100124. getExternalData<T>(key: string): Nullable<T>;
  100125. /**
  100126. * Get an externaly attached data from its key, create it using a factory if it's not already present
  100127. * @param key the unique key that identifies the data
  100128. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  100129. * @return the associated data, can be null if the factory returned null.
  100130. */
  100131. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  100132. /**
  100133. * Remove an externaly attached data from the Engine instance
  100134. * @param key the unique key that identifies the data
  100135. * @return true if the data was successfully removed, false if it doesn't exist
  100136. */
  100137. removeExternalData(key: string): boolean;
  100138. private _evaluateSubMesh;
  100139. /**
  100140. * Clear the processed materials smart array preventing retention point in material dispose.
  100141. */
  100142. freeProcessedMaterials(): void;
  100143. private _preventFreeActiveMeshesAndRenderingGroups;
  100144. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  100145. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  100146. * when disposing several meshes in a row or a hierarchy of meshes.
  100147. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  100148. */
  100149. blockfreeActiveMeshesAndRenderingGroups: boolean;
  100150. /**
  100151. * Clear the active meshes smart array preventing retention point in mesh dispose.
  100152. */
  100153. freeActiveMeshes(): void;
  100154. /**
  100155. * Clear the info related to rendering groups preventing retention points during dispose.
  100156. */
  100157. freeRenderingGroups(): void;
  100158. /** @hidden */
  100159. _isInIntermediateRendering(): boolean;
  100160. /**
  100161. * Lambda returning the list of potentially active meshes.
  100162. */
  100163. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  100164. /**
  100165. * Lambda returning the list of potentially active sub meshes.
  100166. */
  100167. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  100168. /**
  100169. * Lambda returning the list of potentially intersecting sub meshes.
  100170. */
  100171. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  100172. /**
  100173. * Lambda returning the list of potentially colliding sub meshes.
  100174. */
  100175. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  100176. private _activeMeshesFrozen;
  100177. /**
  100178. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  100179. * @returns the current scene
  100180. */
  100181. freezeActiveMeshes(): Scene;
  100182. /**
  100183. * Use this function to restart evaluating active meshes on every frame
  100184. * @returns the current scene
  100185. */
  100186. unfreezeActiveMeshes(): Scene;
  100187. private _evaluateActiveMeshes;
  100188. private _activeMesh;
  100189. /**
  100190. * Update the transform matrix to update from the current active camera
  100191. * @param force defines a boolean used to force the update even if cache is up to date
  100192. */
  100193. updateTransformMatrix(force?: boolean): void;
  100194. private _bindFrameBuffer;
  100195. /** @hidden */
  100196. _allowPostProcessClearColor: boolean;
  100197. /** @hidden */
  100198. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  100199. private _processSubCameras;
  100200. private _checkIntersections;
  100201. /** @hidden */
  100202. _advancePhysicsEngineStep(step: number): void;
  100203. /**
  100204. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  100205. */
  100206. getDeterministicFrameTime: () => number;
  100207. /** @hidden */
  100208. _animate(): void;
  100209. /** Execute all animations (for a frame) */
  100210. animate(): void;
  100211. /**
  100212. * Render the scene
  100213. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  100214. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  100215. */
  100216. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  100217. /**
  100218. * Freeze all materials
  100219. * A frozen material will not be updatable but should be faster to render
  100220. */
  100221. freezeMaterials(): void;
  100222. /**
  100223. * Unfreeze all materials
  100224. * A frozen material will not be updatable but should be faster to render
  100225. */
  100226. unfreezeMaterials(): void;
  100227. /**
  100228. * Releases all held ressources
  100229. */
  100230. dispose(): void;
  100231. /**
  100232. * Gets if the scene is already disposed
  100233. */
  100234. readonly isDisposed: boolean;
  100235. /**
  100236. * Call this function to reduce memory footprint of the scene.
  100237. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  100238. */
  100239. clearCachedVertexData(): void;
  100240. /**
  100241. * This function will remove the local cached buffer data from texture.
  100242. * It will save memory but will prevent the texture from being rebuilt
  100243. */
  100244. cleanCachedTextureBuffer(): void;
  100245. /**
  100246. * Get the world extend vectors with an optional filter
  100247. *
  100248. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  100249. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  100250. */
  100251. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  100252. min: Vector3;
  100253. max: Vector3;
  100254. };
  100255. /**
  100256. * Creates a ray that can be used to pick in the scene
  100257. * @param x defines the x coordinate of the origin (on-screen)
  100258. * @param y defines the y coordinate of the origin (on-screen)
  100259. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100260. * @param camera defines the camera to use for the picking
  100261. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100262. * @returns a Ray
  100263. */
  100264. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  100265. /**
  100266. * Creates a ray that can be used to pick in the scene
  100267. * @param x defines the x coordinate of the origin (on-screen)
  100268. * @param y defines the y coordinate of the origin (on-screen)
  100269. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100270. * @param result defines the ray where to store the picking ray
  100271. * @param camera defines the camera to use for the picking
  100272. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100273. * @returns the current scene
  100274. */
  100275. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  100276. /**
  100277. * Creates a ray that can be used to pick in the scene
  100278. * @param x defines the x coordinate of the origin (on-screen)
  100279. * @param y defines the y coordinate of the origin (on-screen)
  100280. * @param camera defines the camera to use for the picking
  100281. * @returns a Ray
  100282. */
  100283. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  100284. /**
  100285. * Creates a ray that can be used to pick in the scene
  100286. * @param x defines the x coordinate of the origin (on-screen)
  100287. * @param y defines the y coordinate of the origin (on-screen)
  100288. * @param result defines the ray where to store the picking ray
  100289. * @param camera defines the camera to use for the picking
  100290. * @returns the current scene
  100291. */
  100292. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  100293. /** Launch a ray to try to pick a mesh in the scene
  100294. * @param x position on screen
  100295. * @param y position on screen
  100296. * @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
  100297. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  100298. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100299. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100300. * @returns a PickingInfo
  100301. */
  100302. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100303. /** Use the given ray to pick a mesh in the scene
  100304. * @param ray The ray to use to pick meshes
  100305. * @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
  100306. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  100307. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100308. * @returns a PickingInfo
  100309. */
  100310. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100311. /**
  100312. * Launch a ray to try to pick a mesh in the scene
  100313. * @param x X position on screen
  100314. * @param y Y position on screen
  100315. * @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
  100316. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100317. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100318. * @returns an array of PickingInfo
  100319. */
  100320. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100321. /**
  100322. * Launch a ray to try to pick a mesh in the scene
  100323. * @param ray Ray to use
  100324. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  100325. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100326. * @returns an array of PickingInfo
  100327. */
  100328. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100329. /**
  100330. * Force the value of meshUnderPointer
  100331. * @param mesh defines the mesh to use
  100332. */
  100333. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100334. /**
  100335. * Gets the mesh under the pointer
  100336. * @returns a Mesh or null if no mesh is under the pointer
  100337. */
  100338. getPointerOverMesh(): Nullable<AbstractMesh>;
  100339. /** @hidden */
  100340. _rebuildGeometries(): void;
  100341. /** @hidden */
  100342. _rebuildTextures(): void;
  100343. private _getByTags;
  100344. /**
  100345. * Get a list of meshes by tags
  100346. * @param tagsQuery defines the tags query to use
  100347. * @param forEach defines a predicate used to filter results
  100348. * @returns an array of Mesh
  100349. */
  100350. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  100351. /**
  100352. * Get a list of cameras by tags
  100353. * @param tagsQuery defines the tags query to use
  100354. * @param forEach defines a predicate used to filter results
  100355. * @returns an array of Camera
  100356. */
  100357. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  100358. /**
  100359. * Get a list of lights by tags
  100360. * @param tagsQuery defines the tags query to use
  100361. * @param forEach defines a predicate used to filter results
  100362. * @returns an array of Light
  100363. */
  100364. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  100365. /**
  100366. * Get a list of materials by tags
  100367. * @param tagsQuery defines the tags query to use
  100368. * @param forEach defines a predicate used to filter results
  100369. * @returns an array of Material
  100370. */
  100371. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  100372. /**
  100373. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100374. * This allowed control for front to back rendering or reversly depending of the special needs.
  100375. *
  100376. * @param renderingGroupId The rendering group id corresponding to its index
  100377. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100378. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100379. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100380. */
  100381. 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;
  100382. /**
  100383. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100384. *
  100385. * @param renderingGroupId The rendering group id corresponding to its index
  100386. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100387. * @param depth Automatically clears depth between groups if true and autoClear is true.
  100388. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  100389. */
  100390. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  100391. /**
  100392. * Gets the current auto clear configuration for one rendering group of the rendering
  100393. * manager.
  100394. * @param index the rendering group index to get the information for
  100395. * @returns The auto clear setup for the requested rendering group
  100396. */
  100397. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  100398. private _blockMaterialDirtyMechanism;
  100399. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  100400. blockMaterialDirtyMechanism: boolean;
  100401. /**
  100402. * Will flag all materials as dirty to trigger new shader compilation
  100403. * @param flag defines the flag used to specify which material part must be marked as dirty
  100404. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  100405. */
  100406. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  100407. /** @hidden */
  100408. _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;
  100409. /** @hidden */
  100410. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100411. }
  100412. }
  100413. declare module BABYLON {
  100414. /**
  100415. * Set of assets to keep when moving a scene into an asset container.
  100416. */
  100417. export class KeepAssets extends AbstractScene {
  100418. }
  100419. /**
  100420. * Container with a set of assets that can be added or removed from a scene.
  100421. */
  100422. export class AssetContainer extends AbstractScene {
  100423. /**
  100424. * The scene the AssetContainer belongs to.
  100425. */
  100426. scene: Scene;
  100427. /**
  100428. * Instantiates an AssetContainer.
  100429. * @param scene The scene the AssetContainer belongs to.
  100430. */
  100431. constructor(scene: Scene);
  100432. /**
  100433. * Adds all the assets from the container to the scene.
  100434. */
  100435. addAllToScene(): void;
  100436. /**
  100437. * Removes all the assets in the container from the scene
  100438. */
  100439. removeAllFromScene(): void;
  100440. /**
  100441. * Disposes all the assets in the container
  100442. */
  100443. dispose(): void;
  100444. private _moveAssets;
  100445. /**
  100446. * Removes all the assets contained in the scene and adds them to the container.
  100447. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  100448. */
  100449. moveAllFromScene(keepAssets?: KeepAssets): void;
  100450. /**
  100451. * 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.
  100452. * @returns the root mesh
  100453. */
  100454. createRootMesh(): Mesh;
  100455. }
  100456. }
  100457. declare module BABYLON {
  100458. /**
  100459. * Defines how the parser contract is defined.
  100460. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  100461. */
  100462. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  100463. /**
  100464. * Defines how the individual parser contract is defined.
  100465. * These parser can parse an individual asset
  100466. */
  100467. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  100468. /**
  100469. * Base class of the scene acting as a container for the different elements composing a scene.
  100470. * This class is dynamically extended by the different components of the scene increasing
  100471. * flexibility and reducing coupling
  100472. */
  100473. export abstract class AbstractScene {
  100474. /**
  100475. * Stores the list of available parsers in the application.
  100476. */
  100477. private static _BabylonFileParsers;
  100478. /**
  100479. * Stores the list of available individual parsers in the application.
  100480. */
  100481. private static _IndividualBabylonFileParsers;
  100482. /**
  100483. * Adds a parser in the list of available ones
  100484. * @param name Defines the name of the parser
  100485. * @param parser Defines the parser to add
  100486. */
  100487. static AddParser(name: string, parser: BabylonFileParser): void;
  100488. /**
  100489. * Gets a general parser from the list of avaialble ones
  100490. * @param name Defines the name of the parser
  100491. * @returns the requested parser or null
  100492. */
  100493. static GetParser(name: string): Nullable<BabylonFileParser>;
  100494. /**
  100495. * Adds n individual parser in the list of available ones
  100496. * @param name Defines the name of the parser
  100497. * @param parser Defines the parser to add
  100498. */
  100499. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  100500. /**
  100501. * Gets an individual parser from the list of avaialble ones
  100502. * @param name Defines the name of the parser
  100503. * @returns the requested parser or null
  100504. */
  100505. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  100506. /**
  100507. * Parser json data and populate both a scene and its associated container object
  100508. * @param jsonData Defines the data to parse
  100509. * @param scene Defines the scene to parse the data for
  100510. * @param container Defines the container attached to the parsing sequence
  100511. * @param rootUrl Defines the root url of the data
  100512. */
  100513. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  100514. /**
  100515. * Gets the list of root nodes (ie. nodes with no parent)
  100516. */
  100517. rootNodes: Node[];
  100518. /** All of the cameras added to this scene
  100519. * @see http://doc.babylonjs.com/babylon101/cameras
  100520. */
  100521. cameras: Camera[];
  100522. /**
  100523. * All of the lights added to this scene
  100524. * @see http://doc.babylonjs.com/babylon101/lights
  100525. */
  100526. lights: Light[];
  100527. /**
  100528. * All of the (abstract) meshes added to this scene
  100529. */
  100530. meshes: AbstractMesh[];
  100531. /**
  100532. * The list of skeletons added to the scene
  100533. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100534. */
  100535. skeletons: Skeleton[];
  100536. /**
  100537. * All of the particle systems added to this scene
  100538. * @see http://doc.babylonjs.com/babylon101/particles
  100539. */
  100540. particleSystems: IParticleSystem[];
  100541. /**
  100542. * Gets a list of Animations associated with the scene
  100543. */
  100544. animations: Animation[];
  100545. /**
  100546. * All of the animation groups added to this scene
  100547. * @see http://doc.babylonjs.com/how_to/group
  100548. */
  100549. animationGroups: AnimationGroup[];
  100550. /**
  100551. * All of the multi-materials added to this scene
  100552. * @see http://doc.babylonjs.com/how_to/multi_materials
  100553. */
  100554. multiMaterials: MultiMaterial[];
  100555. /**
  100556. * All of the materials added to this scene
  100557. * In the context of a Scene, it is not supposed to be modified manually.
  100558. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  100559. * Note also that the order of the Material wihin the array is not significant and might change.
  100560. * @see http://doc.babylonjs.com/babylon101/materials
  100561. */
  100562. materials: Material[];
  100563. /**
  100564. * The list of morph target managers added to the scene
  100565. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  100566. */
  100567. morphTargetManagers: MorphTargetManager[];
  100568. /**
  100569. * The list of geometries used in the scene.
  100570. */
  100571. geometries: Geometry[];
  100572. /**
  100573. * All of the tranform nodes added to this scene
  100574. * In the context of a Scene, it is not supposed to be modified manually.
  100575. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  100576. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  100577. * @see http://doc.babylonjs.com/how_to/transformnode
  100578. */
  100579. transformNodes: TransformNode[];
  100580. /**
  100581. * ActionManagers available on the scene.
  100582. */
  100583. actionManagers: AbstractActionManager[];
  100584. /**
  100585. * Textures to keep.
  100586. */
  100587. textures: BaseTexture[];
  100588. /**
  100589. * Environment texture for the scene
  100590. */
  100591. environmentTexture: Nullable<BaseTexture>;
  100592. }
  100593. }
  100594. declare module BABYLON {
  100595. /**
  100596. * Interface used to define options for Sound class
  100597. */
  100598. export interface ISoundOptions {
  100599. /**
  100600. * Does the sound autoplay once loaded.
  100601. */
  100602. autoplay?: boolean;
  100603. /**
  100604. * Does the sound loop after it finishes playing once.
  100605. */
  100606. loop?: boolean;
  100607. /**
  100608. * Sound's volume
  100609. */
  100610. volume?: number;
  100611. /**
  100612. * Is it a spatial sound?
  100613. */
  100614. spatialSound?: boolean;
  100615. /**
  100616. * Maximum distance to hear that sound
  100617. */
  100618. maxDistance?: number;
  100619. /**
  100620. * Uses user defined attenuation function
  100621. */
  100622. useCustomAttenuation?: boolean;
  100623. /**
  100624. * Define the roll off factor of spatial sounds.
  100625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100626. */
  100627. rolloffFactor?: number;
  100628. /**
  100629. * Define the reference distance the sound should be heard perfectly.
  100630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100631. */
  100632. refDistance?: number;
  100633. /**
  100634. * Define the distance attenuation model the sound will follow.
  100635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100636. */
  100637. distanceModel?: string;
  100638. /**
  100639. * Defines the playback speed (1 by default)
  100640. */
  100641. playbackRate?: number;
  100642. /**
  100643. * Defines if the sound is from a streaming source
  100644. */
  100645. streaming?: boolean;
  100646. /**
  100647. * Defines an optional length (in seconds) inside the sound file
  100648. */
  100649. length?: number;
  100650. /**
  100651. * Defines an optional offset (in seconds) inside the sound file
  100652. */
  100653. offset?: number;
  100654. /**
  100655. * If true, URLs will not be required to state the audio file codec to use.
  100656. */
  100657. skipCodecCheck?: boolean;
  100658. }
  100659. /**
  100660. * Defines a sound that can be played in the application.
  100661. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  100662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100663. */
  100664. export class Sound {
  100665. /**
  100666. * The name of the sound in the scene.
  100667. */
  100668. name: string;
  100669. /**
  100670. * Does the sound autoplay once loaded.
  100671. */
  100672. autoplay: boolean;
  100673. /**
  100674. * Does the sound loop after it finishes playing once.
  100675. */
  100676. loop: boolean;
  100677. /**
  100678. * Does the sound use a custom attenuation curve to simulate the falloff
  100679. * happening when the source gets further away from the camera.
  100680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100681. */
  100682. useCustomAttenuation: boolean;
  100683. /**
  100684. * The sound track id this sound belongs to.
  100685. */
  100686. soundTrackId: number;
  100687. /**
  100688. * Is this sound currently played.
  100689. */
  100690. isPlaying: boolean;
  100691. /**
  100692. * Is this sound currently paused.
  100693. */
  100694. isPaused: boolean;
  100695. /**
  100696. * Does this sound enables spatial sound.
  100697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100698. */
  100699. spatialSound: boolean;
  100700. /**
  100701. * Define the reference distance the sound should be heard perfectly.
  100702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100703. */
  100704. refDistance: number;
  100705. /**
  100706. * Define the roll off factor of spatial sounds.
  100707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100708. */
  100709. rolloffFactor: number;
  100710. /**
  100711. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  100712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100713. */
  100714. maxDistance: number;
  100715. /**
  100716. * Define the distance attenuation model the sound will follow.
  100717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100718. */
  100719. distanceModel: string;
  100720. /**
  100721. * @hidden
  100722. * Back Compat
  100723. **/
  100724. onended: () => any;
  100725. /**
  100726. * Observable event when the current playing sound finishes.
  100727. */
  100728. onEndedObservable: Observable<Sound>;
  100729. private _panningModel;
  100730. private _playbackRate;
  100731. private _streaming;
  100732. private _startTime;
  100733. private _startOffset;
  100734. private _position;
  100735. /** @hidden */
  100736. _positionInEmitterSpace: boolean;
  100737. private _localDirection;
  100738. private _volume;
  100739. private _isReadyToPlay;
  100740. private _isDirectional;
  100741. private _readyToPlayCallback;
  100742. private _audioBuffer;
  100743. private _soundSource;
  100744. private _streamingSource;
  100745. private _soundPanner;
  100746. private _soundGain;
  100747. private _inputAudioNode;
  100748. private _outputAudioNode;
  100749. private _coneInnerAngle;
  100750. private _coneOuterAngle;
  100751. private _coneOuterGain;
  100752. private _scene;
  100753. private _connectedTransformNode;
  100754. private _customAttenuationFunction;
  100755. private _registerFunc;
  100756. private _isOutputConnected;
  100757. private _htmlAudioElement;
  100758. private _urlType;
  100759. private _length?;
  100760. private _offset?;
  100761. /** @hidden */
  100762. static _SceneComponentInitialization: (scene: Scene) => void;
  100763. /**
  100764. * Create a sound and attach it to a scene
  100765. * @param name Name of your sound
  100766. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  100767. * @param scene defines the scene the sound belongs to
  100768. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  100769. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  100770. */
  100771. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  100772. /**
  100773. * Release the sound and its associated resources
  100774. */
  100775. dispose(): void;
  100776. /**
  100777. * Gets if the sounds is ready to be played or not.
  100778. * @returns true if ready, otherwise false
  100779. */
  100780. isReady(): boolean;
  100781. private _soundLoaded;
  100782. /**
  100783. * Sets the data of the sound from an audiobuffer
  100784. * @param audioBuffer The audioBuffer containing the data
  100785. */
  100786. setAudioBuffer(audioBuffer: AudioBuffer): void;
  100787. /**
  100788. * Updates the current sounds options such as maxdistance, loop...
  100789. * @param options A JSON object containing values named as the object properties
  100790. */
  100791. updateOptions(options: ISoundOptions): void;
  100792. private _createSpatialParameters;
  100793. private _updateSpatialParameters;
  100794. /**
  100795. * Switch the panning model to HRTF:
  100796. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100798. */
  100799. switchPanningModelToHRTF(): void;
  100800. /**
  100801. * Switch the panning model to Equal Power:
  100802. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100803. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100804. */
  100805. switchPanningModelToEqualPower(): void;
  100806. private _switchPanningModel;
  100807. /**
  100808. * Connect this sound to a sound track audio node like gain...
  100809. * @param soundTrackAudioNode the sound track audio node to connect to
  100810. */
  100811. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  100812. /**
  100813. * Transform this sound into a directional source
  100814. * @param coneInnerAngle Size of the inner cone in degree
  100815. * @param coneOuterAngle Size of the outer cone in degree
  100816. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  100817. */
  100818. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  100819. /**
  100820. * Gets or sets the inner angle for the directional cone.
  100821. */
  100822. /**
  100823. * Gets or sets the inner angle for the directional cone.
  100824. */
  100825. directionalConeInnerAngle: number;
  100826. /**
  100827. * Gets or sets the outer angle for the directional cone.
  100828. */
  100829. /**
  100830. * Gets or sets the outer angle for the directional cone.
  100831. */
  100832. directionalConeOuterAngle: number;
  100833. /**
  100834. * Sets the position of the emitter if spatial sound is enabled
  100835. * @param newPosition Defines the new posisiton
  100836. */
  100837. setPosition(newPosition: Vector3): void;
  100838. /**
  100839. * Sets the local direction of the emitter if spatial sound is enabled
  100840. * @param newLocalDirection Defines the new local direction
  100841. */
  100842. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  100843. private _updateDirection;
  100844. /** @hidden */
  100845. updateDistanceFromListener(): void;
  100846. /**
  100847. * Sets a new custom attenuation function for the sound.
  100848. * @param callback Defines the function used for the attenuation
  100849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100850. */
  100851. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  100852. /**
  100853. * Play the sound
  100854. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  100855. * @param offset (optional) Start the sound at a specific time in seconds
  100856. * @param length (optional) Sound duration (in seconds)
  100857. */
  100858. play(time?: number, offset?: number, length?: number): void;
  100859. private _onended;
  100860. /**
  100861. * Stop the sound
  100862. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  100863. */
  100864. stop(time?: number): void;
  100865. /**
  100866. * Put the sound in pause
  100867. */
  100868. pause(): void;
  100869. /**
  100870. * Sets a dedicated volume for this sounds
  100871. * @param newVolume Define the new volume of the sound
  100872. * @param time Define time for gradual change to new volume
  100873. */
  100874. setVolume(newVolume: number, time?: number): void;
  100875. /**
  100876. * Set the sound play back rate
  100877. * @param newPlaybackRate Define the playback rate the sound should be played at
  100878. */
  100879. setPlaybackRate(newPlaybackRate: number): void;
  100880. /**
  100881. * Gets the volume of the sound.
  100882. * @returns the volume of the sound
  100883. */
  100884. getVolume(): number;
  100885. /**
  100886. * Attach the sound to a dedicated mesh
  100887. * @param transformNode The transform node to connect the sound with
  100888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100889. */
  100890. attachToMesh(transformNode: TransformNode): void;
  100891. /**
  100892. * Detach the sound from the previously attached mesh
  100893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100894. */
  100895. detachFromMesh(): void;
  100896. private _onRegisterAfterWorldMatrixUpdate;
  100897. /**
  100898. * Clone the current sound in the scene.
  100899. * @returns the new sound clone
  100900. */
  100901. clone(): Nullable<Sound>;
  100902. /**
  100903. * Gets the current underlying audio buffer containing the data
  100904. * @returns the audio buffer
  100905. */
  100906. getAudioBuffer(): Nullable<AudioBuffer>;
  100907. /**
  100908. * Serializes the Sound in a JSON representation
  100909. * @returns the JSON representation of the sound
  100910. */
  100911. serialize(): any;
  100912. /**
  100913. * Parse a JSON representation of a sound to innstantiate in a given scene
  100914. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  100915. * @param scene Define the scene the new parsed sound should be created in
  100916. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  100917. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  100918. * @returns the newly parsed sound
  100919. */
  100920. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  100921. }
  100922. }
  100923. declare module BABYLON {
  100924. /**
  100925. * This defines an action helpful to play a defined sound on a triggered action.
  100926. */
  100927. export class PlaySoundAction extends Action {
  100928. private _sound;
  100929. /**
  100930. * Instantiate the action
  100931. * @param triggerOptions defines the trigger options
  100932. * @param sound defines the sound to play
  100933. * @param condition defines the trigger related conditions
  100934. */
  100935. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100936. /** @hidden */
  100937. _prepare(): void;
  100938. /**
  100939. * Execute the action and play the sound.
  100940. */
  100941. execute(): void;
  100942. /**
  100943. * Serializes the actions and its related information.
  100944. * @param parent defines the object to serialize in
  100945. * @returns the serialized object
  100946. */
  100947. serialize(parent: any): any;
  100948. }
  100949. /**
  100950. * This defines an action helpful to stop a defined sound on a triggered action.
  100951. */
  100952. export class StopSoundAction extends Action {
  100953. private _sound;
  100954. /**
  100955. * Instantiate the action
  100956. * @param triggerOptions defines the trigger options
  100957. * @param sound defines the sound to stop
  100958. * @param condition defines the trigger related conditions
  100959. */
  100960. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100961. /** @hidden */
  100962. _prepare(): void;
  100963. /**
  100964. * Execute the action and stop the sound.
  100965. */
  100966. execute(): void;
  100967. /**
  100968. * Serializes the actions and its related information.
  100969. * @param parent defines the object to serialize in
  100970. * @returns the serialized object
  100971. */
  100972. serialize(parent: any): any;
  100973. }
  100974. }
  100975. declare module BABYLON {
  100976. /**
  100977. * This defines an action responsible to change the value of a property
  100978. * by interpolating between its current value and the newly set one once triggered.
  100979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100980. */
  100981. export class InterpolateValueAction extends Action {
  100982. /**
  100983. * Defines the path of the property where the value should be interpolated
  100984. */
  100985. propertyPath: string;
  100986. /**
  100987. * Defines the target value at the end of the interpolation.
  100988. */
  100989. value: any;
  100990. /**
  100991. * Defines the time it will take for the property to interpolate to the value.
  100992. */
  100993. duration: number;
  100994. /**
  100995. * Defines if the other scene animations should be stopped when the action has been triggered
  100996. */
  100997. stopOtherAnimations?: boolean;
  100998. /**
  100999. * Defines a callback raised once the interpolation animation has been done.
  101000. */
  101001. onInterpolationDone?: () => void;
  101002. /**
  101003. * Observable triggered once the interpolation animation has been done.
  101004. */
  101005. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  101006. private _target;
  101007. private _effectiveTarget;
  101008. private _property;
  101009. /**
  101010. * Instantiate the action
  101011. * @param triggerOptions defines the trigger options
  101012. * @param target defines the object containing the value to interpolate
  101013. * @param propertyPath defines the path to the property in the target object
  101014. * @param value defines the target value at the end of the interpolation
  101015. * @param duration deines the time it will take for the property to interpolate to the value.
  101016. * @param condition defines the trigger related conditions
  101017. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  101018. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  101019. */
  101020. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  101021. /** @hidden */
  101022. _prepare(): void;
  101023. /**
  101024. * Execute the action starts the value interpolation.
  101025. */
  101026. execute(): void;
  101027. /**
  101028. * Serializes the actions and its related information.
  101029. * @param parent defines the object to serialize in
  101030. * @returns the serialized object
  101031. */
  101032. serialize(parent: any): any;
  101033. }
  101034. }
  101035. declare module BABYLON {
  101036. /**
  101037. * Options allowed during the creation of a sound track.
  101038. */
  101039. export interface ISoundTrackOptions {
  101040. /**
  101041. * The volume the sound track should take during creation
  101042. */
  101043. volume?: number;
  101044. /**
  101045. * Define if the sound track is the main sound track of the scene
  101046. */
  101047. mainTrack?: boolean;
  101048. }
  101049. /**
  101050. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  101051. * It will be also used in a future release to apply effects on a specific track.
  101052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101053. */
  101054. export class SoundTrack {
  101055. /**
  101056. * The unique identifier of the sound track in the scene.
  101057. */
  101058. id: number;
  101059. /**
  101060. * The list of sounds included in the sound track.
  101061. */
  101062. soundCollection: Array<Sound>;
  101063. private _outputAudioNode;
  101064. private _scene;
  101065. private _isMainTrack;
  101066. private _connectedAnalyser;
  101067. private _options;
  101068. private _isInitialized;
  101069. /**
  101070. * Creates a new sound track.
  101071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101072. * @param scene Define the scene the sound track belongs to
  101073. * @param options
  101074. */
  101075. constructor(scene: Scene, options?: ISoundTrackOptions);
  101076. private _initializeSoundTrackAudioGraph;
  101077. /**
  101078. * Release the sound track and its associated resources
  101079. */
  101080. dispose(): void;
  101081. /**
  101082. * Adds a sound to this sound track
  101083. * @param sound define the cound to add
  101084. * @ignoreNaming
  101085. */
  101086. AddSound(sound: Sound): void;
  101087. /**
  101088. * Removes a sound to this sound track
  101089. * @param sound define the cound to remove
  101090. * @ignoreNaming
  101091. */
  101092. RemoveSound(sound: Sound): void;
  101093. /**
  101094. * Set a global volume for the full sound track.
  101095. * @param newVolume Define the new volume of the sound track
  101096. */
  101097. setVolume(newVolume: number): void;
  101098. /**
  101099. * Switch the panning model to HRTF:
  101100. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101102. */
  101103. switchPanningModelToHRTF(): void;
  101104. /**
  101105. * Switch the panning model to Equal Power:
  101106. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101108. */
  101109. switchPanningModelToEqualPower(): void;
  101110. /**
  101111. * Connect the sound track to an audio analyser allowing some amazing
  101112. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101114. * @param analyser The analyser to connect to the engine
  101115. */
  101116. connectToAnalyser(analyser: Analyser): void;
  101117. }
  101118. }
  101119. declare module BABYLON {
  101120. interface AbstractScene {
  101121. /**
  101122. * The list of sounds used in the scene.
  101123. */
  101124. sounds: Nullable<Array<Sound>>;
  101125. }
  101126. interface Scene {
  101127. /**
  101128. * @hidden
  101129. * Backing field
  101130. */
  101131. _mainSoundTrack: SoundTrack;
  101132. /**
  101133. * The main sound track played by the scene.
  101134. * It cotains your primary collection of sounds.
  101135. */
  101136. mainSoundTrack: SoundTrack;
  101137. /**
  101138. * The list of sound tracks added to the scene
  101139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101140. */
  101141. soundTracks: Nullable<Array<SoundTrack>>;
  101142. /**
  101143. * Gets a sound using a given name
  101144. * @param name defines the name to search for
  101145. * @return the found sound or null if not found at all.
  101146. */
  101147. getSoundByName(name: string): Nullable<Sound>;
  101148. /**
  101149. * Gets or sets if audio support is enabled
  101150. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101151. */
  101152. audioEnabled: boolean;
  101153. /**
  101154. * Gets or sets if audio will be output to headphones
  101155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101156. */
  101157. headphone: boolean;
  101158. /**
  101159. * Gets or sets custom audio listener position provider
  101160. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101161. */
  101162. audioListenerPositionProvider: Nullable<() => Vector3>;
  101163. }
  101164. /**
  101165. * Defines the sound scene component responsible to manage any sounds
  101166. * in a given scene.
  101167. */
  101168. export class AudioSceneComponent implements ISceneSerializableComponent {
  101169. /**
  101170. * The component name helpfull to identify the component in the list of scene components.
  101171. */
  101172. readonly name: string;
  101173. /**
  101174. * The scene the component belongs to.
  101175. */
  101176. scene: Scene;
  101177. private _audioEnabled;
  101178. /**
  101179. * Gets whether audio is enabled or not.
  101180. * Please use related enable/disable method to switch state.
  101181. */
  101182. readonly audioEnabled: boolean;
  101183. private _headphone;
  101184. /**
  101185. * Gets whether audio is outputing to headphone or not.
  101186. * Please use the according Switch methods to change output.
  101187. */
  101188. readonly headphone: boolean;
  101189. private _audioListenerPositionProvider;
  101190. /**
  101191. * Gets the current audio listener position provider
  101192. */
  101193. /**
  101194. * Sets a custom listener position for all sounds in the scene
  101195. * By default, this is the position of the first active camera
  101196. */
  101197. audioListenerPositionProvider: Nullable<() => Vector3>;
  101198. /**
  101199. * Creates a new instance of the component for the given scene
  101200. * @param scene Defines the scene to register the component in
  101201. */
  101202. constructor(scene: Scene);
  101203. /**
  101204. * Registers the component in a given scene
  101205. */
  101206. register(): void;
  101207. /**
  101208. * Rebuilds the elements related to this component in case of
  101209. * context lost for instance.
  101210. */
  101211. rebuild(): void;
  101212. /**
  101213. * Serializes the component data to the specified json object
  101214. * @param serializationObject The object to serialize to
  101215. */
  101216. serialize(serializationObject: any): void;
  101217. /**
  101218. * Adds all the elements from the container to the scene
  101219. * @param container the container holding the elements
  101220. */
  101221. addFromContainer(container: AbstractScene): void;
  101222. /**
  101223. * Removes all the elements in the container from the scene
  101224. * @param container contains the elements to remove
  101225. * @param dispose if the removed element should be disposed (default: false)
  101226. */
  101227. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  101228. /**
  101229. * Disposes the component and the associated ressources.
  101230. */
  101231. dispose(): void;
  101232. /**
  101233. * Disables audio in the associated scene.
  101234. */
  101235. disableAudio(): void;
  101236. /**
  101237. * Enables audio in the associated scene.
  101238. */
  101239. enableAudio(): void;
  101240. /**
  101241. * Switch audio to headphone output.
  101242. */
  101243. switchAudioModeForHeadphones(): void;
  101244. /**
  101245. * Switch audio to normal speakers.
  101246. */
  101247. switchAudioModeForNormalSpeakers(): void;
  101248. private _afterRender;
  101249. }
  101250. }
  101251. declare module BABYLON {
  101252. /**
  101253. * Wraps one or more Sound objects and selects one with random weight for playback.
  101254. */
  101255. export class WeightedSound {
  101256. /** When true a Sound will be selected and played when the current playing Sound completes. */
  101257. loop: boolean;
  101258. private _coneInnerAngle;
  101259. private _coneOuterAngle;
  101260. private _volume;
  101261. /** A Sound is currently playing. */
  101262. isPlaying: boolean;
  101263. /** A Sound is currently paused. */
  101264. isPaused: boolean;
  101265. private _sounds;
  101266. private _weights;
  101267. private _currentIndex?;
  101268. /**
  101269. * Creates a new WeightedSound from the list of sounds given.
  101270. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  101271. * @param sounds Array of Sounds that will be selected from.
  101272. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  101273. */
  101274. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  101275. /**
  101276. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  101277. */
  101278. /**
  101279. * The size of cone in degress for a directional sound in which there will be no attenuation.
  101280. */
  101281. directionalConeInnerAngle: number;
  101282. /**
  101283. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101284. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101285. */
  101286. /**
  101287. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101288. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101289. */
  101290. directionalConeOuterAngle: number;
  101291. /**
  101292. * Playback volume.
  101293. */
  101294. /**
  101295. * Playback volume.
  101296. */
  101297. volume: number;
  101298. private _onended;
  101299. /**
  101300. * Suspend playback
  101301. */
  101302. pause(): void;
  101303. /**
  101304. * Stop playback
  101305. */
  101306. stop(): void;
  101307. /**
  101308. * Start playback.
  101309. * @param startOffset Position the clip head at a specific time in seconds.
  101310. */
  101311. play(startOffset?: number): void;
  101312. }
  101313. }
  101314. declare module BABYLON {
  101315. /**
  101316. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  101317. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101318. */
  101319. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  101320. /**
  101321. * Gets the name of the behavior.
  101322. */
  101323. readonly name: string;
  101324. /**
  101325. * The easing function used by animations
  101326. */
  101327. static EasingFunction: BackEase;
  101328. /**
  101329. * The easing mode used by animations
  101330. */
  101331. static EasingMode: number;
  101332. /**
  101333. * The duration of the animation, in milliseconds
  101334. */
  101335. transitionDuration: number;
  101336. /**
  101337. * Length of the distance animated by the transition when lower radius is reached
  101338. */
  101339. lowerRadiusTransitionRange: number;
  101340. /**
  101341. * Length of the distance animated by the transition when upper radius is reached
  101342. */
  101343. upperRadiusTransitionRange: number;
  101344. private _autoTransitionRange;
  101345. /**
  101346. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101347. */
  101348. /**
  101349. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101350. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  101351. */
  101352. autoTransitionRange: boolean;
  101353. private _attachedCamera;
  101354. private _onAfterCheckInputsObserver;
  101355. private _onMeshTargetChangedObserver;
  101356. /**
  101357. * Initializes the behavior.
  101358. */
  101359. init(): void;
  101360. /**
  101361. * Attaches the behavior to its arc rotate camera.
  101362. * @param camera Defines the camera to attach the behavior to
  101363. */
  101364. attach(camera: ArcRotateCamera): void;
  101365. /**
  101366. * Detaches the behavior from its current arc rotate camera.
  101367. */
  101368. detach(): void;
  101369. private _radiusIsAnimating;
  101370. private _radiusBounceTransition;
  101371. private _animatables;
  101372. private _cachedWheelPrecision;
  101373. /**
  101374. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  101375. * @param radiusLimit The limit to check against.
  101376. * @return Bool to indicate if at limit.
  101377. */
  101378. private _isRadiusAtLimit;
  101379. /**
  101380. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  101381. * @param radiusDelta The delta by which to animate to. Can be negative.
  101382. */
  101383. private _applyBoundRadiusAnimation;
  101384. /**
  101385. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  101386. */
  101387. protected _clearAnimationLocks(): void;
  101388. /**
  101389. * Stops and removes all animations that have been applied to the camera
  101390. */
  101391. stopAllAnimations(): void;
  101392. }
  101393. }
  101394. declare module BABYLON {
  101395. /**
  101396. * 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.
  101397. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101398. */
  101399. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  101400. /**
  101401. * Gets the name of the behavior.
  101402. */
  101403. readonly name: string;
  101404. private _mode;
  101405. private _radiusScale;
  101406. private _positionScale;
  101407. private _defaultElevation;
  101408. private _elevationReturnTime;
  101409. private _elevationReturnWaitTime;
  101410. private _zoomStopsAnimation;
  101411. private _framingTime;
  101412. /**
  101413. * The easing function used by animations
  101414. */
  101415. static EasingFunction: ExponentialEase;
  101416. /**
  101417. * The easing mode used by animations
  101418. */
  101419. static EasingMode: number;
  101420. /**
  101421. * Sets the current mode used by the behavior
  101422. */
  101423. /**
  101424. * Gets current mode used by the behavior.
  101425. */
  101426. mode: number;
  101427. /**
  101428. * Sets the scale applied to the radius (1 by default)
  101429. */
  101430. /**
  101431. * Gets the scale applied to the radius
  101432. */
  101433. radiusScale: number;
  101434. /**
  101435. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101436. */
  101437. /**
  101438. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101439. */
  101440. positionScale: number;
  101441. /**
  101442. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101443. * behaviour is triggered, in radians.
  101444. */
  101445. /**
  101446. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101447. * behaviour is triggered, in radians.
  101448. */
  101449. defaultElevation: number;
  101450. /**
  101451. * Sets the time (in milliseconds) taken to return to the default beta position.
  101452. * Negative value indicates camera should not return to default.
  101453. */
  101454. /**
  101455. * Gets the time (in milliseconds) taken to return to the default beta position.
  101456. * Negative value indicates camera should not return to default.
  101457. */
  101458. elevationReturnTime: number;
  101459. /**
  101460. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101461. */
  101462. /**
  101463. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101464. */
  101465. elevationReturnWaitTime: number;
  101466. /**
  101467. * Sets the flag that indicates if user zooming should stop animation.
  101468. */
  101469. /**
  101470. * Gets the flag that indicates if user zooming should stop animation.
  101471. */
  101472. zoomStopsAnimation: boolean;
  101473. /**
  101474. * Sets the transition time when framing the mesh, in milliseconds
  101475. */
  101476. /**
  101477. * Gets the transition time when framing the mesh, in milliseconds
  101478. */
  101479. framingTime: number;
  101480. /**
  101481. * Define if the behavior should automatically change the configured
  101482. * camera limits and sensibilities.
  101483. */
  101484. autoCorrectCameraLimitsAndSensibility: boolean;
  101485. private _onPrePointerObservableObserver;
  101486. private _onAfterCheckInputsObserver;
  101487. private _onMeshTargetChangedObserver;
  101488. private _attachedCamera;
  101489. private _isPointerDown;
  101490. private _lastInteractionTime;
  101491. /**
  101492. * Initializes the behavior.
  101493. */
  101494. init(): void;
  101495. /**
  101496. * Attaches the behavior to its arc rotate camera.
  101497. * @param camera Defines the camera to attach the behavior to
  101498. */
  101499. attach(camera: ArcRotateCamera): void;
  101500. /**
  101501. * Detaches the behavior from its current arc rotate camera.
  101502. */
  101503. detach(): void;
  101504. private _animatables;
  101505. private _betaIsAnimating;
  101506. private _betaTransition;
  101507. private _radiusTransition;
  101508. private _vectorTransition;
  101509. /**
  101510. * Targets the given mesh and updates zoom level accordingly.
  101511. * @param mesh The mesh to target.
  101512. * @param radius Optional. If a cached radius position already exists, overrides default.
  101513. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101514. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101515. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101516. */
  101517. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101518. /**
  101519. * Targets the given mesh with its children and updates zoom level accordingly.
  101520. * @param mesh The mesh to target.
  101521. * @param radius Optional. If a cached radius position already exists, overrides default.
  101522. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101523. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101524. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101525. */
  101526. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101527. /**
  101528. * Targets the given meshes with their children and updates zoom level accordingly.
  101529. * @param meshes The mesh to target.
  101530. * @param radius Optional. If a cached radius position already exists, overrides default.
  101531. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101532. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101533. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101534. */
  101535. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101536. /**
  101537. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  101538. * @param minimumWorld Determines the smaller position of the bounding box extend
  101539. * @param maximumWorld Determines the bigger position of the bounding box extend
  101540. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101541. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101542. */
  101543. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101544. /**
  101545. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  101546. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  101547. * frustum width.
  101548. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  101549. * to fully enclose the mesh in the viewing frustum.
  101550. */
  101551. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  101552. /**
  101553. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  101554. * is automatically returned to its default position (expected to be above ground plane).
  101555. */
  101556. private _maintainCameraAboveGround;
  101557. /**
  101558. * Returns the frustum slope based on the canvas ratio and camera FOV
  101559. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  101560. */
  101561. private _getFrustumSlope;
  101562. /**
  101563. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  101564. */
  101565. private _clearAnimationLocks;
  101566. /**
  101567. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101568. */
  101569. private _applyUserInteraction;
  101570. /**
  101571. * Stops and removes all animations that have been applied to the camera
  101572. */
  101573. stopAllAnimations(): void;
  101574. /**
  101575. * Gets a value indicating if the user is moving the camera
  101576. */
  101577. readonly isUserIsMoving: boolean;
  101578. /**
  101579. * The camera can move all the way towards the mesh.
  101580. */
  101581. static IgnoreBoundsSizeMode: number;
  101582. /**
  101583. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  101584. */
  101585. static FitFrustumSidesMode: number;
  101586. }
  101587. }
  101588. declare module BABYLON {
  101589. /**
  101590. * Base class for Camera Pointer Inputs.
  101591. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  101592. * for example usage.
  101593. */
  101594. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  101595. /**
  101596. * Defines the camera the input is attached to.
  101597. */
  101598. abstract camera: Camera;
  101599. /**
  101600. * Whether keyboard modifier keys are pressed at time of last mouse event.
  101601. */
  101602. protected _altKey: boolean;
  101603. protected _ctrlKey: boolean;
  101604. protected _metaKey: boolean;
  101605. protected _shiftKey: boolean;
  101606. /**
  101607. * Which mouse buttons were pressed at time of last mouse event.
  101608. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  101609. */
  101610. protected _buttonsPressed: number;
  101611. /**
  101612. * Defines the buttons associated with the input to handle camera move.
  101613. */
  101614. buttons: number[];
  101615. /**
  101616. * Attach the input controls to a specific dom element to get the input from.
  101617. * @param element Defines the element the controls should be listened from
  101618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101619. */
  101620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101621. /**
  101622. * Detach the current controls from the specified dom element.
  101623. * @param element Defines the element to stop listening the inputs from
  101624. */
  101625. detachControl(element: Nullable<HTMLElement>): void;
  101626. /**
  101627. * Gets the class name of the current input.
  101628. * @returns the class name
  101629. */
  101630. getClassName(): string;
  101631. /**
  101632. * Get the friendly name associated with the input class.
  101633. * @returns the input friendly name
  101634. */
  101635. getSimpleName(): string;
  101636. /**
  101637. * Called on pointer POINTERDOUBLETAP event.
  101638. * Override this method to provide functionality on POINTERDOUBLETAP event.
  101639. */
  101640. protected onDoubleTap(type: string): void;
  101641. /**
  101642. * Called on pointer POINTERMOVE event if only a single touch is active.
  101643. * Override this method to provide functionality.
  101644. */
  101645. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101646. /**
  101647. * Called on pointer POINTERMOVE event if multiple touches are active.
  101648. * Override this method to provide functionality.
  101649. */
  101650. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101651. /**
  101652. * Called on JS contextmenu event.
  101653. * Override this method to provide functionality.
  101654. */
  101655. protected onContextMenu(evt: PointerEvent): void;
  101656. /**
  101657. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101658. * press.
  101659. * Override this method to provide functionality.
  101660. */
  101661. protected onButtonDown(evt: PointerEvent): void;
  101662. /**
  101663. * Called each time a new POINTERUP event occurs. Ie, for each button
  101664. * release.
  101665. * Override this method to provide functionality.
  101666. */
  101667. protected onButtonUp(evt: PointerEvent): void;
  101668. /**
  101669. * Called when window becomes inactive.
  101670. * Override this method to provide functionality.
  101671. */
  101672. protected onLostFocus(): void;
  101673. private _pointerInput;
  101674. private _observer;
  101675. private _onLostFocus;
  101676. private pointA;
  101677. private pointB;
  101678. }
  101679. }
  101680. declare module BABYLON {
  101681. /**
  101682. * Manage the pointers inputs to control an arc rotate camera.
  101683. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101684. */
  101685. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  101686. /**
  101687. * Defines the camera the input is attached to.
  101688. */
  101689. camera: ArcRotateCamera;
  101690. /**
  101691. * Gets the class name of the current input.
  101692. * @returns the class name
  101693. */
  101694. getClassName(): string;
  101695. /**
  101696. * Defines the buttons associated with the input to handle camera move.
  101697. */
  101698. buttons: number[];
  101699. /**
  101700. * Defines the pointer angular sensibility along the X axis or how fast is
  101701. * the camera rotating.
  101702. */
  101703. angularSensibilityX: number;
  101704. /**
  101705. * Defines the pointer angular sensibility along the Y axis or how fast is
  101706. * the camera rotating.
  101707. */
  101708. angularSensibilityY: number;
  101709. /**
  101710. * Defines the pointer pinch precision or how fast is the camera zooming.
  101711. */
  101712. pinchPrecision: number;
  101713. /**
  101714. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101715. * from 0.
  101716. * It defines the percentage of current camera.radius to use as delta when
  101717. * pinch zoom is used.
  101718. */
  101719. pinchDeltaPercentage: number;
  101720. /**
  101721. * Defines the pointer panning sensibility or how fast is the camera moving.
  101722. */
  101723. panningSensibility: number;
  101724. /**
  101725. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  101726. */
  101727. multiTouchPanning: boolean;
  101728. /**
  101729. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  101730. * zoom (pinch) through multitouch.
  101731. */
  101732. multiTouchPanAndZoom: boolean;
  101733. /**
  101734. * Revers pinch action direction.
  101735. */
  101736. pinchInwards: boolean;
  101737. private _isPanClick;
  101738. private _twoFingerActivityCount;
  101739. private _isPinching;
  101740. /**
  101741. * Called on pointer POINTERMOVE event if only a single touch is active.
  101742. */
  101743. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101744. /**
  101745. * Called on pointer POINTERDOUBLETAP event.
  101746. */
  101747. protected onDoubleTap(type: string): void;
  101748. /**
  101749. * Called on pointer POINTERMOVE event if multiple touches are active.
  101750. */
  101751. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101752. /**
  101753. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101754. * press.
  101755. */
  101756. protected onButtonDown(evt: PointerEvent): void;
  101757. /**
  101758. * Called each time a new POINTERUP event occurs. Ie, for each button
  101759. * release.
  101760. */
  101761. protected onButtonUp(evt: PointerEvent): void;
  101762. /**
  101763. * Called when window becomes inactive.
  101764. */
  101765. protected onLostFocus(): void;
  101766. }
  101767. }
  101768. declare module BABYLON {
  101769. /**
  101770. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  101771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101772. */
  101773. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  101774. /**
  101775. * Defines the camera the input is attached to.
  101776. */
  101777. camera: ArcRotateCamera;
  101778. /**
  101779. * Defines the list of key codes associated with the up action (increase alpha)
  101780. */
  101781. keysUp: number[];
  101782. /**
  101783. * Defines the list of key codes associated with the down action (decrease alpha)
  101784. */
  101785. keysDown: number[];
  101786. /**
  101787. * Defines the list of key codes associated with the left action (increase beta)
  101788. */
  101789. keysLeft: number[];
  101790. /**
  101791. * Defines the list of key codes associated with the right action (decrease beta)
  101792. */
  101793. keysRight: number[];
  101794. /**
  101795. * Defines the list of key codes associated with the reset action.
  101796. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  101797. */
  101798. keysReset: number[];
  101799. /**
  101800. * Defines the panning sensibility of the inputs.
  101801. * (How fast is the camera paning)
  101802. */
  101803. panningSensibility: number;
  101804. /**
  101805. * Defines the zooming sensibility of the inputs.
  101806. * (How fast is the camera zooming)
  101807. */
  101808. zoomingSensibility: number;
  101809. /**
  101810. * Defines wether maintaining the alt key down switch the movement mode from
  101811. * orientation to zoom.
  101812. */
  101813. useAltToZoom: boolean;
  101814. /**
  101815. * Rotation speed of the camera
  101816. */
  101817. angularSpeed: number;
  101818. private _keys;
  101819. private _ctrlPressed;
  101820. private _altPressed;
  101821. private _onCanvasBlurObserver;
  101822. private _onKeyboardObserver;
  101823. private _engine;
  101824. private _scene;
  101825. /**
  101826. * Attach the input controls to a specific dom element to get the input from.
  101827. * @param element Defines the element the controls should be listened from
  101828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101829. */
  101830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101831. /**
  101832. * Detach the current controls from the specified dom element.
  101833. * @param element Defines the element to stop listening the inputs from
  101834. */
  101835. detachControl(element: Nullable<HTMLElement>): void;
  101836. /**
  101837. * Update the current camera state depending on the inputs that have been used this frame.
  101838. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101839. */
  101840. checkInputs(): void;
  101841. /**
  101842. * Gets the class name of the current intput.
  101843. * @returns the class name
  101844. */
  101845. getClassName(): string;
  101846. /**
  101847. * Get the friendly name associated with the input class.
  101848. * @returns the input friendly name
  101849. */
  101850. getSimpleName(): string;
  101851. }
  101852. }
  101853. declare module BABYLON {
  101854. /**
  101855. * Manage the mouse wheel inputs to control an arc rotate camera.
  101856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101857. */
  101858. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  101859. /**
  101860. * Defines the camera the input is attached to.
  101861. */
  101862. camera: ArcRotateCamera;
  101863. /**
  101864. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101865. */
  101866. wheelPrecision: number;
  101867. /**
  101868. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101869. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101870. */
  101871. wheelDeltaPercentage: number;
  101872. private _wheel;
  101873. private _observer;
  101874. private computeDeltaFromMouseWheelLegacyEvent;
  101875. /**
  101876. * Attach the input controls to a specific dom element to get the input from.
  101877. * @param element Defines the element the controls should be listened from
  101878. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101879. */
  101880. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101881. /**
  101882. * Detach the current controls from the specified dom element.
  101883. * @param element Defines the element to stop listening the inputs from
  101884. */
  101885. detachControl(element: Nullable<HTMLElement>): void;
  101886. /**
  101887. * Gets the class name of the current intput.
  101888. * @returns the class name
  101889. */
  101890. getClassName(): string;
  101891. /**
  101892. * Get the friendly name associated with the input class.
  101893. * @returns the input friendly name
  101894. */
  101895. getSimpleName(): string;
  101896. }
  101897. }
  101898. declare module BABYLON {
  101899. /**
  101900. * Default Inputs manager for the ArcRotateCamera.
  101901. * It groups all the default supported inputs for ease of use.
  101902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101903. */
  101904. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  101905. /**
  101906. * Instantiates a new ArcRotateCameraInputsManager.
  101907. * @param camera Defines the camera the inputs belong to
  101908. */
  101909. constructor(camera: ArcRotateCamera);
  101910. /**
  101911. * Add mouse wheel input support to the input manager.
  101912. * @returns the current input manager
  101913. */
  101914. addMouseWheel(): ArcRotateCameraInputsManager;
  101915. /**
  101916. * Add pointers input support to the input manager.
  101917. * @returns the current input manager
  101918. */
  101919. addPointers(): ArcRotateCameraInputsManager;
  101920. /**
  101921. * Add keyboard input support to the input manager.
  101922. * @returns the current input manager
  101923. */
  101924. addKeyboard(): ArcRotateCameraInputsManager;
  101925. }
  101926. }
  101927. declare module BABYLON {
  101928. /**
  101929. * This represents an orbital type of camera.
  101930. *
  101931. * 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.
  101932. * 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.
  101933. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  101934. */
  101935. export class ArcRotateCamera extends TargetCamera {
  101936. /**
  101937. * Defines the rotation angle of the camera along the longitudinal axis.
  101938. */
  101939. alpha: number;
  101940. /**
  101941. * Defines the rotation angle of the camera along the latitudinal axis.
  101942. */
  101943. beta: number;
  101944. /**
  101945. * Defines the radius of the camera from it s target point.
  101946. */
  101947. radius: number;
  101948. protected _target: Vector3;
  101949. protected _targetHost: Nullable<AbstractMesh>;
  101950. /**
  101951. * Defines the target point of the camera.
  101952. * The camera looks towards it form the radius distance.
  101953. */
  101954. target: Vector3;
  101955. /**
  101956. * Define the current local position of the camera in the scene
  101957. */
  101958. position: Vector3;
  101959. protected _upVector: Vector3;
  101960. protected _upToYMatrix: Matrix;
  101961. protected _YToUpMatrix: Matrix;
  101962. /**
  101963. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  101964. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  101965. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  101966. */
  101967. upVector: Vector3;
  101968. /**
  101969. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  101970. */
  101971. setMatUp(): void;
  101972. /**
  101973. * Current inertia value on the longitudinal axis.
  101974. * The bigger this number the longer it will take for the camera to stop.
  101975. */
  101976. inertialAlphaOffset: number;
  101977. /**
  101978. * Current inertia value on the latitudinal axis.
  101979. * The bigger this number the longer it will take for the camera to stop.
  101980. */
  101981. inertialBetaOffset: number;
  101982. /**
  101983. * Current inertia value on the radius axis.
  101984. * The bigger this number the longer it will take for the camera to stop.
  101985. */
  101986. inertialRadiusOffset: number;
  101987. /**
  101988. * Minimum allowed angle on the longitudinal axis.
  101989. * This can help limiting how the Camera is able to move in the scene.
  101990. */
  101991. lowerAlphaLimit: Nullable<number>;
  101992. /**
  101993. * Maximum allowed angle on the longitudinal axis.
  101994. * This can help limiting how the Camera is able to move in the scene.
  101995. */
  101996. upperAlphaLimit: Nullable<number>;
  101997. /**
  101998. * Minimum allowed angle on the latitudinal axis.
  101999. * This can help limiting how the Camera is able to move in the scene.
  102000. */
  102001. lowerBetaLimit: number;
  102002. /**
  102003. * Maximum allowed angle on the latitudinal axis.
  102004. * This can help limiting how the Camera is able to move in the scene.
  102005. */
  102006. upperBetaLimit: number;
  102007. /**
  102008. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  102009. * This can help limiting how the Camera is able to move in the scene.
  102010. */
  102011. lowerRadiusLimit: Nullable<number>;
  102012. /**
  102013. * Maximum allowed distance of the camera to the target (The camera can not get further).
  102014. * This can help limiting how the Camera is able to move in the scene.
  102015. */
  102016. upperRadiusLimit: Nullable<number>;
  102017. /**
  102018. * Defines the current inertia value used during panning of the camera along the X axis.
  102019. */
  102020. inertialPanningX: number;
  102021. /**
  102022. * Defines the current inertia value used during panning of the camera along the Y axis.
  102023. */
  102024. inertialPanningY: number;
  102025. /**
  102026. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  102027. * Basically if your fingers moves away from more than this distance you will be considered
  102028. * in pinch mode.
  102029. */
  102030. pinchToPanMaxDistance: number;
  102031. /**
  102032. * Defines the maximum distance the camera can pan.
  102033. * This could help keeping the cammera always in your scene.
  102034. */
  102035. panningDistanceLimit: Nullable<number>;
  102036. /**
  102037. * Defines the target of the camera before paning.
  102038. */
  102039. panningOriginTarget: Vector3;
  102040. /**
  102041. * Defines the value of the inertia used during panning.
  102042. * 0 would mean stop inertia and one would mean no decelleration at all.
  102043. */
  102044. panningInertia: number;
  102045. /**
  102046. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  102047. */
  102048. angularSensibilityX: number;
  102049. /**
  102050. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  102051. */
  102052. angularSensibilityY: number;
  102053. /**
  102054. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  102055. */
  102056. pinchPrecision: number;
  102057. /**
  102058. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  102059. * It will be used instead of pinchDeltaPrecision if different from 0.
  102060. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102061. */
  102062. pinchDeltaPercentage: number;
  102063. /**
  102064. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  102065. */
  102066. panningSensibility: number;
  102067. /**
  102068. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  102069. */
  102070. keysUp: number[];
  102071. /**
  102072. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  102073. */
  102074. keysDown: number[];
  102075. /**
  102076. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  102077. */
  102078. keysLeft: number[];
  102079. /**
  102080. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  102081. */
  102082. keysRight: number[];
  102083. /**
  102084. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102085. */
  102086. wheelPrecision: number;
  102087. /**
  102088. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  102089. * It will be used instead of pinchDeltaPrecision if different from 0.
  102090. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102091. */
  102092. wheelDeltaPercentage: number;
  102093. /**
  102094. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  102095. */
  102096. zoomOnFactor: number;
  102097. /**
  102098. * Defines a screen offset for the camera position.
  102099. */
  102100. targetScreenOffset: Vector2;
  102101. /**
  102102. * Allows the camera to be completely reversed.
  102103. * If false the camera can not arrive upside down.
  102104. */
  102105. allowUpsideDown: boolean;
  102106. /**
  102107. * Define if double tap/click is used to restore the previously saved state of the camera.
  102108. */
  102109. useInputToRestoreState: boolean;
  102110. /** @hidden */
  102111. _viewMatrix: Matrix;
  102112. /** @hidden */
  102113. _useCtrlForPanning: boolean;
  102114. /** @hidden */
  102115. _panningMouseButton: number;
  102116. /**
  102117. * Defines the input associated to the camera.
  102118. */
  102119. inputs: ArcRotateCameraInputsManager;
  102120. /** @hidden */
  102121. _reset: () => void;
  102122. /**
  102123. * Defines the allowed panning axis.
  102124. */
  102125. panningAxis: Vector3;
  102126. protected _localDirection: Vector3;
  102127. protected _transformedDirection: Vector3;
  102128. private _bouncingBehavior;
  102129. /**
  102130. * Gets the bouncing behavior of the camera if it has been enabled.
  102131. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102132. */
  102133. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  102134. /**
  102135. * Defines if the bouncing behavior of the camera is enabled on the camera.
  102136. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102137. */
  102138. useBouncingBehavior: boolean;
  102139. private _framingBehavior;
  102140. /**
  102141. * Gets the framing behavior of the camera if it has been enabled.
  102142. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102143. */
  102144. readonly framingBehavior: Nullable<FramingBehavior>;
  102145. /**
  102146. * Defines if the framing behavior of the camera is enabled on the camera.
  102147. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102148. */
  102149. useFramingBehavior: boolean;
  102150. private _autoRotationBehavior;
  102151. /**
  102152. * Gets the auto rotation behavior of the camera if it has been enabled.
  102153. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102154. */
  102155. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  102156. /**
  102157. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  102158. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102159. */
  102160. useAutoRotationBehavior: boolean;
  102161. /**
  102162. * Observable triggered when the mesh target has been changed on the camera.
  102163. */
  102164. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  102165. /**
  102166. * Event raised when the camera is colliding with a mesh.
  102167. */
  102168. onCollide: (collidedMesh: AbstractMesh) => void;
  102169. /**
  102170. * Defines whether the camera should check collision with the objects oh the scene.
  102171. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  102172. */
  102173. checkCollisions: boolean;
  102174. /**
  102175. * Defines the collision radius of the camera.
  102176. * This simulates a sphere around the camera.
  102177. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102178. */
  102179. collisionRadius: Vector3;
  102180. protected _collider: Collider;
  102181. protected _previousPosition: Vector3;
  102182. protected _collisionVelocity: Vector3;
  102183. protected _newPosition: Vector3;
  102184. protected _previousAlpha: number;
  102185. protected _previousBeta: number;
  102186. protected _previousRadius: number;
  102187. protected _collisionTriggered: boolean;
  102188. protected _targetBoundingCenter: Nullable<Vector3>;
  102189. private _computationVector;
  102190. /**
  102191. * Instantiates a new ArcRotateCamera in a given scene
  102192. * @param name Defines the name of the camera
  102193. * @param alpha Defines the camera rotation along the logitudinal axis
  102194. * @param beta Defines the camera rotation along the latitudinal axis
  102195. * @param radius Defines the camera distance from its target
  102196. * @param target Defines the camera target
  102197. * @param scene Defines the scene the camera belongs to
  102198. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  102199. */
  102200. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102201. /** @hidden */
  102202. _initCache(): void;
  102203. /** @hidden */
  102204. _updateCache(ignoreParentClass?: boolean): void;
  102205. protected _getTargetPosition(): Vector3;
  102206. private _storedAlpha;
  102207. private _storedBeta;
  102208. private _storedRadius;
  102209. private _storedTarget;
  102210. private _storedTargetScreenOffset;
  102211. /**
  102212. * Stores the current state of the camera (alpha, beta, radius and target)
  102213. * @returns the camera itself
  102214. */
  102215. storeState(): Camera;
  102216. /**
  102217. * @hidden
  102218. * Restored camera state. You must call storeState() first
  102219. */
  102220. _restoreStateValues(): boolean;
  102221. /** @hidden */
  102222. _isSynchronizedViewMatrix(): boolean;
  102223. /**
  102224. * Attached controls to the current camera.
  102225. * @param element Defines the element the controls should be listened from
  102226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102227. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  102228. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  102229. */
  102230. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  102231. /**
  102232. * Detach the current controls from the camera.
  102233. * The camera will stop reacting to inputs.
  102234. * @param element Defines the element to stop listening the inputs from
  102235. */
  102236. detachControl(element: HTMLElement): void;
  102237. /** @hidden */
  102238. _checkInputs(): void;
  102239. protected _checkLimits(): void;
  102240. /**
  102241. * Rebuilds angles (alpha, beta) and radius from the give position and target
  102242. */
  102243. rebuildAnglesAndRadius(): void;
  102244. /**
  102245. * Use a position to define the current camera related information like aplha, beta and radius
  102246. * @param position Defines the position to set the camera at
  102247. */
  102248. setPosition(position: Vector3): void;
  102249. /**
  102250. * Defines the target the camera should look at.
  102251. * This will automatically adapt alpha beta and radius to fit within the new target.
  102252. * @param target Defines the new target as a Vector or a mesh
  102253. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  102254. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  102255. */
  102256. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  102257. /** @hidden */
  102258. _getViewMatrix(): Matrix;
  102259. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  102260. /**
  102261. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  102262. * @param meshes Defines the mesh to zoom on
  102263. * @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)
  102264. */
  102265. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  102266. /**
  102267. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  102268. * The target will be changed but the radius
  102269. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  102270. * @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)
  102271. */
  102272. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  102273. min: Vector3;
  102274. max: Vector3;
  102275. distance: number;
  102276. }, doNotUpdateMaxZ?: boolean): void;
  102277. /**
  102278. * @override
  102279. * Override Camera.createRigCamera
  102280. */
  102281. createRigCamera(name: string, cameraIndex: number): Camera;
  102282. /**
  102283. * @hidden
  102284. * @override
  102285. * Override Camera._updateRigCameras
  102286. */
  102287. _updateRigCameras(): void;
  102288. /**
  102289. * Destroy the camera and release the current resources hold by it.
  102290. */
  102291. dispose(): void;
  102292. /**
  102293. * Gets the current object class name.
  102294. * @return the class name
  102295. */
  102296. getClassName(): string;
  102297. }
  102298. }
  102299. declare module BABYLON {
  102300. /**
  102301. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  102302. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102303. */
  102304. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  102305. /**
  102306. * Gets the name of the behavior.
  102307. */
  102308. readonly name: string;
  102309. private _zoomStopsAnimation;
  102310. private _idleRotationSpeed;
  102311. private _idleRotationWaitTime;
  102312. private _idleRotationSpinupTime;
  102313. /**
  102314. * Sets the flag that indicates if user zooming should stop animation.
  102315. */
  102316. /**
  102317. * Gets the flag that indicates if user zooming should stop animation.
  102318. */
  102319. zoomStopsAnimation: boolean;
  102320. /**
  102321. * Sets the default speed at which the camera rotates around the model.
  102322. */
  102323. /**
  102324. * Gets the default speed at which the camera rotates around the model.
  102325. */
  102326. idleRotationSpeed: number;
  102327. /**
  102328. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  102329. */
  102330. /**
  102331. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  102332. */
  102333. idleRotationWaitTime: number;
  102334. /**
  102335. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102336. */
  102337. /**
  102338. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102339. */
  102340. idleRotationSpinupTime: number;
  102341. /**
  102342. * Gets a value indicating if the camera is currently rotating because of this behavior
  102343. */
  102344. readonly rotationInProgress: boolean;
  102345. private _onPrePointerObservableObserver;
  102346. private _onAfterCheckInputsObserver;
  102347. private _attachedCamera;
  102348. private _isPointerDown;
  102349. private _lastFrameTime;
  102350. private _lastInteractionTime;
  102351. private _cameraRotationSpeed;
  102352. /**
  102353. * Initializes the behavior.
  102354. */
  102355. init(): void;
  102356. /**
  102357. * Attaches the behavior to its arc rotate camera.
  102358. * @param camera Defines the camera to attach the behavior to
  102359. */
  102360. attach(camera: ArcRotateCamera): void;
  102361. /**
  102362. * Detaches the behavior from its current arc rotate camera.
  102363. */
  102364. detach(): void;
  102365. /**
  102366. * Returns true if user is scrolling.
  102367. * @return true if user is scrolling.
  102368. */
  102369. private _userIsZooming;
  102370. private _lastFrameRadius;
  102371. private _shouldAnimationStopForInteraction;
  102372. /**
  102373. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102374. */
  102375. private _applyUserInteraction;
  102376. private _userIsMoving;
  102377. }
  102378. }
  102379. declare module BABYLON {
  102380. /**
  102381. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  102382. */
  102383. export class AttachToBoxBehavior implements Behavior<Mesh> {
  102384. private ui;
  102385. /**
  102386. * The name of the behavior
  102387. */
  102388. name: string;
  102389. /**
  102390. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  102391. */
  102392. distanceAwayFromFace: number;
  102393. /**
  102394. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  102395. */
  102396. distanceAwayFromBottomOfFace: number;
  102397. private _faceVectors;
  102398. private _target;
  102399. private _scene;
  102400. private _onRenderObserver;
  102401. private _tmpMatrix;
  102402. private _tmpVector;
  102403. /**
  102404. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  102405. * @param ui The transform node that should be attched to the mesh
  102406. */
  102407. constructor(ui: TransformNode);
  102408. /**
  102409. * Initializes the behavior
  102410. */
  102411. init(): void;
  102412. private _closestFace;
  102413. private _zeroVector;
  102414. private _lookAtTmpMatrix;
  102415. private _lookAtToRef;
  102416. /**
  102417. * Attaches the AttachToBoxBehavior to the passed in mesh
  102418. * @param target The mesh that the specified node will be attached to
  102419. */
  102420. attach(target: Mesh): void;
  102421. /**
  102422. * Detaches the behavior from the mesh
  102423. */
  102424. detach(): void;
  102425. }
  102426. }
  102427. declare module BABYLON {
  102428. /**
  102429. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  102430. */
  102431. export class FadeInOutBehavior implements Behavior<Mesh> {
  102432. /**
  102433. * Time in milliseconds to delay before fading in (Default: 0)
  102434. */
  102435. delay: number;
  102436. /**
  102437. * Time in milliseconds for the mesh to fade in (Default: 300)
  102438. */
  102439. fadeInTime: number;
  102440. private _millisecondsPerFrame;
  102441. private _hovered;
  102442. private _hoverValue;
  102443. private _ownerNode;
  102444. /**
  102445. * Instatiates the FadeInOutBehavior
  102446. */
  102447. constructor();
  102448. /**
  102449. * The name of the behavior
  102450. */
  102451. readonly name: string;
  102452. /**
  102453. * Initializes the behavior
  102454. */
  102455. init(): void;
  102456. /**
  102457. * Attaches the fade behavior on the passed in mesh
  102458. * @param ownerNode The mesh that will be faded in/out once attached
  102459. */
  102460. attach(ownerNode: Mesh): void;
  102461. /**
  102462. * Detaches the behavior from the mesh
  102463. */
  102464. detach(): void;
  102465. /**
  102466. * Triggers the mesh to begin fading in or out
  102467. * @param value if the object should fade in or out (true to fade in)
  102468. */
  102469. fadeIn(value: boolean): void;
  102470. private _update;
  102471. private _setAllVisibility;
  102472. }
  102473. }
  102474. declare module BABYLON {
  102475. /**
  102476. * Class containing a set of static utilities functions for managing Pivots
  102477. * @hidden
  102478. */
  102479. export class PivotTools {
  102480. private static _PivotCached;
  102481. private static _OldPivotPoint;
  102482. private static _PivotTranslation;
  102483. private static _PivotTmpVector;
  102484. /** @hidden */
  102485. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  102486. /** @hidden */
  102487. static _RestorePivotPoint(mesh: AbstractMesh): void;
  102488. }
  102489. }
  102490. declare module BABYLON {
  102491. /**
  102492. * Class containing static functions to help procedurally build meshes
  102493. */
  102494. export class PlaneBuilder {
  102495. /**
  102496. * Creates a plane mesh
  102497. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  102498. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  102499. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  102500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102503. * @param name defines the name of the mesh
  102504. * @param options defines the options used to create the mesh
  102505. * @param scene defines the hosting scene
  102506. * @returns the plane mesh
  102507. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  102508. */
  102509. static CreatePlane(name: string, options: {
  102510. size?: number;
  102511. width?: number;
  102512. height?: number;
  102513. sideOrientation?: number;
  102514. frontUVs?: Vector4;
  102515. backUVs?: Vector4;
  102516. updatable?: boolean;
  102517. sourcePlane?: Plane;
  102518. }, scene?: Nullable<Scene>): Mesh;
  102519. }
  102520. }
  102521. declare module BABYLON {
  102522. /**
  102523. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  102524. */
  102525. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  102526. private static _AnyMouseID;
  102527. /**
  102528. * Abstract mesh the behavior is set on
  102529. */
  102530. attachedNode: AbstractMesh;
  102531. private _dragPlane;
  102532. private _scene;
  102533. private _pointerObserver;
  102534. private _beforeRenderObserver;
  102535. private static _planeScene;
  102536. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  102537. /**
  102538. * 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)
  102539. */
  102540. maxDragAngle: number;
  102541. /**
  102542. * @hidden
  102543. */
  102544. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  102545. /**
  102546. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102547. */
  102548. currentDraggingPointerID: number;
  102549. /**
  102550. * The last position where the pointer hit the drag plane in world space
  102551. */
  102552. lastDragPosition: Vector3;
  102553. /**
  102554. * If the behavior is currently in a dragging state
  102555. */
  102556. dragging: boolean;
  102557. /**
  102558. * 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)
  102559. */
  102560. dragDeltaRatio: number;
  102561. /**
  102562. * If the drag plane orientation should be updated during the dragging (Default: true)
  102563. */
  102564. updateDragPlane: boolean;
  102565. private _debugMode;
  102566. private _moving;
  102567. /**
  102568. * Fires each time the attached mesh is dragged with the pointer
  102569. * * delta between last drag position and current drag position in world space
  102570. * * dragDistance along the drag axis
  102571. * * dragPlaneNormal normal of the current drag plane used during the drag
  102572. * * dragPlanePoint in world space where the drag intersects the drag plane
  102573. */
  102574. onDragObservable: Observable<{
  102575. delta: Vector3;
  102576. dragPlanePoint: Vector3;
  102577. dragPlaneNormal: Vector3;
  102578. dragDistance: number;
  102579. pointerId: number;
  102580. }>;
  102581. /**
  102582. * Fires each time a drag begins (eg. mouse down on mesh)
  102583. */
  102584. onDragStartObservable: Observable<{
  102585. dragPlanePoint: Vector3;
  102586. pointerId: number;
  102587. }>;
  102588. /**
  102589. * Fires each time a drag ends (eg. mouse release after drag)
  102590. */
  102591. onDragEndObservable: Observable<{
  102592. dragPlanePoint: Vector3;
  102593. pointerId: number;
  102594. }>;
  102595. /**
  102596. * If the attached mesh should be moved when dragged
  102597. */
  102598. moveAttached: boolean;
  102599. /**
  102600. * If the drag behavior will react to drag events (Default: true)
  102601. */
  102602. enabled: boolean;
  102603. /**
  102604. * If pointer events should start and release the drag (Default: true)
  102605. */
  102606. startAndReleaseDragOnPointerEvents: boolean;
  102607. /**
  102608. * If camera controls should be detached during the drag
  102609. */
  102610. detachCameraControls: boolean;
  102611. /**
  102612. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  102613. */
  102614. useObjectOrienationForDragging: boolean;
  102615. private _options;
  102616. /**
  102617. * Creates a pointer drag behavior that can be attached to a mesh
  102618. * @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)
  102619. */
  102620. constructor(options?: {
  102621. dragAxis?: Vector3;
  102622. dragPlaneNormal?: Vector3;
  102623. });
  102624. /**
  102625. * Predicate to determine if it is valid to move the object to a new position when it is moved
  102626. */
  102627. validateDrag: (targetPosition: Vector3) => boolean;
  102628. /**
  102629. * The name of the behavior
  102630. */
  102631. readonly name: string;
  102632. /**
  102633. * Initializes the behavior
  102634. */
  102635. init(): void;
  102636. private _tmpVector;
  102637. private _alternatePickedPoint;
  102638. private _worldDragAxis;
  102639. private _targetPosition;
  102640. private _attachedElement;
  102641. /**
  102642. * Attaches the drag behavior the passed in mesh
  102643. * @param ownerNode The mesh that will be dragged around once attached
  102644. * @param predicate Predicate to use for pick filtering
  102645. */
  102646. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  102647. /**
  102648. * Force relase the drag action by code.
  102649. */
  102650. releaseDrag(): void;
  102651. private _startDragRay;
  102652. private _lastPointerRay;
  102653. /**
  102654. * Simulates the start of a pointer drag event on the behavior
  102655. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  102656. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  102657. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  102658. */
  102659. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  102660. private _startDrag;
  102661. private _dragDelta;
  102662. private _moveDrag;
  102663. private _pickWithRayOnDragPlane;
  102664. private _pointA;
  102665. private _pointB;
  102666. private _pointC;
  102667. private _lineA;
  102668. private _lineB;
  102669. private _localAxis;
  102670. private _lookAt;
  102671. private _updateDragPlanePosition;
  102672. /**
  102673. * Detaches the behavior from the mesh
  102674. */
  102675. detach(): void;
  102676. }
  102677. }
  102678. declare module BABYLON {
  102679. /**
  102680. * A behavior that when attached to a mesh will allow the mesh to be scaled
  102681. */
  102682. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  102683. private _dragBehaviorA;
  102684. private _dragBehaviorB;
  102685. private _startDistance;
  102686. private _initialScale;
  102687. private _targetScale;
  102688. private _ownerNode;
  102689. private _sceneRenderObserver;
  102690. /**
  102691. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  102692. */
  102693. constructor();
  102694. /**
  102695. * The name of the behavior
  102696. */
  102697. readonly name: string;
  102698. /**
  102699. * Initializes the behavior
  102700. */
  102701. init(): void;
  102702. private _getCurrentDistance;
  102703. /**
  102704. * Attaches the scale behavior the passed in mesh
  102705. * @param ownerNode The mesh that will be scaled around once attached
  102706. */
  102707. attach(ownerNode: Mesh): void;
  102708. /**
  102709. * Detaches the behavior from the mesh
  102710. */
  102711. detach(): void;
  102712. }
  102713. }
  102714. declare module BABYLON {
  102715. /**
  102716. * 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
  102717. */
  102718. export class SixDofDragBehavior implements Behavior<Mesh> {
  102719. private static _virtualScene;
  102720. private _ownerNode;
  102721. private _sceneRenderObserver;
  102722. private _scene;
  102723. private _targetPosition;
  102724. private _virtualOriginMesh;
  102725. private _virtualDragMesh;
  102726. private _pointerObserver;
  102727. private _moving;
  102728. private _startingOrientation;
  102729. /**
  102730. * 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)
  102731. */
  102732. private zDragFactor;
  102733. /**
  102734. * If the object should rotate to face the drag origin
  102735. */
  102736. rotateDraggedObject: boolean;
  102737. /**
  102738. * If the behavior is currently in a dragging state
  102739. */
  102740. dragging: boolean;
  102741. /**
  102742. * 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)
  102743. */
  102744. dragDeltaRatio: number;
  102745. /**
  102746. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102747. */
  102748. currentDraggingPointerID: number;
  102749. /**
  102750. * If camera controls should be detached during the drag
  102751. */
  102752. detachCameraControls: boolean;
  102753. /**
  102754. * Fires each time a drag starts
  102755. */
  102756. onDragStartObservable: Observable<{}>;
  102757. /**
  102758. * Fires each time a drag ends (eg. mouse release after drag)
  102759. */
  102760. onDragEndObservable: Observable<{}>;
  102761. /**
  102762. * 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
  102763. */
  102764. constructor();
  102765. /**
  102766. * The name of the behavior
  102767. */
  102768. readonly name: string;
  102769. /**
  102770. * Initializes the behavior
  102771. */
  102772. init(): void;
  102773. /**
  102774. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  102775. */
  102776. private readonly _pointerCamera;
  102777. /**
  102778. * Attaches the scale behavior the passed in mesh
  102779. * @param ownerNode The mesh that will be scaled around once attached
  102780. */
  102781. attach(ownerNode: Mesh): void;
  102782. /**
  102783. * Detaches the behavior from the mesh
  102784. */
  102785. detach(): void;
  102786. }
  102787. }
  102788. declare module BABYLON {
  102789. /**
  102790. * Class used to apply inverse kinematics to bones
  102791. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  102792. */
  102793. export class BoneIKController {
  102794. private static _tmpVecs;
  102795. private static _tmpQuat;
  102796. private static _tmpMats;
  102797. /**
  102798. * Gets or sets the target mesh
  102799. */
  102800. targetMesh: AbstractMesh;
  102801. /** Gets or sets the mesh used as pole */
  102802. poleTargetMesh: AbstractMesh;
  102803. /**
  102804. * Gets or sets the bone used as pole
  102805. */
  102806. poleTargetBone: Nullable<Bone>;
  102807. /**
  102808. * Gets or sets the target position
  102809. */
  102810. targetPosition: Vector3;
  102811. /**
  102812. * Gets or sets the pole target position
  102813. */
  102814. poleTargetPosition: Vector3;
  102815. /**
  102816. * Gets or sets the pole target local offset
  102817. */
  102818. poleTargetLocalOffset: Vector3;
  102819. /**
  102820. * Gets or sets the pole angle
  102821. */
  102822. poleAngle: number;
  102823. /**
  102824. * Gets or sets the mesh associated with the controller
  102825. */
  102826. mesh: AbstractMesh;
  102827. /**
  102828. * 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)
  102829. */
  102830. slerpAmount: number;
  102831. private _bone1Quat;
  102832. private _bone1Mat;
  102833. private _bone2Ang;
  102834. private _bone1;
  102835. private _bone2;
  102836. private _bone1Length;
  102837. private _bone2Length;
  102838. private _maxAngle;
  102839. private _maxReach;
  102840. private _rightHandedSystem;
  102841. private _bendAxis;
  102842. private _slerping;
  102843. private _adjustRoll;
  102844. /**
  102845. * Gets or sets maximum allowed angle
  102846. */
  102847. maxAngle: number;
  102848. /**
  102849. * Creates a new BoneIKController
  102850. * @param mesh defines the mesh to control
  102851. * @param bone defines the bone to control
  102852. * @param options defines options to set up the controller
  102853. */
  102854. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  102855. targetMesh?: AbstractMesh;
  102856. poleTargetMesh?: AbstractMesh;
  102857. poleTargetBone?: Bone;
  102858. poleTargetLocalOffset?: Vector3;
  102859. poleAngle?: number;
  102860. bendAxis?: Vector3;
  102861. maxAngle?: number;
  102862. slerpAmount?: number;
  102863. });
  102864. private _setMaxAngle;
  102865. /**
  102866. * Force the controller to update the bones
  102867. */
  102868. update(): void;
  102869. }
  102870. }
  102871. declare module BABYLON {
  102872. /**
  102873. * Class used to make a bone look toward a point in space
  102874. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  102875. */
  102876. export class BoneLookController {
  102877. private static _tmpVecs;
  102878. private static _tmpQuat;
  102879. private static _tmpMats;
  102880. /**
  102881. * The target Vector3 that the bone will look at
  102882. */
  102883. target: Vector3;
  102884. /**
  102885. * The mesh that the bone is attached to
  102886. */
  102887. mesh: AbstractMesh;
  102888. /**
  102889. * The bone that will be looking to the target
  102890. */
  102891. bone: Bone;
  102892. /**
  102893. * The up axis of the coordinate system that is used when the bone is rotated
  102894. */
  102895. upAxis: Vector3;
  102896. /**
  102897. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  102898. */
  102899. upAxisSpace: Space;
  102900. /**
  102901. * Used to make an adjustment to the yaw of the bone
  102902. */
  102903. adjustYaw: number;
  102904. /**
  102905. * Used to make an adjustment to the pitch of the bone
  102906. */
  102907. adjustPitch: number;
  102908. /**
  102909. * Used to make an adjustment to the roll of the bone
  102910. */
  102911. adjustRoll: number;
  102912. /**
  102913. * 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)
  102914. */
  102915. slerpAmount: number;
  102916. private _minYaw;
  102917. private _maxYaw;
  102918. private _minPitch;
  102919. private _maxPitch;
  102920. private _minYawSin;
  102921. private _minYawCos;
  102922. private _maxYawSin;
  102923. private _maxYawCos;
  102924. private _midYawConstraint;
  102925. private _minPitchTan;
  102926. private _maxPitchTan;
  102927. private _boneQuat;
  102928. private _slerping;
  102929. private _transformYawPitch;
  102930. private _transformYawPitchInv;
  102931. private _firstFrameSkipped;
  102932. private _yawRange;
  102933. private _fowardAxis;
  102934. /**
  102935. * Gets or sets the minimum yaw angle that the bone can look to
  102936. */
  102937. minYaw: number;
  102938. /**
  102939. * Gets or sets the maximum yaw angle that the bone can look to
  102940. */
  102941. maxYaw: number;
  102942. /**
  102943. * Gets or sets the minimum pitch angle that the bone can look to
  102944. */
  102945. minPitch: number;
  102946. /**
  102947. * Gets or sets the maximum pitch angle that the bone can look to
  102948. */
  102949. maxPitch: number;
  102950. /**
  102951. * Create a BoneLookController
  102952. * @param mesh the mesh that the bone belongs to
  102953. * @param bone the bone that will be looking to the target
  102954. * @param target the target Vector3 to look at
  102955. * @param options optional settings:
  102956. * * maxYaw: the maximum angle the bone will yaw to
  102957. * * minYaw: the minimum angle the bone will yaw to
  102958. * * maxPitch: the maximum angle the bone will pitch to
  102959. * * minPitch: the minimum angle the bone will yaw to
  102960. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  102961. * * upAxis: the up axis of the coordinate system
  102962. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  102963. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  102964. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  102965. * * adjustYaw: used to make an adjustment to the yaw of the bone
  102966. * * adjustPitch: used to make an adjustment to the pitch of the bone
  102967. * * adjustRoll: used to make an adjustment to the roll of the bone
  102968. **/
  102969. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  102970. maxYaw?: number;
  102971. minYaw?: number;
  102972. maxPitch?: number;
  102973. minPitch?: number;
  102974. slerpAmount?: number;
  102975. upAxis?: Vector3;
  102976. upAxisSpace?: Space;
  102977. yawAxis?: Vector3;
  102978. pitchAxis?: Vector3;
  102979. adjustYaw?: number;
  102980. adjustPitch?: number;
  102981. adjustRoll?: number;
  102982. });
  102983. /**
  102984. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  102985. */
  102986. update(): void;
  102987. private _getAngleDiff;
  102988. private _getAngleBetween;
  102989. private _isAngleBetween;
  102990. }
  102991. }
  102992. declare module BABYLON {
  102993. /**
  102994. * Manage the gamepad inputs to control an arc rotate camera.
  102995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102996. */
  102997. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  102998. /**
  102999. * Defines the camera the input is attached to.
  103000. */
  103001. camera: ArcRotateCamera;
  103002. /**
  103003. * Defines the gamepad the input is gathering event from.
  103004. */
  103005. gamepad: Nullable<Gamepad>;
  103006. /**
  103007. * Defines the gamepad rotation sensiblity.
  103008. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103009. */
  103010. gamepadRotationSensibility: number;
  103011. /**
  103012. * Defines the gamepad move sensiblity.
  103013. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103014. */
  103015. gamepadMoveSensibility: number;
  103016. private _onGamepadConnectedObserver;
  103017. private _onGamepadDisconnectedObserver;
  103018. /**
  103019. * Attach the input controls to a specific dom element to get the input from.
  103020. * @param element Defines the element the controls should be listened from
  103021. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103022. */
  103023. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103024. /**
  103025. * Detach the current controls from the specified dom element.
  103026. * @param element Defines the element to stop listening the inputs from
  103027. */
  103028. detachControl(element: Nullable<HTMLElement>): void;
  103029. /**
  103030. * Update the current camera state depending on the inputs that have been used this frame.
  103031. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103032. */
  103033. checkInputs(): void;
  103034. /**
  103035. * Gets the class name of the current intput.
  103036. * @returns the class name
  103037. */
  103038. getClassName(): string;
  103039. /**
  103040. * Get the friendly name associated with the input class.
  103041. * @returns the input friendly name
  103042. */
  103043. getSimpleName(): string;
  103044. }
  103045. }
  103046. declare module BABYLON {
  103047. interface ArcRotateCameraInputsManager {
  103048. /**
  103049. * Add orientation input support to the input manager.
  103050. * @returns the current input manager
  103051. */
  103052. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  103053. }
  103054. /**
  103055. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  103056. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103057. */
  103058. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  103059. /**
  103060. * Defines the camera the input is attached to.
  103061. */
  103062. camera: ArcRotateCamera;
  103063. /**
  103064. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  103065. */
  103066. alphaCorrection: number;
  103067. /**
  103068. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  103069. */
  103070. gammaCorrection: number;
  103071. private _alpha;
  103072. private _gamma;
  103073. private _dirty;
  103074. private _deviceOrientationHandler;
  103075. /**
  103076. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  103077. */
  103078. constructor();
  103079. /**
  103080. * Attach the input controls to a specific dom element to get the input from.
  103081. * @param element Defines the element the controls should be listened from
  103082. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103083. */
  103084. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103085. /** @hidden */
  103086. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  103087. /**
  103088. * Update the current camera state depending on the inputs that have been used this frame.
  103089. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103090. */
  103091. checkInputs(): void;
  103092. /**
  103093. * Detach the current controls from the specified dom element.
  103094. * @param element Defines the element to stop listening the inputs from
  103095. */
  103096. detachControl(element: Nullable<HTMLElement>): void;
  103097. /**
  103098. * Gets the class name of the current intput.
  103099. * @returns the class name
  103100. */
  103101. getClassName(): string;
  103102. /**
  103103. * Get the friendly name associated with the input class.
  103104. * @returns the input friendly name
  103105. */
  103106. getSimpleName(): string;
  103107. }
  103108. }
  103109. declare module BABYLON {
  103110. /**
  103111. * Listen to mouse events to control the camera.
  103112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103113. */
  103114. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  103115. /**
  103116. * Defines the camera the input is attached to.
  103117. */
  103118. camera: FlyCamera;
  103119. /**
  103120. * Defines if touch is enabled. (Default is true.)
  103121. */
  103122. touchEnabled: boolean;
  103123. /**
  103124. * Defines the buttons associated with the input to handle camera rotation.
  103125. */
  103126. buttons: number[];
  103127. /**
  103128. * Assign buttons for Yaw control.
  103129. */
  103130. buttonsYaw: number[];
  103131. /**
  103132. * Assign buttons for Pitch control.
  103133. */
  103134. buttonsPitch: number[];
  103135. /**
  103136. * Assign buttons for Roll control.
  103137. */
  103138. buttonsRoll: number[];
  103139. /**
  103140. * Detect if any button is being pressed while mouse is moved.
  103141. * -1 = Mouse locked.
  103142. * 0 = Left button.
  103143. * 1 = Middle Button.
  103144. * 2 = Right Button.
  103145. */
  103146. activeButton: number;
  103147. /**
  103148. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  103149. * Higher values reduce its sensitivity.
  103150. */
  103151. angularSensibility: number;
  103152. private _mousemoveCallback;
  103153. private _observer;
  103154. private _rollObserver;
  103155. private previousPosition;
  103156. private noPreventDefault;
  103157. private element;
  103158. /**
  103159. * Listen to mouse events to control the camera.
  103160. * @param touchEnabled Define if touch is enabled. (Default is true.)
  103161. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103162. */
  103163. constructor(touchEnabled?: boolean);
  103164. /**
  103165. * Attach the mouse control to the HTML DOM element.
  103166. * @param element Defines the element that listens to the input events.
  103167. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  103168. */
  103169. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103170. /**
  103171. * Detach the current controls from the specified dom element.
  103172. * @param element Defines the element to stop listening the inputs from
  103173. */
  103174. detachControl(element: Nullable<HTMLElement>): void;
  103175. /**
  103176. * Gets the class name of the current input.
  103177. * @returns the class name.
  103178. */
  103179. getClassName(): string;
  103180. /**
  103181. * Get the friendly name associated with the input class.
  103182. * @returns the input's friendly name.
  103183. */
  103184. getSimpleName(): string;
  103185. private _pointerInput;
  103186. private _onMouseMove;
  103187. /**
  103188. * Rotate camera by mouse offset.
  103189. */
  103190. private rotateCamera;
  103191. }
  103192. }
  103193. declare module BABYLON {
  103194. /**
  103195. * Default Inputs manager for the FlyCamera.
  103196. * It groups all the default supported inputs for ease of use.
  103197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103198. */
  103199. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  103200. /**
  103201. * Instantiates a new FlyCameraInputsManager.
  103202. * @param camera Defines the camera the inputs belong to.
  103203. */
  103204. constructor(camera: FlyCamera);
  103205. /**
  103206. * Add keyboard input support to the input manager.
  103207. * @returns the new FlyCameraKeyboardMoveInput().
  103208. */
  103209. addKeyboard(): FlyCameraInputsManager;
  103210. /**
  103211. * Add mouse input support to the input manager.
  103212. * @param touchEnabled Enable touch screen support.
  103213. * @returns the new FlyCameraMouseInput().
  103214. */
  103215. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  103216. }
  103217. }
  103218. declare module BABYLON {
  103219. /**
  103220. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103221. * such as in a 3D Space Shooter or a Flight Simulator.
  103222. */
  103223. export class FlyCamera extends TargetCamera {
  103224. /**
  103225. * Define the collision ellipsoid of the camera.
  103226. * This is helpful for simulating a camera body, like a player's body.
  103227. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103228. */
  103229. ellipsoid: Vector3;
  103230. /**
  103231. * Define an offset for the position of the ellipsoid around the camera.
  103232. * This can be helpful if the camera is attached away from the player's body center,
  103233. * such as at its head.
  103234. */
  103235. ellipsoidOffset: Vector3;
  103236. /**
  103237. * Enable or disable collisions of the camera with the rest of the scene objects.
  103238. */
  103239. checkCollisions: boolean;
  103240. /**
  103241. * Enable or disable gravity on the camera.
  103242. */
  103243. applyGravity: boolean;
  103244. /**
  103245. * Define the current direction the camera is moving to.
  103246. */
  103247. cameraDirection: Vector3;
  103248. /**
  103249. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  103250. * This overrides and empties cameraRotation.
  103251. */
  103252. rotationQuaternion: Quaternion;
  103253. /**
  103254. * Track Roll to maintain the wanted Rolling when looking around.
  103255. */
  103256. _trackRoll: number;
  103257. /**
  103258. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  103259. */
  103260. rollCorrect: number;
  103261. /**
  103262. * Mimic a banked turn, Rolling the camera when Yawing.
  103263. * It's recommended to use rollCorrect = 10 for faster banking correction.
  103264. */
  103265. bankedTurn: boolean;
  103266. /**
  103267. * Limit in radians for how much Roll banking will add. (Default: 90°)
  103268. */
  103269. bankedTurnLimit: number;
  103270. /**
  103271. * Value of 0 disables the banked Roll.
  103272. * Value of 1 is equal to the Yaw angle in radians.
  103273. */
  103274. bankedTurnMultiplier: number;
  103275. /**
  103276. * The inputs manager loads all the input sources, such as keyboard and mouse.
  103277. */
  103278. inputs: FlyCameraInputsManager;
  103279. /**
  103280. * Gets the input sensibility for mouse input.
  103281. * Higher values reduce sensitivity.
  103282. */
  103283. /**
  103284. * Sets the input sensibility for a mouse input.
  103285. * Higher values reduce sensitivity.
  103286. */
  103287. angularSensibility: number;
  103288. /**
  103289. * Get the keys for camera movement forward.
  103290. */
  103291. /**
  103292. * Set the keys for camera movement forward.
  103293. */
  103294. keysForward: number[];
  103295. /**
  103296. * Get the keys for camera movement backward.
  103297. */
  103298. keysBackward: number[];
  103299. /**
  103300. * Get the keys for camera movement up.
  103301. */
  103302. /**
  103303. * Set the keys for camera movement up.
  103304. */
  103305. keysUp: number[];
  103306. /**
  103307. * Get the keys for camera movement down.
  103308. */
  103309. /**
  103310. * Set the keys for camera movement down.
  103311. */
  103312. keysDown: number[];
  103313. /**
  103314. * Get the keys for camera movement left.
  103315. */
  103316. /**
  103317. * Set the keys for camera movement left.
  103318. */
  103319. keysLeft: number[];
  103320. /**
  103321. * Set the keys for camera movement right.
  103322. */
  103323. /**
  103324. * Set the keys for camera movement right.
  103325. */
  103326. keysRight: number[];
  103327. /**
  103328. * Event raised when the camera collides with a mesh in the scene.
  103329. */
  103330. onCollide: (collidedMesh: AbstractMesh) => void;
  103331. private _collider;
  103332. private _needMoveForGravity;
  103333. private _oldPosition;
  103334. private _diffPosition;
  103335. private _newPosition;
  103336. /** @hidden */
  103337. _localDirection: Vector3;
  103338. /** @hidden */
  103339. _transformedDirection: Vector3;
  103340. /**
  103341. * Instantiates a FlyCamera.
  103342. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103343. * such as in a 3D Space Shooter or a Flight Simulator.
  103344. * @param name Define the name of the camera in the scene.
  103345. * @param position Define the starting position of the camera in the scene.
  103346. * @param scene Define the scene the camera belongs to.
  103347. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  103348. */
  103349. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103350. /**
  103351. * Attach a control to the HTML DOM element.
  103352. * @param element Defines the element that listens to the input events.
  103353. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  103354. */
  103355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103356. /**
  103357. * Detach a control from the HTML DOM element.
  103358. * The camera will stop reacting to that input.
  103359. * @param element Defines the element that listens to the input events.
  103360. */
  103361. detachControl(element: HTMLElement): void;
  103362. private _collisionMask;
  103363. /**
  103364. * Get the mask that the camera ignores in collision events.
  103365. */
  103366. /**
  103367. * Set the mask that the camera ignores in collision events.
  103368. */
  103369. collisionMask: number;
  103370. /** @hidden */
  103371. _collideWithWorld(displacement: Vector3): void;
  103372. /** @hidden */
  103373. private _onCollisionPositionChange;
  103374. /** @hidden */
  103375. _checkInputs(): void;
  103376. /** @hidden */
  103377. _decideIfNeedsToMove(): boolean;
  103378. /** @hidden */
  103379. _updatePosition(): void;
  103380. /**
  103381. * Restore the Roll to its target value at the rate specified.
  103382. * @param rate - Higher means slower restoring.
  103383. * @hidden
  103384. */
  103385. restoreRoll(rate: number): void;
  103386. /**
  103387. * Destroy the camera and release the current resources held by it.
  103388. */
  103389. dispose(): void;
  103390. /**
  103391. * Get the current object class name.
  103392. * @returns the class name.
  103393. */
  103394. getClassName(): string;
  103395. }
  103396. }
  103397. declare module BABYLON {
  103398. /**
  103399. * Listen to keyboard events to control the camera.
  103400. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103401. */
  103402. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  103403. /**
  103404. * Defines the camera the input is attached to.
  103405. */
  103406. camera: FlyCamera;
  103407. /**
  103408. * The list of keyboard keys used to control the forward move of the camera.
  103409. */
  103410. keysForward: number[];
  103411. /**
  103412. * The list of keyboard keys used to control the backward move of the camera.
  103413. */
  103414. keysBackward: number[];
  103415. /**
  103416. * The list of keyboard keys used to control the forward move of the camera.
  103417. */
  103418. keysUp: number[];
  103419. /**
  103420. * The list of keyboard keys used to control the backward move of the camera.
  103421. */
  103422. keysDown: number[];
  103423. /**
  103424. * The list of keyboard keys used to control the right strafe move of the camera.
  103425. */
  103426. keysRight: number[];
  103427. /**
  103428. * The list of keyboard keys used to control the left strafe move of the camera.
  103429. */
  103430. keysLeft: number[];
  103431. private _keys;
  103432. private _onCanvasBlurObserver;
  103433. private _onKeyboardObserver;
  103434. private _engine;
  103435. private _scene;
  103436. /**
  103437. * Attach the input controls to a specific dom element to get the input from.
  103438. * @param element Defines the element the controls should be listened from
  103439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103440. */
  103441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103442. /**
  103443. * Detach the current controls from the specified dom element.
  103444. * @param element Defines the element to stop listening the inputs from
  103445. */
  103446. detachControl(element: Nullable<HTMLElement>): void;
  103447. /**
  103448. * Gets the class name of the current intput.
  103449. * @returns the class name
  103450. */
  103451. getClassName(): string;
  103452. /** @hidden */
  103453. _onLostFocus(e: FocusEvent): void;
  103454. /**
  103455. * Get the friendly name associated with the input class.
  103456. * @returns the input friendly name
  103457. */
  103458. getSimpleName(): string;
  103459. /**
  103460. * Update the current camera state depending on the inputs that have been used this frame.
  103461. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103462. */
  103463. checkInputs(): void;
  103464. }
  103465. }
  103466. declare module BABYLON {
  103467. /**
  103468. * Manage the mouse wheel inputs to control a follow camera.
  103469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103470. */
  103471. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  103472. /**
  103473. * Defines the camera the input is attached to.
  103474. */
  103475. camera: FollowCamera;
  103476. /**
  103477. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  103478. */
  103479. axisControlRadius: boolean;
  103480. /**
  103481. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  103482. */
  103483. axisControlHeight: boolean;
  103484. /**
  103485. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  103486. */
  103487. axisControlRotation: boolean;
  103488. /**
  103489. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  103490. * relation to mouseWheel events.
  103491. */
  103492. wheelPrecision: number;
  103493. /**
  103494. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103495. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103496. */
  103497. wheelDeltaPercentage: number;
  103498. private _wheel;
  103499. private _observer;
  103500. /**
  103501. * Attach the input controls to a specific dom element to get the input from.
  103502. * @param element Defines the element the controls should be listened from
  103503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103504. */
  103505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103506. /**
  103507. * Detach the current controls from the specified dom element.
  103508. * @param element Defines the element to stop listening the inputs from
  103509. */
  103510. detachControl(element: Nullable<HTMLElement>): void;
  103511. /**
  103512. * Gets the class name of the current intput.
  103513. * @returns the class name
  103514. */
  103515. getClassName(): string;
  103516. /**
  103517. * Get the friendly name associated with the input class.
  103518. * @returns the input friendly name
  103519. */
  103520. getSimpleName(): string;
  103521. }
  103522. }
  103523. declare module BABYLON {
  103524. /**
  103525. * Manage the pointers inputs to control an follow camera.
  103526. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103527. */
  103528. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  103529. /**
  103530. * Defines the camera the input is attached to.
  103531. */
  103532. camera: FollowCamera;
  103533. /**
  103534. * Gets the class name of the current input.
  103535. * @returns the class name
  103536. */
  103537. getClassName(): string;
  103538. /**
  103539. * Defines the pointer angular sensibility along the X axis or how fast is
  103540. * the camera rotating.
  103541. * A negative number will reverse the axis direction.
  103542. */
  103543. angularSensibilityX: number;
  103544. /**
  103545. * Defines the pointer angular sensibility along the Y axis or how fast is
  103546. * the camera rotating.
  103547. * A negative number will reverse the axis direction.
  103548. */
  103549. angularSensibilityY: number;
  103550. /**
  103551. * Defines the pointer pinch precision or how fast is the camera zooming.
  103552. * A negative number will reverse the axis direction.
  103553. */
  103554. pinchPrecision: number;
  103555. /**
  103556. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103557. * from 0.
  103558. * It defines the percentage of current camera.radius to use as delta when
  103559. * pinch zoom is used.
  103560. */
  103561. pinchDeltaPercentage: number;
  103562. /**
  103563. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  103564. */
  103565. axisXControlRadius: boolean;
  103566. /**
  103567. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  103568. */
  103569. axisXControlHeight: boolean;
  103570. /**
  103571. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  103572. */
  103573. axisXControlRotation: boolean;
  103574. /**
  103575. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  103576. */
  103577. axisYControlRadius: boolean;
  103578. /**
  103579. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  103580. */
  103581. axisYControlHeight: boolean;
  103582. /**
  103583. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  103584. */
  103585. axisYControlRotation: boolean;
  103586. /**
  103587. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  103588. */
  103589. axisPinchControlRadius: boolean;
  103590. /**
  103591. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  103592. */
  103593. axisPinchControlHeight: boolean;
  103594. /**
  103595. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  103596. */
  103597. axisPinchControlRotation: boolean;
  103598. /**
  103599. * Log error messages if basic misconfiguration has occurred.
  103600. */
  103601. warningEnable: boolean;
  103602. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103603. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103604. private _warningCounter;
  103605. private _warning;
  103606. }
  103607. }
  103608. declare module BABYLON {
  103609. /**
  103610. * Default Inputs manager for the FollowCamera.
  103611. * It groups all the default supported inputs for ease of use.
  103612. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103613. */
  103614. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  103615. /**
  103616. * Instantiates a new FollowCameraInputsManager.
  103617. * @param camera Defines the camera the inputs belong to
  103618. */
  103619. constructor(camera: FollowCamera);
  103620. /**
  103621. * Add keyboard input support to the input manager.
  103622. * @returns the current input manager
  103623. */
  103624. addKeyboard(): FollowCameraInputsManager;
  103625. /**
  103626. * Add mouse wheel input support to the input manager.
  103627. * @returns the current input manager
  103628. */
  103629. addMouseWheel(): FollowCameraInputsManager;
  103630. /**
  103631. * Add pointers input support to the input manager.
  103632. * @returns the current input manager
  103633. */
  103634. addPointers(): FollowCameraInputsManager;
  103635. /**
  103636. * Add orientation input support to the input manager.
  103637. * @returns the current input manager
  103638. */
  103639. addVRDeviceOrientation(): FollowCameraInputsManager;
  103640. }
  103641. }
  103642. declare module BABYLON {
  103643. /**
  103644. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  103645. * an arc rotate version arcFollowCamera are available.
  103646. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103647. */
  103648. export class FollowCamera extends TargetCamera {
  103649. /**
  103650. * Distance the follow camera should follow an object at
  103651. */
  103652. radius: number;
  103653. /**
  103654. * Minimum allowed distance of the camera to the axis of rotation
  103655. * (The camera can not get closer).
  103656. * This can help limiting how the Camera is able to move in the scene.
  103657. */
  103658. lowerRadiusLimit: Nullable<number>;
  103659. /**
  103660. * Maximum allowed distance of the camera to the axis of rotation
  103661. * (The camera can not get further).
  103662. * This can help limiting how the Camera is able to move in the scene.
  103663. */
  103664. upperRadiusLimit: Nullable<number>;
  103665. /**
  103666. * Define a rotation offset between the camera and the object it follows
  103667. */
  103668. rotationOffset: number;
  103669. /**
  103670. * Minimum allowed angle to camera position relative to target object.
  103671. * This can help limiting how the Camera is able to move in the scene.
  103672. */
  103673. lowerRotationOffsetLimit: Nullable<number>;
  103674. /**
  103675. * Maximum allowed angle to camera position relative to target object.
  103676. * This can help limiting how the Camera is able to move in the scene.
  103677. */
  103678. upperRotationOffsetLimit: Nullable<number>;
  103679. /**
  103680. * Define a height offset between the camera and the object it follows.
  103681. * It can help following an object from the top (like a car chaing a plane)
  103682. */
  103683. heightOffset: number;
  103684. /**
  103685. * Minimum allowed height of camera position relative to target object.
  103686. * This can help limiting how the Camera is able to move in the scene.
  103687. */
  103688. lowerHeightOffsetLimit: Nullable<number>;
  103689. /**
  103690. * Maximum allowed height of camera position relative to target object.
  103691. * This can help limiting how the Camera is able to move in the scene.
  103692. */
  103693. upperHeightOffsetLimit: Nullable<number>;
  103694. /**
  103695. * Define how fast the camera can accelerate to follow it s target.
  103696. */
  103697. cameraAcceleration: number;
  103698. /**
  103699. * Define the speed limit of the camera following an object.
  103700. */
  103701. maxCameraSpeed: number;
  103702. /**
  103703. * Define the target of the camera.
  103704. */
  103705. lockedTarget: Nullable<AbstractMesh>;
  103706. /**
  103707. * Defines the input associated with the camera.
  103708. */
  103709. inputs: FollowCameraInputsManager;
  103710. /**
  103711. * Instantiates the follow camera.
  103712. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103713. * @param name Define the name of the camera in the scene
  103714. * @param position Define the position of the camera
  103715. * @param scene Define the scene the camera belong to
  103716. * @param lockedTarget Define the target of the camera
  103717. */
  103718. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  103719. private _follow;
  103720. /**
  103721. * Attached controls to the current camera.
  103722. * @param element Defines the element the controls should be listened from
  103723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103724. */
  103725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103726. /**
  103727. * Detach the current controls from the camera.
  103728. * The camera will stop reacting to inputs.
  103729. * @param element Defines the element to stop listening the inputs from
  103730. */
  103731. detachControl(element: HTMLElement): void;
  103732. /** @hidden */
  103733. _checkInputs(): void;
  103734. private _checkLimits;
  103735. /**
  103736. * Gets the camera class name.
  103737. * @returns the class name
  103738. */
  103739. getClassName(): string;
  103740. }
  103741. /**
  103742. * Arc Rotate version of the follow camera.
  103743. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  103744. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103745. */
  103746. export class ArcFollowCamera extends TargetCamera {
  103747. /** The longitudinal angle of the camera */
  103748. alpha: number;
  103749. /** The latitudinal angle of the camera */
  103750. beta: number;
  103751. /** The radius of the camera from its target */
  103752. radius: number;
  103753. /** Define the camera target (the messh it should follow) */
  103754. target: Nullable<AbstractMesh>;
  103755. private _cartesianCoordinates;
  103756. /**
  103757. * Instantiates a new ArcFollowCamera
  103758. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103759. * @param name Define the name of the camera
  103760. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  103761. * @param beta Define the rotation angle of the camera around the elevation axis
  103762. * @param radius Define the radius of the camera from its target point
  103763. * @param target Define the target of the camera
  103764. * @param scene Define the scene the camera belongs to
  103765. */
  103766. constructor(name: string,
  103767. /** The longitudinal angle of the camera */
  103768. alpha: number,
  103769. /** The latitudinal angle of the camera */
  103770. beta: number,
  103771. /** The radius of the camera from its target */
  103772. radius: number,
  103773. /** Define the camera target (the messh it should follow) */
  103774. target: Nullable<AbstractMesh>, scene: Scene);
  103775. private _follow;
  103776. /** @hidden */
  103777. _checkInputs(): void;
  103778. /**
  103779. * Returns the class name of the object.
  103780. * It is mostly used internally for serialization purposes.
  103781. */
  103782. getClassName(): string;
  103783. }
  103784. }
  103785. declare module BABYLON {
  103786. /**
  103787. * Manage the keyboard inputs to control the movement of a follow camera.
  103788. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103789. */
  103790. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  103791. /**
  103792. * Defines the camera the input is attached to.
  103793. */
  103794. camera: FollowCamera;
  103795. /**
  103796. * Defines the list of key codes associated with the up action (increase heightOffset)
  103797. */
  103798. keysHeightOffsetIncr: number[];
  103799. /**
  103800. * Defines the list of key codes associated with the down action (decrease heightOffset)
  103801. */
  103802. keysHeightOffsetDecr: number[];
  103803. /**
  103804. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  103805. */
  103806. keysHeightOffsetModifierAlt: boolean;
  103807. /**
  103808. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  103809. */
  103810. keysHeightOffsetModifierCtrl: boolean;
  103811. /**
  103812. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  103813. */
  103814. keysHeightOffsetModifierShift: boolean;
  103815. /**
  103816. * Defines the list of key codes associated with the left action (increase rotationOffset)
  103817. */
  103818. keysRotationOffsetIncr: number[];
  103819. /**
  103820. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  103821. */
  103822. keysRotationOffsetDecr: number[];
  103823. /**
  103824. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  103825. */
  103826. keysRotationOffsetModifierAlt: boolean;
  103827. /**
  103828. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  103829. */
  103830. keysRotationOffsetModifierCtrl: boolean;
  103831. /**
  103832. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  103833. */
  103834. keysRotationOffsetModifierShift: boolean;
  103835. /**
  103836. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  103837. */
  103838. keysRadiusIncr: number[];
  103839. /**
  103840. * Defines the list of key codes associated with the zoom-out action (increase radius)
  103841. */
  103842. keysRadiusDecr: number[];
  103843. /**
  103844. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  103845. */
  103846. keysRadiusModifierAlt: boolean;
  103847. /**
  103848. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  103849. */
  103850. keysRadiusModifierCtrl: boolean;
  103851. /**
  103852. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  103853. */
  103854. keysRadiusModifierShift: boolean;
  103855. /**
  103856. * Defines the rate of change of heightOffset.
  103857. */
  103858. heightSensibility: number;
  103859. /**
  103860. * Defines the rate of change of rotationOffset.
  103861. */
  103862. rotationSensibility: number;
  103863. /**
  103864. * Defines the rate of change of radius.
  103865. */
  103866. radiusSensibility: number;
  103867. private _keys;
  103868. private _ctrlPressed;
  103869. private _altPressed;
  103870. private _shiftPressed;
  103871. private _onCanvasBlurObserver;
  103872. private _onKeyboardObserver;
  103873. private _engine;
  103874. private _scene;
  103875. /**
  103876. * Attach the input controls to a specific dom element to get the input from.
  103877. * @param element Defines the element the controls should be listened from
  103878. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103879. */
  103880. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103881. /**
  103882. * Detach the current controls from the specified dom element.
  103883. * @param element Defines the element to stop listening the inputs from
  103884. */
  103885. detachControl(element: Nullable<HTMLElement>): void;
  103886. /**
  103887. * Update the current camera state depending on the inputs that have been used this frame.
  103888. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103889. */
  103890. checkInputs(): void;
  103891. /**
  103892. * Gets the class name of the current input.
  103893. * @returns the class name
  103894. */
  103895. getClassName(): string;
  103896. /**
  103897. * Get the friendly name associated with the input class.
  103898. * @returns the input friendly name
  103899. */
  103900. getSimpleName(): string;
  103901. /**
  103902. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103903. * allow modification of the heightOffset value.
  103904. */
  103905. private _modifierHeightOffset;
  103906. /**
  103907. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103908. * allow modification of the rotationOffset value.
  103909. */
  103910. private _modifierRotationOffset;
  103911. /**
  103912. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103913. * allow modification of the radius value.
  103914. */
  103915. private _modifierRadius;
  103916. }
  103917. }
  103918. declare module BABYLON {
  103919. interface FreeCameraInputsManager {
  103920. /**
  103921. * @hidden
  103922. */
  103923. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  103924. /**
  103925. * Add orientation input support to the input manager.
  103926. * @returns the current input manager
  103927. */
  103928. addDeviceOrientation(): FreeCameraInputsManager;
  103929. }
  103930. /**
  103931. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  103932. * Screen rotation is taken into account.
  103933. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103934. */
  103935. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  103936. private _camera;
  103937. private _screenOrientationAngle;
  103938. private _constantTranform;
  103939. private _screenQuaternion;
  103940. private _alpha;
  103941. private _beta;
  103942. private _gamma;
  103943. /**
  103944. * Can be used to detect if a device orientation sensor is availible on a device
  103945. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  103946. * @returns a promise that will resolve on orientation change
  103947. */
  103948. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  103949. /**
  103950. * @hidden
  103951. */
  103952. _onDeviceOrientationChangedObservable: Observable<void>;
  103953. /**
  103954. * Instantiates a new input
  103955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103956. */
  103957. constructor();
  103958. /**
  103959. * Define the camera controlled by the input.
  103960. */
  103961. camera: FreeCamera;
  103962. /**
  103963. * Attach the input controls to a specific dom element to get the input from.
  103964. * @param element Defines the element the controls should be listened from
  103965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103966. */
  103967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103968. private _orientationChanged;
  103969. private _deviceOrientation;
  103970. /**
  103971. * Detach the current controls from the specified dom element.
  103972. * @param element Defines the element to stop listening the inputs from
  103973. */
  103974. detachControl(element: Nullable<HTMLElement>): void;
  103975. /**
  103976. * Update the current camera state depending on the inputs that have been used this frame.
  103977. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103978. */
  103979. checkInputs(): void;
  103980. /**
  103981. * Gets the class name of the current intput.
  103982. * @returns the class name
  103983. */
  103984. getClassName(): string;
  103985. /**
  103986. * Get the friendly name associated with the input class.
  103987. * @returns the input friendly name
  103988. */
  103989. getSimpleName(): string;
  103990. }
  103991. }
  103992. declare module BABYLON {
  103993. /**
  103994. * Manage the gamepad inputs to control a free camera.
  103995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103996. */
  103997. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  103998. /**
  103999. * Define the camera the input is attached to.
  104000. */
  104001. camera: FreeCamera;
  104002. /**
  104003. * Define the Gamepad controlling the input
  104004. */
  104005. gamepad: Nullable<Gamepad>;
  104006. /**
  104007. * Defines the gamepad rotation sensiblity.
  104008. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104009. */
  104010. gamepadAngularSensibility: number;
  104011. /**
  104012. * Defines the gamepad move sensiblity.
  104013. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104014. */
  104015. gamepadMoveSensibility: number;
  104016. private _onGamepadConnectedObserver;
  104017. private _onGamepadDisconnectedObserver;
  104018. private _cameraTransform;
  104019. private _deltaTransform;
  104020. private _vector3;
  104021. private _vector2;
  104022. /**
  104023. * Attach the input controls to a specific dom element to get the input from.
  104024. * @param element Defines the element the controls should be listened from
  104025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104026. */
  104027. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104028. /**
  104029. * Detach the current controls from the specified dom element.
  104030. * @param element Defines the element to stop listening the inputs from
  104031. */
  104032. detachControl(element: Nullable<HTMLElement>): void;
  104033. /**
  104034. * Update the current camera state depending on the inputs that have been used this frame.
  104035. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104036. */
  104037. checkInputs(): void;
  104038. /**
  104039. * Gets the class name of the current intput.
  104040. * @returns the class name
  104041. */
  104042. getClassName(): string;
  104043. /**
  104044. * Get the friendly name associated with the input class.
  104045. * @returns the input friendly name
  104046. */
  104047. getSimpleName(): string;
  104048. }
  104049. }
  104050. declare module BABYLON {
  104051. /**
  104052. * Defines the potential axis of a Joystick
  104053. */
  104054. export enum JoystickAxis {
  104055. /** X axis */
  104056. X = 0,
  104057. /** Y axis */
  104058. Y = 1,
  104059. /** Z axis */
  104060. Z = 2
  104061. }
  104062. /**
  104063. * Class used to define virtual joystick (used in touch mode)
  104064. */
  104065. export class VirtualJoystick {
  104066. /**
  104067. * Gets or sets a boolean indicating that left and right values must be inverted
  104068. */
  104069. reverseLeftRight: boolean;
  104070. /**
  104071. * Gets or sets a boolean indicating that up and down values must be inverted
  104072. */
  104073. reverseUpDown: boolean;
  104074. /**
  104075. * Gets the offset value for the position (ie. the change of the position value)
  104076. */
  104077. deltaPosition: Vector3;
  104078. /**
  104079. * Gets a boolean indicating if the virtual joystick was pressed
  104080. */
  104081. pressed: boolean;
  104082. /**
  104083. * Canvas the virtual joystick will render onto, default z-index of this is 5
  104084. */
  104085. static Canvas: Nullable<HTMLCanvasElement>;
  104086. private static _globalJoystickIndex;
  104087. private static vjCanvasContext;
  104088. private static vjCanvasWidth;
  104089. private static vjCanvasHeight;
  104090. private static halfWidth;
  104091. private _action;
  104092. private _axisTargetedByLeftAndRight;
  104093. private _axisTargetedByUpAndDown;
  104094. private _joystickSensibility;
  104095. private _inversedSensibility;
  104096. private _joystickPointerID;
  104097. private _joystickColor;
  104098. private _joystickPointerPos;
  104099. private _joystickPreviousPointerPos;
  104100. private _joystickPointerStartPos;
  104101. private _deltaJoystickVector;
  104102. private _leftJoystick;
  104103. private _touches;
  104104. private _onPointerDownHandlerRef;
  104105. private _onPointerMoveHandlerRef;
  104106. private _onPointerUpHandlerRef;
  104107. private _onResize;
  104108. /**
  104109. * Creates a new virtual joystick
  104110. * @param leftJoystick defines that the joystick is for left hand (false by default)
  104111. */
  104112. constructor(leftJoystick?: boolean);
  104113. /**
  104114. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104115. * @param newJoystickSensibility defines the new sensibility
  104116. */
  104117. setJoystickSensibility(newJoystickSensibility: number): void;
  104118. private _onPointerDown;
  104119. private _onPointerMove;
  104120. private _onPointerUp;
  104121. /**
  104122. * Change the color of the virtual joystick
  104123. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104124. */
  104125. setJoystickColor(newColor: string): void;
  104126. /**
  104127. * Defines a callback to call when the joystick is touched
  104128. * @param action defines the callback
  104129. */
  104130. setActionOnTouch(action: () => any): void;
  104131. /**
  104132. * Defines which axis you'd like to control for left & right
  104133. * @param axis defines the axis to use
  104134. */
  104135. setAxisForLeftRight(axis: JoystickAxis): void;
  104136. /**
  104137. * Defines which axis you'd like to control for up & down
  104138. * @param axis defines the axis to use
  104139. */
  104140. setAxisForUpDown(axis: JoystickAxis): void;
  104141. private _drawVirtualJoystick;
  104142. /**
  104143. * Release internal HTML canvas
  104144. */
  104145. releaseCanvas(): void;
  104146. }
  104147. }
  104148. declare module BABYLON {
  104149. interface FreeCameraInputsManager {
  104150. /**
  104151. * Add virtual joystick input support to the input manager.
  104152. * @returns the current input manager
  104153. */
  104154. addVirtualJoystick(): FreeCameraInputsManager;
  104155. }
  104156. /**
  104157. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  104158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104159. */
  104160. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  104161. /**
  104162. * Defines the camera the input is attached to.
  104163. */
  104164. camera: FreeCamera;
  104165. private _leftjoystick;
  104166. private _rightjoystick;
  104167. /**
  104168. * Gets the left stick of the virtual joystick.
  104169. * @returns The virtual Joystick
  104170. */
  104171. getLeftJoystick(): VirtualJoystick;
  104172. /**
  104173. * Gets the right stick of the virtual joystick.
  104174. * @returns The virtual Joystick
  104175. */
  104176. getRightJoystick(): VirtualJoystick;
  104177. /**
  104178. * Update the current camera state depending on the inputs that have been used this frame.
  104179. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104180. */
  104181. checkInputs(): void;
  104182. /**
  104183. * Attach the input controls to a specific dom element to get the input from.
  104184. * @param element Defines the element the controls should be listened from
  104185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104186. */
  104187. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104188. /**
  104189. * Detach the current controls from the specified dom element.
  104190. * @param element Defines the element to stop listening the inputs from
  104191. */
  104192. detachControl(element: Nullable<HTMLElement>): void;
  104193. /**
  104194. * Gets the class name of the current intput.
  104195. * @returns the class name
  104196. */
  104197. getClassName(): string;
  104198. /**
  104199. * Get the friendly name associated with the input class.
  104200. * @returns the input friendly name
  104201. */
  104202. getSimpleName(): string;
  104203. }
  104204. }
  104205. declare module BABYLON {
  104206. /**
  104207. * This represents a FPS type of camera controlled by touch.
  104208. * This is like a universal camera minus the Gamepad controls.
  104209. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104210. */
  104211. export class TouchCamera extends FreeCamera {
  104212. /**
  104213. * Defines the touch sensibility for rotation.
  104214. * The higher the faster.
  104215. */
  104216. touchAngularSensibility: number;
  104217. /**
  104218. * Defines the touch sensibility for move.
  104219. * The higher the faster.
  104220. */
  104221. touchMoveSensibility: number;
  104222. /**
  104223. * Instantiates a new touch camera.
  104224. * This represents a FPS type of camera controlled by touch.
  104225. * This is like a universal camera minus the Gamepad controls.
  104226. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104227. * @param name Define the name of the camera in the scene
  104228. * @param position Define the start position of the camera in the scene
  104229. * @param scene Define the scene the camera belongs to
  104230. */
  104231. constructor(name: string, position: Vector3, scene: Scene);
  104232. /**
  104233. * Gets the current object class name.
  104234. * @return the class name
  104235. */
  104236. getClassName(): string;
  104237. /** @hidden */
  104238. _setupInputs(): void;
  104239. }
  104240. }
  104241. declare module BABYLON {
  104242. /**
  104243. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  104244. * being tilted forward or back and left or right.
  104245. */
  104246. export class DeviceOrientationCamera extends FreeCamera {
  104247. private _initialQuaternion;
  104248. private _quaternionCache;
  104249. private _tmpDragQuaternion;
  104250. private _disablePointerInputWhenUsingDeviceOrientation;
  104251. /**
  104252. * Creates a new device orientation camera
  104253. * @param name The name of the camera
  104254. * @param position The start position camera
  104255. * @param scene The scene the camera belongs to
  104256. */
  104257. constructor(name: string, position: Vector3, scene: Scene);
  104258. /**
  104259. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  104260. */
  104261. disablePointerInputWhenUsingDeviceOrientation: boolean;
  104262. private _dragFactor;
  104263. /**
  104264. * Enabled turning on the y axis when the orientation sensor is active
  104265. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  104266. */
  104267. enableHorizontalDragging(dragFactor?: number): void;
  104268. /**
  104269. * Gets the current instance class name ("DeviceOrientationCamera").
  104270. * This helps avoiding instanceof at run time.
  104271. * @returns the class name
  104272. */
  104273. getClassName(): string;
  104274. /**
  104275. * @hidden
  104276. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  104277. */
  104278. _checkInputs(): void;
  104279. /**
  104280. * Reset the camera to its default orientation on the specified axis only.
  104281. * @param axis The axis to reset
  104282. */
  104283. resetToCurrentRotation(axis?: Axis): void;
  104284. }
  104285. }
  104286. declare module BABYLON {
  104287. /**
  104288. * Defines supported buttons for XBox360 compatible gamepads
  104289. */
  104290. export enum Xbox360Button {
  104291. /** A */
  104292. A = 0,
  104293. /** B */
  104294. B = 1,
  104295. /** X */
  104296. X = 2,
  104297. /** Y */
  104298. Y = 3,
  104299. /** Start */
  104300. Start = 4,
  104301. /** Back */
  104302. Back = 5,
  104303. /** Left button */
  104304. LB = 6,
  104305. /** Right button */
  104306. RB = 7,
  104307. /** Left stick */
  104308. LeftStick = 8,
  104309. /** Right stick */
  104310. RightStick = 9
  104311. }
  104312. /** Defines values for XBox360 DPad */
  104313. export enum Xbox360Dpad {
  104314. /** Up */
  104315. Up = 0,
  104316. /** Down */
  104317. Down = 1,
  104318. /** Left */
  104319. Left = 2,
  104320. /** Right */
  104321. Right = 3
  104322. }
  104323. /**
  104324. * Defines a XBox360 gamepad
  104325. */
  104326. export class Xbox360Pad extends Gamepad {
  104327. private _leftTrigger;
  104328. private _rightTrigger;
  104329. private _onlefttriggerchanged;
  104330. private _onrighttriggerchanged;
  104331. private _onbuttondown;
  104332. private _onbuttonup;
  104333. private _ondpaddown;
  104334. private _ondpadup;
  104335. /** Observable raised when a button is pressed */
  104336. onButtonDownObservable: Observable<Xbox360Button>;
  104337. /** Observable raised when a button is released */
  104338. onButtonUpObservable: Observable<Xbox360Button>;
  104339. /** Observable raised when a pad is pressed */
  104340. onPadDownObservable: Observable<Xbox360Dpad>;
  104341. /** Observable raised when a pad is released */
  104342. onPadUpObservable: Observable<Xbox360Dpad>;
  104343. private _buttonA;
  104344. private _buttonB;
  104345. private _buttonX;
  104346. private _buttonY;
  104347. private _buttonBack;
  104348. private _buttonStart;
  104349. private _buttonLB;
  104350. private _buttonRB;
  104351. private _buttonLeftStick;
  104352. private _buttonRightStick;
  104353. private _dPadUp;
  104354. private _dPadDown;
  104355. private _dPadLeft;
  104356. private _dPadRight;
  104357. private _isXboxOnePad;
  104358. /**
  104359. * Creates a new XBox360 gamepad object
  104360. * @param id defines the id of this gamepad
  104361. * @param index defines its index
  104362. * @param gamepad defines the internal HTML gamepad object
  104363. * @param xboxOne defines if it is a XBox One gamepad
  104364. */
  104365. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  104366. /**
  104367. * Defines the callback to call when left trigger is pressed
  104368. * @param callback defines the callback to use
  104369. */
  104370. onlefttriggerchanged(callback: (value: number) => void): void;
  104371. /**
  104372. * Defines the callback to call when right trigger is pressed
  104373. * @param callback defines the callback to use
  104374. */
  104375. onrighttriggerchanged(callback: (value: number) => void): void;
  104376. /**
  104377. * Gets the left trigger value
  104378. */
  104379. /**
  104380. * Sets the left trigger value
  104381. */
  104382. leftTrigger: number;
  104383. /**
  104384. * Gets the right trigger value
  104385. */
  104386. /**
  104387. * Sets the right trigger value
  104388. */
  104389. rightTrigger: number;
  104390. /**
  104391. * Defines the callback to call when a button is pressed
  104392. * @param callback defines the callback to use
  104393. */
  104394. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  104395. /**
  104396. * Defines the callback to call when a button is released
  104397. * @param callback defines the callback to use
  104398. */
  104399. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  104400. /**
  104401. * Defines the callback to call when a pad is pressed
  104402. * @param callback defines the callback to use
  104403. */
  104404. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  104405. /**
  104406. * Defines the callback to call when a pad is released
  104407. * @param callback defines the callback to use
  104408. */
  104409. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  104410. private _setButtonValue;
  104411. private _setDPadValue;
  104412. /**
  104413. * Gets the value of the `A` button
  104414. */
  104415. /**
  104416. * Sets the value of the `A` button
  104417. */
  104418. buttonA: number;
  104419. /**
  104420. * Gets the value of the `B` button
  104421. */
  104422. /**
  104423. * Sets the value of the `B` button
  104424. */
  104425. buttonB: number;
  104426. /**
  104427. * Gets the value of the `X` button
  104428. */
  104429. /**
  104430. * Sets the value of the `X` button
  104431. */
  104432. buttonX: number;
  104433. /**
  104434. * Gets the value of the `Y` button
  104435. */
  104436. /**
  104437. * Sets the value of the `Y` button
  104438. */
  104439. buttonY: number;
  104440. /**
  104441. * Gets the value of the `Start` button
  104442. */
  104443. /**
  104444. * Sets the value of the `Start` button
  104445. */
  104446. buttonStart: number;
  104447. /**
  104448. * Gets the value of the `Back` button
  104449. */
  104450. /**
  104451. * Sets the value of the `Back` button
  104452. */
  104453. buttonBack: number;
  104454. /**
  104455. * Gets the value of the `Left` button
  104456. */
  104457. /**
  104458. * Sets the value of the `Left` button
  104459. */
  104460. buttonLB: number;
  104461. /**
  104462. * Gets the value of the `Right` button
  104463. */
  104464. /**
  104465. * Sets the value of the `Right` button
  104466. */
  104467. buttonRB: number;
  104468. /**
  104469. * Gets the value of the Left joystick
  104470. */
  104471. /**
  104472. * Sets the value of the Left joystick
  104473. */
  104474. buttonLeftStick: number;
  104475. /**
  104476. * Gets the value of the Right joystick
  104477. */
  104478. /**
  104479. * Sets the value of the Right joystick
  104480. */
  104481. buttonRightStick: number;
  104482. /**
  104483. * Gets the value of D-pad up
  104484. */
  104485. /**
  104486. * Sets the value of D-pad up
  104487. */
  104488. dPadUp: number;
  104489. /**
  104490. * Gets the value of D-pad down
  104491. */
  104492. /**
  104493. * Sets the value of D-pad down
  104494. */
  104495. dPadDown: number;
  104496. /**
  104497. * Gets the value of D-pad left
  104498. */
  104499. /**
  104500. * Sets the value of D-pad left
  104501. */
  104502. dPadLeft: number;
  104503. /**
  104504. * Gets the value of D-pad right
  104505. */
  104506. /**
  104507. * Sets the value of D-pad right
  104508. */
  104509. dPadRight: number;
  104510. /**
  104511. * Force the gamepad to synchronize with device values
  104512. */
  104513. update(): void;
  104514. /**
  104515. * Disposes the gamepad
  104516. */
  104517. dispose(): void;
  104518. }
  104519. }
  104520. declare module BABYLON {
  104521. /**
  104522. * Defines supported buttons for DualShock compatible gamepads
  104523. */
  104524. export enum DualShockButton {
  104525. /** Cross */
  104526. Cross = 0,
  104527. /** Circle */
  104528. Circle = 1,
  104529. /** Square */
  104530. Square = 2,
  104531. /** Triangle */
  104532. Triangle = 3,
  104533. /** Options */
  104534. Options = 4,
  104535. /** Share */
  104536. Share = 5,
  104537. /** L1 */
  104538. L1 = 6,
  104539. /** R1 */
  104540. R1 = 7,
  104541. /** Left stick */
  104542. LeftStick = 8,
  104543. /** Right stick */
  104544. RightStick = 9
  104545. }
  104546. /** Defines values for DualShock DPad */
  104547. export enum DualShockDpad {
  104548. /** Up */
  104549. Up = 0,
  104550. /** Down */
  104551. Down = 1,
  104552. /** Left */
  104553. Left = 2,
  104554. /** Right */
  104555. Right = 3
  104556. }
  104557. /**
  104558. * Defines a DualShock gamepad
  104559. */
  104560. export class DualShockPad extends Gamepad {
  104561. private _leftTrigger;
  104562. private _rightTrigger;
  104563. private _onlefttriggerchanged;
  104564. private _onrighttriggerchanged;
  104565. private _onbuttondown;
  104566. private _onbuttonup;
  104567. private _ondpaddown;
  104568. private _ondpadup;
  104569. /** Observable raised when a button is pressed */
  104570. onButtonDownObservable: Observable<DualShockButton>;
  104571. /** Observable raised when a button is released */
  104572. onButtonUpObservable: Observable<DualShockButton>;
  104573. /** Observable raised when a pad is pressed */
  104574. onPadDownObservable: Observable<DualShockDpad>;
  104575. /** Observable raised when a pad is released */
  104576. onPadUpObservable: Observable<DualShockDpad>;
  104577. private _buttonCross;
  104578. private _buttonCircle;
  104579. private _buttonSquare;
  104580. private _buttonTriangle;
  104581. private _buttonShare;
  104582. private _buttonOptions;
  104583. private _buttonL1;
  104584. private _buttonR1;
  104585. private _buttonLeftStick;
  104586. private _buttonRightStick;
  104587. private _dPadUp;
  104588. private _dPadDown;
  104589. private _dPadLeft;
  104590. private _dPadRight;
  104591. /**
  104592. * Creates a new DualShock gamepad object
  104593. * @param id defines the id of this gamepad
  104594. * @param index defines its index
  104595. * @param gamepad defines the internal HTML gamepad object
  104596. */
  104597. constructor(id: string, index: number, gamepad: any);
  104598. /**
  104599. * Defines the callback to call when left trigger is pressed
  104600. * @param callback defines the callback to use
  104601. */
  104602. onlefttriggerchanged(callback: (value: number) => void): void;
  104603. /**
  104604. * Defines the callback to call when right trigger is pressed
  104605. * @param callback defines the callback to use
  104606. */
  104607. onrighttriggerchanged(callback: (value: number) => void): void;
  104608. /**
  104609. * Gets the left trigger value
  104610. */
  104611. /**
  104612. * Sets the left trigger value
  104613. */
  104614. leftTrigger: number;
  104615. /**
  104616. * Gets the right trigger value
  104617. */
  104618. /**
  104619. * Sets the right trigger value
  104620. */
  104621. rightTrigger: number;
  104622. /**
  104623. * Defines the callback to call when a button is pressed
  104624. * @param callback defines the callback to use
  104625. */
  104626. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  104627. /**
  104628. * Defines the callback to call when a button is released
  104629. * @param callback defines the callback to use
  104630. */
  104631. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  104632. /**
  104633. * Defines the callback to call when a pad is pressed
  104634. * @param callback defines the callback to use
  104635. */
  104636. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  104637. /**
  104638. * Defines the callback to call when a pad is released
  104639. * @param callback defines the callback to use
  104640. */
  104641. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  104642. private _setButtonValue;
  104643. private _setDPadValue;
  104644. /**
  104645. * Gets the value of the `Cross` button
  104646. */
  104647. /**
  104648. * Sets the value of the `Cross` button
  104649. */
  104650. buttonCross: number;
  104651. /**
  104652. * Gets the value of the `Circle` button
  104653. */
  104654. /**
  104655. * Sets the value of the `Circle` button
  104656. */
  104657. buttonCircle: number;
  104658. /**
  104659. * Gets the value of the `Square` button
  104660. */
  104661. /**
  104662. * Sets the value of the `Square` button
  104663. */
  104664. buttonSquare: number;
  104665. /**
  104666. * Gets the value of the `Triangle` button
  104667. */
  104668. /**
  104669. * Sets the value of the `Triangle` button
  104670. */
  104671. buttonTriangle: number;
  104672. /**
  104673. * Gets the value of the `Options` button
  104674. */
  104675. /**
  104676. * Sets the value of the `Options` button
  104677. */
  104678. buttonOptions: number;
  104679. /**
  104680. * Gets the value of the `Share` button
  104681. */
  104682. /**
  104683. * Sets the value of the `Share` button
  104684. */
  104685. buttonShare: number;
  104686. /**
  104687. * Gets the value of the `L1` button
  104688. */
  104689. /**
  104690. * Sets the value of the `L1` button
  104691. */
  104692. buttonL1: number;
  104693. /**
  104694. * Gets the value of the `R1` button
  104695. */
  104696. /**
  104697. * Sets the value of the `R1` button
  104698. */
  104699. buttonR1: number;
  104700. /**
  104701. * Gets the value of the Left joystick
  104702. */
  104703. /**
  104704. * Sets the value of the Left joystick
  104705. */
  104706. buttonLeftStick: number;
  104707. /**
  104708. * Gets the value of the Right joystick
  104709. */
  104710. /**
  104711. * Sets the value of the Right joystick
  104712. */
  104713. buttonRightStick: number;
  104714. /**
  104715. * Gets the value of D-pad up
  104716. */
  104717. /**
  104718. * Sets the value of D-pad up
  104719. */
  104720. dPadUp: number;
  104721. /**
  104722. * Gets the value of D-pad down
  104723. */
  104724. /**
  104725. * Sets the value of D-pad down
  104726. */
  104727. dPadDown: number;
  104728. /**
  104729. * Gets the value of D-pad left
  104730. */
  104731. /**
  104732. * Sets the value of D-pad left
  104733. */
  104734. dPadLeft: number;
  104735. /**
  104736. * Gets the value of D-pad right
  104737. */
  104738. /**
  104739. * Sets the value of D-pad right
  104740. */
  104741. dPadRight: number;
  104742. /**
  104743. * Force the gamepad to synchronize with device values
  104744. */
  104745. update(): void;
  104746. /**
  104747. * Disposes the gamepad
  104748. */
  104749. dispose(): void;
  104750. }
  104751. }
  104752. declare module BABYLON {
  104753. /**
  104754. * Manager for handling gamepads
  104755. */
  104756. export class GamepadManager {
  104757. private _scene?;
  104758. private _babylonGamepads;
  104759. private _oneGamepadConnected;
  104760. /** @hidden */
  104761. _isMonitoring: boolean;
  104762. private _gamepadEventSupported;
  104763. private _gamepadSupport;
  104764. /**
  104765. * observable to be triggered when the gamepad controller has been connected
  104766. */
  104767. onGamepadConnectedObservable: Observable<Gamepad>;
  104768. /**
  104769. * observable to be triggered when the gamepad controller has been disconnected
  104770. */
  104771. onGamepadDisconnectedObservable: Observable<Gamepad>;
  104772. private _onGamepadConnectedEvent;
  104773. private _onGamepadDisconnectedEvent;
  104774. /**
  104775. * Initializes the gamepad manager
  104776. * @param _scene BabylonJS scene
  104777. */
  104778. constructor(_scene?: Scene | undefined);
  104779. /**
  104780. * The gamepads in the game pad manager
  104781. */
  104782. readonly gamepads: Gamepad[];
  104783. /**
  104784. * Get the gamepad controllers based on type
  104785. * @param type The type of gamepad controller
  104786. * @returns Nullable gamepad
  104787. */
  104788. getGamepadByType(type?: number): Nullable<Gamepad>;
  104789. /**
  104790. * Disposes the gamepad manager
  104791. */
  104792. dispose(): void;
  104793. private _addNewGamepad;
  104794. private _startMonitoringGamepads;
  104795. private _stopMonitoringGamepads;
  104796. /** @hidden */
  104797. _checkGamepadsStatus(): void;
  104798. private _updateGamepadObjects;
  104799. }
  104800. }
  104801. declare module BABYLON {
  104802. interface Scene {
  104803. /** @hidden */
  104804. _gamepadManager: Nullable<GamepadManager>;
  104805. /**
  104806. * Gets the gamepad manager associated with the scene
  104807. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  104808. */
  104809. gamepadManager: GamepadManager;
  104810. }
  104811. /**
  104812. * Interface representing a free camera inputs manager
  104813. */
  104814. interface FreeCameraInputsManager {
  104815. /**
  104816. * Adds gamepad input support to the FreeCameraInputsManager.
  104817. * @returns the FreeCameraInputsManager
  104818. */
  104819. addGamepad(): FreeCameraInputsManager;
  104820. }
  104821. /**
  104822. * Interface representing an arc rotate camera inputs manager
  104823. */
  104824. interface ArcRotateCameraInputsManager {
  104825. /**
  104826. * Adds gamepad input support to the ArcRotateCamera InputManager.
  104827. * @returns the camera inputs manager
  104828. */
  104829. addGamepad(): ArcRotateCameraInputsManager;
  104830. }
  104831. /**
  104832. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  104833. */
  104834. export class GamepadSystemSceneComponent implements ISceneComponent {
  104835. /**
  104836. * The component name helpfull to identify the component in the list of scene components.
  104837. */
  104838. readonly name: string;
  104839. /**
  104840. * The scene the component belongs to.
  104841. */
  104842. scene: Scene;
  104843. /**
  104844. * Creates a new instance of the component for the given scene
  104845. * @param scene Defines the scene to register the component in
  104846. */
  104847. constructor(scene: Scene);
  104848. /**
  104849. * Registers the component in a given scene
  104850. */
  104851. register(): void;
  104852. /**
  104853. * Rebuilds the elements related to this component in case of
  104854. * context lost for instance.
  104855. */
  104856. rebuild(): void;
  104857. /**
  104858. * Disposes the component and the associated ressources
  104859. */
  104860. dispose(): void;
  104861. private _beforeCameraUpdate;
  104862. }
  104863. }
  104864. declare module BABYLON {
  104865. /**
  104866. * 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,
  104867. * which still works and will still be found in many Playgrounds.
  104868. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104869. */
  104870. export class UniversalCamera extends TouchCamera {
  104871. /**
  104872. * Defines the gamepad rotation sensiblity.
  104873. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104874. */
  104875. gamepadAngularSensibility: number;
  104876. /**
  104877. * Defines the gamepad move sensiblity.
  104878. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104879. */
  104880. gamepadMoveSensibility: number;
  104881. /**
  104882. * 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,
  104883. * which still works and will still be found in many Playgrounds.
  104884. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104885. * @param name Define the name of the camera in the scene
  104886. * @param position Define the start position of the camera in the scene
  104887. * @param scene Define the scene the camera belongs to
  104888. */
  104889. constructor(name: string, position: Vector3, scene: Scene);
  104890. /**
  104891. * Gets the current object class name.
  104892. * @return the class name
  104893. */
  104894. getClassName(): string;
  104895. }
  104896. }
  104897. declare module BABYLON {
  104898. /**
  104899. * This represents a FPS type of camera. This is only here for back compat purpose.
  104900. * Please use the UniversalCamera instead as both are identical.
  104901. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104902. */
  104903. export class GamepadCamera extends UniversalCamera {
  104904. /**
  104905. * Instantiates a new Gamepad Camera
  104906. * This represents a FPS type of camera. This is only here for back compat purpose.
  104907. * Please use the UniversalCamera instead as both are identical.
  104908. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104909. * @param name Define the name of the camera in the scene
  104910. * @param position Define the start position of the camera in the scene
  104911. * @param scene Define the scene the camera belongs to
  104912. */
  104913. constructor(name: string, position: Vector3, scene: Scene);
  104914. /**
  104915. * Gets the current object class name.
  104916. * @return the class name
  104917. */
  104918. getClassName(): string;
  104919. }
  104920. }
  104921. declare module BABYLON {
  104922. /** @hidden */
  104923. export var passPixelShader: {
  104924. name: string;
  104925. shader: string;
  104926. };
  104927. }
  104928. declare module BABYLON {
  104929. /** @hidden */
  104930. export var passCubePixelShader: {
  104931. name: string;
  104932. shader: string;
  104933. };
  104934. }
  104935. declare module BABYLON {
  104936. /**
  104937. * PassPostProcess which produces an output the same as it's input
  104938. */
  104939. export class PassPostProcess extends PostProcess {
  104940. /**
  104941. * Creates the PassPostProcess
  104942. * @param name The name of the effect.
  104943. * @param options The required width/height ratio to downsize to before computing the render pass.
  104944. * @param camera The camera to apply the render pass to.
  104945. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104946. * @param engine The engine which the post process will be applied. (default: current engine)
  104947. * @param reusable If the post process can be reused on the same frame. (default: false)
  104948. * @param textureType The type of texture to be used when performing the post processing.
  104949. * @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)
  104950. */
  104951. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104952. }
  104953. /**
  104954. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  104955. */
  104956. export class PassCubePostProcess extends PostProcess {
  104957. private _face;
  104958. /**
  104959. * Gets or sets the cube face to display.
  104960. * * 0 is +X
  104961. * * 1 is -X
  104962. * * 2 is +Y
  104963. * * 3 is -Y
  104964. * * 4 is +Z
  104965. * * 5 is -Z
  104966. */
  104967. face: number;
  104968. /**
  104969. * Creates the PassCubePostProcess
  104970. * @param name The name of the effect.
  104971. * @param options The required width/height ratio to downsize to before computing the render pass.
  104972. * @param camera The camera to apply the render pass to.
  104973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104974. * @param engine The engine which the post process will be applied. (default: current engine)
  104975. * @param reusable If the post process can be reused on the same frame. (default: false)
  104976. * @param textureType The type of texture to be used when performing the post processing.
  104977. * @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)
  104978. */
  104979. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104980. }
  104981. }
  104982. declare module BABYLON {
  104983. /** @hidden */
  104984. export var anaglyphPixelShader: {
  104985. name: string;
  104986. shader: string;
  104987. };
  104988. }
  104989. declare module BABYLON {
  104990. /**
  104991. * Postprocess used to generate anaglyphic rendering
  104992. */
  104993. export class AnaglyphPostProcess extends PostProcess {
  104994. private _passedProcess;
  104995. /**
  104996. * Creates a new AnaglyphPostProcess
  104997. * @param name defines postprocess name
  104998. * @param options defines creation options or target ratio scale
  104999. * @param rigCameras defines cameras using this postprocess
  105000. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  105001. * @param engine defines hosting engine
  105002. * @param reusable defines if the postprocess will be reused multiple times per frame
  105003. */
  105004. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  105005. }
  105006. }
  105007. declare module BABYLON {
  105008. /**
  105009. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  105010. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105011. */
  105012. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  105013. /**
  105014. * Creates a new AnaglyphArcRotateCamera
  105015. * @param name defines camera name
  105016. * @param alpha defines alpha angle (in radians)
  105017. * @param beta defines beta angle (in radians)
  105018. * @param radius defines radius
  105019. * @param target defines camera target
  105020. * @param interaxialDistance defines distance between each color axis
  105021. * @param scene defines the hosting scene
  105022. */
  105023. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  105024. /**
  105025. * Gets camera class name
  105026. * @returns AnaglyphArcRotateCamera
  105027. */
  105028. getClassName(): string;
  105029. }
  105030. }
  105031. declare module BABYLON {
  105032. /**
  105033. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  105034. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105035. */
  105036. export class AnaglyphFreeCamera extends FreeCamera {
  105037. /**
  105038. * Creates a new AnaglyphFreeCamera
  105039. * @param name defines camera name
  105040. * @param position defines initial position
  105041. * @param interaxialDistance defines distance between each color axis
  105042. * @param scene defines the hosting scene
  105043. */
  105044. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105045. /**
  105046. * Gets camera class name
  105047. * @returns AnaglyphFreeCamera
  105048. */
  105049. getClassName(): string;
  105050. }
  105051. }
  105052. declare module BABYLON {
  105053. /**
  105054. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  105055. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105056. */
  105057. export class AnaglyphGamepadCamera extends GamepadCamera {
  105058. /**
  105059. * Creates a new AnaglyphGamepadCamera
  105060. * @param name defines camera name
  105061. * @param position defines initial position
  105062. * @param interaxialDistance defines distance between each color axis
  105063. * @param scene defines the hosting scene
  105064. */
  105065. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105066. /**
  105067. * Gets camera class name
  105068. * @returns AnaglyphGamepadCamera
  105069. */
  105070. getClassName(): string;
  105071. }
  105072. }
  105073. declare module BABYLON {
  105074. /**
  105075. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  105076. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105077. */
  105078. export class AnaglyphUniversalCamera extends UniversalCamera {
  105079. /**
  105080. * Creates a new AnaglyphUniversalCamera
  105081. * @param name defines camera name
  105082. * @param position defines initial position
  105083. * @param interaxialDistance defines distance between each color axis
  105084. * @param scene defines the hosting scene
  105085. */
  105086. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105087. /**
  105088. * Gets camera class name
  105089. * @returns AnaglyphUniversalCamera
  105090. */
  105091. getClassName(): string;
  105092. }
  105093. }
  105094. declare module BABYLON {
  105095. /** @hidden */
  105096. export var stereoscopicInterlacePixelShader: {
  105097. name: string;
  105098. shader: string;
  105099. };
  105100. }
  105101. declare module BABYLON {
  105102. /**
  105103. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  105104. */
  105105. export class StereoscopicInterlacePostProcess extends PostProcess {
  105106. private _stepSize;
  105107. private _passedProcess;
  105108. /**
  105109. * Initializes a StereoscopicInterlacePostProcess
  105110. * @param name The name of the effect.
  105111. * @param rigCameras The rig cameras to be appled to the post process
  105112. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  105113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105114. * @param engine The engine which the post process will be applied. (default: current engine)
  105115. * @param reusable If the post process can be reused on the same frame. (default: false)
  105116. */
  105117. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105118. }
  105119. }
  105120. declare module BABYLON {
  105121. /**
  105122. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  105123. * @see http://doc.babylonjs.com/features/cameras
  105124. */
  105125. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  105126. /**
  105127. * Creates a new StereoscopicArcRotateCamera
  105128. * @param name defines camera name
  105129. * @param alpha defines alpha angle (in radians)
  105130. * @param beta defines beta angle (in radians)
  105131. * @param radius defines radius
  105132. * @param target defines camera target
  105133. * @param interaxialDistance defines distance between each color axis
  105134. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105135. * @param scene defines the hosting scene
  105136. */
  105137. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105138. /**
  105139. * Gets camera class name
  105140. * @returns StereoscopicArcRotateCamera
  105141. */
  105142. getClassName(): string;
  105143. }
  105144. }
  105145. declare module BABYLON {
  105146. /**
  105147. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  105148. * @see http://doc.babylonjs.com/features/cameras
  105149. */
  105150. export class StereoscopicFreeCamera extends FreeCamera {
  105151. /**
  105152. * Creates a new StereoscopicFreeCamera
  105153. * @param name defines camera name
  105154. * @param position defines initial position
  105155. * @param interaxialDistance defines distance between each color axis
  105156. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105157. * @param scene defines the hosting scene
  105158. */
  105159. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105160. /**
  105161. * Gets camera class name
  105162. * @returns StereoscopicFreeCamera
  105163. */
  105164. getClassName(): string;
  105165. }
  105166. }
  105167. declare module BABYLON {
  105168. /**
  105169. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  105170. * @see http://doc.babylonjs.com/features/cameras
  105171. */
  105172. export class StereoscopicGamepadCamera extends GamepadCamera {
  105173. /**
  105174. * Creates a new StereoscopicGamepadCamera
  105175. * @param name defines camera name
  105176. * @param position defines initial position
  105177. * @param interaxialDistance defines distance between each color axis
  105178. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105179. * @param scene defines the hosting scene
  105180. */
  105181. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105182. /**
  105183. * Gets camera class name
  105184. * @returns StereoscopicGamepadCamera
  105185. */
  105186. getClassName(): string;
  105187. }
  105188. }
  105189. declare module BABYLON {
  105190. /**
  105191. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  105192. * @see http://doc.babylonjs.com/features/cameras
  105193. */
  105194. export class StereoscopicUniversalCamera extends UniversalCamera {
  105195. /**
  105196. * Creates a new StereoscopicUniversalCamera
  105197. * @param name defines camera name
  105198. * @param position defines initial position
  105199. * @param interaxialDistance defines distance between each color axis
  105200. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105201. * @param scene defines the hosting scene
  105202. */
  105203. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105204. /**
  105205. * Gets camera class name
  105206. * @returns StereoscopicUniversalCamera
  105207. */
  105208. getClassName(): string;
  105209. }
  105210. }
  105211. declare module BABYLON {
  105212. /**
  105213. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105214. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105215. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105216. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105217. */
  105218. export class VirtualJoysticksCamera extends FreeCamera {
  105219. /**
  105220. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  105221. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105222. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105223. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105224. * @param name Define the name of the camera in the scene
  105225. * @param position Define the start position of the camera in the scene
  105226. * @param scene Define the scene the camera belongs to
  105227. */
  105228. constructor(name: string, position: Vector3, scene: Scene);
  105229. /**
  105230. * Gets the current object class name.
  105231. * @return the class name
  105232. */
  105233. getClassName(): string;
  105234. }
  105235. }
  105236. declare module BABYLON {
  105237. /**
  105238. * This represents all the required metrics to create a VR camera.
  105239. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  105240. */
  105241. export class VRCameraMetrics {
  105242. /**
  105243. * Define the horizontal resolution off the screen.
  105244. */
  105245. hResolution: number;
  105246. /**
  105247. * Define the vertical resolution off the screen.
  105248. */
  105249. vResolution: number;
  105250. /**
  105251. * Define the horizontal screen size.
  105252. */
  105253. hScreenSize: number;
  105254. /**
  105255. * Define the vertical screen size.
  105256. */
  105257. vScreenSize: number;
  105258. /**
  105259. * Define the vertical screen center position.
  105260. */
  105261. vScreenCenter: number;
  105262. /**
  105263. * Define the distance of the eyes to the screen.
  105264. */
  105265. eyeToScreenDistance: number;
  105266. /**
  105267. * Define the distance between both lenses
  105268. */
  105269. lensSeparationDistance: number;
  105270. /**
  105271. * Define the distance between both viewer's eyes.
  105272. */
  105273. interpupillaryDistance: number;
  105274. /**
  105275. * Define the distortion factor of the VR postprocess.
  105276. * Please, touch with care.
  105277. */
  105278. distortionK: number[];
  105279. /**
  105280. * Define the chromatic aberration correction factors for the VR post process.
  105281. */
  105282. chromaAbCorrection: number[];
  105283. /**
  105284. * Define the scale factor of the post process.
  105285. * The smaller the better but the slower.
  105286. */
  105287. postProcessScaleFactor: number;
  105288. /**
  105289. * Define an offset for the lens center.
  105290. */
  105291. lensCenterOffset: number;
  105292. /**
  105293. * Define if the current vr camera should compensate the distortion of the lense or not.
  105294. */
  105295. compensateDistortion: boolean;
  105296. /**
  105297. * Defines if multiview should be enabled when rendering (Default: false)
  105298. */
  105299. multiviewEnabled: boolean;
  105300. /**
  105301. * Gets the rendering aspect ratio based on the provided resolutions.
  105302. */
  105303. readonly aspectRatio: number;
  105304. /**
  105305. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  105306. */
  105307. readonly aspectRatioFov: number;
  105308. /**
  105309. * @hidden
  105310. */
  105311. readonly leftHMatrix: Matrix;
  105312. /**
  105313. * @hidden
  105314. */
  105315. readonly rightHMatrix: Matrix;
  105316. /**
  105317. * @hidden
  105318. */
  105319. readonly leftPreViewMatrix: Matrix;
  105320. /**
  105321. * @hidden
  105322. */
  105323. readonly rightPreViewMatrix: Matrix;
  105324. /**
  105325. * Get the default VRMetrics based on the most generic setup.
  105326. * @returns the default vr metrics
  105327. */
  105328. static GetDefault(): VRCameraMetrics;
  105329. }
  105330. }
  105331. declare module BABYLON {
  105332. /** @hidden */
  105333. export var vrDistortionCorrectionPixelShader: {
  105334. name: string;
  105335. shader: string;
  105336. };
  105337. }
  105338. declare module BABYLON {
  105339. /**
  105340. * VRDistortionCorrectionPostProcess used for mobile VR
  105341. */
  105342. export class VRDistortionCorrectionPostProcess extends PostProcess {
  105343. private _isRightEye;
  105344. private _distortionFactors;
  105345. private _postProcessScaleFactor;
  105346. private _lensCenterOffset;
  105347. private _scaleIn;
  105348. private _scaleFactor;
  105349. private _lensCenter;
  105350. /**
  105351. * Initializes the VRDistortionCorrectionPostProcess
  105352. * @param name The name of the effect.
  105353. * @param camera The camera to apply the render pass to.
  105354. * @param isRightEye If this is for the right eye distortion
  105355. * @param vrMetrics All the required metrics for the VR camera
  105356. */
  105357. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  105358. }
  105359. }
  105360. declare module BABYLON {
  105361. /**
  105362. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  105363. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105364. */
  105365. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  105366. /**
  105367. * Creates a new VRDeviceOrientationArcRotateCamera
  105368. * @param name defines camera name
  105369. * @param alpha defines the camera rotation along the logitudinal axis
  105370. * @param beta defines the camera rotation along the latitudinal axis
  105371. * @param radius defines the camera distance from its target
  105372. * @param target defines the camera target
  105373. * @param scene defines the scene the camera belongs to
  105374. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105375. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105376. */
  105377. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105378. /**
  105379. * Gets camera class name
  105380. * @returns VRDeviceOrientationArcRotateCamera
  105381. */
  105382. getClassName(): string;
  105383. }
  105384. }
  105385. declare module BABYLON {
  105386. /**
  105387. * Camera used to simulate VR rendering (based on FreeCamera)
  105388. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105389. */
  105390. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  105391. /**
  105392. * Creates a new VRDeviceOrientationFreeCamera
  105393. * @param name defines camera name
  105394. * @param position defines the start position of the camera
  105395. * @param scene defines the scene the camera belongs to
  105396. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105397. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105398. */
  105399. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105400. /**
  105401. * Gets camera class name
  105402. * @returns VRDeviceOrientationFreeCamera
  105403. */
  105404. getClassName(): string;
  105405. }
  105406. }
  105407. declare module BABYLON {
  105408. /**
  105409. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  105410. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105411. */
  105412. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  105413. /**
  105414. * Creates a new VRDeviceOrientationGamepadCamera
  105415. * @param name defines camera name
  105416. * @param position defines the start position of the camera
  105417. * @param scene defines the scene the camera belongs to
  105418. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105419. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105420. */
  105421. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105422. /**
  105423. * Gets camera class name
  105424. * @returns VRDeviceOrientationGamepadCamera
  105425. */
  105426. getClassName(): string;
  105427. }
  105428. }
  105429. declare module BABYLON {
  105430. /**
  105431. * Base class of materials working in push mode in babylon JS
  105432. * @hidden
  105433. */
  105434. export class PushMaterial extends Material {
  105435. protected _activeEffect: Effect;
  105436. protected _normalMatrix: Matrix;
  105437. /**
  105438. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  105439. * This means that the material can keep using a previous shader while a new one is being compiled.
  105440. * This is mostly used when shader parallel compilation is supported (true by default)
  105441. */
  105442. allowShaderHotSwapping: boolean;
  105443. constructor(name: string, scene: Scene);
  105444. getEffect(): Effect;
  105445. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105446. /**
  105447. * Binds the given world matrix to the active effect
  105448. *
  105449. * @param world the matrix to bind
  105450. */
  105451. bindOnlyWorldMatrix(world: Matrix): void;
  105452. /**
  105453. * Binds the given normal matrix to the active effect
  105454. *
  105455. * @param normalMatrix the matrix to bind
  105456. */
  105457. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  105458. bind(world: Matrix, mesh?: Mesh): void;
  105459. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  105460. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  105461. }
  105462. }
  105463. declare module BABYLON {
  105464. /**
  105465. * This groups all the flags used to control the materials channel.
  105466. */
  105467. export class MaterialFlags {
  105468. private static _DiffuseTextureEnabled;
  105469. /**
  105470. * Are diffuse textures enabled in the application.
  105471. */
  105472. static DiffuseTextureEnabled: boolean;
  105473. private static _AmbientTextureEnabled;
  105474. /**
  105475. * Are ambient textures enabled in the application.
  105476. */
  105477. static AmbientTextureEnabled: boolean;
  105478. private static _OpacityTextureEnabled;
  105479. /**
  105480. * Are opacity textures enabled in the application.
  105481. */
  105482. static OpacityTextureEnabled: boolean;
  105483. private static _ReflectionTextureEnabled;
  105484. /**
  105485. * Are reflection textures enabled in the application.
  105486. */
  105487. static ReflectionTextureEnabled: boolean;
  105488. private static _EmissiveTextureEnabled;
  105489. /**
  105490. * Are emissive textures enabled in the application.
  105491. */
  105492. static EmissiveTextureEnabled: boolean;
  105493. private static _SpecularTextureEnabled;
  105494. /**
  105495. * Are specular textures enabled in the application.
  105496. */
  105497. static SpecularTextureEnabled: boolean;
  105498. private static _BumpTextureEnabled;
  105499. /**
  105500. * Are bump textures enabled in the application.
  105501. */
  105502. static BumpTextureEnabled: boolean;
  105503. private static _LightmapTextureEnabled;
  105504. /**
  105505. * Are lightmap textures enabled in the application.
  105506. */
  105507. static LightmapTextureEnabled: boolean;
  105508. private static _RefractionTextureEnabled;
  105509. /**
  105510. * Are refraction textures enabled in the application.
  105511. */
  105512. static RefractionTextureEnabled: boolean;
  105513. private static _ColorGradingTextureEnabled;
  105514. /**
  105515. * Are color grading textures enabled in the application.
  105516. */
  105517. static ColorGradingTextureEnabled: boolean;
  105518. private static _FresnelEnabled;
  105519. /**
  105520. * Are fresnels enabled in the application.
  105521. */
  105522. static FresnelEnabled: boolean;
  105523. private static _ClearCoatTextureEnabled;
  105524. /**
  105525. * Are clear coat textures enabled in the application.
  105526. */
  105527. static ClearCoatTextureEnabled: boolean;
  105528. private static _ClearCoatBumpTextureEnabled;
  105529. /**
  105530. * Are clear coat bump textures enabled in the application.
  105531. */
  105532. static ClearCoatBumpTextureEnabled: boolean;
  105533. private static _ClearCoatTintTextureEnabled;
  105534. /**
  105535. * Are clear coat tint textures enabled in the application.
  105536. */
  105537. static ClearCoatTintTextureEnabled: boolean;
  105538. private static _SheenTextureEnabled;
  105539. /**
  105540. * Are sheen textures enabled in the application.
  105541. */
  105542. static SheenTextureEnabled: boolean;
  105543. private static _AnisotropicTextureEnabled;
  105544. /**
  105545. * Are anisotropic textures enabled in the application.
  105546. */
  105547. static AnisotropicTextureEnabled: boolean;
  105548. private static _ThicknessTextureEnabled;
  105549. /**
  105550. * Are thickness textures enabled in the application.
  105551. */
  105552. static ThicknessTextureEnabled: boolean;
  105553. }
  105554. }
  105555. declare module BABYLON {
  105556. /** @hidden */
  105557. export var defaultFragmentDeclaration: {
  105558. name: string;
  105559. shader: string;
  105560. };
  105561. }
  105562. declare module BABYLON {
  105563. /** @hidden */
  105564. export var defaultUboDeclaration: {
  105565. name: string;
  105566. shader: string;
  105567. };
  105568. }
  105569. declare module BABYLON {
  105570. /** @hidden */
  105571. export var lightFragmentDeclaration: {
  105572. name: string;
  105573. shader: string;
  105574. };
  105575. }
  105576. declare module BABYLON {
  105577. /** @hidden */
  105578. export var lightUboDeclaration: {
  105579. name: string;
  105580. shader: string;
  105581. };
  105582. }
  105583. declare module BABYLON {
  105584. /** @hidden */
  105585. export var lightsFragmentFunctions: {
  105586. name: string;
  105587. shader: string;
  105588. };
  105589. }
  105590. declare module BABYLON {
  105591. /** @hidden */
  105592. export var shadowsFragmentFunctions: {
  105593. name: string;
  105594. shader: string;
  105595. };
  105596. }
  105597. declare module BABYLON {
  105598. /** @hidden */
  105599. export var fresnelFunction: {
  105600. name: string;
  105601. shader: string;
  105602. };
  105603. }
  105604. declare module BABYLON {
  105605. /** @hidden */
  105606. export var reflectionFunction: {
  105607. name: string;
  105608. shader: string;
  105609. };
  105610. }
  105611. declare module BABYLON {
  105612. /** @hidden */
  105613. export var bumpFragmentFunctions: {
  105614. name: string;
  105615. shader: string;
  105616. };
  105617. }
  105618. declare module BABYLON {
  105619. /** @hidden */
  105620. export var logDepthDeclaration: {
  105621. name: string;
  105622. shader: string;
  105623. };
  105624. }
  105625. declare module BABYLON {
  105626. /** @hidden */
  105627. export var bumpFragment: {
  105628. name: string;
  105629. shader: string;
  105630. };
  105631. }
  105632. declare module BABYLON {
  105633. /** @hidden */
  105634. export var depthPrePass: {
  105635. name: string;
  105636. shader: string;
  105637. };
  105638. }
  105639. declare module BABYLON {
  105640. /** @hidden */
  105641. export var lightFragment: {
  105642. name: string;
  105643. shader: string;
  105644. };
  105645. }
  105646. declare module BABYLON {
  105647. /** @hidden */
  105648. export var logDepthFragment: {
  105649. name: string;
  105650. shader: string;
  105651. };
  105652. }
  105653. declare module BABYLON {
  105654. /** @hidden */
  105655. export var defaultPixelShader: {
  105656. name: string;
  105657. shader: string;
  105658. };
  105659. }
  105660. declare module BABYLON {
  105661. /** @hidden */
  105662. export var defaultVertexDeclaration: {
  105663. name: string;
  105664. shader: string;
  105665. };
  105666. }
  105667. declare module BABYLON {
  105668. /** @hidden */
  105669. export var bumpVertexDeclaration: {
  105670. name: string;
  105671. shader: string;
  105672. };
  105673. }
  105674. declare module BABYLON {
  105675. /** @hidden */
  105676. export var bumpVertex: {
  105677. name: string;
  105678. shader: string;
  105679. };
  105680. }
  105681. declare module BABYLON {
  105682. /** @hidden */
  105683. export var fogVertex: {
  105684. name: string;
  105685. shader: string;
  105686. };
  105687. }
  105688. declare module BABYLON {
  105689. /** @hidden */
  105690. export var shadowsVertex: {
  105691. name: string;
  105692. shader: string;
  105693. };
  105694. }
  105695. declare module BABYLON {
  105696. /** @hidden */
  105697. export var pointCloudVertex: {
  105698. name: string;
  105699. shader: string;
  105700. };
  105701. }
  105702. declare module BABYLON {
  105703. /** @hidden */
  105704. export var logDepthVertex: {
  105705. name: string;
  105706. shader: string;
  105707. };
  105708. }
  105709. declare module BABYLON {
  105710. /** @hidden */
  105711. export var defaultVertexShader: {
  105712. name: string;
  105713. shader: string;
  105714. };
  105715. }
  105716. declare module BABYLON {
  105717. /** @hidden */
  105718. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  105719. MAINUV1: boolean;
  105720. MAINUV2: boolean;
  105721. DIFFUSE: boolean;
  105722. DIFFUSEDIRECTUV: number;
  105723. AMBIENT: boolean;
  105724. AMBIENTDIRECTUV: number;
  105725. OPACITY: boolean;
  105726. OPACITYDIRECTUV: number;
  105727. OPACITYRGB: boolean;
  105728. REFLECTION: boolean;
  105729. EMISSIVE: boolean;
  105730. EMISSIVEDIRECTUV: number;
  105731. SPECULAR: boolean;
  105732. SPECULARDIRECTUV: number;
  105733. BUMP: boolean;
  105734. BUMPDIRECTUV: number;
  105735. PARALLAX: boolean;
  105736. PARALLAXOCCLUSION: boolean;
  105737. SPECULAROVERALPHA: boolean;
  105738. CLIPPLANE: boolean;
  105739. CLIPPLANE2: boolean;
  105740. CLIPPLANE3: boolean;
  105741. CLIPPLANE4: boolean;
  105742. ALPHATEST: boolean;
  105743. DEPTHPREPASS: boolean;
  105744. ALPHAFROMDIFFUSE: boolean;
  105745. POINTSIZE: boolean;
  105746. FOG: boolean;
  105747. SPECULARTERM: boolean;
  105748. DIFFUSEFRESNEL: boolean;
  105749. OPACITYFRESNEL: boolean;
  105750. REFLECTIONFRESNEL: boolean;
  105751. REFRACTIONFRESNEL: boolean;
  105752. EMISSIVEFRESNEL: boolean;
  105753. FRESNEL: boolean;
  105754. NORMAL: boolean;
  105755. UV1: boolean;
  105756. UV2: boolean;
  105757. VERTEXCOLOR: boolean;
  105758. VERTEXALPHA: boolean;
  105759. NUM_BONE_INFLUENCERS: number;
  105760. BonesPerMesh: number;
  105761. BONETEXTURE: boolean;
  105762. INSTANCES: boolean;
  105763. GLOSSINESS: boolean;
  105764. ROUGHNESS: boolean;
  105765. EMISSIVEASILLUMINATION: boolean;
  105766. LINKEMISSIVEWITHDIFFUSE: boolean;
  105767. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105768. LIGHTMAP: boolean;
  105769. LIGHTMAPDIRECTUV: number;
  105770. OBJECTSPACE_NORMALMAP: boolean;
  105771. USELIGHTMAPASSHADOWMAP: boolean;
  105772. REFLECTIONMAP_3D: boolean;
  105773. REFLECTIONMAP_SPHERICAL: boolean;
  105774. REFLECTIONMAP_PLANAR: boolean;
  105775. REFLECTIONMAP_CUBIC: boolean;
  105776. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105777. REFLECTIONMAP_PROJECTION: boolean;
  105778. REFLECTIONMAP_SKYBOX: boolean;
  105779. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105780. REFLECTIONMAP_EXPLICIT: boolean;
  105781. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105782. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105783. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105784. INVERTCUBICMAP: boolean;
  105785. LOGARITHMICDEPTH: boolean;
  105786. REFRACTION: boolean;
  105787. REFRACTIONMAP_3D: boolean;
  105788. REFLECTIONOVERALPHA: boolean;
  105789. TWOSIDEDLIGHTING: boolean;
  105790. SHADOWFLOAT: boolean;
  105791. MORPHTARGETS: boolean;
  105792. MORPHTARGETS_NORMAL: boolean;
  105793. MORPHTARGETS_TANGENT: boolean;
  105794. MORPHTARGETS_UV: boolean;
  105795. NUM_MORPH_INFLUENCERS: number;
  105796. NONUNIFORMSCALING: boolean;
  105797. PREMULTIPLYALPHA: boolean;
  105798. IMAGEPROCESSING: boolean;
  105799. VIGNETTE: boolean;
  105800. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105801. VIGNETTEBLENDMODEOPAQUE: boolean;
  105802. TONEMAPPING: boolean;
  105803. TONEMAPPING_ACES: boolean;
  105804. CONTRAST: boolean;
  105805. COLORCURVES: boolean;
  105806. COLORGRADING: boolean;
  105807. COLORGRADING3D: boolean;
  105808. SAMPLER3DGREENDEPTH: boolean;
  105809. SAMPLER3DBGRMAP: boolean;
  105810. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105811. MULTIVIEW: boolean;
  105812. /**
  105813. * If the reflection texture on this material is in linear color space
  105814. * @hidden
  105815. */
  105816. IS_REFLECTION_LINEAR: boolean;
  105817. /**
  105818. * If the refraction texture on this material is in linear color space
  105819. * @hidden
  105820. */
  105821. IS_REFRACTION_LINEAR: boolean;
  105822. EXPOSURE: boolean;
  105823. constructor();
  105824. setReflectionMode(modeToEnable: string): void;
  105825. }
  105826. /**
  105827. * This is the default material used in Babylon. It is the best trade off between quality
  105828. * and performances.
  105829. * @see http://doc.babylonjs.com/babylon101/materials
  105830. */
  105831. export class StandardMaterial extends PushMaterial {
  105832. private _diffuseTexture;
  105833. /**
  105834. * The basic texture of the material as viewed under a light.
  105835. */
  105836. diffuseTexture: Nullable<BaseTexture>;
  105837. private _ambientTexture;
  105838. /**
  105839. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105840. */
  105841. ambientTexture: Nullable<BaseTexture>;
  105842. private _opacityTexture;
  105843. /**
  105844. * Define the transparency of the material from a texture.
  105845. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105846. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105847. */
  105848. opacityTexture: Nullable<BaseTexture>;
  105849. private _reflectionTexture;
  105850. /**
  105851. * Define the texture used to display the reflection.
  105852. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105853. */
  105854. reflectionTexture: Nullable<BaseTexture>;
  105855. private _emissiveTexture;
  105856. /**
  105857. * Define texture of the material as if self lit.
  105858. * This will be mixed in the final result even in the absence of light.
  105859. */
  105860. emissiveTexture: Nullable<BaseTexture>;
  105861. private _specularTexture;
  105862. /**
  105863. * Define how the color and intensity of the highlight given by the light in the material.
  105864. */
  105865. specularTexture: Nullable<BaseTexture>;
  105866. private _bumpTexture;
  105867. /**
  105868. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105869. * 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.
  105870. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  105871. */
  105872. bumpTexture: Nullable<BaseTexture>;
  105873. private _lightmapTexture;
  105874. /**
  105875. * Complex lighting can be computationally expensive to compute at runtime.
  105876. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105877. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  105878. */
  105879. lightmapTexture: Nullable<BaseTexture>;
  105880. private _refractionTexture;
  105881. /**
  105882. * Define the texture used to display the refraction.
  105883. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105884. */
  105885. refractionTexture: Nullable<BaseTexture>;
  105886. /**
  105887. * The color of the material lit by the environmental background lighting.
  105888. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105889. */
  105890. ambientColor: Color3;
  105891. /**
  105892. * The basic color of the material as viewed under a light.
  105893. */
  105894. diffuseColor: Color3;
  105895. /**
  105896. * Define how the color and intensity of the highlight given by the light in the material.
  105897. */
  105898. specularColor: Color3;
  105899. /**
  105900. * Define the color of the material as if self lit.
  105901. * This will be mixed in the final result even in the absence of light.
  105902. */
  105903. emissiveColor: Color3;
  105904. /**
  105905. * Defines how sharp are the highlights in the material.
  105906. * The bigger the value the sharper giving a more glossy feeling to the result.
  105907. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  105908. */
  105909. specularPower: number;
  105910. private _useAlphaFromDiffuseTexture;
  105911. /**
  105912. * Does the transparency come from the diffuse texture alpha channel.
  105913. */
  105914. useAlphaFromDiffuseTexture: boolean;
  105915. private _useEmissiveAsIllumination;
  105916. /**
  105917. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105918. */
  105919. useEmissiveAsIllumination: boolean;
  105920. private _linkEmissiveWithDiffuse;
  105921. /**
  105922. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105923. * the emissive level when the final color is close to one.
  105924. */
  105925. linkEmissiveWithDiffuse: boolean;
  105926. private _useSpecularOverAlpha;
  105927. /**
  105928. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105929. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105930. */
  105931. useSpecularOverAlpha: boolean;
  105932. private _useReflectionOverAlpha;
  105933. /**
  105934. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105935. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105936. */
  105937. useReflectionOverAlpha: boolean;
  105938. private _disableLighting;
  105939. /**
  105940. * Does lights from the scene impacts this material.
  105941. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105942. */
  105943. disableLighting: boolean;
  105944. private _useObjectSpaceNormalMap;
  105945. /**
  105946. * Allows using an object space normal map (instead of tangent space).
  105947. */
  105948. useObjectSpaceNormalMap: boolean;
  105949. private _useParallax;
  105950. /**
  105951. * Is parallax enabled or not.
  105952. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105953. */
  105954. useParallax: boolean;
  105955. private _useParallaxOcclusion;
  105956. /**
  105957. * Is parallax occlusion enabled or not.
  105958. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105959. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105960. */
  105961. useParallaxOcclusion: boolean;
  105962. /**
  105963. * 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.
  105964. */
  105965. parallaxScaleBias: number;
  105966. private _roughness;
  105967. /**
  105968. * Helps to define how blurry the reflections should appears in the material.
  105969. */
  105970. roughness: number;
  105971. /**
  105972. * In case of refraction, define the value of the index of refraction.
  105973. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105974. */
  105975. indexOfRefraction: number;
  105976. /**
  105977. * Invert the refraction texture alongside the y axis.
  105978. * It can be useful with procedural textures or probe for instance.
  105979. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105980. */
  105981. invertRefractionY: boolean;
  105982. /**
  105983. * Defines the alpha limits in alpha test mode.
  105984. */
  105985. alphaCutOff: number;
  105986. private _useLightmapAsShadowmap;
  105987. /**
  105988. * In case of light mapping, define whether the map contains light or shadow informations.
  105989. */
  105990. useLightmapAsShadowmap: boolean;
  105991. private _diffuseFresnelParameters;
  105992. /**
  105993. * Define the diffuse fresnel parameters of the material.
  105994. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105995. */
  105996. diffuseFresnelParameters: FresnelParameters;
  105997. private _opacityFresnelParameters;
  105998. /**
  105999. * Define the opacity fresnel parameters of the material.
  106000. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106001. */
  106002. opacityFresnelParameters: FresnelParameters;
  106003. private _reflectionFresnelParameters;
  106004. /**
  106005. * Define the reflection fresnel parameters of the material.
  106006. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106007. */
  106008. reflectionFresnelParameters: FresnelParameters;
  106009. private _refractionFresnelParameters;
  106010. /**
  106011. * Define the refraction fresnel parameters of the material.
  106012. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106013. */
  106014. refractionFresnelParameters: FresnelParameters;
  106015. private _emissiveFresnelParameters;
  106016. /**
  106017. * Define the emissive fresnel parameters of the material.
  106018. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106019. */
  106020. emissiveFresnelParameters: FresnelParameters;
  106021. private _useReflectionFresnelFromSpecular;
  106022. /**
  106023. * If true automatically deducts the fresnels values from the material specularity.
  106024. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106025. */
  106026. useReflectionFresnelFromSpecular: boolean;
  106027. private _useGlossinessFromSpecularMapAlpha;
  106028. /**
  106029. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106030. */
  106031. useGlossinessFromSpecularMapAlpha: boolean;
  106032. private _maxSimultaneousLights;
  106033. /**
  106034. * Defines the maximum number of lights that can be used in the material
  106035. */
  106036. maxSimultaneousLights: number;
  106037. private _invertNormalMapX;
  106038. /**
  106039. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106040. */
  106041. invertNormalMapX: boolean;
  106042. private _invertNormalMapY;
  106043. /**
  106044. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106045. */
  106046. invertNormalMapY: boolean;
  106047. private _twoSidedLighting;
  106048. /**
  106049. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106050. */
  106051. twoSidedLighting: boolean;
  106052. /**
  106053. * Default configuration related to image processing available in the standard Material.
  106054. */
  106055. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106056. /**
  106057. * Gets the image processing configuration used either in this material.
  106058. */
  106059. /**
  106060. * Sets the Default image processing configuration used either in the this material.
  106061. *
  106062. * If sets to null, the scene one is in use.
  106063. */
  106064. imageProcessingConfiguration: ImageProcessingConfiguration;
  106065. /**
  106066. * Keep track of the image processing observer to allow dispose and replace.
  106067. */
  106068. private _imageProcessingObserver;
  106069. /**
  106070. * Attaches a new image processing configuration to the Standard Material.
  106071. * @param configuration
  106072. */
  106073. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106074. /**
  106075. * Gets wether the color curves effect is enabled.
  106076. */
  106077. /**
  106078. * Sets wether the color curves effect is enabled.
  106079. */
  106080. cameraColorCurvesEnabled: boolean;
  106081. /**
  106082. * Gets wether the color grading effect is enabled.
  106083. */
  106084. /**
  106085. * Gets wether the color grading effect is enabled.
  106086. */
  106087. cameraColorGradingEnabled: boolean;
  106088. /**
  106089. * Gets wether tonemapping is enabled or not.
  106090. */
  106091. /**
  106092. * Sets wether tonemapping is enabled or not
  106093. */
  106094. cameraToneMappingEnabled: boolean;
  106095. /**
  106096. * The camera exposure used on this material.
  106097. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106098. * This corresponds to a photographic exposure.
  106099. */
  106100. /**
  106101. * The camera exposure used on this material.
  106102. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106103. * This corresponds to a photographic exposure.
  106104. */
  106105. cameraExposure: number;
  106106. /**
  106107. * Gets The camera contrast used on this material.
  106108. */
  106109. /**
  106110. * Sets The camera contrast used on this material.
  106111. */
  106112. cameraContrast: number;
  106113. /**
  106114. * Gets the Color Grading 2D Lookup Texture.
  106115. */
  106116. /**
  106117. * Sets the Color Grading 2D Lookup Texture.
  106118. */
  106119. cameraColorGradingTexture: Nullable<BaseTexture>;
  106120. /**
  106121. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106122. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106123. * 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;
  106124. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106125. */
  106126. /**
  106127. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106128. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106129. * 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;
  106130. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106131. */
  106132. cameraColorCurves: Nullable<ColorCurves>;
  106133. /**
  106134. * Custom callback helping to override the default shader used in the material.
  106135. */
  106136. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  106137. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106138. protected _worldViewProjectionMatrix: Matrix;
  106139. protected _globalAmbientColor: Color3;
  106140. protected _useLogarithmicDepth: boolean;
  106141. protected _rebuildInParallel: boolean;
  106142. /**
  106143. * Instantiates a new standard material.
  106144. * This is the default material used in Babylon. It is the best trade off between quality
  106145. * and performances.
  106146. * @see http://doc.babylonjs.com/babylon101/materials
  106147. * @param name Define the name of the material in the scene
  106148. * @param scene Define the scene the material belong to
  106149. */
  106150. constructor(name: string, scene: Scene);
  106151. /**
  106152. * Gets a boolean indicating that current material needs to register RTT
  106153. */
  106154. readonly hasRenderTargetTextures: boolean;
  106155. /**
  106156. * Gets the current class name of the material e.g. "StandardMaterial"
  106157. * Mainly use in serialization.
  106158. * @returns the class name
  106159. */
  106160. getClassName(): string;
  106161. /**
  106162. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106163. * You can try switching to logarithmic depth.
  106164. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106165. */
  106166. useLogarithmicDepth: boolean;
  106167. /**
  106168. * Specifies if the material will require alpha blending
  106169. * @returns a boolean specifying if alpha blending is needed
  106170. */
  106171. needAlphaBlending(): boolean;
  106172. /**
  106173. * Specifies if this material should be rendered in alpha test mode
  106174. * @returns a boolean specifying if an alpha test is needed.
  106175. */
  106176. needAlphaTesting(): boolean;
  106177. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106178. /**
  106179. * Get the texture used for alpha test purpose.
  106180. * @returns the diffuse texture in case of the standard material.
  106181. */
  106182. getAlphaTestTexture(): Nullable<BaseTexture>;
  106183. /**
  106184. * Get if the submesh is ready to be used and all its information available.
  106185. * Child classes can use it to update shaders
  106186. * @param mesh defines the mesh to check
  106187. * @param subMesh defines which submesh to check
  106188. * @param useInstances specifies that instances should be used
  106189. * @returns a boolean indicating that the submesh is ready or not
  106190. */
  106191. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106192. /**
  106193. * Builds the material UBO layouts.
  106194. * Used internally during the effect preparation.
  106195. */
  106196. buildUniformLayout(): void;
  106197. /**
  106198. * Unbinds the material from the mesh
  106199. */
  106200. unbind(): void;
  106201. /**
  106202. * Binds the submesh to this material by preparing the effect and shader to draw
  106203. * @param world defines the world transformation matrix
  106204. * @param mesh defines the mesh containing the submesh
  106205. * @param subMesh defines the submesh to bind the material to
  106206. */
  106207. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106208. /**
  106209. * Get the list of animatables in the material.
  106210. * @returns the list of animatables object used in the material
  106211. */
  106212. getAnimatables(): IAnimatable[];
  106213. /**
  106214. * Gets the active textures from the material
  106215. * @returns an array of textures
  106216. */
  106217. getActiveTextures(): BaseTexture[];
  106218. /**
  106219. * Specifies if the material uses a texture
  106220. * @param texture defines the texture to check against the material
  106221. * @returns a boolean specifying if the material uses the texture
  106222. */
  106223. hasTexture(texture: BaseTexture): boolean;
  106224. /**
  106225. * Disposes the material
  106226. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106227. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106228. */
  106229. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106230. /**
  106231. * Makes a duplicate of the material, and gives it a new name
  106232. * @param name defines the new name for the duplicated material
  106233. * @returns the cloned material
  106234. */
  106235. clone(name: string): StandardMaterial;
  106236. /**
  106237. * Serializes this material in a JSON representation
  106238. * @returns the serialized material object
  106239. */
  106240. serialize(): any;
  106241. /**
  106242. * Creates a standard material from parsed material data
  106243. * @param source defines the JSON representation of the material
  106244. * @param scene defines the hosting scene
  106245. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  106246. * @returns a new standard material
  106247. */
  106248. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  106249. /**
  106250. * Are diffuse textures enabled in the application.
  106251. */
  106252. static DiffuseTextureEnabled: boolean;
  106253. /**
  106254. * Are ambient textures enabled in the application.
  106255. */
  106256. static AmbientTextureEnabled: boolean;
  106257. /**
  106258. * Are opacity textures enabled in the application.
  106259. */
  106260. static OpacityTextureEnabled: boolean;
  106261. /**
  106262. * Are reflection textures enabled in the application.
  106263. */
  106264. static ReflectionTextureEnabled: boolean;
  106265. /**
  106266. * Are emissive textures enabled in the application.
  106267. */
  106268. static EmissiveTextureEnabled: boolean;
  106269. /**
  106270. * Are specular textures enabled in the application.
  106271. */
  106272. static SpecularTextureEnabled: boolean;
  106273. /**
  106274. * Are bump textures enabled in the application.
  106275. */
  106276. static BumpTextureEnabled: boolean;
  106277. /**
  106278. * Are lightmap textures enabled in the application.
  106279. */
  106280. static LightmapTextureEnabled: boolean;
  106281. /**
  106282. * Are refraction textures enabled in the application.
  106283. */
  106284. static RefractionTextureEnabled: boolean;
  106285. /**
  106286. * Are color grading textures enabled in the application.
  106287. */
  106288. static ColorGradingTextureEnabled: boolean;
  106289. /**
  106290. * Are fresnels enabled in the application.
  106291. */
  106292. static FresnelEnabled: boolean;
  106293. }
  106294. }
  106295. declare module BABYLON {
  106296. /** @hidden */
  106297. export var imageProcessingPixelShader: {
  106298. name: string;
  106299. shader: string;
  106300. };
  106301. }
  106302. declare module BABYLON {
  106303. /**
  106304. * ImageProcessingPostProcess
  106305. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  106306. */
  106307. export class ImageProcessingPostProcess extends PostProcess {
  106308. /**
  106309. * Default configuration related to image processing available in the PBR Material.
  106310. */
  106311. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106312. /**
  106313. * Gets the image processing configuration used either in this material.
  106314. */
  106315. /**
  106316. * Sets the Default image processing configuration used either in the this material.
  106317. *
  106318. * If sets to null, the scene one is in use.
  106319. */
  106320. imageProcessingConfiguration: ImageProcessingConfiguration;
  106321. /**
  106322. * Keep track of the image processing observer to allow dispose and replace.
  106323. */
  106324. private _imageProcessingObserver;
  106325. /**
  106326. * Attaches a new image processing configuration to the PBR Material.
  106327. * @param configuration
  106328. */
  106329. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  106330. /**
  106331. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106332. */
  106333. /**
  106334. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106335. */
  106336. colorCurves: Nullable<ColorCurves>;
  106337. /**
  106338. * Gets wether the color curves effect is enabled.
  106339. */
  106340. /**
  106341. * Sets wether the color curves effect is enabled.
  106342. */
  106343. colorCurvesEnabled: boolean;
  106344. /**
  106345. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106346. */
  106347. /**
  106348. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106349. */
  106350. colorGradingTexture: Nullable<BaseTexture>;
  106351. /**
  106352. * Gets wether the color grading effect is enabled.
  106353. */
  106354. /**
  106355. * Gets wether the color grading effect is enabled.
  106356. */
  106357. colorGradingEnabled: boolean;
  106358. /**
  106359. * Gets exposure used in the effect.
  106360. */
  106361. /**
  106362. * Sets exposure used in the effect.
  106363. */
  106364. exposure: number;
  106365. /**
  106366. * Gets wether tonemapping is enabled or not.
  106367. */
  106368. /**
  106369. * Sets wether tonemapping is enabled or not
  106370. */
  106371. toneMappingEnabled: boolean;
  106372. /**
  106373. * Gets the type of tone mapping effect.
  106374. */
  106375. /**
  106376. * Sets the type of tone mapping effect.
  106377. */
  106378. toneMappingType: number;
  106379. /**
  106380. * Gets contrast used in the effect.
  106381. */
  106382. /**
  106383. * Sets contrast used in the effect.
  106384. */
  106385. contrast: number;
  106386. /**
  106387. * Gets Vignette stretch size.
  106388. */
  106389. /**
  106390. * Sets Vignette stretch size.
  106391. */
  106392. vignetteStretch: number;
  106393. /**
  106394. * Gets Vignette centre X Offset.
  106395. */
  106396. /**
  106397. * Sets Vignette centre X Offset.
  106398. */
  106399. vignetteCentreX: number;
  106400. /**
  106401. * Gets Vignette centre Y Offset.
  106402. */
  106403. /**
  106404. * Sets Vignette centre Y Offset.
  106405. */
  106406. vignetteCentreY: number;
  106407. /**
  106408. * Gets Vignette weight or intensity of the vignette effect.
  106409. */
  106410. /**
  106411. * Sets Vignette weight or intensity of the vignette effect.
  106412. */
  106413. vignetteWeight: number;
  106414. /**
  106415. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106416. * if vignetteEnabled is set to true.
  106417. */
  106418. /**
  106419. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106420. * if vignetteEnabled is set to true.
  106421. */
  106422. vignetteColor: Color4;
  106423. /**
  106424. * Gets Camera field of view used by the Vignette effect.
  106425. */
  106426. /**
  106427. * Sets Camera field of view used by the Vignette effect.
  106428. */
  106429. vignetteCameraFov: number;
  106430. /**
  106431. * Gets the vignette blend mode allowing different kind of effect.
  106432. */
  106433. /**
  106434. * Sets the vignette blend mode allowing different kind of effect.
  106435. */
  106436. vignetteBlendMode: number;
  106437. /**
  106438. * Gets wether the vignette effect is enabled.
  106439. */
  106440. /**
  106441. * Sets wether the vignette effect is enabled.
  106442. */
  106443. vignetteEnabled: boolean;
  106444. private _fromLinearSpace;
  106445. /**
  106446. * Gets wether the input of the processing is in Gamma or Linear Space.
  106447. */
  106448. /**
  106449. * Sets wether the input of the processing is in Gamma or Linear Space.
  106450. */
  106451. fromLinearSpace: boolean;
  106452. /**
  106453. * Defines cache preventing GC.
  106454. */
  106455. private _defines;
  106456. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  106457. /**
  106458. * "ImageProcessingPostProcess"
  106459. * @returns "ImageProcessingPostProcess"
  106460. */
  106461. getClassName(): string;
  106462. protected _updateParameters(): void;
  106463. dispose(camera?: Camera): void;
  106464. }
  106465. }
  106466. declare module BABYLON {
  106467. /**
  106468. * Class containing static functions to help procedurally build meshes
  106469. */
  106470. export class GroundBuilder {
  106471. /**
  106472. * Creates a ground mesh
  106473. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106474. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106476. * @param name defines the name of the mesh
  106477. * @param options defines the options used to create the mesh
  106478. * @param scene defines the hosting scene
  106479. * @returns the ground mesh
  106480. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106481. */
  106482. static CreateGround(name: string, options: {
  106483. width?: number;
  106484. height?: number;
  106485. subdivisions?: number;
  106486. subdivisionsX?: number;
  106487. subdivisionsY?: number;
  106488. updatable?: boolean;
  106489. }, scene: any): Mesh;
  106490. /**
  106491. * Creates a tiled ground mesh
  106492. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106493. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106494. * * 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
  106495. * * 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
  106496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106497. * @param name defines the name of the mesh
  106498. * @param options defines the options used to create the mesh
  106499. * @param scene defines the hosting scene
  106500. * @returns the tiled ground mesh
  106501. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106502. */
  106503. static CreateTiledGround(name: string, options: {
  106504. xmin: number;
  106505. zmin: number;
  106506. xmax: number;
  106507. zmax: number;
  106508. subdivisions?: {
  106509. w: number;
  106510. h: number;
  106511. };
  106512. precision?: {
  106513. w: number;
  106514. h: number;
  106515. };
  106516. updatable?: boolean;
  106517. }, scene?: Nullable<Scene>): Mesh;
  106518. /**
  106519. * Creates a ground mesh from a height map
  106520. * * The parameter `url` sets the URL of the height map image resource.
  106521. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106522. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106523. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106524. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106525. * * 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.
  106526. * * 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).
  106527. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106529. * @param name defines the name of the mesh
  106530. * @param url defines the url to the height map
  106531. * @param options defines the options used to create the mesh
  106532. * @param scene defines the hosting scene
  106533. * @returns the ground mesh
  106534. * @see https://doc.babylonjs.com/babylon101/height_map
  106535. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106536. */
  106537. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106538. width?: number;
  106539. height?: number;
  106540. subdivisions?: number;
  106541. minHeight?: number;
  106542. maxHeight?: number;
  106543. colorFilter?: Color3;
  106544. alphaFilter?: number;
  106545. updatable?: boolean;
  106546. onReady?: (mesh: GroundMesh) => void;
  106547. }, scene?: Nullable<Scene>): GroundMesh;
  106548. }
  106549. }
  106550. declare module BABYLON {
  106551. /**
  106552. * Class containing static functions to help procedurally build meshes
  106553. */
  106554. export class TorusBuilder {
  106555. /**
  106556. * Creates a torus mesh
  106557. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106558. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106559. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106561. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106563. * @param name defines the name of the mesh
  106564. * @param options defines the options used to create the mesh
  106565. * @param scene defines the hosting scene
  106566. * @returns the torus mesh
  106567. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106568. */
  106569. static CreateTorus(name: string, options: {
  106570. diameter?: number;
  106571. thickness?: number;
  106572. tessellation?: number;
  106573. updatable?: boolean;
  106574. sideOrientation?: number;
  106575. frontUVs?: Vector4;
  106576. backUVs?: Vector4;
  106577. }, scene: any): Mesh;
  106578. }
  106579. }
  106580. declare module BABYLON {
  106581. /**
  106582. * Class containing static functions to help procedurally build meshes
  106583. */
  106584. export class CylinderBuilder {
  106585. /**
  106586. * Creates a cylinder or a cone mesh
  106587. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106588. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106589. * * 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.
  106590. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106591. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106592. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106593. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106594. * * 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).
  106595. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106596. * * 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).
  106597. * * 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
  106598. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106599. * * 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
  106600. * * 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.
  106601. * * If `enclose` is false, a ring surface is one element.
  106602. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106603. * * 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
  106604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106607. * @param name defines the name of the mesh
  106608. * @param options defines the options used to create the mesh
  106609. * @param scene defines the hosting scene
  106610. * @returns the cylinder mesh
  106611. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106612. */
  106613. static CreateCylinder(name: string, options: {
  106614. height?: number;
  106615. diameterTop?: number;
  106616. diameterBottom?: number;
  106617. diameter?: number;
  106618. tessellation?: number;
  106619. subdivisions?: number;
  106620. arc?: number;
  106621. faceColors?: Color4[];
  106622. faceUV?: Vector4[];
  106623. updatable?: boolean;
  106624. hasRings?: boolean;
  106625. enclose?: boolean;
  106626. cap?: number;
  106627. sideOrientation?: number;
  106628. frontUVs?: Vector4;
  106629. backUVs?: Vector4;
  106630. }, scene: any): Mesh;
  106631. }
  106632. }
  106633. declare module BABYLON {
  106634. /**
  106635. * Options to modify the vr teleportation behavior.
  106636. */
  106637. export interface VRTeleportationOptions {
  106638. /**
  106639. * The name of the mesh which should be used as the teleportation floor. (default: null)
  106640. */
  106641. floorMeshName?: string;
  106642. /**
  106643. * A list of meshes to be used as the teleportation floor. (default: empty)
  106644. */
  106645. floorMeshes?: Mesh[];
  106646. }
  106647. /**
  106648. * Options to modify the vr experience helper's behavior.
  106649. */
  106650. export interface VRExperienceHelperOptions extends WebVROptions {
  106651. /**
  106652. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  106653. */
  106654. createDeviceOrientationCamera?: boolean;
  106655. /**
  106656. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  106657. */
  106658. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  106659. /**
  106660. * Uses the main button on the controller to toggle the laser casted. (default: true)
  106661. */
  106662. laserToggle?: boolean;
  106663. /**
  106664. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  106665. */
  106666. floorMeshes?: Mesh[];
  106667. /**
  106668. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  106669. */
  106670. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  106671. }
  106672. /**
  106673. * Event containing information after VR has been entered
  106674. */
  106675. export class OnAfterEnteringVRObservableEvent {
  106676. /**
  106677. * If entering vr was successful
  106678. */
  106679. success: boolean;
  106680. }
  106681. /**
  106682. * Helps to quickly add VR support to an existing scene.
  106683. * See http://doc.babylonjs.com/how_to/webvr_helper
  106684. */
  106685. export class VRExperienceHelper {
  106686. /** Options to modify the vr experience helper's behavior. */
  106687. webVROptions: VRExperienceHelperOptions;
  106688. private _scene;
  106689. private _position;
  106690. private _btnVR;
  106691. private _btnVRDisplayed;
  106692. private _webVRsupported;
  106693. private _webVRready;
  106694. private _webVRrequesting;
  106695. private _webVRpresenting;
  106696. private _hasEnteredVR;
  106697. private _fullscreenVRpresenting;
  106698. private _canvas;
  106699. private _webVRCamera;
  106700. private _vrDeviceOrientationCamera;
  106701. private _deviceOrientationCamera;
  106702. private _existingCamera;
  106703. private _onKeyDown;
  106704. private _onVrDisplayPresentChange;
  106705. private _onVRDisplayChanged;
  106706. private _onVRRequestPresentStart;
  106707. private _onVRRequestPresentComplete;
  106708. /**
  106709. * 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)
  106710. */
  106711. enableGazeEvenWhenNoPointerLock: boolean;
  106712. /**
  106713. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  106714. */
  106715. exitVROnDoubleTap: boolean;
  106716. /**
  106717. * Observable raised right before entering VR.
  106718. */
  106719. onEnteringVRObservable: Observable<VRExperienceHelper>;
  106720. /**
  106721. * Observable raised when entering VR has completed.
  106722. */
  106723. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  106724. /**
  106725. * Observable raised when exiting VR.
  106726. */
  106727. onExitingVRObservable: Observable<VRExperienceHelper>;
  106728. /**
  106729. * Observable raised when controller mesh is loaded.
  106730. */
  106731. onControllerMeshLoadedObservable: Observable<WebVRController>;
  106732. /** Return this.onEnteringVRObservable
  106733. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  106734. */
  106735. readonly onEnteringVR: Observable<VRExperienceHelper>;
  106736. /** Return this.onExitingVRObservable
  106737. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  106738. */
  106739. readonly onExitingVR: Observable<VRExperienceHelper>;
  106740. /** Return this.onControllerMeshLoadedObservable
  106741. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  106742. */
  106743. readonly onControllerMeshLoaded: Observable<WebVRController>;
  106744. private _rayLength;
  106745. private _useCustomVRButton;
  106746. private _teleportationRequested;
  106747. private _teleportActive;
  106748. private _floorMeshName;
  106749. private _floorMeshesCollection;
  106750. private _rotationAllowed;
  106751. private _teleportBackwardsVector;
  106752. private _teleportationTarget;
  106753. private _isDefaultTeleportationTarget;
  106754. private _postProcessMove;
  106755. private _teleportationFillColor;
  106756. private _teleportationBorderColor;
  106757. private _rotationAngle;
  106758. private _haloCenter;
  106759. private _cameraGazer;
  106760. private _padSensibilityUp;
  106761. private _padSensibilityDown;
  106762. private _leftController;
  106763. private _rightController;
  106764. /**
  106765. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  106766. */
  106767. onNewMeshSelected: Observable<AbstractMesh>;
  106768. /**
  106769. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  106770. * This observable will provide the mesh and the controller used to select the mesh
  106771. */
  106772. onMeshSelectedWithController: Observable<{
  106773. mesh: AbstractMesh;
  106774. controller: WebVRController;
  106775. }>;
  106776. /**
  106777. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  106778. */
  106779. onNewMeshPicked: Observable<PickingInfo>;
  106780. private _circleEase;
  106781. /**
  106782. * Observable raised before camera teleportation
  106783. */
  106784. onBeforeCameraTeleport: Observable<Vector3>;
  106785. /**
  106786. * Observable raised after camera teleportation
  106787. */
  106788. onAfterCameraTeleport: Observable<Vector3>;
  106789. /**
  106790. * Observable raised when current selected mesh gets unselected
  106791. */
  106792. onSelectedMeshUnselected: Observable<AbstractMesh>;
  106793. private _raySelectionPredicate;
  106794. /**
  106795. * To be optionaly changed by user to define custom ray selection
  106796. */
  106797. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  106798. /**
  106799. * To be optionaly changed by user to define custom selection logic (after ray selection)
  106800. */
  106801. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106802. /**
  106803. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  106804. */
  106805. teleportationEnabled: boolean;
  106806. private _defaultHeight;
  106807. private _teleportationInitialized;
  106808. private _interactionsEnabled;
  106809. private _interactionsRequested;
  106810. private _displayGaze;
  106811. private _displayLaserPointer;
  106812. /**
  106813. * The mesh used to display where the user is going to teleport.
  106814. */
  106815. /**
  106816. * Sets the mesh to be used to display where the user is going to teleport.
  106817. */
  106818. teleportationTarget: Mesh;
  106819. /**
  106820. * 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
  106821. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  106822. * See http://doc.babylonjs.com/resources/baking_transformations
  106823. */
  106824. gazeTrackerMesh: Mesh;
  106825. /**
  106826. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  106827. */
  106828. updateGazeTrackerScale: boolean;
  106829. /**
  106830. * If the gaze trackers color should be updated when selecting meshes
  106831. */
  106832. updateGazeTrackerColor: boolean;
  106833. /**
  106834. * If the controller laser color should be updated when selecting meshes
  106835. */
  106836. updateControllerLaserColor: boolean;
  106837. /**
  106838. * The gaze tracking mesh corresponding to the left controller
  106839. */
  106840. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106841. /**
  106842. * The gaze tracking mesh corresponding to the right controller
  106843. */
  106844. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106845. /**
  106846. * If the ray of the gaze should be displayed.
  106847. */
  106848. /**
  106849. * Sets if the ray of the gaze should be displayed.
  106850. */
  106851. displayGaze: boolean;
  106852. /**
  106853. * If the ray of the LaserPointer should be displayed.
  106854. */
  106855. /**
  106856. * Sets if the ray of the LaserPointer should be displayed.
  106857. */
  106858. displayLaserPointer: boolean;
  106859. /**
  106860. * The deviceOrientationCamera used as the camera when not in VR.
  106861. */
  106862. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  106863. /**
  106864. * Based on the current WebVR support, returns the current VR camera used.
  106865. */
  106866. readonly currentVRCamera: Nullable<Camera>;
  106867. /**
  106868. * The webVRCamera which is used when in VR.
  106869. */
  106870. readonly webVRCamera: WebVRFreeCamera;
  106871. /**
  106872. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  106873. */
  106874. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  106875. /**
  106876. * The html button that is used to trigger entering into VR.
  106877. */
  106878. readonly vrButton: Nullable<HTMLButtonElement>;
  106879. private readonly _teleportationRequestInitiated;
  106880. /**
  106881. * Defines wether or not Pointer lock should be requested when switching to
  106882. * full screen.
  106883. */
  106884. requestPointerLockOnFullScreen: boolean;
  106885. /**
  106886. * Instantiates a VRExperienceHelper.
  106887. * Helps to quickly add VR support to an existing scene.
  106888. * @param scene The scene the VRExperienceHelper belongs to.
  106889. * @param webVROptions Options to modify the vr experience helper's behavior.
  106890. */
  106891. constructor(scene: Scene,
  106892. /** Options to modify the vr experience helper's behavior. */
  106893. webVROptions?: VRExperienceHelperOptions);
  106894. private _onDefaultMeshLoaded;
  106895. private _onResize;
  106896. private _onFullscreenChange;
  106897. /**
  106898. * Gets a value indicating if we are currently in VR mode.
  106899. */
  106900. readonly isInVRMode: boolean;
  106901. private onVrDisplayPresentChange;
  106902. private onVRDisplayChanged;
  106903. private moveButtonToBottomRight;
  106904. private displayVRButton;
  106905. private updateButtonVisibility;
  106906. private _cachedAngularSensibility;
  106907. /**
  106908. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  106909. * Otherwise, will use the fullscreen API.
  106910. */
  106911. enterVR(): void;
  106912. /**
  106913. * Attempt to exit VR, or fullscreen.
  106914. */
  106915. exitVR(): void;
  106916. /**
  106917. * The position of the vr experience helper.
  106918. */
  106919. /**
  106920. * Sets the position of the vr experience helper.
  106921. */
  106922. position: Vector3;
  106923. /**
  106924. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  106925. */
  106926. enableInteractions(): void;
  106927. private readonly _noControllerIsActive;
  106928. private beforeRender;
  106929. private _isTeleportationFloor;
  106930. /**
  106931. * Adds a floor mesh to be used for teleportation.
  106932. * @param floorMesh the mesh to be used for teleportation.
  106933. */
  106934. addFloorMesh(floorMesh: Mesh): void;
  106935. /**
  106936. * Removes a floor mesh from being used for teleportation.
  106937. * @param floorMesh the mesh to be removed.
  106938. */
  106939. removeFloorMesh(floorMesh: Mesh): void;
  106940. /**
  106941. * Enables interactions and teleportation using the VR controllers and gaze.
  106942. * @param vrTeleportationOptions options to modify teleportation behavior.
  106943. */
  106944. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  106945. private _onNewGamepadConnected;
  106946. private _tryEnableInteractionOnController;
  106947. private _onNewGamepadDisconnected;
  106948. private _enableInteractionOnController;
  106949. private _checkTeleportWithRay;
  106950. private _checkRotate;
  106951. private _checkTeleportBackwards;
  106952. private _enableTeleportationOnController;
  106953. private _createTeleportationCircles;
  106954. private _displayTeleportationTarget;
  106955. private _hideTeleportationTarget;
  106956. private _rotateCamera;
  106957. private _moveTeleportationSelectorTo;
  106958. private _workingVector;
  106959. private _workingQuaternion;
  106960. private _workingMatrix;
  106961. /**
  106962. * Teleports the users feet to the desired location
  106963. * @param location The location where the user's feet should be placed
  106964. */
  106965. teleportCamera(location: Vector3): void;
  106966. private _convertNormalToDirectionOfRay;
  106967. private _castRayAndSelectObject;
  106968. private _notifySelectedMeshUnselected;
  106969. /**
  106970. * Sets the color of the laser ray from the vr controllers.
  106971. * @param color new color for the ray.
  106972. */
  106973. changeLaserColor(color: Color3): void;
  106974. /**
  106975. * Sets the color of the ray from the vr headsets gaze.
  106976. * @param color new color for the ray.
  106977. */
  106978. changeGazeColor(color: Color3): void;
  106979. /**
  106980. * Exits VR and disposes of the vr experience helper
  106981. */
  106982. dispose(): void;
  106983. /**
  106984. * Gets the name of the VRExperienceHelper class
  106985. * @returns "VRExperienceHelper"
  106986. */
  106987. getClassName(): string;
  106988. }
  106989. }
  106990. declare module BABYLON {
  106991. /**
  106992. * Manages an XRSession to work with Babylon's engine
  106993. * @see https://doc.babylonjs.com/how_to/webxr
  106994. */
  106995. export class WebXRSessionManager implements IDisposable {
  106996. private scene;
  106997. /**
  106998. * Fires every time a new xrFrame arrives which can be used to update the camera
  106999. */
  107000. onXRFrameObservable: Observable<any>;
  107001. /**
  107002. * Fires when the xr session is ended either by the device or manually done
  107003. */
  107004. onXRSessionEnded: Observable<any>;
  107005. /**
  107006. * Underlying xr session
  107007. */
  107008. session: XRSession;
  107009. /**
  107010. * Type of reference space used when creating the session
  107011. */
  107012. referenceSpace: XRReferenceSpace;
  107013. /** @hidden */
  107014. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  107015. /**
  107016. * Current XR frame
  107017. */
  107018. currentFrame: Nullable<XRFrame>;
  107019. private _xrNavigator;
  107020. private baseLayer;
  107021. /**
  107022. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  107023. * @param scene The scene which the session should be created for
  107024. */
  107025. constructor(scene: Scene);
  107026. /**
  107027. * Initializes the manager
  107028. * After initialization enterXR can be called to start an XR session
  107029. * @returns Promise which resolves after it is initialized
  107030. */
  107031. initializeAsync(): Promise<void>;
  107032. /**
  107033. * Initializes an xr session
  107034. * @param xrSessionMode mode to initialize
  107035. * @returns a promise which will resolve once the session has been initialized
  107036. */
  107037. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  107038. /**
  107039. * Sets the reference space on the xr session
  107040. * @param referenceSpace space to set
  107041. * @returns a promise that will resolve once the reference space has been set
  107042. */
  107043. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  107044. /**
  107045. * Updates the render state of the session
  107046. * @param state state to set
  107047. * @returns a promise that resolves once the render state has been updated
  107048. */
  107049. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  107050. /**
  107051. * Starts rendering to the xr layer
  107052. * @returns a promise that will resolve once rendering has started
  107053. */
  107054. startRenderingToXRAsync(): Promise<void>;
  107055. /**
  107056. * Stops the xrSession and restores the renderloop
  107057. * @returns Promise which resolves after it exits XR
  107058. */
  107059. exitXRAsync(): Promise<unknown>;
  107060. /**
  107061. * Checks if a session would be supported for the creation options specified
  107062. * @param sessionMode session mode to check if supported eg. immersive-vr
  107063. * @returns true if supported
  107064. */
  107065. supportsSessionAsync(sessionMode: XRSessionMode): any;
  107066. /**
  107067. * @hidden
  107068. * Converts the render layer of xrSession to a render target
  107069. * @param session session to create render target for
  107070. * @param scene scene the new render target should be created for
  107071. */
  107072. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  107073. /**
  107074. * Disposes of the session manager
  107075. */
  107076. dispose(): void;
  107077. }
  107078. }
  107079. declare module BABYLON {
  107080. /**
  107081. * WebXR Camera which holds the views for the xrSession
  107082. * @see https://doc.babylonjs.com/how_to/webxr
  107083. */
  107084. export class WebXRCamera extends FreeCamera {
  107085. private static _TmpMatrix;
  107086. /**
  107087. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  107088. * @param name the name of the camera
  107089. * @param scene the scene to add the camera to
  107090. */
  107091. constructor(name: string, scene: Scene);
  107092. private _updateNumberOfRigCameras;
  107093. /** @hidden */
  107094. _updateForDualEyeDebugging(pupilDistance?: number): void;
  107095. /**
  107096. * Updates the cameras position from the current pose information of the XR session
  107097. * @param xrSessionManager the session containing pose information
  107098. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  107099. */
  107100. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  107101. }
  107102. }
  107103. declare module BABYLON {
  107104. /**
  107105. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  107106. */
  107107. export class WebXRManagedOutputCanvas implements IDisposable {
  107108. private helper;
  107109. private _canvas;
  107110. /**
  107111. * xrpresent context of the canvas which can be used to display/mirror xr content
  107112. */
  107113. canvasContext: WebGLRenderingContext;
  107114. /**
  107115. * xr layer for the canvas
  107116. */
  107117. xrLayer: Nullable<XRWebGLLayer>;
  107118. /**
  107119. * Initializes the xr layer for the session
  107120. * @param xrSession xr session
  107121. * @returns a promise that will resolve once the XR Layer has been created
  107122. */
  107123. initializeXRLayerAsync(xrSession: any): any;
  107124. /**
  107125. * Initializes the canvas to be added/removed upon entering/exiting xr
  107126. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  107127. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  107128. */
  107129. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  107130. /**
  107131. * Disposes of the object
  107132. */
  107133. dispose(): void;
  107134. private _setManagedOutputCanvas;
  107135. private _addCanvas;
  107136. private _removeCanvas;
  107137. }
  107138. }
  107139. declare module BABYLON {
  107140. /**
  107141. * States of the webXR experience
  107142. */
  107143. export enum WebXRState {
  107144. /**
  107145. * Transitioning to being in XR mode
  107146. */
  107147. ENTERING_XR = 0,
  107148. /**
  107149. * Transitioning to non XR mode
  107150. */
  107151. EXITING_XR = 1,
  107152. /**
  107153. * In XR mode and presenting
  107154. */
  107155. IN_XR = 2,
  107156. /**
  107157. * Not entered XR mode
  107158. */
  107159. NOT_IN_XR = 3
  107160. }
  107161. /**
  107162. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  107163. * @see https://doc.babylonjs.com/how_to/webxr
  107164. */
  107165. export class WebXRExperienceHelper implements IDisposable {
  107166. private scene;
  107167. /**
  107168. * 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
  107169. */
  107170. container: AbstractMesh;
  107171. /**
  107172. * Camera used to render xr content
  107173. */
  107174. camera: WebXRCamera;
  107175. /**
  107176. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  107177. */
  107178. state: WebXRState;
  107179. private _setState;
  107180. private static _TmpVector;
  107181. /**
  107182. * Fires when the state of the experience helper has changed
  107183. */
  107184. onStateChangedObservable: Observable<WebXRState>;
  107185. /** Session manager used to keep track of xr session */
  107186. sessionManager: WebXRSessionManager;
  107187. private _nonVRCamera;
  107188. private _originalSceneAutoClear;
  107189. private _supported;
  107190. /**
  107191. * Creates the experience helper
  107192. * @param scene the scene to attach the experience helper to
  107193. * @returns a promise for the experience helper
  107194. */
  107195. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  107196. /**
  107197. * Creates a WebXRExperienceHelper
  107198. * @param scene The scene the helper should be created in
  107199. */
  107200. private constructor();
  107201. /**
  107202. * Exits XR mode and returns the scene to its original state
  107203. * @returns promise that resolves after xr mode has exited
  107204. */
  107205. exitXRAsync(): Promise<unknown>;
  107206. /**
  107207. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  107208. * @param sessionCreationOptions options for the XR session
  107209. * @param referenceSpaceType frame of reference of the XR session
  107210. * @param outputCanvas the output canvas that will be used to enter XR mode
  107211. * @returns promise that resolves after xr mode has entered
  107212. */
  107213. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  107214. /**
  107215. * Updates the global position of the camera by moving the camera's container
  107216. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  107217. * @param position The desired global position of the camera
  107218. */
  107219. setPositionOfCameraUsingContainer(position: Vector3): void;
  107220. /**
  107221. * Rotates the xr camera by rotating the camera's container around the camera's position
  107222. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  107223. * @param rotation the desired quaternion rotation to apply to the camera
  107224. */
  107225. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  107226. /**
  107227. * Disposes of the experience helper
  107228. */
  107229. dispose(): void;
  107230. }
  107231. }
  107232. declare module BABYLON {
  107233. /**
  107234. * Button which can be used to enter a different mode of XR
  107235. */
  107236. export class WebXREnterExitUIButton {
  107237. /** button element */
  107238. element: HTMLElement;
  107239. /** XR initialization options for the button */
  107240. sessionMode: XRSessionMode;
  107241. /** Reference space type */
  107242. referenceSpaceType: XRReferenceSpaceType;
  107243. /**
  107244. * Creates a WebXREnterExitUIButton
  107245. * @param element button element
  107246. * @param sessionMode XR initialization session mode
  107247. * @param referenceSpaceType the type of reference space to be used
  107248. */
  107249. constructor(
  107250. /** button element */
  107251. element: HTMLElement,
  107252. /** XR initialization options for the button */
  107253. sessionMode: XRSessionMode,
  107254. /** Reference space type */
  107255. referenceSpaceType: XRReferenceSpaceType);
  107256. /**
  107257. * Overwritable function which can be used to update the button's visuals when the state changes
  107258. * @param activeButton the current active button in the UI
  107259. */
  107260. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  107261. }
  107262. /**
  107263. * Options to create the webXR UI
  107264. */
  107265. export class WebXREnterExitUIOptions {
  107266. /**
  107267. * Context to enter xr with
  107268. */
  107269. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  107270. /**
  107271. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  107272. */
  107273. customButtons?: Array<WebXREnterExitUIButton>;
  107274. }
  107275. /**
  107276. * UI to allow the user to enter/exit XR mode
  107277. */
  107278. export class WebXREnterExitUI implements IDisposable {
  107279. private scene;
  107280. private _overlay;
  107281. private _buttons;
  107282. private _activeButton;
  107283. /**
  107284. * Fired every time the active button is changed.
  107285. *
  107286. * When xr is entered via a button that launches xr that button will be the callback parameter
  107287. *
  107288. * When exiting xr the callback parameter will be null)
  107289. */
  107290. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  107291. /**
  107292. * Creates UI to allow the user to enter/exit XR mode
  107293. * @param scene the scene to add the ui to
  107294. * @param helper the xr experience helper to enter/exit xr with
  107295. * @param options options to configure the UI
  107296. * @returns the created ui
  107297. */
  107298. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  107299. private constructor();
  107300. private _updateButtons;
  107301. /**
  107302. * Disposes of the object
  107303. */
  107304. dispose(): void;
  107305. }
  107306. }
  107307. declare module BABYLON {
  107308. /**
  107309. * Represents an XR input
  107310. */
  107311. export class WebXRController {
  107312. private scene;
  107313. /** The underlying input source for the controller */
  107314. inputSource: XRInputSource;
  107315. private parentContainer;
  107316. /**
  107317. * 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
  107318. */
  107319. grip?: AbstractMesh;
  107320. /**
  107321. * Pointer which can be used to select objects or attach a visible laser to
  107322. */
  107323. pointer: AbstractMesh;
  107324. /**
  107325. * Event that fires when the controller is removed/disposed
  107326. */
  107327. onDisposeObservable: Observable<{}>;
  107328. private _tmpMatrix;
  107329. private _tmpQuaternion;
  107330. private _tmpVector;
  107331. /**
  107332. * Creates the controller
  107333. * @see https://doc.babylonjs.com/how_to/webxr
  107334. * @param scene the scene which the controller should be associated to
  107335. * @param inputSource the underlying input source for the controller
  107336. * @param parentContainer parent that the controller meshes should be children of
  107337. */
  107338. constructor(scene: Scene,
  107339. /** The underlying input source for the controller */
  107340. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  107341. /**
  107342. * Updates the controller pose based on the given XRFrame
  107343. * @param xrFrame xr frame to update the pose with
  107344. * @param referenceSpace reference space to use
  107345. */
  107346. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  107347. /**
  107348. * Gets a world space ray coming from the controller
  107349. * @param result the resulting ray
  107350. */
  107351. getWorldPointerRayToRef(result: Ray): void;
  107352. /**
  107353. * Disposes of the object
  107354. */
  107355. dispose(): void;
  107356. }
  107357. }
  107358. declare module BABYLON {
  107359. /**
  107360. * XR input used to track XR inputs such as controllers/rays
  107361. */
  107362. export class WebXRInput implements IDisposable {
  107363. /**
  107364. * Base experience the input listens to
  107365. */
  107366. baseExperience: WebXRExperienceHelper;
  107367. /**
  107368. * XR controllers being tracked
  107369. */
  107370. controllers: Array<WebXRController>;
  107371. private _frameObserver;
  107372. private _stateObserver;
  107373. /**
  107374. * Event when a controller has been connected/added
  107375. */
  107376. onControllerAddedObservable: Observable<WebXRController>;
  107377. /**
  107378. * Event when a controller has been removed/disconnected
  107379. */
  107380. onControllerRemovedObservable: Observable<WebXRController>;
  107381. /**
  107382. * Initializes the WebXRInput
  107383. * @param baseExperience experience helper which the input should be created for
  107384. */
  107385. constructor(
  107386. /**
  107387. * Base experience the input listens to
  107388. */
  107389. baseExperience: WebXRExperienceHelper);
  107390. private _onInputSourcesChange;
  107391. private _addAndRemoveControllers;
  107392. /**
  107393. * Disposes of the object
  107394. */
  107395. dispose(): void;
  107396. }
  107397. }
  107398. declare module BABYLON {
  107399. /**
  107400. * Enables teleportation
  107401. */
  107402. export class WebXRControllerTeleportation {
  107403. private _teleportationFillColor;
  107404. private _teleportationBorderColor;
  107405. private _tmpRay;
  107406. private _tmpVector;
  107407. /**
  107408. * Creates a WebXRControllerTeleportation
  107409. * @param input input manager to add teleportation to
  107410. * @param floorMeshes floormeshes which can be teleported to
  107411. */
  107412. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  107413. }
  107414. }
  107415. declare module BABYLON {
  107416. /**
  107417. * Handles pointer input automatically for the pointer of XR controllers
  107418. */
  107419. export class WebXRControllerPointerSelection {
  107420. private static _idCounter;
  107421. private _tmpRay;
  107422. /**
  107423. * Creates a WebXRControllerPointerSelection
  107424. * @param input input manager to setup pointer selection
  107425. */
  107426. constructor(input: WebXRInput);
  107427. private _convertNormalToDirectionOfRay;
  107428. private _updatePointerDistance;
  107429. }
  107430. }
  107431. declare module BABYLON {
  107432. /**
  107433. * Class used to represent data loading progression
  107434. */
  107435. export class SceneLoaderProgressEvent {
  107436. /** defines if data length to load can be evaluated */
  107437. readonly lengthComputable: boolean;
  107438. /** defines the loaded data length */
  107439. readonly loaded: number;
  107440. /** defines the data length to load */
  107441. readonly total: number;
  107442. /**
  107443. * Create a new progress event
  107444. * @param lengthComputable defines if data length to load can be evaluated
  107445. * @param loaded defines the loaded data length
  107446. * @param total defines the data length to load
  107447. */
  107448. constructor(
  107449. /** defines if data length to load can be evaluated */
  107450. lengthComputable: boolean,
  107451. /** defines the loaded data length */
  107452. loaded: number,
  107453. /** defines the data length to load */
  107454. total: number);
  107455. /**
  107456. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  107457. * @param event defines the source event
  107458. * @returns a new SceneLoaderProgressEvent
  107459. */
  107460. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  107461. }
  107462. /**
  107463. * Interface used by SceneLoader plugins to define supported file extensions
  107464. */
  107465. export interface ISceneLoaderPluginExtensions {
  107466. /**
  107467. * Defines the list of supported extensions
  107468. */
  107469. [extension: string]: {
  107470. isBinary: boolean;
  107471. };
  107472. }
  107473. /**
  107474. * Interface used by SceneLoader plugin factory
  107475. */
  107476. export interface ISceneLoaderPluginFactory {
  107477. /**
  107478. * Defines the name of the factory
  107479. */
  107480. name: string;
  107481. /**
  107482. * Function called to create a new plugin
  107483. * @return the new plugin
  107484. */
  107485. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  107486. /**
  107487. * Boolean indicating if the plugin can direct load specific data
  107488. */
  107489. canDirectLoad?: (data: string) => boolean;
  107490. }
  107491. /**
  107492. * Interface used to define a SceneLoader plugin
  107493. */
  107494. export interface ISceneLoaderPlugin {
  107495. /**
  107496. * The friendly name of this plugin.
  107497. */
  107498. name: string;
  107499. /**
  107500. * The file extensions supported by this plugin.
  107501. */
  107502. extensions: string | ISceneLoaderPluginExtensions;
  107503. /**
  107504. * Import meshes into a scene.
  107505. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107506. * @param scene The scene to import into
  107507. * @param data The data to import
  107508. * @param rootUrl The root url for scene and resources
  107509. * @param meshes The meshes array to import into
  107510. * @param particleSystems The particle systems array to import into
  107511. * @param skeletons The skeletons array to import into
  107512. * @param onError The callback when import fails
  107513. * @returns True if successful or false otherwise
  107514. */
  107515. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  107516. /**
  107517. * Load into a scene.
  107518. * @param scene The scene to load into
  107519. * @param data The data to import
  107520. * @param rootUrl The root url for scene and resources
  107521. * @param onError The callback when import fails
  107522. * @returns true if successful or false otherwise
  107523. */
  107524. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  107525. /**
  107526. * The callback that returns true if the data can be directly loaded.
  107527. */
  107528. canDirectLoad?: (data: string) => boolean;
  107529. /**
  107530. * The callback that allows custom handling of the root url based on the response url.
  107531. */
  107532. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107533. /**
  107534. * Load into an asset container.
  107535. * @param scene The scene to load into
  107536. * @param data The data to import
  107537. * @param rootUrl The root url for scene and resources
  107538. * @param onError The callback when import fails
  107539. * @returns The loaded asset container
  107540. */
  107541. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  107542. }
  107543. /**
  107544. * Interface used to define an async SceneLoader plugin
  107545. */
  107546. export interface ISceneLoaderPluginAsync {
  107547. /**
  107548. * The friendly name of this plugin.
  107549. */
  107550. name: string;
  107551. /**
  107552. * The file extensions supported by this plugin.
  107553. */
  107554. extensions: string | ISceneLoaderPluginExtensions;
  107555. /**
  107556. * Import meshes into a scene.
  107557. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107558. * @param scene The scene to import into
  107559. * @param data The data to import
  107560. * @param rootUrl The root url for scene and resources
  107561. * @param onProgress The callback when the load progresses
  107562. * @param fileName Defines the name of the file to load
  107563. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  107564. */
  107565. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  107566. meshes: AbstractMesh[];
  107567. particleSystems: IParticleSystem[];
  107568. skeletons: Skeleton[];
  107569. animationGroups: AnimationGroup[];
  107570. }>;
  107571. /**
  107572. * Load into a scene.
  107573. * @param scene The scene to load into
  107574. * @param data The data to import
  107575. * @param rootUrl The root url for scene and resources
  107576. * @param onProgress The callback when the load progresses
  107577. * @param fileName Defines the name of the file to load
  107578. * @returns Nothing
  107579. */
  107580. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  107581. /**
  107582. * The callback that returns true if the data can be directly loaded.
  107583. */
  107584. canDirectLoad?: (data: string) => boolean;
  107585. /**
  107586. * The callback that allows custom handling of the root url based on the response url.
  107587. */
  107588. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107589. /**
  107590. * Load into an asset container.
  107591. * @param scene The scene to load into
  107592. * @param data The data to import
  107593. * @param rootUrl The root url for scene and resources
  107594. * @param onProgress The callback when the load progresses
  107595. * @param fileName Defines the name of the file to load
  107596. * @returns The loaded asset container
  107597. */
  107598. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  107599. }
  107600. /**
  107601. * Class used to load scene from various file formats using registered plugins
  107602. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  107603. */
  107604. export class SceneLoader {
  107605. /**
  107606. * No logging while loading
  107607. */
  107608. static readonly NO_LOGGING: number;
  107609. /**
  107610. * Minimal logging while loading
  107611. */
  107612. static readonly MINIMAL_LOGGING: number;
  107613. /**
  107614. * Summary logging while loading
  107615. */
  107616. static readonly SUMMARY_LOGGING: number;
  107617. /**
  107618. * Detailled logging while loading
  107619. */
  107620. static readonly DETAILED_LOGGING: number;
  107621. /**
  107622. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  107623. */
  107624. static ForceFullSceneLoadingForIncremental: boolean;
  107625. /**
  107626. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  107627. */
  107628. static ShowLoadingScreen: boolean;
  107629. /**
  107630. * Defines the current logging level (while loading the scene)
  107631. * @ignorenaming
  107632. */
  107633. static loggingLevel: number;
  107634. /**
  107635. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  107636. */
  107637. static CleanBoneMatrixWeights: boolean;
  107638. /**
  107639. * Event raised when a plugin is used to load a scene
  107640. */
  107641. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  107642. private static _registeredPlugins;
  107643. private static _getDefaultPlugin;
  107644. private static _getPluginForExtension;
  107645. private static _getPluginForDirectLoad;
  107646. private static _getPluginForFilename;
  107647. private static _getDirectLoad;
  107648. private static _loadData;
  107649. private static _getFileInfo;
  107650. /**
  107651. * Gets a plugin that can load the given extension
  107652. * @param extension defines the extension to load
  107653. * @returns a plugin or null if none works
  107654. */
  107655. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  107656. /**
  107657. * Gets a boolean indicating that the given extension can be loaded
  107658. * @param extension defines the extension to load
  107659. * @returns true if the extension is supported
  107660. */
  107661. static IsPluginForExtensionAvailable(extension: string): boolean;
  107662. /**
  107663. * Adds a new plugin to the list of registered plugins
  107664. * @param plugin defines the plugin to add
  107665. */
  107666. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  107667. /**
  107668. * Import meshes into a scene
  107669. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107670. * @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)
  107671. * @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)
  107672. * @param scene the instance of BABYLON.Scene to append to
  107673. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  107674. * @param onProgress a callback with a progress event for each file being loaded
  107675. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107676. * @param pluginExtension the extension used to determine the plugin
  107677. * @returns The loaded plugin
  107678. */
  107679. 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>;
  107680. /**
  107681. * Import meshes into a scene
  107682. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107683. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  107684. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  107685. * @param scene the instance of BABYLON.Scene to append to
  107686. * @param onProgress a callback with a progress event for each file being loaded
  107687. * @param pluginExtension the extension used to determine the plugin
  107688. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  107689. */
  107690. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  107691. meshes: AbstractMesh[];
  107692. particleSystems: IParticleSystem[];
  107693. skeletons: Skeleton[];
  107694. animationGroups: AnimationGroup[];
  107695. }>;
  107696. /**
  107697. * Load a scene
  107698. * @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)
  107699. * @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)
  107700. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107701. * @param onSuccess a callback with the scene when import succeeds
  107702. * @param onProgress a callback with a progress event for each file being loaded
  107703. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107704. * @param pluginExtension the extension used to determine the plugin
  107705. * @returns The loaded plugin
  107706. */
  107707. 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>;
  107708. /**
  107709. * Load a scene
  107710. * @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)
  107711. * @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)
  107712. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107713. * @param onProgress a callback with a progress event for each file being loaded
  107714. * @param pluginExtension the extension used to determine the plugin
  107715. * @returns The loaded scene
  107716. */
  107717. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107718. /**
  107719. * Append a scene
  107720. * @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)
  107721. * @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)
  107722. * @param scene is the instance of BABYLON.Scene to append to
  107723. * @param onSuccess a callback with the scene when import succeeds
  107724. * @param onProgress a callback with a progress event for each file being loaded
  107725. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107726. * @param pluginExtension the extension used to determine the plugin
  107727. * @returns The loaded plugin
  107728. */
  107729. 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>;
  107730. /**
  107731. * Append a scene
  107732. * @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)
  107733. * @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)
  107734. * @param scene is the instance of BABYLON.Scene to append to
  107735. * @param onProgress a callback with a progress event for each file being loaded
  107736. * @param pluginExtension the extension used to determine the plugin
  107737. * @returns The given scene
  107738. */
  107739. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107740. /**
  107741. * Load a scene into an asset container
  107742. * @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)
  107743. * @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)
  107744. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107745. * @param onSuccess a callback with the scene when import succeeds
  107746. * @param onProgress a callback with a progress event for each file being loaded
  107747. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107748. * @param pluginExtension the extension used to determine the plugin
  107749. * @returns The loaded plugin
  107750. */
  107751. 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>;
  107752. /**
  107753. * Load a scene into an asset container
  107754. * @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)
  107755. * @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)
  107756. * @param scene is the instance of Scene to append to
  107757. * @param onProgress a callback with a progress event for each file being loaded
  107758. * @param pluginExtension the extension used to determine the plugin
  107759. * @returns The loaded asset container
  107760. */
  107761. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  107762. }
  107763. }
  107764. declare module BABYLON {
  107765. /**
  107766. * Generic Controller
  107767. */
  107768. export class GenericController extends WebVRController {
  107769. /**
  107770. * Base Url for the controller model.
  107771. */
  107772. static readonly MODEL_BASE_URL: string;
  107773. /**
  107774. * File name for the controller model.
  107775. */
  107776. static readonly MODEL_FILENAME: string;
  107777. /**
  107778. * Creates a new GenericController from a gamepad
  107779. * @param vrGamepad the gamepad that the controller should be created from
  107780. */
  107781. constructor(vrGamepad: any);
  107782. /**
  107783. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107784. * @param scene scene in which to add meshes
  107785. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107786. */
  107787. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107788. /**
  107789. * Called once for each button that changed state since the last frame
  107790. * @param buttonIdx Which button index changed
  107791. * @param state New state of the button
  107792. * @param changes Which properties on the state changed since last frame
  107793. */
  107794. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107795. }
  107796. }
  107797. declare module BABYLON {
  107798. /**
  107799. * Defines the WindowsMotionController object that the state of the windows motion controller
  107800. */
  107801. export class WindowsMotionController extends WebVRController {
  107802. /**
  107803. * The base url used to load the left and right controller models
  107804. */
  107805. static MODEL_BASE_URL: string;
  107806. /**
  107807. * The name of the left controller model file
  107808. */
  107809. static MODEL_LEFT_FILENAME: string;
  107810. /**
  107811. * The name of the right controller model file
  107812. */
  107813. static MODEL_RIGHT_FILENAME: string;
  107814. /**
  107815. * The controller name prefix for this controller type
  107816. */
  107817. static readonly GAMEPAD_ID_PREFIX: string;
  107818. /**
  107819. * The controller id pattern for this controller type
  107820. */
  107821. private static readonly GAMEPAD_ID_PATTERN;
  107822. private _loadedMeshInfo;
  107823. private readonly _mapping;
  107824. /**
  107825. * Fired when the trackpad on this controller is clicked
  107826. */
  107827. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  107828. /**
  107829. * Fired when the trackpad on this controller is modified
  107830. */
  107831. onTrackpadValuesChangedObservable: Observable<StickValues>;
  107832. /**
  107833. * The current x and y values of this controller's trackpad
  107834. */
  107835. trackpad: StickValues;
  107836. /**
  107837. * Creates a new WindowsMotionController from a gamepad
  107838. * @param vrGamepad the gamepad that the controller should be created from
  107839. */
  107840. constructor(vrGamepad: any);
  107841. /**
  107842. * Fired when the trigger on this controller is modified
  107843. */
  107844. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107845. /**
  107846. * Fired when the menu button on this controller is modified
  107847. */
  107848. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107849. /**
  107850. * Fired when the grip button on this controller is modified
  107851. */
  107852. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107853. /**
  107854. * Fired when the thumbstick button on this controller is modified
  107855. */
  107856. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107857. /**
  107858. * Fired when the touchpad button on this controller is modified
  107859. */
  107860. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107861. /**
  107862. * Fired when the touchpad values on this controller are modified
  107863. */
  107864. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  107865. private _updateTrackpad;
  107866. /**
  107867. * Called once per frame by the engine.
  107868. */
  107869. update(): void;
  107870. /**
  107871. * Called once for each button that changed state since the last frame
  107872. * @param buttonIdx Which button index changed
  107873. * @param state New state of the button
  107874. * @param changes Which properties on the state changed since last frame
  107875. */
  107876. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107877. /**
  107878. * Moves the buttons on the controller mesh based on their current state
  107879. * @param buttonName the name of the button to move
  107880. * @param buttonValue the value of the button which determines the buttons new position
  107881. */
  107882. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  107883. /**
  107884. * Moves the axis on the controller mesh based on its current state
  107885. * @param axis the index of the axis
  107886. * @param axisValue the value of the axis which determines the meshes new position
  107887. * @hidden
  107888. */
  107889. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  107890. /**
  107891. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107892. * @param scene scene in which to add meshes
  107893. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107894. */
  107895. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  107896. /**
  107897. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  107898. * can be transformed by button presses and axes values, based on this._mapping.
  107899. *
  107900. * @param scene scene in which the meshes exist
  107901. * @param meshes list of meshes that make up the controller model to process
  107902. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  107903. */
  107904. private processModel;
  107905. private createMeshInfo;
  107906. /**
  107907. * Gets the ray of the controller in the direction the controller is pointing
  107908. * @param length the length the resulting ray should be
  107909. * @returns a ray in the direction the controller is pointing
  107910. */
  107911. getForwardRay(length?: number): Ray;
  107912. /**
  107913. * Disposes of the controller
  107914. */
  107915. dispose(): void;
  107916. }
  107917. }
  107918. declare module BABYLON {
  107919. /**
  107920. * Oculus Touch Controller
  107921. */
  107922. export class OculusTouchController extends WebVRController {
  107923. /**
  107924. * Base Url for the controller model.
  107925. */
  107926. static MODEL_BASE_URL: string;
  107927. /**
  107928. * File name for the left controller model.
  107929. */
  107930. static MODEL_LEFT_FILENAME: string;
  107931. /**
  107932. * File name for the right controller model.
  107933. */
  107934. static MODEL_RIGHT_FILENAME: string;
  107935. /**
  107936. * Base Url for the Quest controller model.
  107937. */
  107938. static QUEST_MODEL_BASE_URL: string;
  107939. /**
  107940. * @hidden
  107941. * If the controllers are running on a device that needs the updated Quest controller models
  107942. */
  107943. static _IsQuest: boolean;
  107944. /**
  107945. * Fired when the secondary trigger on this controller is modified
  107946. */
  107947. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  107948. /**
  107949. * Fired when the thumb rest on this controller is modified
  107950. */
  107951. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  107952. /**
  107953. * Creates a new OculusTouchController from a gamepad
  107954. * @param vrGamepad the gamepad that the controller should be created from
  107955. */
  107956. constructor(vrGamepad: any);
  107957. /**
  107958. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107959. * @param scene scene in which to add meshes
  107960. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107961. */
  107962. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107963. /**
  107964. * Fired when the A button on this controller is modified
  107965. */
  107966. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107967. /**
  107968. * Fired when the B button on this controller is modified
  107969. */
  107970. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107971. /**
  107972. * Fired when the X button on this controller is modified
  107973. */
  107974. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107975. /**
  107976. * Fired when the Y button on this controller is modified
  107977. */
  107978. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107979. /**
  107980. * Called once for each button that changed state since the last frame
  107981. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  107982. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  107983. * 2) secondary trigger (same)
  107984. * 3) A (right) X (left), touch, pressed = value
  107985. * 4) B / Y
  107986. * 5) thumb rest
  107987. * @param buttonIdx Which button index changed
  107988. * @param state New state of the button
  107989. * @param changes Which properties on the state changed since last frame
  107990. */
  107991. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107992. }
  107993. }
  107994. declare module BABYLON {
  107995. /**
  107996. * Vive Controller
  107997. */
  107998. export class ViveController extends WebVRController {
  107999. /**
  108000. * Base Url for the controller model.
  108001. */
  108002. static MODEL_BASE_URL: string;
  108003. /**
  108004. * File name for the controller model.
  108005. */
  108006. static MODEL_FILENAME: string;
  108007. /**
  108008. * Creates a new ViveController from a gamepad
  108009. * @param vrGamepad the gamepad that the controller should be created from
  108010. */
  108011. constructor(vrGamepad: any);
  108012. /**
  108013. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108014. * @param scene scene in which to add meshes
  108015. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108016. */
  108017. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108018. /**
  108019. * Fired when the left button on this controller is modified
  108020. */
  108021. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108022. /**
  108023. * Fired when the right button on this controller is modified
  108024. */
  108025. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108026. /**
  108027. * Fired when the menu button on this controller is modified
  108028. */
  108029. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108030. /**
  108031. * Called once for each button that changed state since the last frame
  108032. * Vive mapping:
  108033. * 0: touchpad
  108034. * 1: trigger
  108035. * 2: left AND right buttons
  108036. * 3: menu button
  108037. * @param buttonIdx Which button index changed
  108038. * @param state New state of the button
  108039. * @param changes Which properties on the state changed since last frame
  108040. */
  108041. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108042. }
  108043. }
  108044. declare module BABYLON {
  108045. /**
  108046. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  108047. */
  108048. export class WebXRControllerModelLoader {
  108049. /**
  108050. * Creates the WebXRControllerModelLoader
  108051. * @param input xr input that creates the controllers
  108052. */
  108053. constructor(input: WebXRInput);
  108054. }
  108055. }
  108056. declare module BABYLON {
  108057. /**
  108058. * Contains an array of blocks representing the octree
  108059. */
  108060. export interface IOctreeContainer<T> {
  108061. /**
  108062. * Blocks within the octree
  108063. */
  108064. blocks: Array<OctreeBlock<T>>;
  108065. }
  108066. /**
  108067. * Class used to store a cell in an octree
  108068. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108069. */
  108070. export class OctreeBlock<T> {
  108071. /**
  108072. * Gets the content of the current block
  108073. */
  108074. entries: T[];
  108075. /**
  108076. * Gets the list of block children
  108077. */
  108078. blocks: Array<OctreeBlock<T>>;
  108079. private _depth;
  108080. private _maxDepth;
  108081. private _capacity;
  108082. private _minPoint;
  108083. private _maxPoint;
  108084. private _boundingVectors;
  108085. private _creationFunc;
  108086. /**
  108087. * Creates a new block
  108088. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  108089. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  108090. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108091. * @param depth defines the current depth of this block in the octree
  108092. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  108093. * @param creationFunc defines a callback to call when an element is added to the block
  108094. */
  108095. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  108096. /**
  108097. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108098. */
  108099. readonly capacity: number;
  108100. /**
  108101. * Gets the minimum vector (in world space) of the block's bounding box
  108102. */
  108103. readonly minPoint: Vector3;
  108104. /**
  108105. * Gets the maximum vector (in world space) of the block's bounding box
  108106. */
  108107. readonly maxPoint: Vector3;
  108108. /**
  108109. * Add a new element to this block
  108110. * @param entry defines the element to add
  108111. */
  108112. addEntry(entry: T): void;
  108113. /**
  108114. * Remove an element from this block
  108115. * @param entry defines the element to remove
  108116. */
  108117. removeEntry(entry: T): void;
  108118. /**
  108119. * Add an array of elements to this block
  108120. * @param entries defines the array of elements to add
  108121. */
  108122. addEntries(entries: T[]): void;
  108123. /**
  108124. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  108125. * @param frustumPlanes defines the frustum planes to test
  108126. * @param selection defines the array to store current content if selection is positive
  108127. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108128. */
  108129. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108130. /**
  108131. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  108132. * @param sphereCenter defines the bounding sphere center
  108133. * @param sphereRadius defines the bounding sphere radius
  108134. * @param selection defines the array to store current content if selection is positive
  108135. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108136. */
  108137. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108138. /**
  108139. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  108140. * @param ray defines the ray to test with
  108141. * @param selection defines the array to store current content if selection is positive
  108142. */
  108143. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  108144. /**
  108145. * Subdivide the content into child blocks (this block will then be empty)
  108146. */
  108147. createInnerBlocks(): void;
  108148. /**
  108149. * @hidden
  108150. */
  108151. 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;
  108152. }
  108153. }
  108154. declare module BABYLON {
  108155. /**
  108156. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  108157. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108158. */
  108159. export class Octree<T> {
  108160. /** 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.) */
  108161. maxDepth: number;
  108162. /**
  108163. * Blocks within the octree containing objects
  108164. */
  108165. blocks: Array<OctreeBlock<T>>;
  108166. /**
  108167. * Content stored in the octree
  108168. */
  108169. dynamicContent: T[];
  108170. private _maxBlockCapacity;
  108171. private _selectionContent;
  108172. private _creationFunc;
  108173. /**
  108174. * Creates a octree
  108175. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108176. * @param creationFunc function to be used to instatiate the octree
  108177. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  108178. * @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.)
  108179. */
  108180. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  108181. /** 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.) */
  108182. maxDepth?: number);
  108183. /**
  108184. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  108185. * @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);
  108186. * @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);
  108187. * @param entries meshes to be added to the octree blocks
  108188. */
  108189. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  108190. /**
  108191. * Adds a mesh to the octree
  108192. * @param entry Mesh to add to the octree
  108193. */
  108194. addMesh(entry: T): void;
  108195. /**
  108196. * Remove an element from the octree
  108197. * @param entry defines the element to remove
  108198. */
  108199. removeMesh(entry: T): void;
  108200. /**
  108201. * Selects an array of meshes within the frustum
  108202. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  108203. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  108204. * @returns array of meshes within the frustum
  108205. */
  108206. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  108207. /**
  108208. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  108209. * @param sphereCenter defines the bounding sphere center
  108210. * @param sphereRadius defines the bounding sphere radius
  108211. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108212. * @returns an array of objects that intersect the sphere
  108213. */
  108214. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  108215. /**
  108216. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  108217. * @param ray defines the ray to test with
  108218. * @returns array of intersected objects
  108219. */
  108220. intersectsRay(ray: Ray): SmartArray<T>;
  108221. /**
  108222. * Adds a mesh into the octree block if it intersects the block
  108223. */
  108224. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  108225. /**
  108226. * Adds a submesh into the octree block if it intersects the block
  108227. */
  108228. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  108229. }
  108230. }
  108231. declare module BABYLON {
  108232. interface Scene {
  108233. /**
  108234. * @hidden
  108235. * Backing Filed
  108236. */
  108237. _selectionOctree: Octree<AbstractMesh>;
  108238. /**
  108239. * Gets the octree used to boost mesh selection (picking)
  108240. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108241. */
  108242. selectionOctree: Octree<AbstractMesh>;
  108243. /**
  108244. * Creates or updates the octree used to boost selection (picking)
  108245. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108246. * @param maxCapacity defines the maximum capacity per leaf
  108247. * @param maxDepth defines the maximum depth of the octree
  108248. * @returns an octree of AbstractMesh
  108249. */
  108250. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  108251. }
  108252. interface AbstractMesh {
  108253. /**
  108254. * @hidden
  108255. * Backing Field
  108256. */
  108257. _submeshesOctree: Octree<SubMesh>;
  108258. /**
  108259. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  108260. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  108261. * @param maxCapacity defines the maximum size of each block (64 by default)
  108262. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  108263. * @returns the new octree
  108264. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  108265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108266. */
  108267. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  108268. }
  108269. /**
  108270. * Defines the octree scene component responsible to manage any octrees
  108271. * in a given scene.
  108272. */
  108273. export class OctreeSceneComponent {
  108274. /**
  108275. * The component name help to identify the component in the list of scene components.
  108276. */
  108277. readonly name: string;
  108278. /**
  108279. * The scene the component belongs to.
  108280. */
  108281. scene: Scene;
  108282. /**
  108283. * Indicates if the meshes have been checked to make sure they are isEnabled()
  108284. */
  108285. readonly checksIsEnabled: boolean;
  108286. /**
  108287. * Creates a new instance of the component for the given scene
  108288. * @param scene Defines the scene to register the component in
  108289. */
  108290. constructor(scene: Scene);
  108291. /**
  108292. * Registers the component in a given scene
  108293. */
  108294. register(): void;
  108295. /**
  108296. * Return the list of active meshes
  108297. * @returns the list of active meshes
  108298. */
  108299. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108300. /**
  108301. * Return the list of active sub meshes
  108302. * @param mesh The mesh to get the candidates sub meshes from
  108303. * @returns the list of active sub meshes
  108304. */
  108305. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108306. private _tempRay;
  108307. /**
  108308. * Return the list of sub meshes intersecting with a given local ray
  108309. * @param mesh defines the mesh to find the submesh for
  108310. * @param localRay defines the ray in local space
  108311. * @returns the list of intersecting sub meshes
  108312. */
  108313. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  108314. /**
  108315. * Return the list of sub meshes colliding with a collider
  108316. * @param mesh defines the mesh to find the submesh for
  108317. * @param collider defines the collider to evaluate the collision against
  108318. * @returns the list of colliding sub meshes
  108319. */
  108320. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  108321. /**
  108322. * Rebuilds the elements related to this component in case of
  108323. * context lost for instance.
  108324. */
  108325. rebuild(): void;
  108326. /**
  108327. * Disposes the component and the associated ressources.
  108328. */
  108329. dispose(): void;
  108330. }
  108331. }
  108332. declare module BABYLON {
  108333. /**
  108334. * Renders a layer on top of an existing scene
  108335. */
  108336. export class UtilityLayerRenderer implements IDisposable {
  108337. /** the original scene that will be rendered on top of */
  108338. originalScene: Scene;
  108339. private _pointerCaptures;
  108340. private _lastPointerEvents;
  108341. private static _DefaultUtilityLayer;
  108342. private static _DefaultKeepDepthUtilityLayer;
  108343. private _sharedGizmoLight;
  108344. private _renderCamera;
  108345. /**
  108346. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  108347. * @returns the camera that is used when rendering the utility layer
  108348. */
  108349. getRenderCamera(): Nullable<Camera>;
  108350. /**
  108351. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  108352. * @param cam the camera that should be used when rendering the utility layer
  108353. */
  108354. setRenderCamera(cam: Nullable<Camera>): void;
  108355. /**
  108356. * @hidden
  108357. * Light which used by gizmos to get light shading
  108358. */
  108359. _getSharedGizmoLight(): HemisphericLight;
  108360. /**
  108361. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  108362. */
  108363. pickUtilitySceneFirst: boolean;
  108364. /**
  108365. * 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)
  108366. */
  108367. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  108368. /**
  108369. * 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)
  108370. */
  108371. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  108372. /**
  108373. * The scene that is rendered on top of the original scene
  108374. */
  108375. utilityLayerScene: Scene;
  108376. /**
  108377. * If the utility layer should automatically be rendered on top of existing scene
  108378. */
  108379. shouldRender: boolean;
  108380. /**
  108381. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  108382. */
  108383. onlyCheckPointerDownEvents: boolean;
  108384. /**
  108385. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  108386. */
  108387. processAllEvents: boolean;
  108388. /**
  108389. * Observable raised when the pointer move from the utility layer scene to the main scene
  108390. */
  108391. onPointerOutObservable: Observable<number>;
  108392. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  108393. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  108394. private _afterRenderObserver;
  108395. private _sceneDisposeObserver;
  108396. private _originalPointerObserver;
  108397. /**
  108398. * Instantiates a UtilityLayerRenderer
  108399. * @param originalScene the original scene that will be rendered on top of
  108400. * @param handleEvents boolean indicating if the utility layer should handle events
  108401. */
  108402. constructor(
  108403. /** the original scene that will be rendered on top of */
  108404. originalScene: Scene, handleEvents?: boolean);
  108405. private _notifyObservers;
  108406. /**
  108407. * Renders the utility layers scene on top of the original scene
  108408. */
  108409. render(): void;
  108410. /**
  108411. * Disposes of the renderer
  108412. */
  108413. dispose(): void;
  108414. private _updateCamera;
  108415. }
  108416. }
  108417. declare module BABYLON {
  108418. /**
  108419. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  108420. */
  108421. export class Gizmo implements IDisposable {
  108422. /** The utility layer the gizmo will be added to */
  108423. gizmoLayer: UtilityLayerRenderer;
  108424. /**
  108425. * The root mesh of the gizmo
  108426. */
  108427. _rootMesh: Mesh;
  108428. private _attachedMesh;
  108429. /**
  108430. * Ratio for the scale of the gizmo (Default: 1)
  108431. */
  108432. scaleRatio: number;
  108433. /**
  108434. * If a custom mesh has been set (Default: false)
  108435. */
  108436. protected _customMeshSet: boolean;
  108437. /**
  108438. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  108439. * * When set, interactions will be enabled
  108440. */
  108441. attachedMesh: Nullable<AbstractMesh>;
  108442. /**
  108443. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108444. * @param mesh The mesh to replace the default mesh of the gizmo
  108445. */
  108446. setCustomMesh(mesh: Mesh): void;
  108447. /**
  108448. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  108449. */
  108450. updateGizmoRotationToMatchAttachedMesh: boolean;
  108451. /**
  108452. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  108453. */
  108454. updateGizmoPositionToMatchAttachedMesh: boolean;
  108455. /**
  108456. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  108457. */
  108458. updateScale: boolean;
  108459. protected _interactionsEnabled: boolean;
  108460. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108461. private _beforeRenderObserver;
  108462. private _tempVector;
  108463. /**
  108464. * Creates a gizmo
  108465. * @param gizmoLayer The utility layer the gizmo will be added to
  108466. */
  108467. constructor(
  108468. /** The utility layer the gizmo will be added to */
  108469. gizmoLayer?: UtilityLayerRenderer);
  108470. /**
  108471. * Updates the gizmo to match the attached mesh's position/rotation
  108472. */
  108473. protected _update(): void;
  108474. /**
  108475. * Disposes of the gizmo
  108476. */
  108477. dispose(): void;
  108478. }
  108479. }
  108480. declare module BABYLON {
  108481. /**
  108482. * Single plane drag gizmo
  108483. */
  108484. export class PlaneDragGizmo extends Gizmo {
  108485. /**
  108486. * Drag behavior responsible for the gizmos dragging interactions
  108487. */
  108488. dragBehavior: PointerDragBehavior;
  108489. private _pointerObserver;
  108490. /**
  108491. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108492. */
  108493. snapDistance: number;
  108494. /**
  108495. * Event that fires each time the gizmo snaps to a new location.
  108496. * * snapDistance is the the change in distance
  108497. */
  108498. onSnapObservable: Observable<{
  108499. snapDistance: number;
  108500. }>;
  108501. private _plane;
  108502. private _coloredMaterial;
  108503. private _hoverMaterial;
  108504. private _isEnabled;
  108505. private _parent;
  108506. /** @hidden */
  108507. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  108508. /** @hidden */
  108509. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108510. /**
  108511. * Creates a PlaneDragGizmo
  108512. * @param gizmoLayer The utility layer the gizmo will be added to
  108513. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  108514. * @param color The color of the gizmo
  108515. */
  108516. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108517. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108518. /**
  108519. * If the gizmo is enabled
  108520. */
  108521. isEnabled: boolean;
  108522. /**
  108523. * Disposes of the gizmo
  108524. */
  108525. dispose(): void;
  108526. }
  108527. }
  108528. declare module BABYLON {
  108529. /**
  108530. * Gizmo that enables dragging a mesh along 3 axis
  108531. */
  108532. export class PositionGizmo extends Gizmo {
  108533. /**
  108534. * Internal gizmo used for interactions on the x axis
  108535. */
  108536. xGizmo: AxisDragGizmo;
  108537. /**
  108538. * Internal gizmo used for interactions on the y axis
  108539. */
  108540. yGizmo: AxisDragGizmo;
  108541. /**
  108542. * Internal gizmo used for interactions on the z axis
  108543. */
  108544. zGizmo: AxisDragGizmo;
  108545. /**
  108546. * Internal gizmo used for interactions on the yz plane
  108547. */
  108548. xPlaneGizmo: PlaneDragGizmo;
  108549. /**
  108550. * Internal gizmo used for interactions on the xz plane
  108551. */
  108552. yPlaneGizmo: PlaneDragGizmo;
  108553. /**
  108554. * Internal gizmo used for interactions on the xy plane
  108555. */
  108556. zPlaneGizmo: PlaneDragGizmo;
  108557. /**
  108558. * private variables
  108559. */
  108560. private _meshAttached;
  108561. private _updateGizmoRotationToMatchAttachedMesh;
  108562. private _snapDistance;
  108563. private _scaleRatio;
  108564. /** Fires an event when any of it's sub gizmos are dragged */
  108565. onDragStartObservable: Observable<unknown>;
  108566. /** Fires an event when any of it's sub gizmos are released from dragging */
  108567. onDragEndObservable: Observable<unknown>;
  108568. /**
  108569. * If set to true, planar drag is enabled
  108570. */
  108571. private _planarGizmoEnabled;
  108572. attachedMesh: Nullable<AbstractMesh>;
  108573. /**
  108574. * Creates a PositionGizmo
  108575. * @param gizmoLayer The utility layer the gizmo will be added to
  108576. */
  108577. constructor(gizmoLayer?: UtilityLayerRenderer);
  108578. /**
  108579. * If the planar drag gizmo is enabled
  108580. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  108581. */
  108582. planarGizmoEnabled: boolean;
  108583. updateGizmoRotationToMatchAttachedMesh: boolean;
  108584. /**
  108585. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108586. */
  108587. snapDistance: number;
  108588. /**
  108589. * Ratio for the scale of the gizmo (Default: 1)
  108590. */
  108591. scaleRatio: number;
  108592. /**
  108593. * Disposes of the gizmo
  108594. */
  108595. dispose(): void;
  108596. /**
  108597. * CustomMeshes are not supported by this gizmo
  108598. * @param mesh The mesh to replace the default mesh of the gizmo
  108599. */
  108600. setCustomMesh(mesh: Mesh): void;
  108601. }
  108602. }
  108603. declare module BABYLON {
  108604. /**
  108605. * Single axis drag gizmo
  108606. */
  108607. export class AxisDragGizmo extends Gizmo {
  108608. /**
  108609. * Drag behavior responsible for the gizmos dragging interactions
  108610. */
  108611. dragBehavior: PointerDragBehavior;
  108612. private _pointerObserver;
  108613. /**
  108614. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108615. */
  108616. snapDistance: number;
  108617. /**
  108618. * Event that fires each time the gizmo snaps to a new location.
  108619. * * snapDistance is the the change in distance
  108620. */
  108621. onSnapObservable: Observable<{
  108622. snapDistance: number;
  108623. }>;
  108624. private _isEnabled;
  108625. private _parent;
  108626. private _arrow;
  108627. private _coloredMaterial;
  108628. private _hoverMaterial;
  108629. /** @hidden */
  108630. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  108631. /** @hidden */
  108632. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108633. /**
  108634. * Creates an AxisDragGizmo
  108635. * @param gizmoLayer The utility layer the gizmo will be added to
  108636. * @param dragAxis The axis which the gizmo will be able to drag on
  108637. * @param color The color of the gizmo
  108638. */
  108639. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108640. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108641. /**
  108642. * If the gizmo is enabled
  108643. */
  108644. isEnabled: boolean;
  108645. /**
  108646. * Disposes of the gizmo
  108647. */
  108648. dispose(): void;
  108649. }
  108650. }
  108651. declare module BABYLON.Debug {
  108652. /**
  108653. * The Axes viewer will show 3 axes in a specific point in space
  108654. */
  108655. export class AxesViewer {
  108656. private _xAxis;
  108657. private _yAxis;
  108658. private _zAxis;
  108659. private _scaleLinesFactor;
  108660. private _instanced;
  108661. /**
  108662. * Gets the hosting scene
  108663. */
  108664. scene: Scene;
  108665. /**
  108666. * Gets or sets a number used to scale line length
  108667. */
  108668. scaleLines: number;
  108669. /** Gets the node hierarchy used to render x-axis */
  108670. readonly xAxis: TransformNode;
  108671. /** Gets the node hierarchy used to render y-axis */
  108672. readonly yAxis: TransformNode;
  108673. /** Gets the node hierarchy used to render z-axis */
  108674. readonly zAxis: TransformNode;
  108675. /**
  108676. * Creates a new AxesViewer
  108677. * @param scene defines the hosting scene
  108678. * @param scaleLines defines a number used to scale line length (1 by default)
  108679. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  108680. * @param xAxis defines the node hierarchy used to render the x-axis
  108681. * @param yAxis defines the node hierarchy used to render the y-axis
  108682. * @param zAxis defines the node hierarchy used to render the z-axis
  108683. */
  108684. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  108685. /**
  108686. * Force the viewer to update
  108687. * @param position defines the position of the viewer
  108688. * @param xaxis defines the x axis of the viewer
  108689. * @param yaxis defines the y axis of the viewer
  108690. * @param zaxis defines the z axis of the viewer
  108691. */
  108692. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  108693. /**
  108694. * Creates an instance of this axes viewer.
  108695. * @returns a new axes viewer with instanced meshes
  108696. */
  108697. createInstance(): AxesViewer;
  108698. /** Releases resources */
  108699. dispose(): void;
  108700. private static _SetRenderingGroupId;
  108701. }
  108702. }
  108703. declare module BABYLON.Debug {
  108704. /**
  108705. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  108706. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  108707. */
  108708. export class BoneAxesViewer extends AxesViewer {
  108709. /**
  108710. * Gets or sets the target mesh where to display the axes viewer
  108711. */
  108712. mesh: Nullable<Mesh>;
  108713. /**
  108714. * Gets or sets the target bone where to display the axes viewer
  108715. */
  108716. bone: Nullable<Bone>;
  108717. /** Gets current position */
  108718. pos: Vector3;
  108719. /** Gets direction of X axis */
  108720. xaxis: Vector3;
  108721. /** Gets direction of Y axis */
  108722. yaxis: Vector3;
  108723. /** Gets direction of Z axis */
  108724. zaxis: Vector3;
  108725. /**
  108726. * Creates a new BoneAxesViewer
  108727. * @param scene defines the hosting scene
  108728. * @param bone defines the target bone
  108729. * @param mesh defines the target mesh
  108730. * @param scaleLines defines a scaling factor for line length (1 by default)
  108731. */
  108732. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  108733. /**
  108734. * Force the viewer to update
  108735. */
  108736. update(): void;
  108737. /** Releases resources */
  108738. dispose(): void;
  108739. }
  108740. }
  108741. declare module BABYLON {
  108742. /**
  108743. * Interface used to define scene explorer extensibility option
  108744. */
  108745. export interface IExplorerExtensibilityOption {
  108746. /**
  108747. * Define the option label
  108748. */
  108749. label: string;
  108750. /**
  108751. * Defines the action to execute on click
  108752. */
  108753. action: (entity: any) => void;
  108754. }
  108755. /**
  108756. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  108757. */
  108758. export interface IExplorerExtensibilityGroup {
  108759. /**
  108760. * Defines a predicate to test if a given type mut be extended
  108761. */
  108762. predicate: (entity: any) => boolean;
  108763. /**
  108764. * Gets the list of options added to a type
  108765. */
  108766. entries: IExplorerExtensibilityOption[];
  108767. }
  108768. /**
  108769. * Interface used to define the options to use to create the Inspector
  108770. */
  108771. export interface IInspectorOptions {
  108772. /**
  108773. * Display in overlay mode (default: false)
  108774. */
  108775. overlay?: boolean;
  108776. /**
  108777. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  108778. */
  108779. globalRoot?: HTMLElement;
  108780. /**
  108781. * Display the Scene explorer
  108782. */
  108783. showExplorer?: boolean;
  108784. /**
  108785. * Display the property inspector
  108786. */
  108787. showInspector?: boolean;
  108788. /**
  108789. * Display in embed mode (both panes on the right)
  108790. */
  108791. embedMode?: boolean;
  108792. /**
  108793. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  108794. */
  108795. handleResize?: boolean;
  108796. /**
  108797. * Allow the panes to popup (default: true)
  108798. */
  108799. enablePopup?: boolean;
  108800. /**
  108801. * Allow the panes to be closed by users (default: true)
  108802. */
  108803. enableClose?: boolean;
  108804. /**
  108805. * Optional list of extensibility entries
  108806. */
  108807. explorerExtensibility?: IExplorerExtensibilityGroup[];
  108808. /**
  108809. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  108810. */
  108811. inspectorURL?: string;
  108812. }
  108813. interface Scene {
  108814. /**
  108815. * @hidden
  108816. * Backing field
  108817. */
  108818. _debugLayer: DebugLayer;
  108819. /**
  108820. * Gets the debug layer (aka Inspector) associated with the scene
  108821. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108822. */
  108823. debugLayer: DebugLayer;
  108824. }
  108825. /**
  108826. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108827. * what is happening in your scene
  108828. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108829. */
  108830. export class DebugLayer {
  108831. /**
  108832. * Define the url to get the inspector script from.
  108833. * By default it uses the babylonjs CDN.
  108834. * @ignoreNaming
  108835. */
  108836. static InspectorURL: string;
  108837. private _scene;
  108838. private BJSINSPECTOR;
  108839. private _onPropertyChangedObservable?;
  108840. /**
  108841. * Observable triggered when a property is changed through the inspector.
  108842. */
  108843. readonly onPropertyChangedObservable: any;
  108844. /**
  108845. * Instantiates a new debug layer.
  108846. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108847. * what is happening in your scene
  108848. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108849. * @param scene Defines the scene to inspect
  108850. */
  108851. constructor(scene: Scene);
  108852. /** Creates the inspector window. */
  108853. private _createInspector;
  108854. /**
  108855. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  108856. * @param entity defines the entity to select
  108857. * @param lineContainerTitle defines the specific block to highlight
  108858. */
  108859. select(entity: any, lineContainerTitle?: string): void;
  108860. /** Get the inspector from bundle or global */
  108861. private _getGlobalInspector;
  108862. /**
  108863. * Get if the inspector is visible or not.
  108864. * @returns true if visible otherwise, false
  108865. */
  108866. isVisible(): boolean;
  108867. /**
  108868. * Hide the inspector and close its window.
  108869. */
  108870. hide(): void;
  108871. /**
  108872. * Launch the debugLayer.
  108873. * @param config Define the configuration of the inspector
  108874. * @return a promise fulfilled when the debug layer is visible
  108875. */
  108876. show(config?: IInspectorOptions): Promise<DebugLayer>;
  108877. }
  108878. }
  108879. declare module BABYLON {
  108880. /**
  108881. * Class containing static functions to help procedurally build meshes
  108882. */
  108883. export class BoxBuilder {
  108884. /**
  108885. * Creates a box mesh
  108886. * * The parameter `size` sets the size (float) of each box side (default 1)
  108887. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  108888. * * 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)
  108889. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108893. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  108894. * @param name defines the name of the mesh
  108895. * @param options defines the options used to create the mesh
  108896. * @param scene defines the hosting scene
  108897. * @returns the box mesh
  108898. */
  108899. static CreateBox(name: string, options: {
  108900. size?: number;
  108901. width?: number;
  108902. height?: number;
  108903. depth?: number;
  108904. faceUV?: Vector4[];
  108905. faceColors?: Color4[];
  108906. sideOrientation?: number;
  108907. frontUVs?: Vector4;
  108908. backUVs?: Vector4;
  108909. wrap?: boolean;
  108910. topBaseAt?: number;
  108911. bottomBaseAt?: number;
  108912. updatable?: boolean;
  108913. }, scene?: Nullable<Scene>): Mesh;
  108914. }
  108915. }
  108916. declare module BABYLON {
  108917. /**
  108918. * Class containing static functions to help procedurally build meshes
  108919. */
  108920. export class SphereBuilder {
  108921. /**
  108922. * Creates a sphere mesh
  108923. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  108924. * * 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`)
  108925. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  108926. * * 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
  108927. * * 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)
  108928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108931. * @param name defines the name of the mesh
  108932. * @param options defines the options used to create the mesh
  108933. * @param scene defines the hosting scene
  108934. * @returns the sphere mesh
  108935. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108936. */
  108937. static CreateSphere(name: string, options: {
  108938. segments?: number;
  108939. diameter?: number;
  108940. diameterX?: number;
  108941. diameterY?: number;
  108942. diameterZ?: number;
  108943. arc?: number;
  108944. slice?: number;
  108945. sideOrientation?: number;
  108946. frontUVs?: Vector4;
  108947. backUVs?: Vector4;
  108948. updatable?: boolean;
  108949. }, scene?: Nullable<Scene>): Mesh;
  108950. }
  108951. }
  108952. declare module BABYLON.Debug {
  108953. /**
  108954. * Used to show the physics impostor around the specific mesh
  108955. */
  108956. export class PhysicsViewer {
  108957. /** @hidden */
  108958. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  108959. /** @hidden */
  108960. protected _meshes: Array<Nullable<AbstractMesh>>;
  108961. /** @hidden */
  108962. protected _scene: Nullable<Scene>;
  108963. /** @hidden */
  108964. protected _numMeshes: number;
  108965. /** @hidden */
  108966. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  108967. private _renderFunction;
  108968. private _utilityLayer;
  108969. private _debugBoxMesh;
  108970. private _debugSphereMesh;
  108971. private _debugCylinderMesh;
  108972. private _debugMaterial;
  108973. private _debugMeshMeshes;
  108974. /**
  108975. * Creates a new PhysicsViewer
  108976. * @param scene defines the hosting scene
  108977. */
  108978. constructor(scene: Scene);
  108979. /** @hidden */
  108980. protected _updateDebugMeshes(): void;
  108981. /**
  108982. * Renders a specified physic impostor
  108983. * @param impostor defines the impostor to render
  108984. * @param targetMesh defines the mesh represented by the impostor
  108985. * @returns the new debug mesh used to render the impostor
  108986. */
  108987. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  108988. /**
  108989. * Hides a specified physic impostor
  108990. * @param impostor defines the impostor to hide
  108991. */
  108992. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  108993. private _getDebugMaterial;
  108994. private _getDebugBoxMesh;
  108995. private _getDebugSphereMesh;
  108996. private _getDebugCylinderMesh;
  108997. private _getDebugMeshMesh;
  108998. private _getDebugMesh;
  108999. /** Releases all resources */
  109000. dispose(): void;
  109001. }
  109002. }
  109003. declare module BABYLON {
  109004. /**
  109005. * Class containing static functions to help procedurally build meshes
  109006. */
  109007. export class LinesBuilder {
  109008. /**
  109009. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109010. * * 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
  109011. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109012. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109013. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109014. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109015. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109016. * * 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
  109017. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109020. * @param name defines the name of the new line system
  109021. * @param options defines the options used to create the line system
  109022. * @param scene defines the hosting scene
  109023. * @returns a new line system mesh
  109024. */
  109025. static CreateLineSystem(name: string, options: {
  109026. lines: Vector3[][];
  109027. updatable?: boolean;
  109028. instance?: Nullable<LinesMesh>;
  109029. colors?: Nullable<Color4[][]>;
  109030. useVertexAlpha?: boolean;
  109031. }, scene: Nullable<Scene>): LinesMesh;
  109032. /**
  109033. * Creates a line mesh
  109034. * 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
  109035. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109036. * * The parameter `points` is an array successive Vector3
  109037. * * 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
  109038. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109039. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109040. * * When updating an instance, remember that only point positions can change, not the number of points
  109041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109043. * @param name defines the name of the new line system
  109044. * @param options defines the options used to create the line system
  109045. * @param scene defines the hosting scene
  109046. * @returns a new line mesh
  109047. */
  109048. static CreateLines(name: string, options: {
  109049. points: Vector3[];
  109050. updatable?: boolean;
  109051. instance?: Nullable<LinesMesh>;
  109052. colors?: Color4[];
  109053. useVertexAlpha?: boolean;
  109054. }, scene?: Nullable<Scene>): LinesMesh;
  109055. /**
  109056. * Creates a dashed line mesh
  109057. * * 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
  109058. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109059. * * The parameter `points` is an array successive Vector3
  109060. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109061. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109062. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109063. * * 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
  109064. * * When updating an instance, remember that only point positions can change, not the number of points
  109065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109066. * @param name defines the name of the mesh
  109067. * @param options defines the options used to create the mesh
  109068. * @param scene defines the hosting scene
  109069. * @returns the dashed line mesh
  109070. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109071. */
  109072. static CreateDashedLines(name: string, options: {
  109073. points: Vector3[];
  109074. dashSize?: number;
  109075. gapSize?: number;
  109076. dashNb?: number;
  109077. updatable?: boolean;
  109078. instance?: LinesMesh;
  109079. }, scene?: Nullable<Scene>): LinesMesh;
  109080. }
  109081. }
  109082. declare module BABYLON {
  109083. /**
  109084. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109085. * in order to better appreciate the issue one might have.
  109086. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109087. */
  109088. export class RayHelper {
  109089. /**
  109090. * Defines the ray we are currently tryin to visualize.
  109091. */
  109092. ray: Nullable<Ray>;
  109093. private _renderPoints;
  109094. private _renderLine;
  109095. private _renderFunction;
  109096. private _scene;
  109097. private _updateToMeshFunction;
  109098. private _attachedToMesh;
  109099. private _meshSpaceDirection;
  109100. private _meshSpaceOrigin;
  109101. /**
  109102. * Helper function to create a colored helper in a scene in one line.
  109103. * @param ray Defines the ray we are currently tryin to visualize
  109104. * @param scene Defines the scene the ray is used in
  109105. * @param color Defines the color we want to see the ray in
  109106. * @returns The newly created ray helper.
  109107. */
  109108. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  109109. /**
  109110. * Instantiate a new ray helper.
  109111. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109112. * in order to better appreciate the issue one might have.
  109113. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109114. * @param ray Defines the ray we are currently tryin to visualize
  109115. */
  109116. constructor(ray: Ray);
  109117. /**
  109118. * Shows the ray we are willing to debug.
  109119. * @param scene Defines the scene the ray needs to be rendered in
  109120. * @param color Defines the color the ray needs to be rendered in
  109121. */
  109122. show(scene: Scene, color?: Color3): void;
  109123. /**
  109124. * Hides the ray we are debugging.
  109125. */
  109126. hide(): void;
  109127. private _render;
  109128. /**
  109129. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  109130. * @param mesh Defines the mesh we want the helper attached to
  109131. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  109132. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  109133. * @param length Defines the length of the ray
  109134. */
  109135. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  109136. /**
  109137. * Detach the ray helper from the mesh it has previously been attached to.
  109138. */
  109139. detachFromMesh(): void;
  109140. private _updateToMesh;
  109141. /**
  109142. * Dispose the helper and release its associated resources.
  109143. */
  109144. dispose(): void;
  109145. }
  109146. }
  109147. declare module BABYLON.Debug {
  109148. /**
  109149. * Class used to render a debug view of a given skeleton
  109150. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  109151. */
  109152. export class SkeletonViewer {
  109153. /** defines the skeleton to render */
  109154. skeleton: Skeleton;
  109155. /** defines the mesh attached to the skeleton */
  109156. mesh: AbstractMesh;
  109157. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109158. autoUpdateBonesMatrices: boolean;
  109159. /** defines the rendering group id to use with the viewer */
  109160. renderingGroupId: number;
  109161. /** Gets or sets the color used to render the skeleton */
  109162. color: Color3;
  109163. private _scene;
  109164. private _debugLines;
  109165. private _debugMesh;
  109166. private _isEnabled;
  109167. private _renderFunction;
  109168. private _utilityLayer;
  109169. /**
  109170. * Returns the mesh used to render the bones
  109171. */
  109172. readonly debugMesh: Nullable<LinesMesh>;
  109173. /**
  109174. * Creates a new SkeletonViewer
  109175. * @param skeleton defines the skeleton to render
  109176. * @param mesh defines the mesh attached to the skeleton
  109177. * @param scene defines the hosting scene
  109178. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  109179. * @param renderingGroupId defines the rendering group id to use with the viewer
  109180. */
  109181. constructor(
  109182. /** defines the skeleton to render */
  109183. skeleton: Skeleton,
  109184. /** defines the mesh attached to the skeleton */
  109185. mesh: AbstractMesh, scene: Scene,
  109186. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109187. autoUpdateBonesMatrices?: boolean,
  109188. /** defines the rendering group id to use with the viewer */
  109189. renderingGroupId?: number);
  109190. /** Gets or sets a boolean indicating if the viewer is enabled */
  109191. isEnabled: boolean;
  109192. private _getBonePosition;
  109193. private _getLinesForBonesWithLength;
  109194. private _getLinesForBonesNoLength;
  109195. /** Update the viewer to sync with current skeleton state */
  109196. update(): void;
  109197. /** Release associated resources */
  109198. dispose(): void;
  109199. }
  109200. }
  109201. declare module BABYLON {
  109202. /**
  109203. * Options to create the null engine
  109204. */
  109205. export class NullEngineOptions {
  109206. /**
  109207. * Render width (Default: 512)
  109208. */
  109209. renderWidth: number;
  109210. /**
  109211. * Render height (Default: 256)
  109212. */
  109213. renderHeight: number;
  109214. /**
  109215. * Texture size (Default: 512)
  109216. */
  109217. textureSize: number;
  109218. /**
  109219. * If delta time between frames should be constant
  109220. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109221. */
  109222. deterministicLockstep: boolean;
  109223. /**
  109224. * Maximum about of steps between frames (Default: 4)
  109225. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109226. */
  109227. lockstepMaxSteps: number;
  109228. }
  109229. /**
  109230. * The null engine class provides support for headless version of babylon.js.
  109231. * This can be used in server side scenario or for testing purposes
  109232. */
  109233. export class NullEngine extends Engine {
  109234. private _options;
  109235. /**
  109236. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109237. */
  109238. isDeterministicLockStep(): boolean;
  109239. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  109240. getLockstepMaxSteps(): number;
  109241. /**
  109242. * Sets hardware scaling, used to save performance if needed
  109243. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109244. */
  109245. getHardwareScalingLevel(): number;
  109246. constructor(options?: NullEngineOptions);
  109247. createVertexBuffer(vertices: FloatArray): DataBuffer;
  109248. createIndexBuffer(indices: IndicesArray): DataBuffer;
  109249. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109250. getRenderWidth(useScreen?: boolean): number;
  109251. getRenderHeight(useScreen?: boolean): number;
  109252. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  109253. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  109254. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  109255. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109256. bindSamplers(effect: Effect): void;
  109257. enableEffect(effect: Effect): void;
  109258. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109259. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109260. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109261. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109262. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109263. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109264. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109265. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109266. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109267. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109268. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109269. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109270. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109271. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109272. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109273. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109274. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109275. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109276. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109277. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109278. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109279. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109280. bindBuffers(vertexBuffers: {
  109281. [key: string]: VertexBuffer;
  109282. }, indexBuffer: DataBuffer, effect: Effect): void;
  109283. wipeCaches(bruteForce?: boolean): void;
  109284. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  109285. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109286. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109287. /** @hidden */
  109288. _createTexture(): WebGLTexture;
  109289. /** @hidden */
  109290. _releaseTexture(texture: InternalTexture): void;
  109291. 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;
  109292. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  109293. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  109294. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  109295. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  109296. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  109297. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  109298. areAllEffectsReady(): boolean;
  109299. /**
  109300. * @hidden
  109301. * Get the current error code of the webGL context
  109302. * @returns the error code
  109303. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  109304. */
  109305. getError(): number;
  109306. /** @hidden */
  109307. _getUnpackAlignement(): number;
  109308. /** @hidden */
  109309. _unpackFlipY(value: boolean): void;
  109310. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  109311. /**
  109312. * Updates a dynamic vertex buffer.
  109313. * @param vertexBuffer the vertex buffer to update
  109314. * @param data the data used to update the vertex buffer
  109315. * @param byteOffset the byte offset of the data (optional)
  109316. * @param byteLength the byte length of the data (optional)
  109317. */
  109318. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  109319. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  109320. /** @hidden */
  109321. _bindTexture(channel: number, texture: InternalTexture): void;
  109322. protected _deleteBuffer(buffer: WebGLBuffer): void;
  109323. releaseEffects(): void;
  109324. displayLoadingUI(): void;
  109325. hideLoadingUI(): void;
  109326. /** @hidden */
  109327. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109328. /** @hidden */
  109329. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109330. /** @hidden */
  109331. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109332. /** @hidden */
  109333. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109334. }
  109335. }
  109336. declare module BABYLON {
  109337. /** @hidden */
  109338. export class _OcclusionDataStorage {
  109339. /** @hidden */
  109340. occlusionInternalRetryCounter: number;
  109341. /** @hidden */
  109342. isOcclusionQueryInProgress: boolean;
  109343. /** @hidden */
  109344. isOccluded: boolean;
  109345. /** @hidden */
  109346. occlusionRetryCount: number;
  109347. /** @hidden */
  109348. occlusionType: number;
  109349. /** @hidden */
  109350. occlusionQueryAlgorithmType: number;
  109351. }
  109352. interface Engine {
  109353. /**
  109354. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  109355. * @return the new query
  109356. */
  109357. createQuery(): WebGLQuery;
  109358. /**
  109359. * Delete and release a webGL query
  109360. * @param query defines the query to delete
  109361. * @return the current engine
  109362. */
  109363. deleteQuery(query: WebGLQuery): Engine;
  109364. /**
  109365. * Check if a given query has resolved and got its value
  109366. * @param query defines the query to check
  109367. * @returns true if the query got its value
  109368. */
  109369. isQueryResultAvailable(query: WebGLQuery): boolean;
  109370. /**
  109371. * Gets the value of a given query
  109372. * @param query defines the query to check
  109373. * @returns the value of the query
  109374. */
  109375. getQueryResult(query: WebGLQuery): number;
  109376. /**
  109377. * Initiates an occlusion query
  109378. * @param algorithmType defines the algorithm to use
  109379. * @param query defines the query to use
  109380. * @returns the current engine
  109381. * @see http://doc.babylonjs.com/features/occlusionquery
  109382. */
  109383. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  109384. /**
  109385. * Ends an occlusion query
  109386. * @see http://doc.babylonjs.com/features/occlusionquery
  109387. * @param algorithmType defines the algorithm to use
  109388. * @returns the current engine
  109389. */
  109390. endOcclusionQuery(algorithmType: number): Engine;
  109391. /**
  109392. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  109393. * Please note that only one query can be issued at a time
  109394. * @returns a time token used to track the time span
  109395. */
  109396. startTimeQuery(): Nullable<_TimeToken>;
  109397. /**
  109398. * Ends a time query
  109399. * @param token defines the token used to measure the time span
  109400. * @returns the time spent (in ns)
  109401. */
  109402. endTimeQuery(token: _TimeToken): int;
  109403. /** @hidden */
  109404. _currentNonTimestampToken: Nullable<_TimeToken>;
  109405. /** @hidden */
  109406. _createTimeQuery(): WebGLQuery;
  109407. /** @hidden */
  109408. _deleteTimeQuery(query: WebGLQuery): void;
  109409. /** @hidden */
  109410. _getGlAlgorithmType(algorithmType: number): number;
  109411. /** @hidden */
  109412. _getTimeQueryResult(query: WebGLQuery): any;
  109413. /** @hidden */
  109414. _getTimeQueryAvailability(query: WebGLQuery): any;
  109415. }
  109416. interface AbstractMesh {
  109417. /**
  109418. * Backing filed
  109419. * @hidden
  109420. */
  109421. __occlusionDataStorage: _OcclusionDataStorage;
  109422. /**
  109423. * Access property
  109424. * @hidden
  109425. */
  109426. _occlusionDataStorage: _OcclusionDataStorage;
  109427. /**
  109428. * 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.
  109429. * The default value is -1 which means don't break the query and wait till the result
  109430. * @see http://doc.babylonjs.com/features/occlusionquery
  109431. */
  109432. occlusionRetryCount: number;
  109433. /**
  109434. * 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:
  109435. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  109436. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  109437. * * 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.
  109438. * @see http://doc.babylonjs.com/features/occlusionquery
  109439. */
  109440. occlusionType: number;
  109441. /**
  109442. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  109443. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  109444. * * 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.
  109445. * @see http://doc.babylonjs.com/features/occlusionquery
  109446. */
  109447. occlusionQueryAlgorithmType: number;
  109448. /**
  109449. * 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
  109450. * @see http://doc.babylonjs.com/features/occlusionquery
  109451. */
  109452. isOccluded: boolean;
  109453. /**
  109454. * Flag to check the progress status of the query
  109455. * @see http://doc.babylonjs.com/features/occlusionquery
  109456. */
  109457. isOcclusionQueryInProgress: boolean;
  109458. }
  109459. }
  109460. declare module BABYLON {
  109461. /** @hidden */
  109462. export var _forceTransformFeedbackToBundle: boolean;
  109463. interface Engine {
  109464. /**
  109465. * Creates a webGL transform feedback object
  109466. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  109467. * @returns the webGL transform feedback object
  109468. */
  109469. createTransformFeedback(): WebGLTransformFeedback;
  109470. /**
  109471. * Delete a webGL transform feedback object
  109472. * @param value defines the webGL transform feedback object to delete
  109473. */
  109474. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  109475. /**
  109476. * Bind a webGL transform feedback object to the webgl context
  109477. * @param value defines the webGL transform feedback object to bind
  109478. */
  109479. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  109480. /**
  109481. * Begins a transform feedback operation
  109482. * @param usePoints defines if points or triangles must be used
  109483. */
  109484. beginTransformFeedback(usePoints: boolean): void;
  109485. /**
  109486. * Ends a transform feedback operation
  109487. */
  109488. endTransformFeedback(): void;
  109489. /**
  109490. * Specify the varyings to use with transform feedback
  109491. * @param program defines the associated webGL program
  109492. * @param value defines the list of strings representing the varying names
  109493. */
  109494. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  109495. /**
  109496. * Bind a webGL buffer for a transform feedback operation
  109497. * @param value defines the webGL buffer to bind
  109498. */
  109499. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  109500. }
  109501. }
  109502. declare module BABYLON {
  109503. /**
  109504. * Creation options of the multi render target texture.
  109505. */
  109506. export interface IMultiRenderTargetOptions {
  109507. /**
  109508. * Define if the texture needs to create mip maps after render.
  109509. */
  109510. generateMipMaps?: boolean;
  109511. /**
  109512. * Define the types of all the draw buffers we want to create
  109513. */
  109514. types?: number[];
  109515. /**
  109516. * Define the sampling modes of all the draw buffers we want to create
  109517. */
  109518. samplingModes?: number[];
  109519. /**
  109520. * Define if a depth buffer is required
  109521. */
  109522. generateDepthBuffer?: boolean;
  109523. /**
  109524. * Define if a stencil buffer is required
  109525. */
  109526. generateStencilBuffer?: boolean;
  109527. /**
  109528. * Define if a depth texture is required instead of a depth buffer
  109529. */
  109530. generateDepthTexture?: boolean;
  109531. /**
  109532. * Define the number of desired draw buffers
  109533. */
  109534. textureCount?: number;
  109535. /**
  109536. * Define if aspect ratio should be adapted to the texture or stay the scene one
  109537. */
  109538. doNotChangeAspectRatio?: boolean;
  109539. /**
  109540. * Define the default type of the buffers we are creating
  109541. */
  109542. defaultType?: number;
  109543. }
  109544. /**
  109545. * A multi render target, like a render target provides the ability to render to a texture.
  109546. * Unlike the render target, it can render to several draw buffers in one draw.
  109547. * This is specially interesting in deferred rendering or for any effects requiring more than
  109548. * just one color from a single pass.
  109549. */
  109550. export class MultiRenderTarget extends RenderTargetTexture {
  109551. private _internalTextures;
  109552. private _textures;
  109553. private _multiRenderTargetOptions;
  109554. /**
  109555. * Get if draw buffers are currently supported by the used hardware and browser.
  109556. */
  109557. readonly isSupported: boolean;
  109558. /**
  109559. * Get the list of textures generated by the multi render target.
  109560. */
  109561. readonly textures: Texture[];
  109562. /**
  109563. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  109564. */
  109565. readonly depthTexture: Texture;
  109566. /**
  109567. * Set the wrapping mode on U of all the textures we are rendering to.
  109568. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109569. */
  109570. wrapU: number;
  109571. /**
  109572. * Set the wrapping mode on V of all the textures we are rendering to.
  109573. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109574. */
  109575. wrapV: number;
  109576. /**
  109577. * Instantiate a new multi render target texture.
  109578. * A multi render target, like a render target provides the ability to render to a texture.
  109579. * Unlike the render target, it can render to several draw buffers in one draw.
  109580. * This is specially interesting in deferred rendering or for any effects requiring more than
  109581. * just one color from a single pass.
  109582. * @param name Define the name of the texture
  109583. * @param size Define the size of the buffers to render to
  109584. * @param count Define the number of target we are rendering into
  109585. * @param scene Define the scene the texture belongs to
  109586. * @param options Define the options used to create the multi render target
  109587. */
  109588. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  109589. /** @hidden */
  109590. _rebuild(): void;
  109591. private _createInternalTextures;
  109592. private _createTextures;
  109593. /**
  109594. * Define the number of samples used if MSAA is enabled.
  109595. */
  109596. samples: number;
  109597. /**
  109598. * Resize all the textures in the multi render target.
  109599. * Be carrefull as it will recreate all the data in the new texture.
  109600. * @param size Define the new size
  109601. */
  109602. resize(size: any): void;
  109603. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109604. /**
  109605. * Dispose the render targets and their associated resources
  109606. */
  109607. dispose(): void;
  109608. /**
  109609. * Release all the underlying texture used as draw buffers.
  109610. */
  109611. releaseInternalTextures(): void;
  109612. }
  109613. }
  109614. declare module BABYLON {
  109615. interface Engine {
  109616. /**
  109617. * Unbind a list of render target textures from the webGL context
  109618. * This is used only when drawBuffer extension or webGL2 are active
  109619. * @param textures defines the render target textures to unbind
  109620. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  109621. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  109622. */
  109623. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  109624. /**
  109625. * Create a multi render target texture
  109626. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  109627. * @param size defines the size of the texture
  109628. * @param options defines the creation options
  109629. * @returns the cube texture as an InternalTexture
  109630. */
  109631. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  109632. /**
  109633. * Update the sample count for a given multiple render target texture
  109634. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  109635. * @param textures defines the textures to update
  109636. * @param samples defines the sample count to set
  109637. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  109638. */
  109639. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  109640. }
  109641. }
  109642. declare module BABYLON {
  109643. /** @hidden */
  109644. export var rgbdEncodePixelShader: {
  109645. name: string;
  109646. shader: string;
  109647. };
  109648. }
  109649. declare module BABYLON {
  109650. /** @hidden */
  109651. export var rgbdDecodePixelShader: {
  109652. name: string;
  109653. shader: string;
  109654. };
  109655. }
  109656. declare module BABYLON {
  109657. /**
  109658. * Raw texture data and descriptor sufficient for WebGL texture upload
  109659. */
  109660. export interface EnvironmentTextureInfo {
  109661. /**
  109662. * Version of the environment map
  109663. */
  109664. version: number;
  109665. /**
  109666. * Width of image
  109667. */
  109668. width: number;
  109669. /**
  109670. * Irradiance information stored in the file.
  109671. */
  109672. irradiance: any;
  109673. /**
  109674. * Specular information stored in the file.
  109675. */
  109676. specular: any;
  109677. }
  109678. /**
  109679. * Defines One Image in the file. It requires only the position in the file
  109680. * as well as the length.
  109681. */
  109682. interface BufferImageData {
  109683. /**
  109684. * Length of the image data.
  109685. */
  109686. length: number;
  109687. /**
  109688. * Position of the data from the null terminator delimiting the end of the JSON.
  109689. */
  109690. position: number;
  109691. }
  109692. /**
  109693. * Defines the specular data enclosed in the file.
  109694. * This corresponds to the version 1 of the data.
  109695. */
  109696. export interface EnvironmentTextureSpecularInfoV1 {
  109697. /**
  109698. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  109699. */
  109700. specularDataPosition?: number;
  109701. /**
  109702. * This contains all the images data needed to reconstruct the cubemap.
  109703. */
  109704. mipmaps: Array<BufferImageData>;
  109705. /**
  109706. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  109707. */
  109708. lodGenerationScale: number;
  109709. }
  109710. /**
  109711. * Sets of helpers addressing the serialization and deserialization of environment texture
  109712. * stored in a BabylonJS env file.
  109713. * Those files are usually stored as .env files.
  109714. */
  109715. export class EnvironmentTextureTools {
  109716. /**
  109717. * Magic number identifying the env file.
  109718. */
  109719. private static _MagicBytes;
  109720. /**
  109721. * Gets the environment info from an env file.
  109722. * @param data The array buffer containing the .env bytes.
  109723. * @returns the environment file info (the json header) if successfully parsed.
  109724. */
  109725. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109726. /**
  109727. * Creates an environment texture from a loaded cube texture.
  109728. * @param texture defines the cube texture to convert in env file
  109729. * @return a promise containing the environment data if succesfull.
  109730. */
  109731. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109732. /**
  109733. * Creates a JSON representation of the spherical data.
  109734. * @param texture defines the texture containing the polynomials
  109735. * @return the JSON representation of the spherical info
  109736. */
  109737. private static _CreateEnvTextureIrradiance;
  109738. /**
  109739. * Creates the ArrayBufferViews used for initializing environment texture image data.
  109740. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  109741. * @param info parameters that determine what views will be created for accessing the underlying buffer
  109742. * @return the views described by info providing access to the underlying buffer
  109743. */
  109744. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  109745. /**
  109746. * Uploads the texture info contained in the env file to the GPU.
  109747. * @param texture defines the internal texture to upload to
  109748. * @param arrayBuffer defines the buffer cotaining the data to load
  109749. * @param info defines the texture info retrieved through the GetEnvInfo method
  109750. * @returns a promise
  109751. */
  109752. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109753. /**
  109754. * Uploads the levels of image data to the GPU.
  109755. * @param texture defines the internal texture to upload to
  109756. * @param imageData defines the array buffer views of image data [mipmap][face]
  109757. * @returns a promise
  109758. */
  109759. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109760. /**
  109761. * Uploads spherical polynomials information to the texture.
  109762. * @param texture defines the texture we are trying to upload the information to
  109763. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109764. */
  109765. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109766. /** @hidden */
  109767. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109768. }
  109769. }
  109770. declare module BABYLON {
  109771. /**
  109772. * Contains position and normal vectors for a vertex
  109773. */
  109774. export class PositionNormalVertex {
  109775. /** the position of the vertex (defaut: 0,0,0) */
  109776. position: Vector3;
  109777. /** the normal of the vertex (defaut: 0,1,0) */
  109778. normal: Vector3;
  109779. /**
  109780. * Creates a PositionNormalVertex
  109781. * @param position the position of the vertex (defaut: 0,0,0)
  109782. * @param normal the normal of the vertex (defaut: 0,1,0)
  109783. */
  109784. constructor(
  109785. /** the position of the vertex (defaut: 0,0,0) */
  109786. position?: Vector3,
  109787. /** the normal of the vertex (defaut: 0,1,0) */
  109788. normal?: Vector3);
  109789. /**
  109790. * Clones the PositionNormalVertex
  109791. * @returns the cloned PositionNormalVertex
  109792. */
  109793. clone(): PositionNormalVertex;
  109794. }
  109795. /**
  109796. * Contains position, normal and uv vectors for a vertex
  109797. */
  109798. export class PositionNormalTextureVertex {
  109799. /** the position of the vertex (defaut: 0,0,0) */
  109800. position: Vector3;
  109801. /** the normal of the vertex (defaut: 0,1,0) */
  109802. normal: Vector3;
  109803. /** the uv of the vertex (default: 0,0) */
  109804. uv: Vector2;
  109805. /**
  109806. * Creates a PositionNormalTextureVertex
  109807. * @param position the position of the vertex (defaut: 0,0,0)
  109808. * @param normal the normal of the vertex (defaut: 0,1,0)
  109809. * @param uv the uv of the vertex (default: 0,0)
  109810. */
  109811. constructor(
  109812. /** the position of the vertex (defaut: 0,0,0) */
  109813. position?: Vector3,
  109814. /** the normal of the vertex (defaut: 0,1,0) */
  109815. normal?: Vector3,
  109816. /** the uv of the vertex (default: 0,0) */
  109817. uv?: Vector2);
  109818. /**
  109819. * Clones the PositionNormalTextureVertex
  109820. * @returns the cloned PositionNormalTextureVertex
  109821. */
  109822. clone(): PositionNormalTextureVertex;
  109823. }
  109824. }
  109825. declare module BABYLON {
  109826. /** @hidden */
  109827. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  109828. private _genericAttributeLocation;
  109829. private _varyingLocationCount;
  109830. private _varyingLocationMap;
  109831. private _replacements;
  109832. private _textureCount;
  109833. private _uniforms;
  109834. lineProcessor(line: string): string;
  109835. attributeProcessor(attribute: string): string;
  109836. varyingProcessor(varying: string, isFragment: boolean): string;
  109837. uniformProcessor(uniform: string): string;
  109838. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  109839. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  109840. }
  109841. }
  109842. declare module BABYLON {
  109843. /**
  109844. * Container for accessors for natively-stored mesh data buffers.
  109845. */
  109846. class NativeDataBuffer extends DataBuffer {
  109847. /**
  109848. * Accessor value used to identify/retrieve a natively-stored index buffer.
  109849. */
  109850. nativeIndexBuffer?: any;
  109851. /**
  109852. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  109853. */
  109854. nativeVertexBuffer?: any;
  109855. }
  109856. /** @hidden */
  109857. export class NativeEngine extends Engine {
  109858. private readonly _native;
  109859. getHardwareScalingLevel(): number;
  109860. constructor();
  109861. /**
  109862. * Can be used to override the current requestAnimationFrame requester.
  109863. * @hidden
  109864. */
  109865. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  109866. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109867. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  109868. createVertexBuffer(data: DataArray): NativeDataBuffer;
  109869. recordVertexArrayObject(vertexBuffers: {
  109870. [key: string]: VertexBuffer;
  109871. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  109872. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109873. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109874. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109875. /**
  109876. * Draw a list of indexed primitives
  109877. * @param fillMode defines the primitive to use
  109878. * @param indexStart defines the starting index
  109879. * @param indexCount defines the number of index to draw
  109880. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109881. */
  109882. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109883. /**
  109884. * Draw a list of unindexed primitives
  109885. * @param fillMode defines the primitive to use
  109886. * @param verticesStart defines the index of first vertex to draw
  109887. * @param verticesCount defines the count of vertices to draw
  109888. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109889. */
  109890. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109891. createPipelineContext(): IPipelineContext;
  109892. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  109893. /** @hidden */
  109894. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  109895. /** @hidden */
  109896. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  109897. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109898. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109899. protected _setProgram(program: WebGLProgram): void;
  109900. _releaseEffect(effect: Effect): void;
  109901. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  109902. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  109903. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  109904. bindSamplers(effect: Effect): void;
  109905. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  109906. getRenderWidth(useScreen?: boolean): number;
  109907. getRenderHeight(useScreen?: boolean): number;
  109908. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  109909. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109910. /**
  109911. * Set the z offset to apply to current rendering
  109912. * @param value defines the offset to apply
  109913. */
  109914. setZOffset(value: number): void;
  109915. /**
  109916. * Gets the current value of the zOffset
  109917. * @returns the current zOffset state
  109918. */
  109919. getZOffset(): number;
  109920. /**
  109921. * Enable or disable depth buffering
  109922. * @param enable defines the state to set
  109923. */
  109924. setDepthBuffer(enable: boolean): void;
  109925. /**
  109926. * Gets a boolean indicating if depth writing is enabled
  109927. * @returns the current depth writing state
  109928. */
  109929. getDepthWrite(): boolean;
  109930. /**
  109931. * Enable or disable depth writing
  109932. * @param enable defines the state to set
  109933. */
  109934. setDepthWrite(enable: boolean): void;
  109935. /**
  109936. * Enable or disable color writing
  109937. * @param enable defines the state to set
  109938. */
  109939. setColorWrite(enable: boolean): void;
  109940. /**
  109941. * Gets a boolean indicating if color writing is enabled
  109942. * @returns the current color writing state
  109943. */
  109944. getColorWrite(): boolean;
  109945. /**
  109946. * Sets alpha constants used by some alpha blending modes
  109947. * @param r defines the red component
  109948. * @param g defines the green component
  109949. * @param b defines the blue component
  109950. * @param a defines the alpha component
  109951. */
  109952. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  109953. /**
  109954. * Sets the current alpha mode
  109955. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  109956. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109957. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109958. */
  109959. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109960. /**
  109961. * Gets the current alpha mode
  109962. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109963. * @returns the current alpha mode
  109964. */
  109965. getAlphaMode(): number;
  109966. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109967. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109968. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109969. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109970. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109971. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109972. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109973. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109974. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109975. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109976. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109977. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109978. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109979. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109980. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109981. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109982. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109983. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109984. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109985. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109986. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  109987. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  109988. wipeCaches(bruteForce?: boolean): void;
  109989. _createTexture(): WebGLTexture;
  109990. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  109991. /**
  109992. * Usually called from BABYLON.Texture.ts.
  109993. * Passed information to create a WebGLTexture
  109994. * @param urlArg defines a value which contains one of the following:
  109995. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  109996. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  109997. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  109998. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  109999. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  110000. * @param scene needed for loading to the correct scene
  110001. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  110002. * @param onLoad optional callback to be called upon successful completion
  110003. * @param onError optional callback to be called upon failure
  110004. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  110005. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110006. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110007. * @param forcedExtension defines the extension to use to pick the right loader
  110008. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110009. */
  110010. 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;
  110011. /**
  110012. * Creates a cube texture
  110013. * @param rootUrl defines the url where the files to load is located
  110014. * @param scene defines the current scene
  110015. * @param files defines the list of files to load (1 per face)
  110016. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  110017. * @param onLoad defines an optional callback raised when the texture is loaded
  110018. * @param onError defines an optional callback raised if there is an issue to load the texture
  110019. * @param format defines the format of the data
  110020. * @param forcedExtension defines the extension to use to pick the right loader
  110021. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  110022. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  110023. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  110024. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  110025. * @returns the cube texture as an InternalTexture
  110026. */
  110027. 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;
  110028. private _getSamplingFilter;
  110029. private static _GetNativeTextureFormat;
  110030. createRenderTargetTexture(size: number | {
  110031. width: number;
  110032. height: number;
  110033. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110034. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110035. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110036. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110037. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  110038. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110039. /**
  110040. * Updates a dynamic vertex buffer.
  110041. * @param vertexBuffer the vertex buffer to update
  110042. * @param data the data used to update the vertex buffer
  110043. * @param byteOffset the byte offset of the data (optional)
  110044. * @param byteLength the byte length of the data (optional)
  110045. */
  110046. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110047. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  110048. private _updateAnisotropicLevel;
  110049. private _getAddressMode;
  110050. /** @hidden */
  110051. _bindTexture(channel: number, texture: InternalTexture): void;
  110052. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  110053. releaseEffects(): void;
  110054. /** @hidden */
  110055. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110056. /** @hidden */
  110057. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110058. /** @hidden */
  110059. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110060. /** @hidden */
  110061. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110062. }
  110063. }
  110064. declare module BABYLON {
  110065. /**
  110066. * Gather the list of clipboard event types as constants.
  110067. */
  110068. export class ClipboardEventTypes {
  110069. /**
  110070. * The clipboard event is fired when a copy command is active (pressed).
  110071. */
  110072. static readonly COPY: number;
  110073. /**
  110074. * The clipboard event is fired when a cut command is active (pressed).
  110075. */
  110076. static readonly CUT: number;
  110077. /**
  110078. * The clipboard event is fired when a paste command is active (pressed).
  110079. */
  110080. static readonly PASTE: number;
  110081. }
  110082. /**
  110083. * This class is used to store clipboard related info for the onClipboardObservable event.
  110084. */
  110085. export class ClipboardInfo {
  110086. /**
  110087. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110088. */
  110089. type: number;
  110090. /**
  110091. * Defines the related dom event
  110092. */
  110093. event: ClipboardEvent;
  110094. /**
  110095. *Creates an instance of ClipboardInfo.
  110096. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  110097. * @param event Defines the related dom event
  110098. */
  110099. constructor(
  110100. /**
  110101. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110102. */
  110103. type: number,
  110104. /**
  110105. * Defines the related dom event
  110106. */
  110107. event: ClipboardEvent);
  110108. /**
  110109. * Get the clipboard event's type from the keycode.
  110110. * @param keyCode Defines the keyCode for the current keyboard event.
  110111. * @return {number}
  110112. */
  110113. static GetTypeFromCharacter(keyCode: number): number;
  110114. }
  110115. }
  110116. declare module BABYLON {
  110117. /**
  110118. * Google Daydream controller
  110119. */
  110120. export class DaydreamController extends WebVRController {
  110121. /**
  110122. * Base Url for the controller model.
  110123. */
  110124. static MODEL_BASE_URL: string;
  110125. /**
  110126. * File name for the controller model.
  110127. */
  110128. static MODEL_FILENAME: string;
  110129. /**
  110130. * Gamepad Id prefix used to identify Daydream Controller.
  110131. */
  110132. static readonly GAMEPAD_ID_PREFIX: string;
  110133. /**
  110134. * Creates a new DaydreamController from a gamepad
  110135. * @param vrGamepad the gamepad that the controller should be created from
  110136. */
  110137. constructor(vrGamepad: any);
  110138. /**
  110139. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110140. * @param scene scene in which to add meshes
  110141. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110142. */
  110143. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110144. /**
  110145. * Called once for each button that changed state since the last frame
  110146. * @param buttonIdx Which button index changed
  110147. * @param state New state of the button
  110148. * @param changes Which properties on the state changed since last frame
  110149. */
  110150. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110151. }
  110152. }
  110153. declare module BABYLON {
  110154. /**
  110155. * Gear VR Controller
  110156. */
  110157. export class GearVRController extends WebVRController {
  110158. /**
  110159. * Base Url for the controller model.
  110160. */
  110161. static MODEL_BASE_URL: string;
  110162. /**
  110163. * File name for the controller model.
  110164. */
  110165. static MODEL_FILENAME: string;
  110166. /**
  110167. * Gamepad Id prefix used to identify this controller.
  110168. */
  110169. static readonly GAMEPAD_ID_PREFIX: string;
  110170. private readonly _buttonIndexToObservableNameMap;
  110171. /**
  110172. * Creates a new GearVRController from a gamepad
  110173. * @param vrGamepad the gamepad that the controller should be created from
  110174. */
  110175. constructor(vrGamepad: any);
  110176. /**
  110177. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110178. * @param scene scene in which to add meshes
  110179. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110180. */
  110181. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110182. /**
  110183. * Called once for each button that changed state since the last frame
  110184. * @param buttonIdx Which button index changed
  110185. * @param state New state of the button
  110186. * @param changes Which properties on the state changed since last frame
  110187. */
  110188. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110189. }
  110190. }
  110191. declare module BABYLON {
  110192. /**
  110193. * Class containing static functions to help procedurally build meshes
  110194. */
  110195. export class PolyhedronBuilder {
  110196. /**
  110197. * Creates a polyhedron mesh
  110198. * * 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
  110199. * * The parameter `size` (positive float, default 1) sets the polygon size
  110200. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110201. * * 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`
  110202. * * 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
  110203. * * 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)`)
  110204. * * 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
  110205. * * 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
  110206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110207. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110209. * @param name defines the name of the mesh
  110210. * @param options defines the options used to create the mesh
  110211. * @param scene defines the hosting scene
  110212. * @returns the polyhedron mesh
  110213. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110214. */
  110215. static CreatePolyhedron(name: string, options: {
  110216. type?: number;
  110217. size?: number;
  110218. sizeX?: number;
  110219. sizeY?: number;
  110220. sizeZ?: number;
  110221. custom?: any;
  110222. faceUV?: Vector4[];
  110223. faceColors?: Color4[];
  110224. flat?: boolean;
  110225. updatable?: boolean;
  110226. sideOrientation?: number;
  110227. frontUVs?: Vector4;
  110228. backUVs?: Vector4;
  110229. }, scene?: Nullable<Scene>): Mesh;
  110230. }
  110231. }
  110232. declare module BABYLON {
  110233. /**
  110234. * Gizmo that enables scaling a mesh along 3 axis
  110235. */
  110236. export class ScaleGizmo extends Gizmo {
  110237. /**
  110238. * Internal gizmo used for interactions on the x axis
  110239. */
  110240. xGizmo: AxisScaleGizmo;
  110241. /**
  110242. * Internal gizmo used for interactions on the y axis
  110243. */
  110244. yGizmo: AxisScaleGizmo;
  110245. /**
  110246. * Internal gizmo used for interactions on the z axis
  110247. */
  110248. zGizmo: AxisScaleGizmo;
  110249. /**
  110250. * Internal gizmo used to scale all axis equally
  110251. */
  110252. uniformScaleGizmo: AxisScaleGizmo;
  110253. private _meshAttached;
  110254. private _updateGizmoRotationToMatchAttachedMesh;
  110255. private _snapDistance;
  110256. private _scaleRatio;
  110257. private _uniformScalingMesh;
  110258. private _octahedron;
  110259. /** Fires an event when any of it's sub gizmos are dragged */
  110260. onDragStartObservable: Observable<unknown>;
  110261. /** Fires an event when any of it's sub gizmos are released from dragging */
  110262. onDragEndObservable: Observable<unknown>;
  110263. attachedMesh: Nullable<AbstractMesh>;
  110264. /**
  110265. * Creates a ScaleGizmo
  110266. * @param gizmoLayer The utility layer the gizmo will be added to
  110267. */
  110268. constructor(gizmoLayer?: UtilityLayerRenderer);
  110269. updateGizmoRotationToMatchAttachedMesh: boolean;
  110270. /**
  110271. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110272. */
  110273. snapDistance: number;
  110274. /**
  110275. * Ratio for the scale of the gizmo (Default: 1)
  110276. */
  110277. scaleRatio: number;
  110278. /**
  110279. * Disposes of the gizmo
  110280. */
  110281. dispose(): void;
  110282. }
  110283. }
  110284. declare module BABYLON {
  110285. /**
  110286. * Single axis scale gizmo
  110287. */
  110288. export class AxisScaleGizmo extends Gizmo {
  110289. /**
  110290. * Drag behavior responsible for the gizmos dragging interactions
  110291. */
  110292. dragBehavior: PointerDragBehavior;
  110293. private _pointerObserver;
  110294. /**
  110295. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110296. */
  110297. snapDistance: number;
  110298. /**
  110299. * Event that fires each time the gizmo snaps to a new location.
  110300. * * snapDistance is the the change in distance
  110301. */
  110302. onSnapObservable: Observable<{
  110303. snapDistance: number;
  110304. }>;
  110305. /**
  110306. * If the scaling operation should be done on all axis (default: false)
  110307. */
  110308. uniformScaling: boolean;
  110309. private _isEnabled;
  110310. private _parent;
  110311. private _arrow;
  110312. private _coloredMaterial;
  110313. private _hoverMaterial;
  110314. /**
  110315. * Creates an AxisScaleGizmo
  110316. * @param gizmoLayer The utility layer the gizmo will be added to
  110317. * @param dragAxis The axis which the gizmo will be able to scale on
  110318. * @param color The color of the gizmo
  110319. */
  110320. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  110321. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110322. /**
  110323. * If the gizmo is enabled
  110324. */
  110325. isEnabled: boolean;
  110326. /**
  110327. * Disposes of the gizmo
  110328. */
  110329. dispose(): void;
  110330. /**
  110331. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110332. * @param mesh The mesh to replace the default mesh of the gizmo
  110333. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  110334. */
  110335. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  110336. }
  110337. }
  110338. declare module BABYLON {
  110339. /**
  110340. * Bounding box gizmo
  110341. */
  110342. export class BoundingBoxGizmo extends Gizmo {
  110343. private _lineBoundingBox;
  110344. private _rotateSpheresParent;
  110345. private _scaleBoxesParent;
  110346. private _boundingDimensions;
  110347. private _renderObserver;
  110348. private _pointerObserver;
  110349. private _scaleDragSpeed;
  110350. private _tmpQuaternion;
  110351. private _tmpVector;
  110352. private _tmpRotationMatrix;
  110353. /**
  110354. * 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)
  110355. */
  110356. ignoreChildren: boolean;
  110357. /**
  110358. * 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)
  110359. */
  110360. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  110361. /**
  110362. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  110363. */
  110364. rotationSphereSize: number;
  110365. /**
  110366. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  110367. */
  110368. scaleBoxSize: number;
  110369. /**
  110370. * 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)
  110371. */
  110372. fixedDragMeshScreenSize: boolean;
  110373. /**
  110374. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  110375. */
  110376. fixedDragMeshScreenSizeDistanceFactor: number;
  110377. /**
  110378. * Fired when a rotation sphere or scale box is dragged
  110379. */
  110380. onDragStartObservable: Observable<{}>;
  110381. /**
  110382. * Fired when a scale box is dragged
  110383. */
  110384. onScaleBoxDragObservable: Observable<{}>;
  110385. /**
  110386. * Fired when a scale box drag is ended
  110387. */
  110388. onScaleBoxDragEndObservable: Observable<{}>;
  110389. /**
  110390. * Fired when a rotation sphere is dragged
  110391. */
  110392. onRotationSphereDragObservable: Observable<{}>;
  110393. /**
  110394. * Fired when a rotation sphere drag is ended
  110395. */
  110396. onRotationSphereDragEndObservable: Observable<{}>;
  110397. /**
  110398. * 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)
  110399. */
  110400. scalePivot: Nullable<Vector3>;
  110401. /**
  110402. * Mesh used as a pivot to rotate the attached mesh
  110403. */
  110404. private _anchorMesh;
  110405. private _existingMeshScale;
  110406. private _dragMesh;
  110407. private pointerDragBehavior;
  110408. private coloredMaterial;
  110409. private hoverColoredMaterial;
  110410. /**
  110411. * Sets the color of the bounding box gizmo
  110412. * @param color the color to set
  110413. */
  110414. setColor(color: Color3): void;
  110415. /**
  110416. * Creates an BoundingBoxGizmo
  110417. * @param gizmoLayer The utility layer the gizmo will be added to
  110418. * @param color The color of the gizmo
  110419. */
  110420. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  110421. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110422. private _selectNode;
  110423. /**
  110424. * Updates the bounding box information for the Gizmo
  110425. */
  110426. updateBoundingBox(): void;
  110427. private _updateRotationSpheres;
  110428. private _updateScaleBoxes;
  110429. /**
  110430. * Enables rotation on the specified axis and disables rotation on the others
  110431. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  110432. */
  110433. setEnabledRotationAxis(axis: string): void;
  110434. /**
  110435. * Enables/disables scaling
  110436. * @param enable if scaling should be enabled
  110437. */
  110438. setEnabledScaling(enable: boolean): void;
  110439. private _updateDummy;
  110440. /**
  110441. * Enables a pointer drag behavior on the bounding box of the gizmo
  110442. */
  110443. enableDragBehavior(): void;
  110444. /**
  110445. * Disposes of the gizmo
  110446. */
  110447. dispose(): void;
  110448. /**
  110449. * 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)
  110450. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  110451. * @returns the bounding box mesh with the passed in mesh as a child
  110452. */
  110453. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  110454. /**
  110455. * CustomMeshes are not supported by this gizmo
  110456. * @param mesh The mesh to replace the default mesh of the gizmo
  110457. */
  110458. setCustomMesh(mesh: Mesh): void;
  110459. }
  110460. }
  110461. declare module BABYLON {
  110462. /**
  110463. * Single plane rotation gizmo
  110464. */
  110465. export class PlaneRotationGizmo extends Gizmo {
  110466. /**
  110467. * Drag behavior responsible for the gizmos dragging interactions
  110468. */
  110469. dragBehavior: PointerDragBehavior;
  110470. private _pointerObserver;
  110471. /**
  110472. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  110473. */
  110474. snapDistance: number;
  110475. /**
  110476. * Event that fires each time the gizmo snaps to a new location.
  110477. * * snapDistance is the the change in distance
  110478. */
  110479. onSnapObservable: Observable<{
  110480. snapDistance: number;
  110481. }>;
  110482. private _isEnabled;
  110483. private _parent;
  110484. /**
  110485. * Creates a PlaneRotationGizmo
  110486. * @param gizmoLayer The utility layer the gizmo will be added to
  110487. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  110488. * @param color The color of the gizmo
  110489. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110490. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110491. */
  110492. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  110493. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110494. /**
  110495. * If the gizmo is enabled
  110496. */
  110497. isEnabled: boolean;
  110498. /**
  110499. * Disposes of the gizmo
  110500. */
  110501. dispose(): void;
  110502. }
  110503. }
  110504. declare module BABYLON {
  110505. /**
  110506. * Gizmo that enables rotating a mesh along 3 axis
  110507. */
  110508. export class RotationGizmo extends Gizmo {
  110509. /**
  110510. * Internal gizmo used for interactions on the x axis
  110511. */
  110512. xGizmo: PlaneRotationGizmo;
  110513. /**
  110514. * Internal gizmo used for interactions on the y axis
  110515. */
  110516. yGizmo: PlaneRotationGizmo;
  110517. /**
  110518. * Internal gizmo used for interactions on the z axis
  110519. */
  110520. zGizmo: PlaneRotationGizmo;
  110521. /** Fires an event when any of it's sub gizmos are dragged */
  110522. onDragStartObservable: Observable<unknown>;
  110523. /** Fires an event when any of it's sub gizmos are released from dragging */
  110524. onDragEndObservable: Observable<unknown>;
  110525. private _meshAttached;
  110526. attachedMesh: Nullable<AbstractMesh>;
  110527. /**
  110528. * Creates a RotationGizmo
  110529. * @param gizmoLayer The utility layer the gizmo will be added to
  110530. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110531. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110532. */
  110533. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  110534. updateGizmoRotationToMatchAttachedMesh: boolean;
  110535. /**
  110536. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110537. */
  110538. snapDistance: number;
  110539. /**
  110540. * Ratio for the scale of the gizmo (Default: 1)
  110541. */
  110542. scaleRatio: number;
  110543. /**
  110544. * Disposes of the gizmo
  110545. */
  110546. dispose(): void;
  110547. /**
  110548. * CustomMeshes are not supported by this gizmo
  110549. * @param mesh The mesh to replace the default mesh of the gizmo
  110550. */
  110551. setCustomMesh(mesh: Mesh): void;
  110552. }
  110553. }
  110554. declare module BABYLON {
  110555. /**
  110556. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  110557. */
  110558. export class GizmoManager implements IDisposable {
  110559. private scene;
  110560. /**
  110561. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  110562. */
  110563. gizmos: {
  110564. positionGizmo: Nullable<PositionGizmo>;
  110565. rotationGizmo: Nullable<RotationGizmo>;
  110566. scaleGizmo: Nullable<ScaleGizmo>;
  110567. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  110568. };
  110569. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  110570. clearGizmoOnEmptyPointerEvent: boolean;
  110571. /** Fires an event when the manager is attached to a mesh */
  110572. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  110573. private _gizmosEnabled;
  110574. private _pointerObserver;
  110575. private _attachedMesh;
  110576. private _boundingBoxColor;
  110577. private _defaultUtilityLayer;
  110578. private _defaultKeepDepthUtilityLayer;
  110579. /**
  110580. * When bounding box gizmo is enabled, this can be used to track drag/end events
  110581. */
  110582. boundingBoxDragBehavior: SixDofDragBehavior;
  110583. /**
  110584. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  110585. */
  110586. attachableMeshes: Nullable<Array<AbstractMesh>>;
  110587. /**
  110588. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  110589. */
  110590. usePointerToAttachGizmos: boolean;
  110591. /**
  110592. * Utility layer that the bounding box gizmo belongs to
  110593. */
  110594. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  110595. /**
  110596. * Utility layer that all gizmos besides bounding box belong to
  110597. */
  110598. readonly utilityLayer: UtilityLayerRenderer;
  110599. /**
  110600. * Instatiates a gizmo manager
  110601. * @param scene the scene to overlay the gizmos on top of
  110602. */
  110603. constructor(scene: Scene);
  110604. /**
  110605. * Attaches a set of gizmos to the specified mesh
  110606. * @param mesh The mesh the gizmo's should be attached to
  110607. */
  110608. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  110609. /**
  110610. * If the position gizmo is enabled
  110611. */
  110612. positionGizmoEnabled: boolean;
  110613. /**
  110614. * If the rotation gizmo is enabled
  110615. */
  110616. rotationGizmoEnabled: boolean;
  110617. /**
  110618. * If the scale gizmo is enabled
  110619. */
  110620. scaleGizmoEnabled: boolean;
  110621. /**
  110622. * If the boundingBox gizmo is enabled
  110623. */
  110624. boundingBoxGizmoEnabled: boolean;
  110625. /**
  110626. * Disposes of the gizmo manager
  110627. */
  110628. dispose(): void;
  110629. }
  110630. }
  110631. declare module BABYLON {
  110632. /**
  110633. * A directional light is defined by a direction (what a surprise!).
  110634. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  110635. * 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.
  110636. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110637. */
  110638. export class DirectionalLight extends ShadowLight {
  110639. private _shadowFrustumSize;
  110640. /**
  110641. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  110642. */
  110643. /**
  110644. * Specifies a fix frustum size for the shadow generation.
  110645. */
  110646. shadowFrustumSize: number;
  110647. private _shadowOrthoScale;
  110648. /**
  110649. * Gets the shadow projection scale against the optimal computed one.
  110650. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110651. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110652. */
  110653. /**
  110654. * Sets the shadow projection scale against the optimal computed one.
  110655. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110656. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110657. */
  110658. shadowOrthoScale: number;
  110659. /**
  110660. * Automatically compute the projection matrix to best fit (including all the casters)
  110661. * on each frame.
  110662. */
  110663. autoUpdateExtends: boolean;
  110664. private _orthoLeft;
  110665. private _orthoRight;
  110666. private _orthoTop;
  110667. private _orthoBottom;
  110668. /**
  110669. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  110670. * The directional light is emitted from everywhere in the given direction.
  110671. * It can cast shadows.
  110672. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110673. * @param name The friendly name of the light
  110674. * @param direction The direction of the light
  110675. * @param scene The scene the light belongs to
  110676. */
  110677. constructor(name: string, direction: Vector3, scene: Scene);
  110678. /**
  110679. * Returns the string "DirectionalLight".
  110680. * @return The class name
  110681. */
  110682. getClassName(): string;
  110683. /**
  110684. * Returns the integer 1.
  110685. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110686. */
  110687. getTypeID(): number;
  110688. /**
  110689. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  110690. * Returns the DirectionalLight Shadow projection matrix.
  110691. */
  110692. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110693. /**
  110694. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  110695. * Returns the DirectionalLight Shadow projection matrix.
  110696. */
  110697. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  110698. /**
  110699. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  110700. * Returns the DirectionalLight Shadow projection matrix.
  110701. */
  110702. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110703. protected _buildUniformLayout(): void;
  110704. /**
  110705. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  110706. * @param effect The effect to update
  110707. * @param lightIndex The index of the light in the effect to update
  110708. * @returns The directional light
  110709. */
  110710. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  110711. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  110712. /**
  110713. * Gets the minZ used for shadow according to both the scene and the light.
  110714. *
  110715. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110716. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110717. * @param activeCamera The camera we are returning the min for
  110718. * @returns the depth min z
  110719. */
  110720. getDepthMinZ(activeCamera: Camera): number;
  110721. /**
  110722. * Gets the maxZ used for shadow according to both the scene and the light.
  110723. *
  110724. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110725. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110726. * @param activeCamera The camera we are returning the max for
  110727. * @returns the depth max z
  110728. */
  110729. getDepthMaxZ(activeCamera: Camera): number;
  110730. /**
  110731. * Prepares the list of defines specific to the light type.
  110732. * @param defines the list of defines
  110733. * @param lightIndex defines the index of the light for the effect
  110734. */
  110735. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110736. }
  110737. }
  110738. declare module BABYLON {
  110739. /**
  110740. * Class containing static functions to help procedurally build meshes
  110741. */
  110742. export class HemisphereBuilder {
  110743. /**
  110744. * Creates a hemisphere mesh
  110745. * @param name defines the name of the mesh
  110746. * @param options defines the options used to create the mesh
  110747. * @param scene defines the hosting scene
  110748. * @returns the hemisphere mesh
  110749. */
  110750. static CreateHemisphere(name: string, options: {
  110751. segments?: number;
  110752. diameter?: number;
  110753. sideOrientation?: number;
  110754. }, scene: any): Mesh;
  110755. }
  110756. }
  110757. declare module BABYLON {
  110758. /**
  110759. * A spot light is defined by a position, a direction, an angle, and an exponent.
  110760. * These values define a cone of light starting from the position, emitting toward the direction.
  110761. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  110762. * and the exponent defines the speed of the decay of the light with distance (reach).
  110763. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110764. */
  110765. export class SpotLight extends ShadowLight {
  110766. private _angle;
  110767. private _innerAngle;
  110768. private _cosHalfAngle;
  110769. private _lightAngleScale;
  110770. private _lightAngleOffset;
  110771. /**
  110772. * Gets the cone angle of the spot light in Radians.
  110773. */
  110774. /**
  110775. * Sets the cone angle of the spot light in Radians.
  110776. */
  110777. angle: number;
  110778. /**
  110779. * Only used in gltf falloff mode, this defines the angle where
  110780. * the directional falloff will start before cutting at angle which could be seen
  110781. * as outer angle.
  110782. */
  110783. /**
  110784. * Only used in gltf falloff mode, this defines the angle where
  110785. * the directional falloff will start before cutting at angle which could be seen
  110786. * as outer angle.
  110787. */
  110788. innerAngle: number;
  110789. private _shadowAngleScale;
  110790. /**
  110791. * Allows scaling the angle of the light for shadow generation only.
  110792. */
  110793. /**
  110794. * Allows scaling the angle of the light for shadow generation only.
  110795. */
  110796. shadowAngleScale: number;
  110797. /**
  110798. * The light decay speed with the distance from the emission spot.
  110799. */
  110800. exponent: number;
  110801. private _projectionTextureMatrix;
  110802. /**
  110803. * Allows reading the projecton texture
  110804. */
  110805. readonly projectionTextureMatrix: Matrix;
  110806. protected _projectionTextureLightNear: number;
  110807. /**
  110808. * Gets the near clip of the Spotlight for texture projection.
  110809. */
  110810. /**
  110811. * Sets the near clip of the Spotlight for texture projection.
  110812. */
  110813. projectionTextureLightNear: number;
  110814. protected _projectionTextureLightFar: number;
  110815. /**
  110816. * Gets the far clip of the Spotlight for texture projection.
  110817. */
  110818. /**
  110819. * Sets the far clip of the Spotlight for texture projection.
  110820. */
  110821. projectionTextureLightFar: number;
  110822. protected _projectionTextureUpDirection: Vector3;
  110823. /**
  110824. * Gets the Up vector of the Spotlight for texture projection.
  110825. */
  110826. /**
  110827. * Sets the Up vector of the Spotlight for texture projection.
  110828. */
  110829. projectionTextureUpDirection: Vector3;
  110830. private _projectionTexture;
  110831. /**
  110832. * Gets the projection texture of the light.
  110833. */
  110834. /**
  110835. * Sets the projection texture of the light.
  110836. */
  110837. projectionTexture: Nullable<BaseTexture>;
  110838. private _projectionTextureViewLightDirty;
  110839. private _projectionTextureProjectionLightDirty;
  110840. private _projectionTextureDirty;
  110841. private _projectionTextureViewTargetVector;
  110842. private _projectionTextureViewLightMatrix;
  110843. private _projectionTextureProjectionLightMatrix;
  110844. private _projectionTextureScalingMatrix;
  110845. /**
  110846. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  110847. * It can cast shadows.
  110848. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110849. * @param name The light friendly name
  110850. * @param position The position of the spot light in the scene
  110851. * @param direction The direction of the light in the scene
  110852. * @param angle The cone angle of the light in Radians
  110853. * @param exponent The light decay speed with the distance from the emission spot
  110854. * @param scene The scene the lights belongs to
  110855. */
  110856. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  110857. /**
  110858. * Returns the string "SpotLight".
  110859. * @returns the class name
  110860. */
  110861. getClassName(): string;
  110862. /**
  110863. * Returns the integer 2.
  110864. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110865. */
  110866. getTypeID(): number;
  110867. /**
  110868. * Overrides the direction setter to recompute the projection texture view light Matrix.
  110869. */
  110870. protected _setDirection(value: Vector3): void;
  110871. /**
  110872. * Overrides the position setter to recompute the projection texture view light Matrix.
  110873. */
  110874. protected _setPosition(value: Vector3): void;
  110875. /**
  110876. * 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.
  110877. * Returns the SpotLight.
  110878. */
  110879. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110880. protected _computeProjectionTextureViewLightMatrix(): void;
  110881. protected _computeProjectionTextureProjectionLightMatrix(): void;
  110882. /**
  110883. * Main function for light texture projection matrix computing.
  110884. */
  110885. protected _computeProjectionTextureMatrix(): void;
  110886. protected _buildUniformLayout(): void;
  110887. private _computeAngleValues;
  110888. /**
  110889. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  110890. * @param effect The effect to update
  110891. * @param lightIndex The index of the light in the effect to update
  110892. * @returns The spot light
  110893. */
  110894. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  110895. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  110896. /**
  110897. * Disposes the light and the associated resources.
  110898. */
  110899. dispose(): void;
  110900. /**
  110901. * Prepares the list of defines specific to the light type.
  110902. * @param defines the list of defines
  110903. * @param lightIndex defines the index of the light for the effect
  110904. */
  110905. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110906. }
  110907. }
  110908. declare module BABYLON {
  110909. /**
  110910. * Gizmo that enables viewing a light
  110911. */
  110912. export class LightGizmo extends Gizmo {
  110913. private _lightMesh;
  110914. private _material;
  110915. private cachedPosition;
  110916. private cachedForward;
  110917. /**
  110918. * Creates a LightGizmo
  110919. * @param gizmoLayer The utility layer the gizmo will be added to
  110920. */
  110921. constructor(gizmoLayer?: UtilityLayerRenderer);
  110922. private _light;
  110923. /**
  110924. * The light that the gizmo is attached to
  110925. */
  110926. light: Nullable<Light>;
  110927. /**
  110928. * Gets the material used to render the light gizmo
  110929. */
  110930. readonly material: StandardMaterial;
  110931. /**
  110932. * @hidden
  110933. * Updates the gizmo to match the attached mesh's position/rotation
  110934. */
  110935. protected _update(): void;
  110936. private static _Scale;
  110937. /**
  110938. * Creates the lines for a light mesh
  110939. */
  110940. private static _createLightLines;
  110941. /**
  110942. * Disposes of the light gizmo
  110943. */
  110944. dispose(): void;
  110945. private static _CreateHemisphericLightMesh;
  110946. private static _CreatePointLightMesh;
  110947. private static _CreateSpotLightMesh;
  110948. private static _CreateDirectionalLightMesh;
  110949. }
  110950. }
  110951. declare module BABYLON {
  110952. /** @hidden */
  110953. export var backgroundFragmentDeclaration: {
  110954. name: string;
  110955. shader: string;
  110956. };
  110957. }
  110958. declare module BABYLON {
  110959. /** @hidden */
  110960. export var backgroundUboDeclaration: {
  110961. name: string;
  110962. shader: string;
  110963. };
  110964. }
  110965. declare module BABYLON {
  110966. /** @hidden */
  110967. export var backgroundPixelShader: {
  110968. name: string;
  110969. shader: string;
  110970. };
  110971. }
  110972. declare module BABYLON {
  110973. /** @hidden */
  110974. export var backgroundVertexDeclaration: {
  110975. name: string;
  110976. shader: string;
  110977. };
  110978. }
  110979. declare module BABYLON {
  110980. /** @hidden */
  110981. export var backgroundVertexShader: {
  110982. name: string;
  110983. shader: string;
  110984. };
  110985. }
  110986. declare module BABYLON {
  110987. /**
  110988. * Background material used to create an efficient environement around your scene.
  110989. */
  110990. export class BackgroundMaterial extends PushMaterial {
  110991. /**
  110992. * Standard reflectance value at parallel view angle.
  110993. */
  110994. static StandardReflectance0: number;
  110995. /**
  110996. * Standard reflectance value at grazing angle.
  110997. */
  110998. static StandardReflectance90: number;
  110999. protected _primaryColor: Color3;
  111000. /**
  111001. * Key light Color (multiply against the environement texture)
  111002. */
  111003. primaryColor: Color3;
  111004. protected __perceptualColor: Nullable<Color3>;
  111005. /**
  111006. * Experimental Internal Use Only.
  111007. *
  111008. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  111009. * This acts as a helper to set the primary color to a more "human friendly" value.
  111010. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  111011. * output color as close as possible from the chosen value.
  111012. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  111013. * part of lighting setup.)
  111014. */
  111015. _perceptualColor: Nullable<Color3>;
  111016. protected _primaryColorShadowLevel: float;
  111017. /**
  111018. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  111019. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  111020. */
  111021. primaryColorShadowLevel: float;
  111022. protected _primaryColorHighlightLevel: float;
  111023. /**
  111024. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  111025. * The primary color is used at the level chosen to define what the white area would look.
  111026. */
  111027. primaryColorHighlightLevel: float;
  111028. protected _reflectionTexture: Nullable<BaseTexture>;
  111029. /**
  111030. * Reflection Texture used in the material.
  111031. * Should be author in a specific way for the best result (refer to the documentation).
  111032. */
  111033. reflectionTexture: Nullable<BaseTexture>;
  111034. protected _reflectionBlur: float;
  111035. /**
  111036. * Reflection Texture level of blur.
  111037. *
  111038. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  111039. * texture twice.
  111040. */
  111041. reflectionBlur: float;
  111042. protected _diffuseTexture: Nullable<BaseTexture>;
  111043. /**
  111044. * Diffuse Texture used in the material.
  111045. * Should be author in a specific way for the best result (refer to the documentation).
  111046. */
  111047. diffuseTexture: Nullable<BaseTexture>;
  111048. protected _shadowLights: Nullable<IShadowLight[]>;
  111049. /**
  111050. * Specify the list of lights casting shadow on the material.
  111051. * All scene shadow lights will be included if null.
  111052. */
  111053. shadowLights: Nullable<IShadowLight[]>;
  111054. protected _shadowLevel: float;
  111055. /**
  111056. * Helps adjusting the shadow to a softer level if required.
  111057. * 0 means black shadows and 1 means no shadows.
  111058. */
  111059. shadowLevel: float;
  111060. protected _sceneCenter: Vector3;
  111061. /**
  111062. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  111063. * It is usually zero but might be interesting to modify according to your setup.
  111064. */
  111065. sceneCenter: Vector3;
  111066. protected _opacityFresnel: boolean;
  111067. /**
  111068. * This helps specifying that the material is falling off to the sky box at grazing angle.
  111069. * This helps ensuring a nice transition when the camera goes under the ground.
  111070. */
  111071. opacityFresnel: boolean;
  111072. protected _reflectionFresnel: boolean;
  111073. /**
  111074. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  111075. * This helps adding a mirror texture on the ground.
  111076. */
  111077. reflectionFresnel: boolean;
  111078. protected _reflectionFalloffDistance: number;
  111079. /**
  111080. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  111081. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  111082. */
  111083. reflectionFalloffDistance: number;
  111084. protected _reflectionAmount: number;
  111085. /**
  111086. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  111087. */
  111088. reflectionAmount: number;
  111089. protected _reflectionReflectance0: number;
  111090. /**
  111091. * This specifies the weight of the reflection at grazing angle.
  111092. */
  111093. reflectionReflectance0: number;
  111094. protected _reflectionReflectance90: number;
  111095. /**
  111096. * This specifies the weight of the reflection at a perpendicular point of view.
  111097. */
  111098. reflectionReflectance90: number;
  111099. /**
  111100. * Sets the reflection reflectance fresnel values according to the default standard
  111101. * empirically know to work well :-)
  111102. */
  111103. reflectionStandardFresnelWeight: number;
  111104. protected _useRGBColor: boolean;
  111105. /**
  111106. * Helps to directly use the maps channels instead of their level.
  111107. */
  111108. useRGBColor: boolean;
  111109. protected _enableNoise: boolean;
  111110. /**
  111111. * This helps reducing the banding effect that could occur on the background.
  111112. */
  111113. enableNoise: boolean;
  111114. /**
  111115. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111116. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  111117. * Recommended to be keep at 1.0 except for special cases.
  111118. */
  111119. fovMultiplier: number;
  111120. private _fovMultiplier;
  111121. /**
  111122. * Enable the FOV adjustment feature controlled by fovMultiplier.
  111123. */
  111124. useEquirectangularFOV: boolean;
  111125. private _maxSimultaneousLights;
  111126. /**
  111127. * Number of Simultaneous lights allowed on the material.
  111128. */
  111129. maxSimultaneousLights: int;
  111130. /**
  111131. * Default configuration related to image processing available in the Background Material.
  111132. */
  111133. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111134. /**
  111135. * Keep track of the image processing observer to allow dispose and replace.
  111136. */
  111137. private _imageProcessingObserver;
  111138. /**
  111139. * Attaches a new image processing configuration to the PBR Material.
  111140. * @param configuration (if null the scene configuration will be use)
  111141. */
  111142. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111143. /**
  111144. * Gets the image processing configuration used either in this material.
  111145. */
  111146. /**
  111147. * Sets the Default image processing configuration used either in the this material.
  111148. *
  111149. * If sets to null, the scene one is in use.
  111150. */
  111151. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  111152. /**
  111153. * Gets wether the color curves effect is enabled.
  111154. */
  111155. /**
  111156. * Sets wether the color curves effect is enabled.
  111157. */
  111158. cameraColorCurvesEnabled: boolean;
  111159. /**
  111160. * Gets wether the color grading effect is enabled.
  111161. */
  111162. /**
  111163. * Gets wether the color grading effect is enabled.
  111164. */
  111165. cameraColorGradingEnabled: boolean;
  111166. /**
  111167. * Gets wether tonemapping is enabled or not.
  111168. */
  111169. /**
  111170. * Sets wether tonemapping is enabled or not
  111171. */
  111172. cameraToneMappingEnabled: boolean;
  111173. /**
  111174. * The camera exposure used on this material.
  111175. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111176. * This corresponds to a photographic exposure.
  111177. */
  111178. /**
  111179. * The camera exposure used on this material.
  111180. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111181. * This corresponds to a photographic exposure.
  111182. */
  111183. cameraExposure: float;
  111184. /**
  111185. * Gets The camera contrast used on this material.
  111186. */
  111187. /**
  111188. * Sets The camera contrast used on this material.
  111189. */
  111190. cameraContrast: float;
  111191. /**
  111192. * Gets the Color Grading 2D Lookup Texture.
  111193. */
  111194. /**
  111195. * Sets the Color Grading 2D Lookup Texture.
  111196. */
  111197. cameraColorGradingTexture: Nullable<BaseTexture>;
  111198. /**
  111199. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111200. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111201. * 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;
  111202. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111203. */
  111204. /**
  111205. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111206. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111207. * 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;
  111208. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111209. */
  111210. cameraColorCurves: Nullable<ColorCurves>;
  111211. /**
  111212. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  111213. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  111214. */
  111215. switchToBGR: boolean;
  111216. private _renderTargets;
  111217. private _reflectionControls;
  111218. private _white;
  111219. private _primaryShadowColor;
  111220. private _primaryHighlightColor;
  111221. /**
  111222. * Instantiates a Background Material in the given scene
  111223. * @param name The friendly name of the material
  111224. * @param scene The scene to add the material to
  111225. */
  111226. constructor(name: string, scene: Scene);
  111227. /**
  111228. * Gets a boolean indicating that current material needs to register RTT
  111229. */
  111230. readonly hasRenderTargetTextures: boolean;
  111231. /**
  111232. * The entire material has been created in order to prevent overdraw.
  111233. * @returns false
  111234. */
  111235. needAlphaTesting(): boolean;
  111236. /**
  111237. * The entire material has been created in order to prevent overdraw.
  111238. * @returns true if blending is enable
  111239. */
  111240. needAlphaBlending(): boolean;
  111241. /**
  111242. * Checks wether the material is ready to be rendered for a given mesh.
  111243. * @param mesh The mesh to render
  111244. * @param subMesh The submesh to check against
  111245. * @param useInstances Specify wether or not the material is used with instances
  111246. * @returns true if all the dependencies are ready (Textures, Effects...)
  111247. */
  111248. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111249. /**
  111250. * Compute the primary color according to the chosen perceptual color.
  111251. */
  111252. private _computePrimaryColorFromPerceptualColor;
  111253. /**
  111254. * Compute the highlights and shadow colors according to their chosen levels.
  111255. */
  111256. private _computePrimaryColors;
  111257. /**
  111258. * Build the uniform buffer used in the material.
  111259. */
  111260. buildUniformLayout(): void;
  111261. /**
  111262. * Unbind the material.
  111263. */
  111264. unbind(): void;
  111265. /**
  111266. * Bind only the world matrix to the material.
  111267. * @param world The world matrix to bind.
  111268. */
  111269. bindOnlyWorldMatrix(world: Matrix): void;
  111270. /**
  111271. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  111272. * @param world The world matrix to bind.
  111273. * @param subMesh The submesh to bind for.
  111274. */
  111275. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111276. /**
  111277. * Checks to see if a texture is used in the material.
  111278. * @param texture - Base texture to use.
  111279. * @returns - Boolean specifying if a texture is used in the material.
  111280. */
  111281. hasTexture(texture: BaseTexture): boolean;
  111282. /**
  111283. * Dispose the material.
  111284. * @param forceDisposeEffect Force disposal of the associated effect.
  111285. * @param forceDisposeTextures Force disposal of the associated textures.
  111286. */
  111287. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111288. /**
  111289. * Clones the material.
  111290. * @param name The cloned name.
  111291. * @returns The cloned material.
  111292. */
  111293. clone(name: string): BackgroundMaterial;
  111294. /**
  111295. * Serializes the current material to its JSON representation.
  111296. * @returns The JSON representation.
  111297. */
  111298. serialize(): any;
  111299. /**
  111300. * Gets the class name of the material
  111301. * @returns "BackgroundMaterial"
  111302. */
  111303. getClassName(): string;
  111304. /**
  111305. * Parse a JSON input to create back a background material.
  111306. * @param source The JSON data to parse
  111307. * @param scene The scene to create the parsed material in
  111308. * @param rootUrl The root url of the assets the material depends upon
  111309. * @returns the instantiated BackgroundMaterial.
  111310. */
  111311. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  111312. }
  111313. }
  111314. declare module BABYLON {
  111315. /**
  111316. * Represents the different options available during the creation of
  111317. * a Environment helper.
  111318. *
  111319. * This can control the default ground, skybox and image processing setup of your scene.
  111320. */
  111321. export interface IEnvironmentHelperOptions {
  111322. /**
  111323. * Specifies wether or not to create a ground.
  111324. * True by default.
  111325. */
  111326. createGround: boolean;
  111327. /**
  111328. * Specifies the ground size.
  111329. * 15 by default.
  111330. */
  111331. groundSize: number;
  111332. /**
  111333. * The texture used on the ground for the main color.
  111334. * Comes from the BabylonJS CDN by default.
  111335. *
  111336. * Remarks: Can be either a texture or a url.
  111337. */
  111338. groundTexture: string | BaseTexture;
  111339. /**
  111340. * The color mixed in the ground texture by default.
  111341. * BabylonJS clearColor by default.
  111342. */
  111343. groundColor: Color3;
  111344. /**
  111345. * Specifies the ground opacity.
  111346. * 1 by default.
  111347. */
  111348. groundOpacity: number;
  111349. /**
  111350. * Enables the ground to receive shadows.
  111351. * True by default.
  111352. */
  111353. enableGroundShadow: boolean;
  111354. /**
  111355. * Helps preventing the shadow to be fully black on the ground.
  111356. * 0.5 by default.
  111357. */
  111358. groundShadowLevel: number;
  111359. /**
  111360. * Creates a mirror texture attach to the ground.
  111361. * false by default.
  111362. */
  111363. enableGroundMirror: boolean;
  111364. /**
  111365. * Specifies the ground mirror size ratio.
  111366. * 0.3 by default as the default kernel is 64.
  111367. */
  111368. groundMirrorSizeRatio: number;
  111369. /**
  111370. * Specifies the ground mirror blur kernel size.
  111371. * 64 by default.
  111372. */
  111373. groundMirrorBlurKernel: number;
  111374. /**
  111375. * Specifies the ground mirror visibility amount.
  111376. * 1 by default
  111377. */
  111378. groundMirrorAmount: number;
  111379. /**
  111380. * Specifies the ground mirror reflectance weight.
  111381. * This uses the standard weight of the background material to setup the fresnel effect
  111382. * of the mirror.
  111383. * 1 by default.
  111384. */
  111385. groundMirrorFresnelWeight: number;
  111386. /**
  111387. * Specifies the ground mirror Falloff distance.
  111388. * This can helps reducing the size of the reflection.
  111389. * 0 by Default.
  111390. */
  111391. groundMirrorFallOffDistance: number;
  111392. /**
  111393. * Specifies the ground mirror texture type.
  111394. * Unsigned Int by Default.
  111395. */
  111396. groundMirrorTextureType: number;
  111397. /**
  111398. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  111399. * the shown objects.
  111400. */
  111401. groundYBias: number;
  111402. /**
  111403. * Specifies wether or not to create a skybox.
  111404. * True by default.
  111405. */
  111406. createSkybox: boolean;
  111407. /**
  111408. * Specifies the skybox size.
  111409. * 20 by default.
  111410. */
  111411. skyboxSize: number;
  111412. /**
  111413. * The texture used on the skybox for the main color.
  111414. * Comes from the BabylonJS CDN by default.
  111415. *
  111416. * Remarks: Can be either a texture or a url.
  111417. */
  111418. skyboxTexture: string | BaseTexture;
  111419. /**
  111420. * The color mixed in the skybox texture by default.
  111421. * BabylonJS clearColor by default.
  111422. */
  111423. skyboxColor: Color3;
  111424. /**
  111425. * The background rotation around the Y axis of the scene.
  111426. * This helps aligning the key lights of your scene with the background.
  111427. * 0 by default.
  111428. */
  111429. backgroundYRotation: number;
  111430. /**
  111431. * Compute automatically the size of the elements to best fit with the scene.
  111432. */
  111433. sizeAuto: boolean;
  111434. /**
  111435. * Default position of the rootMesh if autoSize is not true.
  111436. */
  111437. rootPosition: Vector3;
  111438. /**
  111439. * Sets up the image processing in the scene.
  111440. * true by default.
  111441. */
  111442. setupImageProcessing: boolean;
  111443. /**
  111444. * The texture used as your environment texture in the scene.
  111445. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  111446. *
  111447. * Remarks: Can be either a texture or a url.
  111448. */
  111449. environmentTexture: string | BaseTexture;
  111450. /**
  111451. * The value of the exposure to apply to the scene.
  111452. * 0.6 by default if setupImageProcessing is true.
  111453. */
  111454. cameraExposure: number;
  111455. /**
  111456. * The value of the contrast to apply to the scene.
  111457. * 1.6 by default if setupImageProcessing is true.
  111458. */
  111459. cameraContrast: number;
  111460. /**
  111461. * Specifies wether or not tonemapping should be enabled in the scene.
  111462. * true by default if setupImageProcessing is true.
  111463. */
  111464. toneMappingEnabled: boolean;
  111465. }
  111466. /**
  111467. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  111468. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  111469. * It also helps with the default setup of your imageProcessing configuration.
  111470. */
  111471. export class EnvironmentHelper {
  111472. /**
  111473. * Default ground texture URL.
  111474. */
  111475. private static _groundTextureCDNUrl;
  111476. /**
  111477. * Default skybox texture URL.
  111478. */
  111479. private static _skyboxTextureCDNUrl;
  111480. /**
  111481. * Default environment texture URL.
  111482. */
  111483. private static _environmentTextureCDNUrl;
  111484. /**
  111485. * Creates the default options for the helper.
  111486. */
  111487. private static _getDefaultOptions;
  111488. private _rootMesh;
  111489. /**
  111490. * Gets the root mesh created by the helper.
  111491. */
  111492. readonly rootMesh: Mesh;
  111493. private _skybox;
  111494. /**
  111495. * Gets the skybox created by the helper.
  111496. */
  111497. readonly skybox: Nullable<Mesh>;
  111498. private _skyboxTexture;
  111499. /**
  111500. * Gets the skybox texture created by the helper.
  111501. */
  111502. readonly skyboxTexture: Nullable<BaseTexture>;
  111503. private _skyboxMaterial;
  111504. /**
  111505. * Gets the skybox material created by the helper.
  111506. */
  111507. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  111508. private _ground;
  111509. /**
  111510. * Gets the ground mesh created by the helper.
  111511. */
  111512. readonly ground: Nullable<Mesh>;
  111513. private _groundTexture;
  111514. /**
  111515. * Gets the ground texture created by the helper.
  111516. */
  111517. readonly groundTexture: Nullable<BaseTexture>;
  111518. private _groundMirror;
  111519. /**
  111520. * Gets the ground mirror created by the helper.
  111521. */
  111522. readonly groundMirror: Nullable<MirrorTexture>;
  111523. /**
  111524. * Gets the ground mirror render list to helps pushing the meshes
  111525. * you wish in the ground reflection.
  111526. */
  111527. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  111528. private _groundMaterial;
  111529. /**
  111530. * Gets the ground material created by the helper.
  111531. */
  111532. readonly groundMaterial: Nullable<BackgroundMaterial>;
  111533. /**
  111534. * Stores the creation options.
  111535. */
  111536. private readonly _scene;
  111537. private _options;
  111538. /**
  111539. * This observable will be notified with any error during the creation of the environment,
  111540. * mainly texture creation errors.
  111541. */
  111542. onErrorObservable: Observable<{
  111543. message?: string;
  111544. exception?: any;
  111545. }>;
  111546. /**
  111547. * constructor
  111548. * @param options Defines the options we want to customize the helper
  111549. * @param scene The scene to add the material to
  111550. */
  111551. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  111552. /**
  111553. * Updates the background according to the new options
  111554. * @param options
  111555. */
  111556. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  111557. /**
  111558. * Sets the primary color of all the available elements.
  111559. * @param color the main color to affect to the ground and the background
  111560. */
  111561. setMainColor(color: Color3): void;
  111562. /**
  111563. * Setup the image processing according to the specified options.
  111564. */
  111565. private _setupImageProcessing;
  111566. /**
  111567. * Setup the environment texture according to the specified options.
  111568. */
  111569. private _setupEnvironmentTexture;
  111570. /**
  111571. * Setup the background according to the specified options.
  111572. */
  111573. private _setupBackground;
  111574. /**
  111575. * Get the scene sizes according to the setup.
  111576. */
  111577. private _getSceneSize;
  111578. /**
  111579. * Setup the ground according to the specified options.
  111580. */
  111581. private _setupGround;
  111582. /**
  111583. * Setup the ground material according to the specified options.
  111584. */
  111585. private _setupGroundMaterial;
  111586. /**
  111587. * Setup the ground diffuse texture according to the specified options.
  111588. */
  111589. private _setupGroundDiffuseTexture;
  111590. /**
  111591. * Setup the ground mirror texture according to the specified options.
  111592. */
  111593. private _setupGroundMirrorTexture;
  111594. /**
  111595. * Setup the ground to receive the mirror texture.
  111596. */
  111597. private _setupMirrorInGroundMaterial;
  111598. /**
  111599. * Setup the skybox according to the specified options.
  111600. */
  111601. private _setupSkybox;
  111602. /**
  111603. * Setup the skybox material according to the specified options.
  111604. */
  111605. private _setupSkyboxMaterial;
  111606. /**
  111607. * Setup the skybox reflection texture according to the specified options.
  111608. */
  111609. private _setupSkyboxReflectionTexture;
  111610. private _errorHandler;
  111611. /**
  111612. * Dispose all the elements created by the Helper.
  111613. */
  111614. dispose(): void;
  111615. }
  111616. }
  111617. declare module BABYLON {
  111618. /**
  111619. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  111620. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  111621. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  111622. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111623. */
  111624. export class PhotoDome extends TransformNode {
  111625. /**
  111626. * Define the image as a Monoscopic panoramic 360 image.
  111627. */
  111628. static readonly MODE_MONOSCOPIC: number;
  111629. /**
  111630. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111631. */
  111632. static readonly MODE_TOPBOTTOM: number;
  111633. /**
  111634. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111635. */
  111636. static readonly MODE_SIDEBYSIDE: number;
  111637. private _useDirectMapping;
  111638. /**
  111639. * The texture being displayed on the sphere
  111640. */
  111641. protected _photoTexture: Texture;
  111642. /**
  111643. * Gets or sets the texture being displayed on the sphere
  111644. */
  111645. photoTexture: Texture;
  111646. /**
  111647. * Observable raised when an error occured while loading the 360 image
  111648. */
  111649. onLoadErrorObservable: Observable<string>;
  111650. /**
  111651. * The skybox material
  111652. */
  111653. protected _material: BackgroundMaterial;
  111654. /**
  111655. * The surface used for the skybox
  111656. */
  111657. protected _mesh: Mesh;
  111658. /**
  111659. * Gets the mesh used for the skybox.
  111660. */
  111661. readonly mesh: Mesh;
  111662. /**
  111663. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111664. * Also see the options.resolution property.
  111665. */
  111666. fovMultiplier: number;
  111667. private _imageMode;
  111668. /**
  111669. * Gets or set the current video mode for the video. It can be:
  111670. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  111671. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111672. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111673. */
  111674. imageMode: number;
  111675. /**
  111676. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  111677. * @param name Element's name, child elements will append suffixes for their own names.
  111678. * @param urlsOfPhoto defines the url of the photo to display
  111679. * @param options defines an object containing optional or exposed sub element properties
  111680. * @param onError defines a callback called when an error occured while loading the texture
  111681. */
  111682. constructor(name: string, urlOfPhoto: string, options: {
  111683. resolution?: number;
  111684. size?: number;
  111685. useDirectMapping?: boolean;
  111686. faceForward?: boolean;
  111687. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  111688. private _onBeforeCameraRenderObserver;
  111689. private _changeImageMode;
  111690. /**
  111691. * Releases resources associated with this node.
  111692. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111693. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111694. */
  111695. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111696. }
  111697. }
  111698. declare module BABYLON {
  111699. /**
  111700. * Class used to host RGBD texture specific utilities
  111701. */
  111702. export class RGBDTextureTools {
  111703. /**
  111704. * Expand the RGBD Texture from RGBD to Half Float if possible.
  111705. * @param texture the texture to expand.
  111706. */
  111707. static ExpandRGBDTexture(texture: Texture): void;
  111708. }
  111709. }
  111710. declare module BABYLON {
  111711. /**
  111712. * Class used to host texture specific utilities
  111713. */
  111714. export class BRDFTextureTools {
  111715. /**
  111716. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  111717. * @param scene defines the hosting scene
  111718. * @returns the environment BRDF texture
  111719. */
  111720. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  111721. private static _environmentBRDFBase64Texture;
  111722. }
  111723. }
  111724. declare module BABYLON {
  111725. /**
  111726. * @hidden
  111727. */
  111728. export interface IMaterialClearCoatDefines {
  111729. CLEARCOAT: boolean;
  111730. CLEARCOAT_DEFAULTIOR: boolean;
  111731. CLEARCOAT_TEXTURE: boolean;
  111732. CLEARCOAT_TEXTUREDIRECTUV: number;
  111733. CLEARCOAT_BUMP: boolean;
  111734. CLEARCOAT_BUMPDIRECTUV: number;
  111735. CLEARCOAT_TINT: boolean;
  111736. CLEARCOAT_TINT_TEXTURE: boolean;
  111737. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111738. /** @hidden */
  111739. _areTexturesDirty: boolean;
  111740. }
  111741. /**
  111742. * Define the code related to the clear coat parameters of the pbr material.
  111743. */
  111744. export class PBRClearCoatConfiguration {
  111745. /**
  111746. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111747. * The default fits with a polyurethane material.
  111748. */
  111749. private static readonly _DefaultIndexOfRefraction;
  111750. private _isEnabled;
  111751. /**
  111752. * Defines if the clear coat is enabled in the material.
  111753. */
  111754. isEnabled: boolean;
  111755. /**
  111756. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  111757. */
  111758. intensity: number;
  111759. /**
  111760. * Defines the clear coat layer roughness.
  111761. */
  111762. roughness: number;
  111763. private _indexOfRefraction;
  111764. /**
  111765. * Defines the index of refraction of the clear coat.
  111766. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111767. * The default fits with a polyurethane material.
  111768. * Changing the default value is more performance intensive.
  111769. */
  111770. indexOfRefraction: number;
  111771. private _texture;
  111772. /**
  111773. * Stores the clear coat values in a texture.
  111774. */
  111775. texture: Nullable<BaseTexture>;
  111776. private _bumpTexture;
  111777. /**
  111778. * Define the clear coat specific bump texture.
  111779. */
  111780. bumpTexture: Nullable<BaseTexture>;
  111781. private _isTintEnabled;
  111782. /**
  111783. * Defines if the clear coat tint is enabled in the material.
  111784. */
  111785. isTintEnabled: boolean;
  111786. /**
  111787. * Defines the clear coat tint of the material.
  111788. * This is only use if tint is enabled
  111789. */
  111790. tintColor: Color3;
  111791. /**
  111792. * Defines the distance at which the tint color should be found in the
  111793. * clear coat media.
  111794. * This is only use if tint is enabled
  111795. */
  111796. tintColorAtDistance: number;
  111797. /**
  111798. * Defines the clear coat layer thickness.
  111799. * This is only use if tint is enabled
  111800. */
  111801. tintThickness: number;
  111802. private _tintTexture;
  111803. /**
  111804. * Stores the clear tint values in a texture.
  111805. * rgb is tint
  111806. * a is a thickness factor
  111807. */
  111808. tintTexture: Nullable<BaseTexture>;
  111809. /** @hidden */
  111810. private _internalMarkAllSubMeshesAsTexturesDirty;
  111811. /** @hidden */
  111812. _markAllSubMeshesAsTexturesDirty(): void;
  111813. /**
  111814. * Instantiate a new istance of clear coat configuration.
  111815. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111816. */
  111817. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111818. /**
  111819. * Gets wehter the submesh is ready to be used or not.
  111820. * @param defines the list of "defines" to update.
  111821. * @param scene defines the scene the material belongs to.
  111822. * @param engine defines the engine the material belongs to.
  111823. * @param disableBumpMap defines wether the material disables bump or not.
  111824. * @returns - boolean indicating that the submesh is ready or not.
  111825. */
  111826. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  111827. /**
  111828. * Checks to see if a texture is used in the material.
  111829. * @param defines the list of "defines" to update.
  111830. * @param scene defines the scene to the material belongs to.
  111831. */
  111832. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  111833. /**
  111834. * Binds the material data.
  111835. * @param uniformBuffer defines the Uniform buffer to fill in.
  111836. * @param scene defines the scene the material belongs to.
  111837. * @param engine defines the engine the material belongs to.
  111838. * @param disableBumpMap defines wether the material disables bump or not.
  111839. * @param isFrozen defines wether the material is frozen or not.
  111840. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111841. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111842. */
  111843. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  111844. /**
  111845. * Checks to see if a texture is used in the material.
  111846. * @param texture - Base texture to use.
  111847. * @returns - Boolean specifying if a texture is used in the material.
  111848. */
  111849. hasTexture(texture: BaseTexture): boolean;
  111850. /**
  111851. * Returns an array of the actively used textures.
  111852. * @param activeTextures Array of BaseTextures
  111853. */
  111854. getActiveTextures(activeTextures: BaseTexture[]): void;
  111855. /**
  111856. * Returns the animatable textures.
  111857. * @param animatables Array of animatable textures.
  111858. */
  111859. getAnimatables(animatables: IAnimatable[]): void;
  111860. /**
  111861. * Disposes the resources of the material.
  111862. * @param forceDisposeTextures - Forces the disposal of all textures.
  111863. */
  111864. dispose(forceDisposeTextures?: boolean): void;
  111865. /**
  111866. * Get the current class name of the texture useful for serialization or dynamic coding.
  111867. * @returns "PBRClearCoatConfiguration"
  111868. */
  111869. getClassName(): string;
  111870. /**
  111871. * Add fallbacks to the effect fallbacks list.
  111872. * @param defines defines the Base texture to use.
  111873. * @param fallbacks defines the current fallback list.
  111874. * @param currentRank defines the current fallback rank.
  111875. * @returns the new fallback rank.
  111876. */
  111877. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111878. /**
  111879. * Add the required uniforms to the current list.
  111880. * @param uniforms defines the current uniform list.
  111881. */
  111882. static AddUniforms(uniforms: string[]): void;
  111883. /**
  111884. * Add the required samplers to the current list.
  111885. * @param samplers defines the current sampler list.
  111886. */
  111887. static AddSamplers(samplers: string[]): void;
  111888. /**
  111889. * Add the required uniforms to the current buffer.
  111890. * @param uniformBuffer defines the current uniform buffer.
  111891. */
  111892. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111893. /**
  111894. * Makes a duplicate of the current configuration into another one.
  111895. * @param clearCoatConfiguration define the config where to copy the info
  111896. */
  111897. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  111898. /**
  111899. * Serializes this clear coat configuration.
  111900. * @returns - An object with the serialized config.
  111901. */
  111902. serialize(): any;
  111903. /**
  111904. * Parses a anisotropy Configuration from a serialized object.
  111905. * @param source - Serialized object.
  111906. * @param scene Defines the scene we are parsing for
  111907. * @param rootUrl Defines the rootUrl to load from
  111908. */
  111909. parse(source: any, scene: Scene, rootUrl: string): void;
  111910. }
  111911. }
  111912. declare module BABYLON {
  111913. /**
  111914. * @hidden
  111915. */
  111916. export interface IMaterialAnisotropicDefines {
  111917. ANISOTROPIC: boolean;
  111918. ANISOTROPIC_TEXTURE: boolean;
  111919. ANISOTROPIC_TEXTUREDIRECTUV: number;
  111920. MAINUV1: boolean;
  111921. _areTexturesDirty: boolean;
  111922. _needUVs: boolean;
  111923. }
  111924. /**
  111925. * Define the code related to the anisotropic parameters of the pbr material.
  111926. */
  111927. export class PBRAnisotropicConfiguration {
  111928. private _isEnabled;
  111929. /**
  111930. * Defines if the anisotropy is enabled in the material.
  111931. */
  111932. isEnabled: boolean;
  111933. /**
  111934. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  111935. */
  111936. intensity: number;
  111937. /**
  111938. * Defines if the effect is along the tangents, bitangents or in between.
  111939. * By default, the effect is "strectching" the highlights along the tangents.
  111940. */
  111941. direction: Vector2;
  111942. private _texture;
  111943. /**
  111944. * Stores the anisotropy values in a texture.
  111945. * rg is direction (like normal from -1 to 1)
  111946. * b is a intensity
  111947. */
  111948. texture: Nullable<BaseTexture>;
  111949. /** @hidden */
  111950. private _internalMarkAllSubMeshesAsTexturesDirty;
  111951. /** @hidden */
  111952. _markAllSubMeshesAsTexturesDirty(): void;
  111953. /**
  111954. * Instantiate a new istance of anisotropy configuration.
  111955. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111956. */
  111957. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111958. /**
  111959. * Specifies that the submesh is ready to be used.
  111960. * @param defines the list of "defines" to update.
  111961. * @param scene defines the scene the material belongs to.
  111962. * @returns - boolean indicating that the submesh is ready or not.
  111963. */
  111964. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  111965. /**
  111966. * Checks to see if a texture is used in the material.
  111967. * @param defines the list of "defines" to update.
  111968. * @param mesh the mesh we are preparing the defines for.
  111969. * @param scene defines the scene the material belongs to.
  111970. */
  111971. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  111972. /**
  111973. * Binds the material data.
  111974. * @param uniformBuffer defines the Uniform buffer to fill in.
  111975. * @param scene defines the scene the material belongs to.
  111976. * @param isFrozen defines wether the material is frozen or not.
  111977. */
  111978. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  111979. /**
  111980. * Checks to see if a texture is used in the material.
  111981. * @param texture - Base texture to use.
  111982. * @returns - Boolean specifying if a texture is used in the material.
  111983. */
  111984. hasTexture(texture: BaseTexture): boolean;
  111985. /**
  111986. * Returns an array of the actively used textures.
  111987. * @param activeTextures Array of BaseTextures
  111988. */
  111989. getActiveTextures(activeTextures: BaseTexture[]): void;
  111990. /**
  111991. * Returns the animatable textures.
  111992. * @param animatables Array of animatable textures.
  111993. */
  111994. getAnimatables(animatables: IAnimatable[]): void;
  111995. /**
  111996. * Disposes the resources of the material.
  111997. * @param forceDisposeTextures - Forces the disposal of all textures.
  111998. */
  111999. dispose(forceDisposeTextures?: boolean): void;
  112000. /**
  112001. * Get the current class name of the texture useful for serialization or dynamic coding.
  112002. * @returns "PBRAnisotropicConfiguration"
  112003. */
  112004. getClassName(): string;
  112005. /**
  112006. * Add fallbacks to the effect fallbacks list.
  112007. * @param defines defines the Base texture to use.
  112008. * @param fallbacks defines the current fallback list.
  112009. * @param currentRank defines the current fallback rank.
  112010. * @returns the new fallback rank.
  112011. */
  112012. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112013. /**
  112014. * Add the required uniforms to the current list.
  112015. * @param uniforms defines the current uniform list.
  112016. */
  112017. static AddUniforms(uniforms: string[]): void;
  112018. /**
  112019. * Add the required uniforms to the current buffer.
  112020. * @param uniformBuffer defines the current uniform buffer.
  112021. */
  112022. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112023. /**
  112024. * Add the required samplers to the current list.
  112025. * @param samplers defines the current sampler list.
  112026. */
  112027. static AddSamplers(samplers: string[]): void;
  112028. /**
  112029. * Makes a duplicate of the current configuration into another one.
  112030. * @param anisotropicConfiguration define the config where to copy the info
  112031. */
  112032. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  112033. /**
  112034. * Serializes this anisotropy configuration.
  112035. * @returns - An object with the serialized config.
  112036. */
  112037. serialize(): any;
  112038. /**
  112039. * Parses a anisotropy Configuration from a serialized object.
  112040. * @param source - Serialized object.
  112041. * @param scene Defines the scene we are parsing for
  112042. * @param rootUrl Defines the rootUrl to load from
  112043. */
  112044. parse(source: any, scene: Scene, rootUrl: string): void;
  112045. }
  112046. }
  112047. declare module BABYLON {
  112048. /**
  112049. * @hidden
  112050. */
  112051. export interface IMaterialBRDFDefines {
  112052. BRDF_V_HEIGHT_CORRELATED: boolean;
  112053. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112054. SPHERICAL_HARMONICS: boolean;
  112055. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112056. /** @hidden */
  112057. _areMiscDirty: boolean;
  112058. }
  112059. /**
  112060. * Define the code related to the BRDF parameters of the pbr material.
  112061. */
  112062. export class PBRBRDFConfiguration {
  112063. /**
  112064. * Default value used for the energy conservation.
  112065. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112066. */
  112067. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  112068. /**
  112069. * Default value used for the Smith Visibility Height Correlated mode.
  112070. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112071. */
  112072. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  112073. /**
  112074. * Default value used for the IBL diffuse part.
  112075. * This can help switching back to the polynomials mode globally which is a tiny bit
  112076. * less GPU intensive at the drawback of a lower quality.
  112077. */
  112078. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  112079. /**
  112080. * Default value used for activating energy conservation for the specular workflow.
  112081. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112082. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112083. */
  112084. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  112085. private _useEnergyConservation;
  112086. /**
  112087. * Defines if the material uses energy conservation.
  112088. */
  112089. useEnergyConservation: boolean;
  112090. private _useSmithVisibilityHeightCorrelated;
  112091. /**
  112092. * LEGACY Mode set to false
  112093. * Defines if the material uses height smith correlated visibility term.
  112094. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  112095. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  112096. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  112097. * Not relying on height correlated will also disable energy conservation.
  112098. */
  112099. useSmithVisibilityHeightCorrelated: boolean;
  112100. private _useSphericalHarmonics;
  112101. /**
  112102. * LEGACY Mode set to false
  112103. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  112104. * diffuse part of the IBL.
  112105. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  112106. * to the ground truth.
  112107. */
  112108. useSphericalHarmonics: boolean;
  112109. private _useSpecularGlossinessInputEnergyConservation;
  112110. /**
  112111. * Defines if the material uses energy conservation, when the specular workflow is active.
  112112. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112113. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112114. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  112115. */
  112116. useSpecularGlossinessInputEnergyConservation: boolean;
  112117. /** @hidden */
  112118. private _internalMarkAllSubMeshesAsMiscDirty;
  112119. /** @hidden */
  112120. _markAllSubMeshesAsMiscDirty(): void;
  112121. /**
  112122. * Instantiate a new istance of clear coat configuration.
  112123. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  112124. */
  112125. constructor(markAllSubMeshesAsMiscDirty: () => void);
  112126. /**
  112127. * Checks to see if a texture is used in the material.
  112128. * @param defines the list of "defines" to update.
  112129. */
  112130. prepareDefines(defines: IMaterialBRDFDefines): void;
  112131. /**
  112132. * Get the current class name of the texture useful for serialization or dynamic coding.
  112133. * @returns "PBRClearCoatConfiguration"
  112134. */
  112135. getClassName(): string;
  112136. /**
  112137. * Makes a duplicate of the current configuration into another one.
  112138. * @param brdfConfiguration define the config where to copy the info
  112139. */
  112140. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  112141. /**
  112142. * Serializes this BRDF configuration.
  112143. * @returns - An object with the serialized config.
  112144. */
  112145. serialize(): any;
  112146. /**
  112147. * Parses a anisotropy Configuration from a serialized object.
  112148. * @param source - Serialized object.
  112149. * @param scene Defines the scene we are parsing for
  112150. * @param rootUrl Defines the rootUrl to load from
  112151. */
  112152. parse(source: any, scene: Scene, rootUrl: string): void;
  112153. }
  112154. }
  112155. declare module BABYLON {
  112156. /**
  112157. * @hidden
  112158. */
  112159. export interface IMaterialSheenDefines {
  112160. SHEEN: boolean;
  112161. SHEEN_TEXTURE: boolean;
  112162. SHEEN_TEXTUREDIRECTUV: number;
  112163. SHEEN_LINKWITHALBEDO: boolean;
  112164. /** @hidden */
  112165. _areTexturesDirty: boolean;
  112166. }
  112167. /**
  112168. * Define the code related to the Sheen parameters of the pbr material.
  112169. */
  112170. export class PBRSheenConfiguration {
  112171. private _isEnabled;
  112172. /**
  112173. * Defines if the material uses sheen.
  112174. */
  112175. isEnabled: boolean;
  112176. private _linkSheenWithAlbedo;
  112177. /**
  112178. * Defines if the sheen is linked to the sheen color.
  112179. */
  112180. linkSheenWithAlbedo: boolean;
  112181. /**
  112182. * Defines the sheen intensity.
  112183. */
  112184. intensity: number;
  112185. /**
  112186. * Defines the sheen color.
  112187. */
  112188. color: Color3;
  112189. private _texture;
  112190. /**
  112191. * Stores the sheen tint values in a texture.
  112192. * rgb is tint
  112193. * a is a intensity
  112194. */
  112195. texture: Nullable<BaseTexture>;
  112196. /** @hidden */
  112197. private _internalMarkAllSubMeshesAsTexturesDirty;
  112198. /** @hidden */
  112199. _markAllSubMeshesAsTexturesDirty(): void;
  112200. /**
  112201. * Instantiate a new istance of clear coat configuration.
  112202. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112203. */
  112204. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112205. /**
  112206. * Specifies that the submesh is ready to be used.
  112207. * @param defines the list of "defines" to update.
  112208. * @param scene defines the scene the material belongs to.
  112209. * @returns - boolean indicating that the submesh is ready or not.
  112210. */
  112211. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  112212. /**
  112213. * Checks to see if a texture is used in the material.
  112214. * @param defines the list of "defines" to update.
  112215. * @param scene defines the scene the material belongs to.
  112216. */
  112217. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  112218. /**
  112219. * Binds the material data.
  112220. * @param uniformBuffer defines the Uniform buffer to fill in.
  112221. * @param scene defines the scene the material belongs to.
  112222. * @param isFrozen defines wether the material is frozen or not.
  112223. */
  112224. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112225. /**
  112226. * Checks to see if a texture is used in the material.
  112227. * @param texture - Base texture to use.
  112228. * @returns - Boolean specifying if a texture is used in the material.
  112229. */
  112230. hasTexture(texture: BaseTexture): boolean;
  112231. /**
  112232. * Returns an array of the actively used textures.
  112233. * @param activeTextures Array of BaseTextures
  112234. */
  112235. getActiveTextures(activeTextures: BaseTexture[]): void;
  112236. /**
  112237. * Returns the animatable textures.
  112238. * @param animatables Array of animatable textures.
  112239. */
  112240. getAnimatables(animatables: IAnimatable[]): void;
  112241. /**
  112242. * Disposes the resources of the material.
  112243. * @param forceDisposeTextures - Forces the disposal of all textures.
  112244. */
  112245. dispose(forceDisposeTextures?: boolean): void;
  112246. /**
  112247. * Get the current class name of the texture useful for serialization or dynamic coding.
  112248. * @returns "PBRSheenConfiguration"
  112249. */
  112250. getClassName(): string;
  112251. /**
  112252. * Add fallbacks to the effect fallbacks list.
  112253. * @param defines defines the Base texture to use.
  112254. * @param fallbacks defines the current fallback list.
  112255. * @param currentRank defines the current fallback rank.
  112256. * @returns the new fallback rank.
  112257. */
  112258. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112259. /**
  112260. * Add the required uniforms to the current list.
  112261. * @param uniforms defines the current uniform list.
  112262. */
  112263. static AddUniforms(uniforms: string[]): void;
  112264. /**
  112265. * Add the required uniforms to the current buffer.
  112266. * @param uniformBuffer defines the current uniform buffer.
  112267. */
  112268. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112269. /**
  112270. * Add the required samplers to the current list.
  112271. * @param samplers defines the current sampler list.
  112272. */
  112273. static AddSamplers(samplers: string[]): void;
  112274. /**
  112275. * Makes a duplicate of the current configuration into another one.
  112276. * @param sheenConfiguration define the config where to copy the info
  112277. */
  112278. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  112279. /**
  112280. * Serializes this BRDF configuration.
  112281. * @returns - An object with the serialized config.
  112282. */
  112283. serialize(): any;
  112284. /**
  112285. * Parses a anisotropy Configuration from a serialized object.
  112286. * @param source - Serialized object.
  112287. * @param scene Defines the scene we are parsing for
  112288. * @param rootUrl Defines the rootUrl to load from
  112289. */
  112290. parse(source: any, scene: Scene, rootUrl: string): void;
  112291. }
  112292. }
  112293. declare module BABYLON {
  112294. /**
  112295. * @hidden
  112296. */
  112297. export interface IMaterialSubSurfaceDefines {
  112298. SUBSURFACE: boolean;
  112299. SS_REFRACTION: boolean;
  112300. SS_TRANSLUCENCY: boolean;
  112301. SS_SCATERRING: boolean;
  112302. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112303. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112304. SS_REFRACTIONMAP_3D: boolean;
  112305. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112306. SS_LODINREFRACTIONALPHA: boolean;
  112307. SS_GAMMAREFRACTION: boolean;
  112308. SS_RGBDREFRACTION: boolean;
  112309. SS_LINEARSPECULARREFRACTION: boolean;
  112310. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112311. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112312. /** @hidden */
  112313. _areTexturesDirty: boolean;
  112314. }
  112315. /**
  112316. * Define the code related to the sub surface parameters of the pbr material.
  112317. */
  112318. export class PBRSubSurfaceConfiguration {
  112319. private _isRefractionEnabled;
  112320. /**
  112321. * Defines if the refraction is enabled in the material.
  112322. */
  112323. isRefractionEnabled: boolean;
  112324. private _isTranslucencyEnabled;
  112325. /**
  112326. * Defines if the translucency is enabled in the material.
  112327. */
  112328. isTranslucencyEnabled: boolean;
  112329. private _isScatteringEnabled;
  112330. /**
  112331. * Defines the refraction intensity of the material.
  112332. * The refraction when enabled replaces the Diffuse part of the material.
  112333. * The intensity helps transitionning between diffuse and refraction.
  112334. */
  112335. refractionIntensity: number;
  112336. /**
  112337. * Defines the translucency intensity of the material.
  112338. * When translucency has been enabled, this defines how much of the "translucency"
  112339. * is addded to the diffuse part of the material.
  112340. */
  112341. translucencyIntensity: number;
  112342. /**
  112343. * Defines the scattering intensity of the material.
  112344. * When scattering has been enabled, this defines how much of the "scattered light"
  112345. * is addded to the diffuse part of the material.
  112346. */
  112347. scatteringIntensity: number;
  112348. private _thicknessTexture;
  112349. /**
  112350. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  112351. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  112352. * 0 would mean minimumThickness
  112353. * 1 would mean maximumThickness
  112354. * The other channels might be use as a mask to vary the different effects intensity.
  112355. */
  112356. thicknessTexture: Nullable<BaseTexture>;
  112357. private _refractionTexture;
  112358. /**
  112359. * Defines the texture to use for refraction.
  112360. */
  112361. refractionTexture: Nullable<BaseTexture>;
  112362. private _indexOfRefraction;
  112363. /**
  112364. * Defines the index of refraction used in the material.
  112365. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  112366. */
  112367. indexOfRefraction: number;
  112368. private _invertRefractionY;
  112369. /**
  112370. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112371. */
  112372. invertRefractionY: boolean;
  112373. private _linkRefractionWithTransparency;
  112374. /**
  112375. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112376. * Materials half opaque for instance using refraction could benefit from this control.
  112377. */
  112378. linkRefractionWithTransparency: boolean;
  112379. /**
  112380. * Defines the minimum thickness stored in the thickness map.
  112381. * If no thickness map is defined, this value will be used to simulate thickness.
  112382. */
  112383. minimumThickness: number;
  112384. /**
  112385. * Defines the maximum thickness stored in the thickness map.
  112386. */
  112387. maximumThickness: number;
  112388. /**
  112389. * Defines the volume tint of the material.
  112390. * This is used for both translucency and scattering.
  112391. */
  112392. tintColor: Color3;
  112393. /**
  112394. * Defines the distance at which the tint color should be found in the media.
  112395. * This is used for refraction only.
  112396. */
  112397. tintColorAtDistance: number;
  112398. /**
  112399. * Defines how far each channel transmit through the media.
  112400. * It is defined as a color to simplify it selection.
  112401. */
  112402. diffusionDistance: Color3;
  112403. private _useMaskFromThicknessTexture;
  112404. /**
  112405. * Stores the intensity of the different subsurface effects in the thickness texture.
  112406. * * the green channel is the translucency intensity.
  112407. * * the blue channel is the scattering intensity.
  112408. * * the alpha channel is the refraction intensity.
  112409. */
  112410. useMaskFromThicknessTexture: boolean;
  112411. /** @hidden */
  112412. private _internalMarkAllSubMeshesAsTexturesDirty;
  112413. /** @hidden */
  112414. _markAllSubMeshesAsTexturesDirty(): void;
  112415. /**
  112416. * Instantiate a new istance of sub surface configuration.
  112417. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112418. */
  112419. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112420. /**
  112421. * Gets wehter the submesh is ready to be used or not.
  112422. * @param defines the list of "defines" to update.
  112423. * @param scene defines the scene the material belongs to.
  112424. * @returns - boolean indicating that the submesh is ready or not.
  112425. */
  112426. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  112427. /**
  112428. * Checks to see if a texture is used in the material.
  112429. * @param defines the list of "defines" to update.
  112430. * @param scene defines the scene to the material belongs to.
  112431. */
  112432. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  112433. /**
  112434. * Binds the material data.
  112435. * @param uniformBuffer defines the Uniform buffer to fill in.
  112436. * @param scene defines the scene the material belongs to.
  112437. * @param engine defines the engine the material belongs to.
  112438. * @param isFrozen defines wether the material is frozen or not.
  112439. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  112440. */
  112441. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  112442. /**
  112443. * Unbinds the material from the mesh.
  112444. * @param activeEffect defines the effect that should be unbound from.
  112445. * @returns true if unbound, otherwise false
  112446. */
  112447. unbind(activeEffect: Effect): boolean;
  112448. /**
  112449. * Returns the texture used for refraction or null if none is used.
  112450. * @param scene defines the scene the material belongs to.
  112451. * @returns - Refraction texture if present. If no refraction texture and refraction
  112452. * is linked with transparency, returns environment texture. Otherwise, returns null.
  112453. */
  112454. private _getRefractionTexture;
  112455. /**
  112456. * Returns true if alpha blending should be disabled.
  112457. */
  112458. readonly disableAlphaBlending: boolean;
  112459. /**
  112460. * Fills the list of render target textures.
  112461. * @param renderTargets the list of render targets to update
  112462. */
  112463. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  112464. /**
  112465. * Checks to see if a texture is used in the material.
  112466. * @param texture - Base texture to use.
  112467. * @returns - Boolean specifying if a texture is used in the material.
  112468. */
  112469. hasTexture(texture: BaseTexture): boolean;
  112470. /**
  112471. * Gets a boolean indicating that current material needs to register RTT
  112472. * @returns true if this uses a render target otherwise false.
  112473. */
  112474. hasRenderTargetTextures(): boolean;
  112475. /**
  112476. * Returns an array of the actively used textures.
  112477. * @param activeTextures Array of BaseTextures
  112478. */
  112479. getActiveTextures(activeTextures: BaseTexture[]): void;
  112480. /**
  112481. * Returns the animatable textures.
  112482. * @param animatables Array of animatable textures.
  112483. */
  112484. getAnimatables(animatables: IAnimatable[]): void;
  112485. /**
  112486. * Disposes the resources of the material.
  112487. * @param forceDisposeTextures - Forces the disposal of all textures.
  112488. */
  112489. dispose(forceDisposeTextures?: boolean): void;
  112490. /**
  112491. * Get the current class name of the texture useful for serialization or dynamic coding.
  112492. * @returns "PBRSubSurfaceConfiguration"
  112493. */
  112494. getClassName(): string;
  112495. /**
  112496. * Add fallbacks to the effect fallbacks list.
  112497. * @param defines defines the Base texture to use.
  112498. * @param fallbacks defines the current fallback list.
  112499. * @param currentRank defines the current fallback rank.
  112500. * @returns the new fallback rank.
  112501. */
  112502. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112503. /**
  112504. * Add the required uniforms to the current list.
  112505. * @param uniforms defines the current uniform list.
  112506. */
  112507. static AddUniforms(uniforms: string[]): void;
  112508. /**
  112509. * Add the required samplers to the current list.
  112510. * @param samplers defines the current sampler list.
  112511. */
  112512. static AddSamplers(samplers: string[]): void;
  112513. /**
  112514. * Add the required uniforms to the current buffer.
  112515. * @param uniformBuffer defines the current uniform buffer.
  112516. */
  112517. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112518. /**
  112519. * Makes a duplicate of the current configuration into another one.
  112520. * @param configuration define the config where to copy the info
  112521. */
  112522. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  112523. /**
  112524. * Serializes this Sub Surface configuration.
  112525. * @returns - An object with the serialized config.
  112526. */
  112527. serialize(): any;
  112528. /**
  112529. * Parses a anisotropy Configuration from a serialized object.
  112530. * @param source - Serialized object.
  112531. * @param scene Defines the scene we are parsing for
  112532. * @param rootUrl Defines the rootUrl to load from
  112533. */
  112534. parse(source: any, scene: Scene, rootUrl: string): void;
  112535. }
  112536. }
  112537. declare module BABYLON {
  112538. /** @hidden */
  112539. export var pbrFragmentDeclaration: {
  112540. name: string;
  112541. shader: string;
  112542. };
  112543. }
  112544. declare module BABYLON {
  112545. /** @hidden */
  112546. export var pbrUboDeclaration: {
  112547. name: string;
  112548. shader: string;
  112549. };
  112550. }
  112551. declare module BABYLON {
  112552. /** @hidden */
  112553. export var pbrFragmentExtraDeclaration: {
  112554. name: string;
  112555. shader: string;
  112556. };
  112557. }
  112558. declare module BABYLON {
  112559. /** @hidden */
  112560. export var pbrFragmentSamplersDeclaration: {
  112561. name: string;
  112562. shader: string;
  112563. };
  112564. }
  112565. declare module BABYLON {
  112566. /** @hidden */
  112567. export var pbrHelperFunctions: {
  112568. name: string;
  112569. shader: string;
  112570. };
  112571. }
  112572. declare module BABYLON {
  112573. /** @hidden */
  112574. export var harmonicsFunctions: {
  112575. name: string;
  112576. shader: string;
  112577. };
  112578. }
  112579. declare module BABYLON {
  112580. /** @hidden */
  112581. export var pbrDirectLightingSetupFunctions: {
  112582. name: string;
  112583. shader: string;
  112584. };
  112585. }
  112586. declare module BABYLON {
  112587. /** @hidden */
  112588. export var pbrDirectLightingFalloffFunctions: {
  112589. name: string;
  112590. shader: string;
  112591. };
  112592. }
  112593. declare module BABYLON {
  112594. /** @hidden */
  112595. export var pbrBRDFFunctions: {
  112596. name: string;
  112597. shader: string;
  112598. };
  112599. }
  112600. declare module BABYLON {
  112601. /** @hidden */
  112602. export var pbrDirectLightingFunctions: {
  112603. name: string;
  112604. shader: string;
  112605. };
  112606. }
  112607. declare module BABYLON {
  112608. /** @hidden */
  112609. export var pbrIBLFunctions: {
  112610. name: string;
  112611. shader: string;
  112612. };
  112613. }
  112614. declare module BABYLON {
  112615. /** @hidden */
  112616. export var pbrDebug: {
  112617. name: string;
  112618. shader: string;
  112619. };
  112620. }
  112621. declare module BABYLON {
  112622. /** @hidden */
  112623. export var pbrPixelShader: {
  112624. name: string;
  112625. shader: string;
  112626. };
  112627. }
  112628. declare module BABYLON {
  112629. /** @hidden */
  112630. export var pbrVertexDeclaration: {
  112631. name: string;
  112632. shader: string;
  112633. };
  112634. }
  112635. declare module BABYLON {
  112636. /** @hidden */
  112637. export var pbrVertexShader: {
  112638. name: string;
  112639. shader: string;
  112640. };
  112641. }
  112642. declare module BABYLON {
  112643. /**
  112644. * Manages the defines for the PBR Material.
  112645. * @hidden
  112646. */
  112647. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  112648. PBR: boolean;
  112649. MAINUV1: boolean;
  112650. MAINUV2: boolean;
  112651. UV1: boolean;
  112652. UV2: boolean;
  112653. ALBEDO: boolean;
  112654. ALBEDODIRECTUV: number;
  112655. VERTEXCOLOR: boolean;
  112656. AMBIENT: boolean;
  112657. AMBIENTDIRECTUV: number;
  112658. AMBIENTINGRAYSCALE: boolean;
  112659. OPACITY: boolean;
  112660. VERTEXALPHA: boolean;
  112661. OPACITYDIRECTUV: number;
  112662. OPACITYRGB: boolean;
  112663. ALPHATEST: boolean;
  112664. DEPTHPREPASS: boolean;
  112665. ALPHABLEND: boolean;
  112666. ALPHAFROMALBEDO: boolean;
  112667. ALPHATESTVALUE: string;
  112668. SPECULAROVERALPHA: boolean;
  112669. RADIANCEOVERALPHA: boolean;
  112670. ALPHAFRESNEL: boolean;
  112671. LINEARALPHAFRESNEL: boolean;
  112672. PREMULTIPLYALPHA: boolean;
  112673. EMISSIVE: boolean;
  112674. EMISSIVEDIRECTUV: number;
  112675. REFLECTIVITY: boolean;
  112676. REFLECTIVITYDIRECTUV: number;
  112677. SPECULARTERM: boolean;
  112678. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  112679. MICROSURFACEAUTOMATIC: boolean;
  112680. LODBASEDMICROSFURACE: boolean;
  112681. MICROSURFACEMAP: boolean;
  112682. MICROSURFACEMAPDIRECTUV: number;
  112683. METALLICWORKFLOW: boolean;
  112684. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  112685. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  112686. METALLNESSSTOREINMETALMAPBLUE: boolean;
  112687. AOSTOREINMETALMAPRED: boolean;
  112688. ENVIRONMENTBRDF: boolean;
  112689. ENVIRONMENTBRDF_RGBD: boolean;
  112690. NORMAL: boolean;
  112691. TANGENT: boolean;
  112692. BUMP: boolean;
  112693. BUMPDIRECTUV: number;
  112694. OBJECTSPACE_NORMALMAP: boolean;
  112695. PARALLAX: boolean;
  112696. PARALLAXOCCLUSION: boolean;
  112697. NORMALXYSCALE: boolean;
  112698. LIGHTMAP: boolean;
  112699. LIGHTMAPDIRECTUV: number;
  112700. USELIGHTMAPASSHADOWMAP: boolean;
  112701. GAMMALIGHTMAP: boolean;
  112702. RGBDLIGHTMAP: boolean;
  112703. REFLECTION: boolean;
  112704. REFLECTIONMAP_3D: boolean;
  112705. REFLECTIONMAP_SPHERICAL: boolean;
  112706. REFLECTIONMAP_PLANAR: boolean;
  112707. REFLECTIONMAP_CUBIC: boolean;
  112708. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  112709. REFLECTIONMAP_PROJECTION: boolean;
  112710. REFLECTIONMAP_SKYBOX: boolean;
  112711. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  112712. REFLECTIONMAP_EXPLICIT: boolean;
  112713. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  112714. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  112715. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  112716. INVERTCUBICMAP: boolean;
  112717. USESPHERICALFROMREFLECTIONMAP: boolean;
  112718. USEIRRADIANCEMAP: boolean;
  112719. SPHERICAL_HARMONICS: boolean;
  112720. USESPHERICALINVERTEX: boolean;
  112721. REFLECTIONMAP_OPPOSITEZ: boolean;
  112722. LODINREFLECTIONALPHA: boolean;
  112723. GAMMAREFLECTION: boolean;
  112724. RGBDREFLECTION: boolean;
  112725. LINEARSPECULARREFLECTION: boolean;
  112726. RADIANCEOCCLUSION: boolean;
  112727. HORIZONOCCLUSION: boolean;
  112728. INSTANCES: boolean;
  112729. NUM_BONE_INFLUENCERS: number;
  112730. BonesPerMesh: number;
  112731. BONETEXTURE: boolean;
  112732. NONUNIFORMSCALING: boolean;
  112733. MORPHTARGETS: boolean;
  112734. MORPHTARGETS_NORMAL: boolean;
  112735. MORPHTARGETS_TANGENT: boolean;
  112736. MORPHTARGETS_UV: boolean;
  112737. NUM_MORPH_INFLUENCERS: number;
  112738. IMAGEPROCESSING: boolean;
  112739. VIGNETTE: boolean;
  112740. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112741. VIGNETTEBLENDMODEOPAQUE: boolean;
  112742. TONEMAPPING: boolean;
  112743. TONEMAPPING_ACES: boolean;
  112744. CONTRAST: boolean;
  112745. COLORCURVES: boolean;
  112746. COLORGRADING: boolean;
  112747. COLORGRADING3D: boolean;
  112748. SAMPLER3DGREENDEPTH: boolean;
  112749. SAMPLER3DBGRMAP: boolean;
  112750. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112751. EXPOSURE: boolean;
  112752. MULTIVIEW: boolean;
  112753. USEPHYSICALLIGHTFALLOFF: boolean;
  112754. USEGLTFLIGHTFALLOFF: boolean;
  112755. TWOSIDEDLIGHTING: boolean;
  112756. SHADOWFLOAT: boolean;
  112757. CLIPPLANE: boolean;
  112758. CLIPPLANE2: boolean;
  112759. CLIPPLANE3: boolean;
  112760. CLIPPLANE4: boolean;
  112761. POINTSIZE: boolean;
  112762. FOG: boolean;
  112763. LOGARITHMICDEPTH: boolean;
  112764. FORCENORMALFORWARD: boolean;
  112765. SPECULARAA: boolean;
  112766. CLEARCOAT: boolean;
  112767. CLEARCOAT_DEFAULTIOR: boolean;
  112768. CLEARCOAT_TEXTURE: boolean;
  112769. CLEARCOAT_TEXTUREDIRECTUV: number;
  112770. CLEARCOAT_BUMP: boolean;
  112771. CLEARCOAT_BUMPDIRECTUV: number;
  112772. CLEARCOAT_TINT: boolean;
  112773. CLEARCOAT_TINT_TEXTURE: boolean;
  112774. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112775. ANISOTROPIC: boolean;
  112776. ANISOTROPIC_TEXTURE: boolean;
  112777. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112778. BRDF_V_HEIGHT_CORRELATED: boolean;
  112779. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112780. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112781. SHEEN: boolean;
  112782. SHEEN_TEXTURE: boolean;
  112783. SHEEN_TEXTUREDIRECTUV: number;
  112784. SHEEN_LINKWITHALBEDO: boolean;
  112785. SUBSURFACE: boolean;
  112786. SS_REFRACTION: boolean;
  112787. SS_TRANSLUCENCY: boolean;
  112788. SS_SCATERRING: boolean;
  112789. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112790. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112791. SS_REFRACTIONMAP_3D: boolean;
  112792. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112793. SS_LODINREFRACTIONALPHA: boolean;
  112794. SS_GAMMAREFRACTION: boolean;
  112795. SS_RGBDREFRACTION: boolean;
  112796. SS_LINEARSPECULARREFRACTION: boolean;
  112797. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112798. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112799. UNLIT: boolean;
  112800. DEBUGMODE: number;
  112801. /**
  112802. * Initializes the PBR Material defines.
  112803. */
  112804. constructor();
  112805. /**
  112806. * Resets the PBR Material defines.
  112807. */
  112808. reset(): void;
  112809. }
  112810. /**
  112811. * The Physically based material base class of BJS.
  112812. *
  112813. * This offers the main features of a standard PBR material.
  112814. * For more information, please refer to the documentation :
  112815. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112816. */
  112817. export abstract class PBRBaseMaterial extends PushMaterial {
  112818. /**
  112819. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112820. */
  112821. static readonly PBRMATERIAL_OPAQUE: number;
  112822. /**
  112823. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112824. */
  112825. static readonly PBRMATERIAL_ALPHATEST: number;
  112826. /**
  112827. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112828. */
  112829. static readonly PBRMATERIAL_ALPHABLEND: number;
  112830. /**
  112831. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112832. * They are also discarded below the alpha cutoff threshold to improve performances.
  112833. */
  112834. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112835. /**
  112836. * Defines the default value of how much AO map is occluding the analytical lights
  112837. * (point spot...).
  112838. */
  112839. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112840. /**
  112841. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  112842. */
  112843. static readonly LIGHTFALLOFF_PHYSICAL: number;
  112844. /**
  112845. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  112846. * to enhance interoperability with other engines.
  112847. */
  112848. static readonly LIGHTFALLOFF_GLTF: number;
  112849. /**
  112850. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  112851. * to enhance interoperability with other materials.
  112852. */
  112853. static readonly LIGHTFALLOFF_STANDARD: number;
  112854. /**
  112855. * Intensity of the direct lights e.g. the four lights available in your scene.
  112856. * This impacts both the direct diffuse and specular highlights.
  112857. */
  112858. protected _directIntensity: number;
  112859. /**
  112860. * Intensity of the emissive part of the material.
  112861. * This helps controlling the emissive effect without modifying the emissive color.
  112862. */
  112863. protected _emissiveIntensity: number;
  112864. /**
  112865. * Intensity of the environment e.g. how much the environment will light the object
  112866. * either through harmonics for rough material or through the refelction for shiny ones.
  112867. */
  112868. protected _environmentIntensity: number;
  112869. /**
  112870. * This is a special control allowing the reduction of the specular highlights coming from the
  112871. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  112872. */
  112873. protected _specularIntensity: number;
  112874. /**
  112875. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  112876. */
  112877. private _lightingInfos;
  112878. /**
  112879. * Debug Control allowing disabling the bump map on this material.
  112880. */
  112881. protected _disableBumpMap: boolean;
  112882. /**
  112883. * AKA Diffuse Texture in standard nomenclature.
  112884. */
  112885. protected _albedoTexture: Nullable<BaseTexture>;
  112886. /**
  112887. * AKA Occlusion Texture in other nomenclature.
  112888. */
  112889. protected _ambientTexture: Nullable<BaseTexture>;
  112890. /**
  112891. * AKA Occlusion Texture Intensity in other nomenclature.
  112892. */
  112893. protected _ambientTextureStrength: number;
  112894. /**
  112895. * Defines how much the AO map is occluding the analytical lights (point spot...).
  112896. * 1 means it completely occludes it
  112897. * 0 mean it has no impact
  112898. */
  112899. protected _ambientTextureImpactOnAnalyticalLights: number;
  112900. /**
  112901. * Stores the alpha values in a texture.
  112902. */
  112903. protected _opacityTexture: Nullable<BaseTexture>;
  112904. /**
  112905. * Stores the reflection values in a texture.
  112906. */
  112907. protected _reflectionTexture: Nullable<BaseTexture>;
  112908. /**
  112909. * Stores the emissive values in a texture.
  112910. */
  112911. protected _emissiveTexture: Nullable<BaseTexture>;
  112912. /**
  112913. * AKA Specular texture in other nomenclature.
  112914. */
  112915. protected _reflectivityTexture: Nullable<BaseTexture>;
  112916. /**
  112917. * Used to switch from specular/glossiness to metallic/roughness workflow.
  112918. */
  112919. protected _metallicTexture: Nullable<BaseTexture>;
  112920. /**
  112921. * Specifies the metallic scalar of the metallic/roughness workflow.
  112922. * Can also be used to scale the metalness values of the metallic texture.
  112923. */
  112924. protected _metallic: Nullable<number>;
  112925. /**
  112926. * Specifies the roughness scalar of the metallic/roughness workflow.
  112927. * Can also be used to scale the roughness values of the metallic texture.
  112928. */
  112929. protected _roughness: Nullable<number>;
  112930. /**
  112931. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  112932. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  112933. */
  112934. protected _microSurfaceTexture: Nullable<BaseTexture>;
  112935. /**
  112936. * Stores surface normal data used to displace a mesh in a texture.
  112937. */
  112938. protected _bumpTexture: Nullable<BaseTexture>;
  112939. /**
  112940. * Stores the pre-calculated light information of a mesh in a texture.
  112941. */
  112942. protected _lightmapTexture: Nullable<BaseTexture>;
  112943. /**
  112944. * The color of a material in ambient lighting.
  112945. */
  112946. protected _ambientColor: Color3;
  112947. /**
  112948. * AKA Diffuse Color in other nomenclature.
  112949. */
  112950. protected _albedoColor: Color3;
  112951. /**
  112952. * AKA Specular Color in other nomenclature.
  112953. */
  112954. protected _reflectivityColor: Color3;
  112955. /**
  112956. * The color applied when light is reflected from a material.
  112957. */
  112958. protected _reflectionColor: Color3;
  112959. /**
  112960. * The color applied when light is emitted from a material.
  112961. */
  112962. protected _emissiveColor: Color3;
  112963. /**
  112964. * AKA Glossiness in other nomenclature.
  112965. */
  112966. protected _microSurface: number;
  112967. /**
  112968. * Specifies that the material will use the light map as a show map.
  112969. */
  112970. protected _useLightmapAsShadowmap: boolean;
  112971. /**
  112972. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  112973. * makes the reflect vector face the model (under horizon).
  112974. */
  112975. protected _useHorizonOcclusion: boolean;
  112976. /**
  112977. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  112978. * too much the area relying on ambient texture to define their ambient occlusion.
  112979. */
  112980. protected _useRadianceOcclusion: boolean;
  112981. /**
  112982. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  112983. */
  112984. protected _useAlphaFromAlbedoTexture: boolean;
  112985. /**
  112986. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  112987. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  112988. */
  112989. protected _useSpecularOverAlpha: boolean;
  112990. /**
  112991. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  112992. */
  112993. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  112994. /**
  112995. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  112996. */
  112997. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  112998. /**
  112999. * Specifies if the metallic texture contains the roughness information in its green channel.
  113000. */
  113001. protected _useRoughnessFromMetallicTextureGreen: boolean;
  113002. /**
  113003. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113004. */
  113005. protected _useMetallnessFromMetallicTextureBlue: boolean;
  113006. /**
  113007. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113008. */
  113009. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  113010. /**
  113011. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113012. */
  113013. protected _useAmbientInGrayScale: boolean;
  113014. /**
  113015. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113016. * The material will try to infer what glossiness each pixel should be.
  113017. */
  113018. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  113019. /**
  113020. * Defines the falloff type used in this material.
  113021. * It by default is Physical.
  113022. */
  113023. protected _lightFalloff: number;
  113024. /**
  113025. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113026. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113027. */
  113028. protected _useRadianceOverAlpha: boolean;
  113029. /**
  113030. * Allows using an object space normal map (instead of tangent space).
  113031. */
  113032. protected _useObjectSpaceNormalMap: boolean;
  113033. /**
  113034. * Allows using the bump map in parallax mode.
  113035. */
  113036. protected _useParallax: boolean;
  113037. /**
  113038. * Allows using the bump map in parallax occlusion mode.
  113039. */
  113040. protected _useParallaxOcclusion: boolean;
  113041. /**
  113042. * Controls the scale bias of the parallax mode.
  113043. */
  113044. protected _parallaxScaleBias: number;
  113045. /**
  113046. * If sets to true, disables all the lights affecting the material.
  113047. */
  113048. protected _disableLighting: boolean;
  113049. /**
  113050. * Number of Simultaneous lights allowed on the material.
  113051. */
  113052. protected _maxSimultaneousLights: number;
  113053. /**
  113054. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113055. */
  113056. protected _invertNormalMapX: boolean;
  113057. /**
  113058. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113059. */
  113060. protected _invertNormalMapY: boolean;
  113061. /**
  113062. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113063. */
  113064. protected _twoSidedLighting: boolean;
  113065. /**
  113066. * Defines the alpha limits in alpha test mode.
  113067. */
  113068. protected _alphaCutOff: number;
  113069. /**
  113070. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113071. */
  113072. protected _forceAlphaTest: boolean;
  113073. /**
  113074. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113075. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113076. */
  113077. protected _useAlphaFresnel: boolean;
  113078. /**
  113079. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113080. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113081. */
  113082. protected _useLinearAlphaFresnel: boolean;
  113083. /**
  113084. * The transparency mode of the material.
  113085. */
  113086. protected _transparencyMode: Nullable<number>;
  113087. /**
  113088. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  113089. * from cos thetav and roughness:
  113090. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  113091. */
  113092. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  113093. /**
  113094. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113095. */
  113096. protected _forceIrradianceInFragment: boolean;
  113097. /**
  113098. * Force normal to face away from face.
  113099. */
  113100. protected _forceNormalForward: boolean;
  113101. /**
  113102. * Enables specular anti aliasing in the PBR shader.
  113103. * It will both interacts on the Geometry for analytical and IBL lighting.
  113104. * It also prefilter the roughness map based on the bump values.
  113105. */
  113106. protected _enableSpecularAntiAliasing: boolean;
  113107. /**
  113108. * Default configuration related to image processing available in the PBR Material.
  113109. */
  113110. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113111. /**
  113112. * Keep track of the image processing observer to allow dispose and replace.
  113113. */
  113114. private _imageProcessingObserver;
  113115. /**
  113116. * Attaches a new image processing configuration to the PBR Material.
  113117. * @param configuration
  113118. */
  113119. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113120. /**
  113121. * Stores the available render targets.
  113122. */
  113123. private _renderTargets;
  113124. /**
  113125. * Sets the global ambient color for the material used in lighting calculations.
  113126. */
  113127. private _globalAmbientColor;
  113128. /**
  113129. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  113130. */
  113131. private _useLogarithmicDepth;
  113132. /**
  113133. * If set to true, no lighting calculations will be applied.
  113134. */
  113135. private _unlit;
  113136. private _debugMode;
  113137. /**
  113138. * @hidden
  113139. * This is reserved for the inspector.
  113140. * Defines the material debug mode.
  113141. * It helps seeing only some components of the material while troubleshooting.
  113142. */
  113143. debugMode: number;
  113144. /**
  113145. * @hidden
  113146. * This is reserved for the inspector.
  113147. * Specify from where on screen the debug mode should start.
  113148. * The value goes from -1 (full screen) to 1 (not visible)
  113149. * It helps with side by side comparison against the final render
  113150. * This defaults to -1
  113151. */
  113152. private debugLimit;
  113153. /**
  113154. * @hidden
  113155. * This is reserved for the inspector.
  113156. * As the default viewing range might not be enough (if the ambient is really small for instance)
  113157. * You can use the factor to better multiply the final value.
  113158. */
  113159. private debugFactor;
  113160. /**
  113161. * Defines the clear coat layer parameters for the material.
  113162. */
  113163. readonly clearCoat: PBRClearCoatConfiguration;
  113164. /**
  113165. * Defines the anisotropic parameters for the material.
  113166. */
  113167. readonly anisotropy: PBRAnisotropicConfiguration;
  113168. /**
  113169. * Defines the BRDF parameters for the material.
  113170. */
  113171. readonly brdf: PBRBRDFConfiguration;
  113172. /**
  113173. * Defines the Sheen parameters for the material.
  113174. */
  113175. readonly sheen: PBRSheenConfiguration;
  113176. /**
  113177. * Defines the SubSurface parameters for the material.
  113178. */
  113179. readonly subSurface: PBRSubSurfaceConfiguration;
  113180. /**
  113181. * Custom callback helping to override the default shader used in the material.
  113182. */
  113183. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  113184. protected _rebuildInParallel: boolean;
  113185. /**
  113186. * Instantiates a new PBRMaterial instance.
  113187. *
  113188. * @param name The material name
  113189. * @param scene The scene the material will be use in.
  113190. */
  113191. constructor(name: string, scene: Scene);
  113192. /**
  113193. * Gets a boolean indicating that current material needs to register RTT
  113194. */
  113195. readonly hasRenderTargetTextures: boolean;
  113196. /**
  113197. * Gets the name of the material class.
  113198. */
  113199. getClassName(): string;
  113200. /**
  113201. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113202. */
  113203. /**
  113204. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113205. */
  113206. useLogarithmicDepth: boolean;
  113207. /**
  113208. * Gets the current transparency mode.
  113209. */
  113210. /**
  113211. * Sets the transparency mode of the material.
  113212. *
  113213. * | Value | Type | Description |
  113214. * | ----- | ----------------------------------- | ----------- |
  113215. * | 0 | OPAQUE | |
  113216. * | 1 | ALPHATEST | |
  113217. * | 2 | ALPHABLEND | |
  113218. * | 3 | ALPHATESTANDBLEND | |
  113219. *
  113220. */
  113221. transparencyMode: Nullable<number>;
  113222. /**
  113223. * Returns true if alpha blending should be disabled.
  113224. */
  113225. private readonly _disableAlphaBlending;
  113226. /**
  113227. * Specifies whether or not this material should be rendered in alpha blend mode.
  113228. */
  113229. needAlphaBlending(): boolean;
  113230. /**
  113231. * Specifies if the mesh will require alpha blending.
  113232. * @param mesh - BJS mesh.
  113233. */
  113234. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  113235. /**
  113236. * Specifies whether or not this material should be rendered in alpha test mode.
  113237. */
  113238. needAlphaTesting(): boolean;
  113239. /**
  113240. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  113241. */
  113242. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  113243. /**
  113244. * Gets the texture used for the alpha test.
  113245. */
  113246. getAlphaTestTexture(): Nullable<BaseTexture>;
  113247. /**
  113248. * Specifies that the submesh is ready to be used.
  113249. * @param mesh - BJS mesh.
  113250. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  113251. * @param useInstances - Specifies that instances should be used.
  113252. * @returns - boolean indicating that the submesh is ready or not.
  113253. */
  113254. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113255. /**
  113256. * Specifies if the material uses metallic roughness workflow.
  113257. * @returns boolean specifiying if the material uses metallic roughness workflow.
  113258. */
  113259. isMetallicWorkflow(): boolean;
  113260. private _prepareEffect;
  113261. private _prepareDefines;
  113262. /**
  113263. * Force shader compilation
  113264. */
  113265. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  113266. clipPlane: boolean;
  113267. }>): void;
  113268. /**
  113269. * Initializes the uniform buffer layout for the shader.
  113270. */
  113271. buildUniformLayout(): void;
  113272. /**
  113273. * Unbinds the material from the mesh
  113274. */
  113275. unbind(): void;
  113276. /**
  113277. * Binds the submesh data.
  113278. * @param world - The world matrix.
  113279. * @param mesh - The BJS mesh.
  113280. * @param subMesh - A submesh of the BJS mesh.
  113281. */
  113282. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113283. /**
  113284. * Returns the animatable textures.
  113285. * @returns - Array of animatable textures.
  113286. */
  113287. getAnimatables(): IAnimatable[];
  113288. /**
  113289. * Returns the texture used for reflections.
  113290. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  113291. */
  113292. private _getReflectionTexture;
  113293. /**
  113294. * Returns an array of the actively used textures.
  113295. * @returns - Array of BaseTextures
  113296. */
  113297. getActiveTextures(): BaseTexture[];
  113298. /**
  113299. * Checks to see if a texture is used in the material.
  113300. * @param texture - Base texture to use.
  113301. * @returns - Boolean specifying if a texture is used in the material.
  113302. */
  113303. hasTexture(texture: BaseTexture): boolean;
  113304. /**
  113305. * Disposes the resources of the material.
  113306. * @param forceDisposeEffect - Forces the disposal of effects.
  113307. * @param forceDisposeTextures - Forces the disposal of all textures.
  113308. */
  113309. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113310. }
  113311. }
  113312. declare module BABYLON {
  113313. /**
  113314. * The Physically based material of BJS.
  113315. *
  113316. * This offers the main features of a standard PBR material.
  113317. * For more information, please refer to the documentation :
  113318. * https://doc.babylonjs.com/how_to/physically_based_rendering
  113319. */
  113320. export class PBRMaterial extends PBRBaseMaterial {
  113321. /**
  113322. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  113323. */
  113324. static readonly PBRMATERIAL_OPAQUE: number;
  113325. /**
  113326. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  113327. */
  113328. static readonly PBRMATERIAL_ALPHATEST: number;
  113329. /**
  113330. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113331. */
  113332. static readonly PBRMATERIAL_ALPHABLEND: number;
  113333. /**
  113334. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113335. * They are also discarded below the alpha cutoff threshold to improve performances.
  113336. */
  113337. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  113338. /**
  113339. * Defines the default value of how much AO map is occluding the analytical lights
  113340. * (point spot...).
  113341. */
  113342. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  113343. /**
  113344. * Intensity of the direct lights e.g. the four lights available in your scene.
  113345. * This impacts both the direct diffuse and specular highlights.
  113346. */
  113347. directIntensity: number;
  113348. /**
  113349. * Intensity of the emissive part of the material.
  113350. * This helps controlling the emissive effect without modifying the emissive color.
  113351. */
  113352. emissiveIntensity: number;
  113353. /**
  113354. * Intensity of the environment e.g. how much the environment will light the object
  113355. * either through harmonics for rough material or through the refelction for shiny ones.
  113356. */
  113357. environmentIntensity: number;
  113358. /**
  113359. * This is a special control allowing the reduction of the specular highlights coming from the
  113360. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113361. */
  113362. specularIntensity: number;
  113363. /**
  113364. * Debug Control allowing disabling the bump map on this material.
  113365. */
  113366. disableBumpMap: boolean;
  113367. /**
  113368. * AKA Diffuse Texture in standard nomenclature.
  113369. */
  113370. albedoTexture: BaseTexture;
  113371. /**
  113372. * AKA Occlusion Texture in other nomenclature.
  113373. */
  113374. ambientTexture: BaseTexture;
  113375. /**
  113376. * AKA Occlusion Texture Intensity in other nomenclature.
  113377. */
  113378. ambientTextureStrength: number;
  113379. /**
  113380. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113381. * 1 means it completely occludes it
  113382. * 0 mean it has no impact
  113383. */
  113384. ambientTextureImpactOnAnalyticalLights: number;
  113385. /**
  113386. * Stores the alpha values in a texture.
  113387. */
  113388. opacityTexture: BaseTexture;
  113389. /**
  113390. * Stores the reflection values in a texture.
  113391. */
  113392. reflectionTexture: Nullable<BaseTexture>;
  113393. /**
  113394. * Stores the emissive values in a texture.
  113395. */
  113396. emissiveTexture: BaseTexture;
  113397. /**
  113398. * AKA Specular texture in other nomenclature.
  113399. */
  113400. reflectivityTexture: BaseTexture;
  113401. /**
  113402. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113403. */
  113404. metallicTexture: BaseTexture;
  113405. /**
  113406. * Specifies the metallic scalar of the metallic/roughness workflow.
  113407. * Can also be used to scale the metalness values of the metallic texture.
  113408. */
  113409. metallic: Nullable<number>;
  113410. /**
  113411. * Specifies the roughness scalar of the metallic/roughness workflow.
  113412. * Can also be used to scale the roughness values of the metallic texture.
  113413. */
  113414. roughness: Nullable<number>;
  113415. /**
  113416. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113417. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113418. */
  113419. microSurfaceTexture: BaseTexture;
  113420. /**
  113421. * Stores surface normal data used to displace a mesh in a texture.
  113422. */
  113423. bumpTexture: BaseTexture;
  113424. /**
  113425. * Stores the pre-calculated light information of a mesh in a texture.
  113426. */
  113427. lightmapTexture: BaseTexture;
  113428. /**
  113429. * Stores the refracted light information in a texture.
  113430. */
  113431. refractionTexture: Nullable<BaseTexture>;
  113432. /**
  113433. * The color of a material in ambient lighting.
  113434. */
  113435. ambientColor: Color3;
  113436. /**
  113437. * AKA Diffuse Color in other nomenclature.
  113438. */
  113439. albedoColor: Color3;
  113440. /**
  113441. * AKA Specular Color in other nomenclature.
  113442. */
  113443. reflectivityColor: Color3;
  113444. /**
  113445. * The color reflected from the material.
  113446. */
  113447. reflectionColor: Color3;
  113448. /**
  113449. * The color emitted from the material.
  113450. */
  113451. emissiveColor: Color3;
  113452. /**
  113453. * AKA Glossiness in other nomenclature.
  113454. */
  113455. microSurface: number;
  113456. /**
  113457. * source material index of refraction (IOR)' / 'destination material IOR.
  113458. */
  113459. indexOfRefraction: number;
  113460. /**
  113461. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113462. */
  113463. invertRefractionY: boolean;
  113464. /**
  113465. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113466. * Materials half opaque for instance using refraction could benefit from this control.
  113467. */
  113468. linkRefractionWithTransparency: boolean;
  113469. /**
  113470. * If true, the light map contains occlusion information instead of lighting info.
  113471. */
  113472. useLightmapAsShadowmap: boolean;
  113473. /**
  113474. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113475. */
  113476. useAlphaFromAlbedoTexture: boolean;
  113477. /**
  113478. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113479. */
  113480. forceAlphaTest: boolean;
  113481. /**
  113482. * Defines the alpha limits in alpha test mode.
  113483. */
  113484. alphaCutOff: number;
  113485. /**
  113486. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  113487. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113488. */
  113489. useSpecularOverAlpha: boolean;
  113490. /**
  113491. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113492. */
  113493. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113494. /**
  113495. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113496. */
  113497. useRoughnessFromMetallicTextureAlpha: boolean;
  113498. /**
  113499. * Specifies if the metallic texture contains the roughness information in its green channel.
  113500. */
  113501. useRoughnessFromMetallicTextureGreen: boolean;
  113502. /**
  113503. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113504. */
  113505. useMetallnessFromMetallicTextureBlue: boolean;
  113506. /**
  113507. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113508. */
  113509. useAmbientOcclusionFromMetallicTextureRed: boolean;
  113510. /**
  113511. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113512. */
  113513. useAmbientInGrayScale: boolean;
  113514. /**
  113515. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113516. * The material will try to infer what glossiness each pixel should be.
  113517. */
  113518. useAutoMicroSurfaceFromReflectivityMap: boolean;
  113519. /**
  113520. * BJS is using an harcoded light falloff based on a manually sets up range.
  113521. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113522. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113523. */
  113524. /**
  113525. * BJS is using an harcoded light falloff based on a manually sets up range.
  113526. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113527. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113528. */
  113529. usePhysicalLightFalloff: boolean;
  113530. /**
  113531. * In order to support the falloff compatibility with gltf, a special mode has been added
  113532. * to reproduce the gltf light falloff.
  113533. */
  113534. /**
  113535. * In order to support the falloff compatibility with gltf, a special mode has been added
  113536. * to reproduce the gltf light falloff.
  113537. */
  113538. useGLTFLightFalloff: boolean;
  113539. /**
  113540. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113541. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113542. */
  113543. useRadianceOverAlpha: boolean;
  113544. /**
  113545. * Allows using an object space normal map (instead of tangent space).
  113546. */
  113547. useObjectSpaceNormalMap: boolean;
  113548. /**
  113549. * Allows using the bump map in parallax mode.
  113550. */
  113551. useParallax: boolean;
  113552. /**
  113553. * Allows using the bump map in parallax occlusion mode.
  113554. */
  113555. useParallaxOcclusion: boolean;
  113556. /**
  113557. * Controls the scale bias of the parallax mode.
  113558. */
  113559. parallaxScaleBias: number;
  113560. /**
  113561. * If sets to true, disables all the lights affecting the material.
  113562. */
  113563. disableLighting: boolean;
  113564. /**
  113565. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113566. */
  113567. forceIrradianceInFragment: boolean;
  113568. /**
  113569. * Number of Simultaneous lights allowed on the material.
  113570. */
  113571. maxSimultaneousLights: number;
  113572. /**
  113573. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  113574. */
  113575. invertNormalMapX: boolean;
  113576. /**
  113577. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  113578. */
  113579. invertNormalMapY: boolean;
  113580. /**
  113581. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113582. */
  113583. twoSidedLighting: boolean;
  113584. /**
  113585. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113586. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113587. */
  113588. useAlphaFresnel: boolean;
  113589. /**
  113590. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113591. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113592. */
  113593. useLinearAlphaFresnel: boolean;
  113594. /**
  113595. * Let user defines the brdf lookup texture used for IBL.
  113596. * A default 8bit version is embedded but you could point at :
  113597. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  113598. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  113599. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  113600. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  113601. */
  113602. environmentBRDFTexture: Nullable<BaseTexture>;
  113603. /**
  113604. * Force normal to face away from face.
  113605. */
  113606. forceNormalForward: boolean;
  113607. /**
  113608. * Enables specular anti aliasing in the PBR shader.
  113609. * It will both interacts on the Geometry for analytical and IBL lighting.
  113610. * It also prefilter the roughness map based on the bump values.
  113611. */
  113612. enableSpecularAntiAliasing: boolean;
  113613. /**
  113614. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113615. * makes the reflect vector face the model (under horizon).
  113616. */
  113617. useHorizonOcclusion: boolean;
  113618. /**
  113619. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113620. * too much the area relying on ambient texture to define their ambient occlusion.
  113621. */
  113622. useRadianceOcclusion: boolean;
  113623. /**
  113624. * If set to true, no lighting calculations will be applied.
  113625. */
  113626. unlit: boolean;
  113627. /**
  113628. * Gets the image processing configuration used either in this material.
  113629. */
  113630. /**
  113631. * Sets the Default image processing configuration used either in the this material.
  113632. *
  113633. * If sets to null, the scene one is in use.
  113634. */
  113635. imageProcessingConfiguration: ImageProcessingConfiguration;
  113636. /**
  113637. * Gets wether the color curves effect is enabled.
  113638. */
  113639. /**
  113640. * Sets wether the color curves effect is enabled.
  113641. */
  113642. cameraColorCurvesEnabled: boolean;
  113643. /**
  113644. * Gets wether the color grading effect is enabled.
  113645. */
  113646. /**
  113647. * Gets wether the color grading effect is enabled.
  113648. */
  113649. cameraColorGradingEnabled: boolean;
  113650. /**
  113651. * Gets wether tonemapping is enabled or not.
  113652. */
  113653. /**
  113654. * Sets wether tonemapping is enabled or not
  113655. */
  113656. cameraToneMappingEnabled: boolean;
  113657. /**
  113658. * The camera exposure used on this material.
  113659. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113660. * This corresponds to a photographic exposure.
  113661. */
  113662. /**
  113663. * The camera exposure used on this material.
  113664. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113665. * This corresponds to a photographic exposure.
  113666. */
  113667. cameraExposure: number;
  113668. /**
  113669. * Gets The camera contrast used on this material.
  113670. */
  113671. /**
  113672. * Sets The camera contrast used on this material.
  113673. */
  113674. cameraContrast: number;
  113675. /**
  113676. * Gets the Color Grading 2D Lookup Texture.
  113677. */
  113678. /**
  113679. * Sets the Color Grading 2D Lookup Texture.
  113680. */
  113681. cameraColorGradingTexture: Nullable<BaseTexture>;
  113682. /**
  113683. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113684. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113685. * 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;
  113686. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113687. */
  113688. /**
  113689. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113690. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113691. * 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;
  113692. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113693. */
  113694. cameraColorCurves: Nullable<ColorCurves>;
  113695. /**
  113696. * Instantiates a new PBRMaterial instance.
  113697. *
  113698. * @param name The material name
  113699. * @param scene The scene the material will be use in.
  113700. */
  113701. constructor(name: string, scene: Scene);
  113702. /**
  113703. * Returns the name of this material class.
  113704. */
  113705. getClassName(): string;
  113706. /**
  113707. * Makes a duplicate of the current material.
  113708. * @param name - name to use for the new material.
  113709. */
  113710. clone(name: string): PBRMaterial;
  113711. /**
  113712. * Serializes this PBR Material.
  113713. * @returns - An object with the serialized material.
  113714. */
  113715. serialize(): any;
  113716. /**
  113717. * Parses a PBR Material from a serialized object.
  113718. * @param source - Serialized object.
  113719. * @param scene - BJS scene instance.
  113720. * @param rootUrl - url for the scene object
  113721. * @returns - PBRMaterial
  113722. */
  113723. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  113724. }
  113725. }
  113726. declare module BABYLON {
  113727. /**
  113728. * Direct draw surface info
  113729. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  113730. */
  113731. export interface DDSInfo {
  113732. /**
  113733. * Width of the texture
  113734. */
  113735. width: number;
  113736. /**
  113737. * Width of the texture
  113738. */
  113739. height: number;
  113740. /**
  113741. * Number of Mipmaps for the texture
  113742. * @see https://en.wikipedia.org/wiki/Mipmap
  113743. */
  113744. mipmapCount: number;
  113745. /**
  113746. * If the textures format is a known fourCC format
  113747. * @see https://www.fourcc.org/
  113748. */
  113749. isFourCC: boolean;
  113750. /**
  113751. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  113752. */
  113753. isRGB: boolean;
  113754. /**
  113755. * If the texture is a lumincance format
  113756. */
  113757. isLuminance: boolean;
  113758. /**
  113759. * If this is a cube texture
  113760. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  113761. */
  113762. isCube: boolean;
  113763. /**
  113764. * If the texture is a compressed format eg. FOURCC_DXT1
  113765. */
  113766. isCompressed: boolean;
  113767. /**
  113768. * The dxgiFormat of the texture
  113769. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  113770. */
  113771. dxgiFormat: number;
  113772. /**
  113773. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  113774. */
  113775. textureType: number;
  113776. /**
  113777. * Sphericle polynomial created for the dds texture
  113778. */
  113779. sphericalPolynomial?: SphericalPolynomial;
  113780. }
  113781. /**
  113782. * Class used to provide DDS decompression tools
  113783. */
  113784. export class DDSTools {
  113785. /**
  113786. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  113787. */
  113788. static StoreLODInAlphaChannel: boolean;
  113789. /**
  113790. * Gets DDS information from an array buffer
  113791. * @param arrayBuffer defines the array buffer to read data from
  113792. * @returns the DDS information
  113793. */
  113794. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  113795. private static _FloatView;
  113796. private static _Int32View;
  113797. private static _ToHalfFloat;
  113798. private static _FromHalfFloat;
  113799. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  113800. private static _GetHalfFloatRGBAArrayBuffer;
  113801. private static _GetFloatRGBAArrayBuffer;
  113802. private static _GetFloatAsUIntRGBAArrayBuffer;
  113803. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  113804. private static _GetRGBAArrayBuffer;
  113805. private static _ExtractLongWordOrder;
  113806. private static _GetRGBArrayBuffer;
  113807. private static _GetLuminanceArrayBuffer;
  113808. /**
  113809. * Uploads DDS Levels to a Babylon Texture
  113810. * @hidden
  113811. */
  113812. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  113813. }
  113814. interface Engine {
  113815. /**
  113816. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  113817. * @param rootUrl defines the url where the file to load is located
  113818. * @param scene defines the current scene
  113819. * @param lodScale defines scale to apply to the mip map selection
  113820. * @param lodOffset defines offset to apply to the mip map selection
  113821. * @param onLoad defines an optional callback raised when the texture is loaded
  113822. * @param onError defines an optional callback raised if there is an issue to load the texture
  113823. * @param format defines the format of the data
  113824. * @param forcedExtension defines the extension to use to pick the right loader
  113825. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  113826. * @returns the cube texture as an InternalTexture
  113827. */
  113828. 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;
  113829. }
  113830. }
  113831. declare module BABYLON {
  113832. /**
  113833. * Implementation of the DDS Texture Loader.
  113834. * @hidden
  113835. */
  113836. export class _DDSTextureLoader implements IInternalTextureLoader {
  113837. /**
  113838. * Defines wether the loader supports cascade loading the different faces.
  113839. */
  113840. readonly supportCascades: boolean;
  113841. /**
  113842. * This returns if the loader support the current file information.
  113843. * @param extension defines the file extension of the file being loaded
  113844. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113845. * @param fallback defines the fallback internal texture if any
  113846. * @param isBase64 defines whether the texture is encoded as a base64
  113847. * @param isBuffer defines whether the texture data are stored as a buffer
  113848. * @returns true if the loader can load the specified file
  113849. */
  113850. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113851. /**
  113852. * Transform the url before loading if required.
  113853. * @param rootUrl the url of the texture
  113854. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113855. * @returns the transformed texture
  113856. */
  113857. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113858. /**
  113859. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113860. * @param rootUrl the url of the texture
  113861. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113862. * @returns the fallback texture
  113863. */
  113864. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113865. /**
  113866. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113867. * @param data contains the texture data
  113868. * @param texture defines the BabylonJS internal texture
  113869. * @param createPolynomials will be true if polynomials have been requested
  113870. * @param onLoad defines the callback to trigger once the texture is ready
  113871. * @param onError defines the callback to trigger in case of error
  113872. */
  113873. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113874. /**
  113875. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113876. * @param data contains the texture data
  113877. * @param texture defines the BabylonJS internal texture
  113878. * @param callback defines the method to call once ready to upload
  113879. */
  113880. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113881. }
  113882. }
  113883. declare module BABYLON {
  113884. /**
  113885. * Implementation of the ENV Texture Loader.
  113886. * @hidden
  113887. */
  113888. export class _ENVTextureLoader implements IInternalTextureLoader {
  113889. /**
  113890. * Defines wether the loader supports cascade loading the different faces.
  113891. */
  113892. readonly supportCascades: boolean;
  113893. /**
  113894. * This returns if the loader support the current file information.
  113895. * @param extension defines the file extension of the file being loaded
  113896. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113897. * @param fallback defines the fallback internal texture if any
  113898. * @param isBase64 defines whether the texture is encoded as a base64
  113899. * @param isBuffer defines whether the texture data are stored as a buffer
  113900. * @returns true if the loader can load the specified file
  113901. */
  113902. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113903. /**
  113904. * Transform the url before loading if required.
  113905. * @param rootUrl the url of the texture
  113906. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113907. * @returns the transformed texture
  113908. */
  113909. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113910. /**
  113911. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113912. * @param rootUrl the url of the texture
  113913. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113914. * @returns the fallback texture
  113915. */
  113916. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113917. /**
  113918. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113919. * @param data contains the texture data
  113920. * @param texture defines the BabylonJS internal texture
  113921. * @param createPolynomials will be true if polynomials have been requested
  113922. * @param onLoad defines the callback to trigger once the texture is ready
  113923. * @param onError defines the callback to trigger in case of error
  113924. */
  113925. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113926. /**
  113927. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113928. * @param data contains the texture data
  113929. * @param texture defines the BabylonJS internal texture
  113930. * @param callback defines the method to call once ready to upload
  113931. */
  113932. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113933. }
  113934. }
  113935. declare module BABYLON {
  113936. /**
  113937. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  113938. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  113939. */
  113940. export class KhronosTextureContainer {
  113941. /** contents of the KTX container file */
  113942. arrayBuffer: any;
  113943. private static HEADER_LEN;
  113944. private static COMPRESSED_2D;
  113945. private static COMPRESSED_3D;
  113946. private static TEX_2D;
  113947. private static TEX_3D;
  113948. /**
  113949. * Gets the openGL type
  113950. */
  113951. glType: number;
  113952. /**
  113953. * Gets the openGL type size
  113954. */
  113955. glTypeSize: number;
  113956. /**
  113957. * Gets the openGL format
  113958. */
  113959. glFormat: number;
  113960. /**
  113961. * Gets the openGL internal format
  113962. */
  113963. glInternalFormat: number;
  113964. /**
  113965. * Gets the base internal format
  113966. */
  113967. glBaseInternalFormat: number;
  113968. /**
  113969. * Gets image width in pixel
  113970. */
  113971. pixelWidth: number;
  113972. /**
  113973. * Gets image height in pixel
  113974. */
  113975. pixelHeight: number;
  113976. /**
  113977. * Gets image depth in pixels
  113978. */
  113979. pixelDepth: number;
  113980. /**
  113981. * Gets the number of array elements
  113982. */
  113983. numberOfArrayElements: number;
  113984. /**
  113985. * Gets the number of faces
  113986. */
  113987. numberOfFaces: number;
  113988. /**
  113989. * Gets the number of mipmap levels
  113990. */
  113991. numberOfMipmapLevels: number;
  113992. /**
  113993. * Gets the bytes of key value data
  113994. */
  113995. bytesOfKeyValueData: number;
  113996. /**
  113997. * Gets the load type
  113998. */
  113999. loadType: number;
  114000. /**
  114001. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  114002. */
  114003. isInvalid: boolean;
  114004. /**
  114005. * Creates a new KhronosTextureContainer
  114006. * @param arrayBuffer contents of the KTX container file
  114007. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  114008. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  114009. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  114010. */
  114011. constructor(
  114012. /** contents of the KTX container file */
  114013. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  114014. /**
  114015. * Uploads KTX content to a Babylon Texture.
  114016. * It is assumed that the texture has already been created & is currently bound
  114017. * @hidden
  114018. */
  114019. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  114020. private _upload2DCompressedLevels;
  114021. }
  114022. }
  114023. declare module BABYLON {
  114024. /**
  114025. * Implementation of the KTX Texture Loader.
  114026. * @hidden
  114027. */
  114028. export class _KTXTextureLoader implements IInternalTextureLoader {
  114029. /**
  114030. * Defines wether the loader supports cascade loading the different faces.
  114031. */
  114032. readonly supportCascades: boolean;
  114033. /**
  114034. * This returns if the loader support the current file information.
  114035. * @param extension defines the file extension of the file being loaded
  114036. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114037. * @param fallback defines the fallback internal texture if any
  114038. * @param isBase64 defines whether the texture is encoded as a base64
  114039. * @param isBuffer defines whether the texture data are stored as a buffer
  114040. * @returns true if the loader can load the specified file
  114041. */
  114042. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114043. /**
  114044. * Transform the url before loading if required.
  114045. * @param rootUrl the url of the texture
  114046. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114047. * @returns the transformed texture
  114048. */
  114049. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114050. /**
  114051. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114052. * @param rootUrl the url of the texture
  114053. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114054. * @returns the fallback texture
  114055. */
  114056. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114057. /**
  114058. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114059. * @param data contains the texture data
  114060. * @param texture defines the BabylonJS internal texture
  114061. * @param createPolynomials will be true if polynomials have been requested
  114062. * @param onLoad defines the callback to trigger once the texture is ready
  114063. * @param onError defines the callback to trigger in case of error
  114064. */
  114065. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114066. /**
  114067. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114068. * @param data contains the texture data
  114069. * @param texture defines the BabylonJS internal texture
  114070. * @param callback defines the method to call once ready to upload
  114071. */
  114072. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  114073. }
  114074. }
  114075. declare module BABYLON {
  114076. /**
  114077. * Options for the default xr helper
  114078. */
  114079. export class WebXRDefaultExperienceOptions {
  114080. /**
  114081. * Floor meshes that should be used for teleporting
  114082. */
  114083. floorMeshes: Array<AbstractMesh>;
  114084. }
  114085. /**
  114086. * Default experience which provides a similar setup to the previous webVRExperience
  114087. */
  114088. export class WebXRDefaultExperience {
  114089. /**
  114090. * Base experience
  114091. */
  114092. baseExperience: WebXRExperienceHelper;
  114093. /**
  114094. * Input experience extension
  114095. */
  114096. input: WebXRInput;
  114097. /**
  114098. * Loads the controller models
  114099. */
  114100. controllerModelLoader: WebXRControllerModelLoader;
  114101. /**
  114102. * Enables laser pointer and selection
  114103. */
  114104. pointerSelection: WebXRControllerPointerSelection;
  114105. /**
  114106. * Enables teleportation
  114107. */
  114108. teleportation: WebXRControllerTeleportation;
  114109. /**
  114110. * Enables ui for enetering/exiting xr
  114111. */
  114112. enterExitUI: WebXREnterExitUI;
  114113. /**
  114114. * Default output canvas xr should render to
  114115. */
  114116. outputCanvas: WebXRManagedOutputCanvas;
  114117. /**
  114118. * Creates the default xr experience
  114119. * @param scene scene
  114120. * @param options options for basic configuration
  114121. * @returns resulting WebXRDefaultExperience
  114122. */
  114123. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114124. private constructor();
  114125. /**
  114126. * DIsposes of the experience helper
  114127. */
  114128. dispose(): void;
  114129. }
  114130. }
  114131. declare module BABYLON {
  114132. /** @hidden */
  114133. export var _forceSceneHelpersToBundle: boolean;
  114134. interface Scene {
  114135. /**
  114136. * Creates a default light for the scene.
  114137. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  114138. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  114139. */
  114140. createDefaultLight(replace?: boolean): void;
  114141. /**
  114142. * Creates a default camera for the scene.
  114143. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  114144. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114145. * @param replace has default false, when true replaces the active camera in the scene
  114146. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  114147. */
  114148. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114149. /**
  114150. * Creates a default camera and a default light.
  114151. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  114152. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114153. * @param replace has the default false, when true replaces the active camera/light in the scene
  114154. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  114155. */
  114156. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114157. /**
  114158. * Creates a new sky box
  114159. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  114160. * @param environmentTexture defines the texture to use as environment texture
  114161. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  114162. * @param scale defines the overall scale of the skybox
  114163. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  114164. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  114165. * @returns a new mesh holding the sky box
  114166. */
  114167. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  114168. /**
  114169. * Creates a new environment
  114170. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  114171. * @param options defines the options you can use to configure the environment
  114172. * @returns the new EnvironmentHelper
  114173. */
  114174. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  114175. /**
  114176. * Creates a new VREXperienceHelper
  114177. * @see http://doc.babylonjs.com/how_to/webvr_helper
  114178. * @param webVROptions defines the options used to create the new VREXperienceHelper
  114179. * @returns a new VREXperienceHelper
  114180. */
  114181. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  114182. /**
  114183. * Creates a new WebXRDefaultExperience
  114184. * @see http://doc.babylonjs.com/how_to/webxr
  114185. * @param options experience options
  114186. * @returns a promise for a new WebXRDefaultExperience
  114187. */
  114188. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114189. }
  114190. }
  114191. declare module BABYLON {
  114192. /**
  114193. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  114194. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  114195. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  114196. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114197. */
  114198. export class VideoDome extends TransformNode {
  114199. /**
  114200. * Define the video source as a Monoscopic panoramic 360 video.
  114201. */
  114202. static readonly MODE_MONOSCOPIC: number;
  114203. /**
  114204. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114205. */
  114206. static readonly MODE_TOPBOTTOM: number;
  114207. /**
  114208. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114209. */
  114210. static readonly MODE_SIDEBYSIDE: number;
  114211. private _halfDome;
  114212. private _useDirectMapping;
  114213. /**
  114214. * The video texture being displayed on the sphere
  114215. */
  114216. protected _videoTexture: VideoTexture;
  114217. /**
  114218. * Gets the video texture being displayed on the sphere
  114219. */
  114220. readonly videoTexture: VideoTexture;
  114221. /**
  114222. * The skybox material
  114223. */
  114224. protected _material: BackgroundMaterial;
  114225. /**
  114226. * The surface used for the skybox
  114227. */
  114228. protected _mesh: Mesh;
  114229. /**
  114230. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  114231. */
  114232. private _halfDomeMask;
  114233. /**
  114234. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114235. * Also see the options.resolution property.
  114236. */
  114237. fovMultiplier: number;
  114238. private _videoMode;
  114239. /**
  114240. * Gets or set the current video mode for the video. It can be:
  114241. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  114242. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114243. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114244. */
  114245. videoMode: number;
  114246. /**
  114247. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  114248. *
  114249. */
  114250. /**
  114251. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  114252. */
  114253. halfDome: boolean;
  114254. /**
  114255. * Oberserver used in Stereoscopic VR Mode.
  114256. */
  114257. private _onBeforeCameraRenderObserver;
  114258. /**
  114259. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  114260. * @param name Element's name, child elements will append suffixes for their own names.
  114261. * @param urlsOrVideo defines the url(s) or the video element to use
  114262. * @param options An object containing optional or exposed sub element properties
  114263. */
  114264. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  114265. resolution?: number;
  114266. clickToPlay?: boolean;
  114267. autoPlay?: boolean;
  114268. loop?: boolean;
  114269. size?: number;
  114270. poster?: string;
  114271. faceForward?: boolean;
  114272. useDirectMapping?: boolean;
  114273. halfDomeMode?: boolean;
  114274. }, scene: Scene);
  114275. private _changeVideoMode;
  114276. /**
  114277. * Releases resources associated with this node.
  114278. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114279. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114280. */
  114281. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114282. }
  114283. }
  114284. declare module BABYLON {
  114285. /**
  114286. * This class can be used to get instrumentation data from a Babylon engine
  114287. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114288. */
  114289. export class EngineInstrumentation implements IDisposable {
  114290. /**
  114291. * Define the instrumented engine.
  114292. */
  114293. engine: Engine;
  114294. private _captureGPUFrameTime;
  114295. private _gpuFrameTimeToken;
  114296. private _gpuFrameTime;
  114297. private _captureShaderCompilationTime;
  114298. private _shaderCompilationTime;
  114299. private _onBeginFrameObserver;
  114300. private _onEndFrameObserver;
  114301. private _onBeforeShaderCompilationObserver;
  114302. private _onAfterShaderCompilationObserver;
  114303. /**
  114304. * Gets the perf counter used for GPU frame time
  114305. */
  114306. readonly gpuFrameTimeCounter: PerfCounter;
  114307. /**
  114308. * Gets the GPU frame time capture status
  114309. */
  114310. /**
  114311. * Enable or disable the GPU frame time capture
  114312. */
  114313. captureGPUFrameTime: boolean;
  114314. /**
  114315. * Gets the perf counter used for shader compilation time
  114316. */
  114317. readonly shaderCompilationTimeCounter: PerfCounter;
  114318. /**
  114319. * Gets the shader compilation time capture status
  114320. */
  114321. /**
  114322. * Enable or disable the shader compilation time capture
  114323. */
  114324. captureShaderCompilationTime: boolean;
  114325. /**
  114326. * Instantiates a new engine instrumentation.
  114327. * This class can be used to get instrumentation data from a Babylon engine
  114328. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114329. * @param engine Defines the engine to instrument
  114330. */
  114331. constructor(
  114332. /**
  114333. * Define the instrumented engine.
  114334. */
  114335. engine: Engine);
  114336. /**
  114337. * Dispose and release associated resources.
  114338. */
  114339. dispose(): void;
  114340. }
  114341. }
  114342. declare module BABYLON {
  114343. /**
  114344. * This class can be used to get instrumentation data from a Babylon engine
  114345. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114346. */
  114347. export class SceneInstrumentation implements IDisposable {
  114348. /**
  114349. * Defines the scene to instrument
  114350. */
  114351. scene: Scene;
  114352. private _captureActiveMeshesEvaluationTime;
  114353. private _activeMeshesEvaluationTime;
  114354. private _captureRenderTargetsRenderTime;
  114355. private _renderTargetsRenderTime;
  114356. private _captureFrameTime;
  114357. private _frameTime;
  114358. private _captureRenderTime;
  114359. private _renderTime;
  114360. private _captureInterFrameTime;
  114361. private _interFrameTime;
  114362. private _captureParticlesRenderTime;
  114363. private _particlesRenderTime;
  114364. private _captureSpritesRenderTime;
  114365. private _spritesRenderTime;
  114366. private _capturePhysicsTime;
  114367. private _physicsTime;
  114368. private _captureAnimationsTime;
  114369. private _animationsTime;
  114370. private _captureCameraRenderTime;
  114371. private _cameraRenderTime;
  114372. private _onBeforeActiveMeshesEvaluationObserver;
  114373. private _onAfterActiveMeshesEvaluationObserver;
  114374. private _onBeforeRenderTargetsRenderObserver;
  114375. private _onAfterRenderTargetsRenderObserver;
  114376. private _onAfterRenderObserver;
  114377. private _onBeforeDrawPhaseObserver;
  114378. private _onAfterDrawPhaseObserver;
  114379. private _onBeforeAnimationsObserver;
  114380. private _onBeforeParticlesRenderingObserver;
  114381. private _onAfterParticlesRenderingObserver;
  114382. private _onBeforeSpritesRenderingObserver;
  114383. private _onAfterSpritesRenderingObserver;
  114384. private _onBeforePhysicsObserver;
  114385. private _onAfterPhysicsObserver;
  114386. private _onAfterAnimationsObserver;
  114387. private _onBeforeCameraRenderObserver;
  114388. private _onAfterCameraRenderObserver;
  114389. /**
  114390. * Gets the perf counter used for active meshes evaluation time
  114391. */
  114392. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  114393. /**
  114394. * Gets the active meshes evaluation time capture status
  114395. */
  114396. /**
  114397. * Enable or disable the active meshes evaluation time capture
  114398. */
  114399. captureActiveMeshesEvaluationTime: boolean;
  114400. /**
  114401. * Gets the perf counter used for render targets render time
  114402. */
  114403. readonly renderTargetsRenderTimeCounter: PerfCounter;
  114404. /**
  114405. * Gets the render targets render time capture status
  114406. */
  114407. /**
  114408. * Enable or disable the render targets render time capture
  114409. */
  114410. captureRenderTargetsRenderTime: boolean;
  114411. /**
  114412. * Gets the perf counter used for particles render time
  114413. */
  114414. readonly particlesRenderTimeCounter: PerfCounter;
  114415. /**
  114416. * Gets the particles render time capture status
  114417. */
  114418. /**
  114419. * Enable or disable the particles render time capture
  114420. */
  114421. captureParticlesRenderTime: boolean;
  114422. /**
  114423. * Gets the perf counter used for sprites render time
  114424. */
  114425. readonly spritesRenderTimeCounter: PerfCounter;
  114426. /**
  114427. * Gets the sprites render time capture status
  114428. */
  114429. /**
  114430. * Enable or disable the sprites render time capture
  114431. */
  114432. captureSpritesRenderTime: boolean;
  114433. /**
  114434. * Gets the perf counter used for physics time
  114435. */
  114436. readonly physicsTimeCounter: PerfCounter;
  114437. /**
  114438. * Gets the physics time capture status
  114439. */
  114440. /**
  114441. * Enable or disable the physics time capture
  114442. */
  114443. capturePhysicsTime: boolean;
  114444. /**
  114445. * Gets the perf counter used for animations time
  114446. */
  114447. readonly animationsTimeCounter: PerfCounter;
  114448. /**
  114449. * Gets the animations time capture status
  114450. */
  114451. /**
  114452. * Enable or disable the animations time capture
  114453. */
  114454. captureAnimationsTime: boolean;
  114455. /**
  114456. * Gets the perf counter used for frame time capture
  114457. */
  114458. readonly frameTimeCounter: PerfCounter;
  114459. /**
  114460. * Gets the frame time capture status
  114461. */
  114462. /**
  114463. * Enable or disable the frame time capture
  114464. */
  114465. captureFrameTime: boolean;
  114466. /**
  114467. * Gets the perf counter used for inter-frames time capture
  114468. */
  114469. readonly interFrameTimeCounter: PerfCounter;
  114470. /**
  114471. * Gets the inter-frames time capture status
  114472. */
  114473. /**
  114474. * Enable or disable the inter-frames time capture
  114475. */
  114476. captureInterFrameTime: boolean;
  114477. /**
  114478. * Gets the perf counter used for render time capture
  114479. */
  114480. readonly renderTimeCounter: PerfCounter;
  114481. /**
  114482. * Gets the render time capture status
  114483. */
  114484. /**
  114485. * Enable or disable the render time capture
  114486. */
  114487. captureRenderTime: boolean;
  114488. /**
  114489. * Gets the perf counter used for camera render time capture
  114490. */
  114491. readonly cameraRenderTimeCounter: PerfCounter;
  114492. /**
  114493. * Gets the camera render time capture status
  114494. */
  114495. /**
  114496. * Enable or disable the camera render time capture
  114497. */
  114498. captureCameraRenderTime: boolean;
  114499. /**
  114500. * Gets the perf counter used for draw calls
  114501. */
  114502. readonly drawCallsCounter: PerfCounter;
  114503. /**
  114504. * Instantiates a new scene instrumentation.
  114505. * This class can be used to get instrumentation data from a Babylon engine
  114506. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114507. * @param scene Defines the scene to instrument
  114508. */
  114509. constructor(
  114510. /**
  114511. * Defines the scene to instrument
  114512. */
  114513. scene: Scene);
  114514. /**
  114515. * Dispose and release associated resources.
  114516. */
  114517. dispose(): void;
  114518. }
  114519. }
  114520. declare module BABYLON {
  114521. /** @hidden */
  114522. export var glowMapGenerationPixelShader: {
  114523. name: string;
  114524. shader: string;
  114525. };
  114526. }
  114527. declare module BABYLON {
  114528. /** @hidden */
  114529. export var glowMapGenerationVertexShader: {
  114530. name: string;
  114531. shader: string;
  114532. };
  114533. }
  114534. declare module BABYLON {
  114535. /**
  114536. * Effect layer options. This helps customizing the behaviour
  114537. * of the effect layer.
  114538. */
  114539. export interface IEffectLayerOptions {
  114540. /**
  114541. * Multiplication factor apply to the canvas size to compute the render target size
  114542. * used to generated the objects (the smaller the faster).
  114543. */
  114544. mainTextureRatio: number;
  114545. /**
  114546. * Enforces a fixed size texture to ensure effect stability across devices.
  114547. */
  114548. mainTextureFixedSize?: number;
  114549. /**
  114550. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  114551. */
  114552. alphaBlendingMode: number;
  114553. /**
  114554. * The camera attached to the layer.
  114555. */
  114556. camera: Nullable<Camera>;
  114557. /**
  114558. * The rendering group to draw the layer in.
  114559. */
  114560. renderingGroupId: number;
  114561. }
  114562. /**
  114563. * The effect layer Helps adding post process effect blended with the main pass.
  114564. *
  114565. * This can be for instance use to generate glow or higlight effects on the scene.
  114566. *
  114567. * The effect layer class can not be used directly and is intented to inherited from to be
  114568. * customized per effects.
  114569. */
  114570. export abstract class EffectLayer {
  114571. private _vertexBuffers;
  114572. private _indexBuffer;
  114573. private _cachedDefines;
  114574. private _effectLayerMapGenerationEffect;
  114575. private _effectLayerOptions;
  114576. private _mergeEffect;
  114577. protected _scene: Scene;
  114578. protected _engine: Engine;
  114579. protected _maxSize: number;
  114580. protected _mainTextureDesiredSize: ISize;
  114581. protected _mainTexture: RenderTargetTexture;
  114582. protected _shouldRender: boolean;
  114583. protected _postProcesses: PostProcess[];
  114584. protected _textures: BaseTexture[];
  114585. protected _emissiveTextureAndColor: {
  114586. texture: Nullable<BaseTexture>;
  114587. color: Color4;
  114588. };
  114589. /**
  114590. * The name of the layer
  114591. */
  114592. name: string;
  114593. /**
  114594. * The clear color of the texture used to generate the glow map.
  114595. */
  114596. neutralColor: Color4;
  114597. /**
  114598. * Specifies wether the highlight layer is enabled or not.
  114599. */
  114600. isEnabled: boolean;
  114601. /**
  114602. * Gets the camera attached to the layer.
  114603. */
  114604. readonly camera: Nullable<Camera>;
  114605. /**
  114606. * Gets the rendering group id the layer should render in.
  114607. */
  114608. renderingGroupId: number;
  114609. /**
  114610. * An event triggered when the effect layer has been disposed.
  114611. */
  114612. onDisposeObservable: Observable<EffectLayer>;
  114613. /**
  114614. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  114615. */
  114616. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  114617. /**
  114618. * An event triggered when the generated texture is being merged in the scene.
  114619. */
  114620. onBeforeComposeObservable: Observable<EffectLayer>;
  114621. /**
  114622. * An event triggered when the generated texture has been merged in the scene.
  114623. */
  114624. onAfterComposeObservable: Observable<EffectLayer>;
  114625. /**
  114626. * An event triggered when the efffect layer changes its size.
  114627. */
  114628. onSizeChangedObservable: Observable<EffectLayer>;
  114629. /** @hidden */
  114630. static _SceneComponentInitialization: (scene: Scene) => void;
  114631. /**
  114632. * Instantiates a new effect Layer and references it in the scene.
  114633. * @param name The name of the layer
  114634. * @param scene The scene to use the layer in
  114635. */
  114636. constructor(
  114637. /** The Friendly of the effect in the scene */
  114638. name: string, scene: Scene);
  114639. /**
  114640. * Get the effect name of the layer.
  114641. * @return The effect name
  114642. */
  114643. abstract getEffectName(): string;
  114644. /**
  114645. * Checks for the readiness of the element composing the layer.
  114646. * @param subMesh the mesh to check for
  114647. * @param useInstances specify wether or not to use instances to render the mesh
  114648. * @return true if ready otherwise, false
  114649. */
  114650. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114651. /**
  114652. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114653. * @returns true if the effect requires stencil during the main canvas render pass.
  114654. */
  114655. abstract needStencil(): boolean;
  114656. /**
  114657. * Create the merge effect. This is the shader use to blit the information back
  114658. * to the main canvas at the end of the scene rendering.
  114659. * @returns The effect containing the shader used to merge the effect on the main canvas
  114660. */
  114661. protected abstract _createMergeEffect(): Effect;
  114662. /**
  114663. * Creates the render target textures and post processes used in the effect layer.
  114664. */
  114665. protected abstract _createTextureAndPostProcesses(): void;
  114666. /**
  114667. * Implementation specific of rendering the generating effect on the main canvas.
  114668. * @param effect The effect used to render through
  114669. */
  114670. protected abstract _internalRender(effect: Effect): void;
  114671. /**
  114672. * Sets the required values for both the emissive texture and and the main color.
  114673. */
  114674. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114675. /**
  114676. * Free any resources and references associated to a mesh.
  114677. * Internal use
  114678. * @param mesh The mesh to free.
  114679. */
  114680. abstract _disposeMesh(mesh: Mesh): void;
  114681. /**
  114682. * Serializes this layer (Glow or Highlight for example)
  114683. * @returns a serialized layer object
  114684. */
  114685. abstract serialize?(): any;
  114686. /**
  114687. * Initializes the effect layer with the required options.
  114688. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  114689. */
  114690. protected _init(options: Partial<IEffectLayerOptions>): void;
  114691. /**
  114692. * Generates the index buffer of the full screen quad blending to the main canvas.
  114693. */
  114694. private _generateIndexBuffer;
  114695. /**
  114696. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  114697. */
  114698. private _generateVertexBuffer;
  114699. /**
  114700. * Sets the main texture desired size which is the closest power of two
  114701. * of the engine canvas size.
  114702. */
  114703. private _setMainTextureSize;
  114704. /**
  114705. * Creates the main texture for the effect layer.
  114706. */
  114707. protected _createMainTexture(): void;
  114708. /**
  114709. * Adds specific effects defines.
  114710. * @param defines The defines to add specifics to.
  114711. */
  114712. protected _addCustomEffectDefines(defines: string[]): void;
  114713. /**
  114714. * Checks for the readiness of the element composing the layer.
  114715. * @param subMesh the mesh to check for
  114716. * @param useInstances specify wether or not to use instances to render the mesh
  114717. * @param emissiveTexture the associated emissive texture used to generate the glow
  114718. * @return true if ready otherwise, false
  114719. */
  114720. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  114721. /**
  114722. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  114723. */
  114724. render(): void;
  114725. /**
  114726. * Determine if a given mesh will be used in the current effect.
  114727. * @param mesh mesh to test
  114728. * @returns true if the mesh will be used
  114729. */
  114730. hasMesh(mesh: AbstractMesh): boolean;
  114731. /**
  114732. * Returns true if the layer contains information to display, otherwise false.
  114733. * @returns true if the glow layer should be rendered
  114734. */
  114735. shouldRender(): boolean;
  114736. /**
  114737. * Returns true if the mesh should render, otherwise false.
  114738. * @param mesh The mesh to render
  114739. * @returns true if it should render otherwise false
  114740. */
  114741. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  114742. /**
  114743. * Returns true if the mesh can be rendered, otherwise false.
  114744. * @param mesh The mesh to render
  114745. * @param material The material used on the mesh
  114746. * @returns true if it can be rendered otherwise false
  114747. */
  114748. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114749. /**
  114750. * Returns true if the mesh should render, otherwise false.
  114751. * @param mesh The mesh to render
  114752. * @returns true if it should render otherwise false
  114753. */
  114754. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  114755. /**
  114756. * Renders the submesh passed in parameter to the generation map.
  114757. */
  114758. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  114759. /**
  114760. * Rebuild the required buffers.
  114761. * @hidden Internal use only.
  114762. */
  114763. _rebuild(): void;
  114764. /**
  114765. * Dispose only the render target textures and post process.
  114766. */
  114767. private _disposeTextureAndPostProcesses;
  114768. /**
  114769. * Dispose the highlight layer and free resources.
  114770. */
  114771. dispose(): void;
  114772. /**
  114773. * Gets the class name of the effect layer
  114774. * @returns the string with the class name of the effect layer
  114775. */
  114776. getClassName(): string;
  114777. /**
  114778. * Creates an effect layer from parsed effect layer data
  114779. * @param parsedEffectLayer defines effect layer data
  114780. * @param scene defines the current scene
  114781. * @param rootUrl defines the root URL containing the effect layer information
  114782. * @returns a parsed effect Layer
  114783. */
  114784. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  114785. }
  114786. }
  114787. declare module BABYLON {
  114788. interface AbstractScene {
  114789. /**
  114790. * The list of effect layers (highlights/glow) added to the scene
  114791. * @see http://doc.babylonjs.com/how_to/highlight_layer
  114792. * @see http://doc.babylonjs.com/how_to/glow_layer
  114793. */
  114794. effectLayers: Array<EffectLayer>;
  114795. /**
  114796. * Removes the given effect layer from this scene.
  114797. * @param toRemove defines the effect layer to remove
  114798. * @returns the index of the removed effect layer
  114799. */
  114800. removeEffectLayer(toRemove: EffectLayer): number;
  114801. /**
  114802. * Adds the given effect layer to this scene
  114803. * @param newEffectLayer defines the effect layer to add
  114804. */
  114805. addEffectLayer(newEffectLayer: EffectLayer): void;
  114806. }
  114807. /**
  114808. * Defines the layer scene component responsible to manage any effect layers
  114809. * in a given scene.
  114810. */
  114811. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  114812. /**
  114813. * The component name helpfull to identify the component in the list of scene components.
  114814. */
  114815. readonly name: string;
  114816. /**
  114817. * The scene the component belongs to.
  114818. */
  114819. scene: Scene;
  114820. private _engine;
  114821. private _renderEffects;
  114822. private _needStencil;
  114823. private _previousStencilState;
  114824. /**
  114825. * Creates a new instance of the component for the given scene
  114826. * @param scene Defines the scene to register the component in
  114827. */
  114828. constructor(scene: Scene);
  114829. /**
  114830. * Registers the component in a given scene
  114831. */
  114832. register(): void;
  114833. /**
  114834. * Rebuilds the elements related to this component in case of
  114835. * context lost for instance.
  114836. */
  114837. rebuild(): void;
  114838. /**
  114839. * Serializes the component data to the specified json object
  114840. * @param serializationObject The object to serialize to
  114841. */
  114842. serialize(serializationObject: any): void;
  114843. /**
  114844. * Adds all the elements from the container to the scene
  114845. * @param container the container holding the elements
  114846. */
  114847. addFromContainer(container: AbstractScene): void;
  114848. /**
  114849. * Removes all the elements in the container from the scene
  114850. * @param container contains the elements to remove
  114851. * @param dispose if the removed element should be disposed (default: false)
  114852. */
  114853. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114854. /**
  114855. * Disposes the component and the associated ressources.
  114856. */
  114857. dispose(): void;
  114858. private _isReadyForMesh;
  114859. private _renderMainTexture;
  114860. private _setStencil;
  114861. private _setStencilBack;
  114862. private _draw;
  114863. private _drawCamera;
  114864. private _drawRenderingGroup;
  114865. }
  114866. }
  114867. declare module BABYLON {
  114868. /** @hidden */
  114869. export var glowMapMergePixelShader: {
  114870. name: string;
  114871. shader: string;
  114872. };
  114873. }
  114874. declare module BABYLON {
  114875. /** @hidden */
  114876. export var glowMapMergeVertexShader: {
  114877. name: string;
  114878. shader: string;
  114879. };
  114880. }
  114881. declare module BABYLON {
  114882. interface AbstractScene {
  114883. /**
  114884. * Return a the first highlight layer of the scene with a given name.
  114885. * @param name The name of the highlight layer to look for.
  114886. * @return The highlight layer if found otherwise null.
  114887. */
  114888. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  114889. }
  114890. /**
  114891. * Glow layer options. This helps customizing the behaviour
  114892. * of the glow layer.
  114893. */
  114894. export interface IGlowLayerOptions {
  114895. /**
  114896. * Multiplication factor apply to the canvas size to compute the render target size
  114897. * used to generated the glowing objects (the smaller the faster).
  114898. */
  114899. mainTextureRatio: number;
  114900. /**
  114901. * Enforces a fixed size texture to ensure resize independant blur.
  114902. */
  114903. mainTextureFixedSize?: number;
  114904. /**
  114905. * How big is the kernel of the blur texture.
  114906. */
  114907. blurKernelSize: number;
  114908. /**
  114909. * The camera attached to the layer.
  114910. */
  114911. camera: Nullable<Camera>;
  114912. /**
  114913. * Enable MSAA by chosing the number of samples.
  114914. */
  114915. mainTextureSamples?: number;
  114916. /**
  114917. * The rendering group to draw the layer in.
  114918. */
  114919. renderingGroupId: number;
  114920. }
  114921. /**
  114922. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  114923. *
  114924. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  114925. * glowy meshes to your scene.
  114926. *
  114927. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  114928. */
  114929. export class GlowLayer extends EffectLayer {
  114930. /**
  114931. * Effect Name of the layer.
  114932. */
  114933. static readonly EffectName: string;
  114934. /**
  114935. * The default blur kernel size used for the glow.
  114936. */
  114937. static DefaultBlurKernelSize: number;
  114938. /**
  114939. * The default texture size ratio used for the glow.
  114940. */
  114941. static DefaultTextureRatio: number;
  114942. /**
  114943. * Sets the kernel size of the blur.
  114944. */
  114945. /**
  114946. * Gets the kernel size of the blur.
  114947. */
  114948. blurKernelSize: number;
  114949. /**
  114950. * Sets the glow intensity.
  114951. */
  114952. /**
  114953. * Gets the glow intensity.
  114954. */
  114955. intensity: number;
  114956. private _options;
  114957. private _intensity;
  114958. private _horizontalBlurPostprocess1;
  114959. private _verticalBlurPostprocess1;
  114960. private _horizontalBlurPostprocess2;
  114961. private _verticalBlurPostprocess2;
  114962. private _blurTexture1;
  114963. private _blurTexture2;
  114964. private _postProcesses1;
  114965. private _postProcesses2;
  114966. private _includedOnlyMeshes;
  114967. private _excludedMeshes;
  114968. /**
  114969. * Callback used to let the user override the color selection on a per mesh basis
  114970. */
  114971. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  114972. /**
  114973. * Callback used to let the user override the texture selection on a per mesh basis
  114974. */
  114975. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  114976. /**
  114977. * Instantiates a new glow Layer and references it to the scene.
  114978. * @param name The name of the layer
  114979. * @param scene The scene to use the layer in
  114980. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  114981. */
  114982. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  114983. /**
  114984. * Get the effect name of the layer.
  114985. * @return The effect name
  114986. */
  114987. getEffectName(): string;
  114988. /**
  114989. * Create the merge effect. This is the shader use to blit the information back
  114990. * to the main canvas at the end of the scene rendering.
  114991. */
  114992. protected _createMergeEffect(): Effect;
  114993. /**
  114994. * Creates the render target textures and post processes used in the glow layer.
  114995. */
  114996. protected _createTextureAndPostProcesses(): void;
  114997. /**
  114998. * Checks for the readiness of the element composing the layer.
  114999. * @param subMesh the mesh to check for
  115000. * @param useInstances specify wether or not to use instances to render the mesh
  115001. * @param emissiveTexture the associated emissive texture used to generate the glow
  115002. * @return true if ready otherwise, false
  115003. */
  115004. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115005. /**
  115006. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115007. */
  115008. needStencil(): boolean;
  115009. /**
  115010. * Returns true if the mesh can be rendered, otherwise false.
  115011. * @param mesh The mesh to render
  115012. * @param material The material used on the mesh
  115013. * @returns true if it can be rendered otherwise false
  115014. */
  115015. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  115016. /**
  115017. * Implementation specific of rendering the generating effect on the main canvas.
  115018. * @param effect The effect used to render through
  115019. */
  115020. protected _internalRender(effect: Effect): void;
  115021. /**
  115022. * Sets the required values for both the emissive texture and and the main color.
  115023. */
  115024. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115025. /**
  115026. * Returns true if the mesh should render, otherwise false.
  115027. * @param mesh The mesh to render
  115028. * @returns true if it should render otherwise false
  115029. */
  115030. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115031. /**
  115032. * Adds specific effects defines.
  115033. * @param defines The defines to add specifics to.
  115034. */
  115035. protected _addCustomEffectDefines(defines: string[]): void;
  115036. /**
  115037. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  115038. * @param mesh The mesh to exclude from the glow layer
  115039. */
  115040. addExcludedMesh(mesh: Mesh): void;
  115041. /**
  115042. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  115043. * @param mesh The mesh to remove
  115044. */
  115045. removeExcludedMesh(mesh: Mesh): void;
  115046. /**
  115047. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  115048. * @param mesh The mesh to include in the glow layer
  115049. */
  115050. addIncludedOnlyMesh(mesh: Mesh): void;
  115051. /**
  115052. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  115053. * @param mesh The mesh to remove
  115054. */
  115055. removeIncludedOnlyMesh(mesh: Mesh): void;
  115056. /**
  115057. * Determine if a given mesh will be used in the glow layer
  115058. * @param mesh The mesh to test
  115059. * @returns true if the mesh will be highlighted by the current glow layer
  115060. */
  115061. hasMesh(mesh: AbstractMesh): boolean;
  115062. /**
  115063. * Free any resources and references associated to a mesh.
  115064. * Internal use
  115065. * @param mesh The mesh to free.
  115066. * @hidden
  115067. */
  115068. _disposeMesh(mesh: Mesh): void;
  115069. /**
  115070. * Gets the class name of the effect layer
  115071. * @returns the string with the class name of the effect layer
  115072. */
  115073. getClassName(): string;
  115074. /**
  115075. * Serializes this glow layer
  115076. * @returns a serialized glow layer object
  115077. */
  115078. serialize(): any;
  115079. /**
  115080. * Creates a Glow Layer from parsed glow layer data
  115081. * @param parsedGlowLayer defines glow layer data
  115082. * @param scene defines the current scene
  115083. * @param rootUrl defines the root URL containing the glow layer information
  115084. * @returns a parsed Glow Layer
  115085. */
  115086. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  115087. }
  115088. }
  115089. declare module BABYLON {
  115090. /** @hidden */
  115091. export var glowBlurPostProcessPixelShader: {
  115092. name: string;
  115093. shader: string;
  115094. };
  115095. }
  115096. declare module BABYLON {
  115097. interface AbstractScene {
  115098. /**
  115099. * Return a the first highlight layer of the scene with a given name.
  115100. * @param name The name of the highlight layer to look for.
  115101. * @return The highlight layer if found otherwise null.
  115102. */
  115103. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  115104. }
  115105. /**
  115106. * Highlight layer options. This helps customizing the behaviour
  115107. * of the highlight layer.
  115108. */
  115109. export interface IHighlightLayerOptions {
  115110. /**
  115111. * Multiplication factor apply to the canvas size to compute the render target size
  115112. * used to generated the glowing objects (the smaller the faster).
  115113. */
  115114. mainTextureRatio: number;
  115115. /**
  115116. * Enforces a fixed size texture to ensure resize independant blur.
  115117. */
  115118. mainTextureFixedSize?: number;
  115119. /**
  115120. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  115121. * of the picture to blur (the smaller the faster).
  115122. */
  115123. blurTextureSizeRatio: number;
  115124. /**
  115125. * How big in texel of the blur texture is the vertical blur.
  115126. */
  115127. blurVerticalSize: number;
  115128. /**
  115129. * How big in texel of the blur texture is the horizontal blur.
  115130. */
  115131. blurHorizontalSize: number;
  115132. /**
  115133. * Alpha blending mode used to apply the blur. Default is combine.
  115134. */
  115135. alphaBlendingMode: number;
  115136. /**
  115137. * The camera attached to the layer.
  115138. */
  115139. camera: Nullable<Camera>;
  115140. /**
  115141. * Should we display highlight as a solid stroke?
  115142. */
  115143. isStroke?: boolean;
  115144. /**
  115145. * The rendering group to draw the layer in.
  115146. */
  115147. renderingGroupId: number;
  115148. }
  115149. /**
  115150. * The highlight layer Helps adding a glow effect around a mesh.
  115151. *
  115152. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115153. * glowy meshes to your scene.
  115154. *
  115155. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  115156. */
  115157. export class HighlightLayer extends EffectLayer {
  115158. name: string;
  115159. /**
  115160. * Effect Name of the highlight layer.
  115161. */
  115162. static readonly EffectName: string;
  115163. /**
  115164. * The neutral color used during the preparation of the glow effect.
  115165. * This is black by default as the blend operation is a blend operation.
  115166. */
  115167. static NeutralColor: Color4;
  115168. /**
  115169. * Stencil value used for glowing meshes.
  115170. */
  115171. static GlowingMeshStencilReference: number;
  115172. /**
  115173. * Stencil value used for the other meshes in the scene.
  115174. */
  115175. static NormalMeshStencilReference: number;
  115176. /**
  115177. * Specifies whether or not the inner glow is ACTIVE in the layer.
  115178. */
  115179. innerGlow: boolean;
  115180. /**
  115181. * Specifies whether or not the outer glow is ACTIVE in the layer.
  115182. */
  115183. outerGlow: boolean;
  115184. /**
  115185. * Specifies the horizontal size of the blur.
  115186. */
  115187. /**
  115188. * Gets the horizontal size of the blur.
  115189. */
  115190. blurHorizontalSize: number;
  115191. /**
  115192. * Specifies the vertical size of the blur.
  115193. */
  115194. /**
  115195. * Gets the vertical size of the blur.
  115196. */
  115197. blurVerticalSize: number;
  115198. /**
  115199. * An event triggered when the highlight layer is being blurred.
  115200. */
  115201. onBeforeBlurObservable: Observable<HighlightLayer>;
  115202. /**
  115203. * An event triggered when the highlight layer has been blurred.
  115204. */
  115205. onAfterBlurObservable: Observable<HighlightLayer>;
  115206. private _instanceGlowingMeshStencilReference;
  115207. private _options;
  115208. private _downSamplePostprocess;
  115209. private _horizontalBlurPostprocess;
  115210. private _verticalBlurPostprocess;
  115211. private _blurTexture;
  115212. private _meshes;
  115213. private _excludedMeshes;
  115214. /**
  115215. * Instantiates a new highlight Layer and references it to the scene..
  115216. * @param name The name of the layer
  115217. * @param scene The scene to use the layer in
  115218. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  115219. */
  115220. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  115221. /**
  115222. * Get the effect name of the layer.
  115223. * @return The effect name
  115224. */
  115225. getEffectName(): string;
  115226. /**
  115227. * Create the merge effect. This is the shader use to blit the information back
  115228. * to the main canvas at the end of the scene rendering.
  115229. */
  115230. protected _createMergeEffect(): Effect;
  115231. /**
  115232. * Creates the render target textures and post processes used in the highlight layer.
  115233. */
  115234. protected _createTextureAndPostProcesses(): void;
  115235. /**
  115236. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115237. */
  115238. needStencil(): boolean;
  115239. /**
  115240. * Checks for the readiness of the element composing the layer.
  115241. * @param subMesh the mesh to check for
  115242. * @param useInstances specify wether or not to use instances to render the mesh
  115243. * @param emissiveTexture the associated emissive texture used to generate the glow
  115244. * @return true if ready otherwise, false
  115245. */
  115246. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115247. /**
  115248. * Implementation specific of rendering the generating effect on the main canvas.
  115249. * @param effect The effect used to render through
  115250. */
  115251. protected _internalRender(effect: Effect): void;
  115252. /**
  115253. * Returns true if the layer contains information to display, otherwise false.
  115254. */
  115255. shouldRender(): boolean;
  115256. /**
  115257. * Returns true if the mesh should render, otherwise false.
  115258. * @param mesh The mesh to render
  115259. * @returns true if it should render otherwise false
  115260. */
  115261. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115262. /**
  115263. * Sets the required values for both the emissive texture and and the main color.
  115264. */
  115265. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115266. /**
  115267. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  115268. * @param mesh The mesh to exclude from the highlight layer
  115269. */
  115270. addExcludedMesh(mesh: Mesh): void;
  115271. /**
  115272. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  115273. * @param mesh The mesh to highlight
  115274. */
  115275. removeExcludedMesh(mesh: Mesh): void;
  115276. /**
  115277. * Determine if a given mesh will be highlighted by the current HighlightLayer
  115278. * @param mesh mesh to test
  115279. * @returns true if the mesh will be highlighted by the current HighlightLayer
  115280. */
  115281. hasMesh(mesh: AbstractMesh): boolean;
  115282. /**
  115283. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  115284. * @param mesh The mesh to highlight
  115285. * @param color The color of the highlight
  115286. * @param glowEmissiveOnly Extract the glow from the emissive texture
  115287. */
  115288. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  115289. /**
  115290. * Remove a mesh from the highlight layer in order to make it stop glowing.
  115291. * @param mesh The mesh to highlight
  115292. */
  115293. removeMesh(mesh: Mesh): void;
  115294. /**
  115295. * Force the stencil to the normal expected value for none glowing parts
  115296. */
  115297. private _defaultStencilReference;
  115298. /**
  115299. * Free any resources and references associated to a mesh.
  115300. * Internal use
  115301. * @param mesh The mesh to free.
  115302. * @hidden
  115303. */
  115304. _disposeMesh(mesh: Mesh): void;
  115305. /**
  115306. * Dispose the highlight layer and free resources.
  115307. */
  115308. dispose(): void;
  115309. /**
  115310. * Gets the class name of the effect layer
  115311. * @returns the string with the class name of the effect layer
  115312. */
  115313. getClassName(): string;
  115314. /**
  115315. * Serializes this Highlight layer
  115316. * @returns a serialized Highlight layer object
  115317. */
  115318. serialize(): any;
  115319. /**
  115320. * Creates a Highlight layer from parsed Highlight layer data
  115321. * @param parsedHightlightLayer defines the Highlight layer data
  115322. * @param scene defines the current scene
  115323. * @param rootUrl defines the root URL containing the Highlight layer information
  115324. * @returns a parsed Highlight layer
  115325. */
  115326. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  115327. }
  115328. }
  115329. declare module BABYLON {
  115330. interface AbstractScene {
  115331. /**
  115332. * The list of layers (background and foreground) of the scene
  115333. */
  115334. layers: Array<Layer>;
  115335. }
  115336. /**
  115337. * Defines the layer scene component responsible to manage any layers
  115338. * in a given scene.
  115339. */
  115340. export class LayerSceneComponent implements ISceneComponent {
  115341. /**
  115342. * The component name helpfull to identify the component in the list of scene components.
  115343. */
  115344. readonly name: string;
  115345. /**
  115346. * The scene the component belongs to.
  115347. */
  115348. scene: Scene;
  115349. private _engine;
  115350. /**
  115351. * Creates a new instance of the component for the given scene
  115352. * @param scene Defines the scene to register the component in
  115353. */
  115354. constructor(scene: Scene);
  115355. /**
  115356. * Registers the component in a given scene
  115357. */
  115358. register(): void;
  115359. /**
  115360. * Rebuilds the elements related to this component in case of
  115361. * context lost for instance.
  115362. */
  115363. rebuild(): void;
  115364. /**
  115365. * Disposes the component and the associated ressources.
  115366. */
  115367. dispose(): void;
  115368. private _draw;
  115369. private _drawCameraPredicate;
  115370. private _drawCameraBackground;
  115371. private _drawCameraForeground;
  115372. private _drawRenderTargetPredicate;
  115373. private _drawRenderTargetBackground;
  115374. private _drawRenderTargetForeground;
  115375. /**
  115376. * Adds all the elements from the container to the scene
  115377. * @param container the container holding the elements
  115378. */
  115379. addFromContainer(container: AbstractScene): void;
  115380. /**
  115381. * Removes all the elements in the container from the scene
  115382. * @param container contains the elements to remove
  115383. * @param dispose if the removed element should be disposed (default: false)
  115384. */
  115385. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115386. }
  115387. }
  115388. declare module BABYLON {
  115389. /** @hidden */
  115390. export var layerPixelShader: {
  115391. name: string;
  115392. shader: string;
  115393. };
  115394. }
  115395. declare module BABYLON {
  115396. /** @hidden */
  115397. export var layerVertexShader: {
  115398. name: string;
  115399. shader: string;
  115400. };
  115401. }
  115402. declare module BABYLON {
  115403. /**
  115404. * This represents a full screen 2d layer.
  115405. * This can be useful to display a picture in the background of your scene for instance.
  115406. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115407. */
  115408. export class Layer {
  115409. /**
  115410. * Define the name of the layer.
  115411. */
  115412. name: string;
  115413. /**
  115414. * Define the texture the layer should display.
  115415. */
  115416. texture: Nullable<Texture>;
  115417. /**
  115418. * Is the layer in background or foreground.
  115419. */
  115420. isBackground: boolean;
  115421. /**
  115422. * Define the color of the layer (instead of texture).
  115423. */
  115424. color: Color4;
  115425. /**
  115426. * Define the scale of the layer in order to zoom in out of the texture.
  115427. */
  115428. scale: Vector2;
  115429. /**
  115430. * Define an offset for the layer in order to shift the texture.
  115431. */
  115432. offset: Vector2;
  115433. /**
  115434. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  115435. */
  115436. alphaBlendingMode: number;
  115437. /**
  115438. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  115439. * Alpha test will not mix with the background color in case of transparency.
  115440. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  115441. */
  115442. alphaTest: boolean;
  115443. /**
  115444. * Define a mask to restrict the layer to only some of the scene cameras.
  115445. */
  115446. layerMask: number;
  115447. /**
  115448. * Define the list of render target the layer is visible into.
  115449. */
  115450. renderTargetTextures: RenderTargetTexture[];
  115451. /**
  115452. * Define if the layer is only used in renderTarget or if it also
  115453. * renders in the main frame buffer of the canvas.
  115454. */
  115455. renderOnlyInRenderTargetTextures: boolean;
  115456. private _scene;
  115457. private _vertexBuffers;
  115458. private _indexBuffer;
  115459. private _effect;
  115460. private _alphaTestEffect;
  115461. /**
  115462. * An event triggered when the layer is disposed.
  115463. */
  115464. onDisposeObservable: Observable<Layer>;
  115465. private _onDisposeObserver;
  115466. /**
  115467. * Back compatibility with callback before the onDisposeObservable existed.
  115468. * The set callback will be triggered when the layer has been disposed.
  115469. */
  115470. onDispose: () => void;
  115471. /**
  115472. * An event triggered before rendering the scene
  115473. */
  115474. onBeforeRenderObservable: Observable<Layer>;
  115475. private _onBeforeRenderObserver;
  115476. /**
  115477. * Back compatibility with callback before the onBeforeRenderObservable existed.
  115478. * The set callback will be triggered just before rendering the layer.
  115479. */
  115480. onBeforeRender: () => void;
  115481. /**
  115482. * An event triggered after rendering the scene
  115483. */
  115484. onAfterRenderObservable: Observable<Layer>;
  115485. private _onAfterRenderObserver;
  115486. /**
  115487. * Back compatibility with callback before the onAfterRenderObservable existed.
  115488. * The set callback will be triggered just after rendering the layer.
  115489. */
  115490. onAfterRender: () => void;
  115491. /**
  115492. * Instantiates a new layer.
  115493. * This represents a full screen 2d layer.
  115494. * This can be useful to display a picture in the background of your scene for instance.
  115495. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115496. * @param name Define the name of the layer in the scene
  115497. * @param imgUrl Define the url of the texture to display in the layer
  115498. * @param scene Define the scene the layer belongs to
  115499. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  115500. * @param color Defines a color for the layer
  115501. */
  115502. constructor(
  115503. /**
  115504. * Define the name of the layer.
  115505. */
  115506. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  115507. private _createIndexBuffer;
  115508. /** @hidden */
  115509. _rebuild(): void;
  115510. /**
  115511. * Renders the layer in the scene.
  115512. */
  115513. render(): void;
  115514. /**
  115515. * Disposes and releases the associated ressources.
  115516. */
  115517. dispose(): void;
  115518. }
  115519. }
  115520. declare module BABYLON {
  115521. /** @hidden */
  115522. export var lensFlarePixelShader: {
  115523. name: string;
  115524. shader: string;
  115525. };
  115526. }
  115527. declare module BABYLON {
  115528. /** @hidden */
  115529. export var lensFlareVertexShader: {
  115530. name: string;
  115531. shader: string;
  115532. };
  115533. }
  115534. declare module BABYLON {
  115535. /**
  115536. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115537. * It is usually composed of several `lensFlare`.
  115538. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115539. */
  115540. export class LensFlareSystem {
  115541. /**
  115542. * Define the name of the lens flare system
  115543. */
  115544. name: string;
  115545. /**
  115546. * List of lens flares used in this system.
  115547. */
  115548. lensFlares: LensFlare[];
  115549. /**
  115550. * Define a limit from the border the lens flare can be visible.
  115551. */
  115552. borderLimit: number;
  115553. /**
  115554. * Define a viewport border we do not want to see the lens flare in.
  115555. */
  115556. viewportBorder: number;
  115557. /**
  115558. * Define a predicate which could limit the list of meshes able to occlude the effect.
  115559. */
  115560. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115561. /**
  115562. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  115563. */
  115564. layerMask: number;
  115565. /**
  115566. * Define the id of the lens flare system in the scene.
  115567. * (equal to name by default)
  115568. */
  115569. id: string;
  115570. private _scene;
  115571. private _emitter;
  115572. private _vertexBuffers;
  115573. private _indexBuffer;
  115574. private _effect;
  115575. private _positionX;
  115576. private _positionY;
  115577. private _isEnabled;
  115578. /** @hidden */
  115579. static _SceneComponentInitialization: (scene: Scene) => void;
  115580. /**
  115581. * Instantiates a lens flare system.
  115582. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115583. * It is usually composed of several `lensFlare`.
  115584. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115585. * @param name Define the name of the lens flare system in the scene
  115586. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  115587. * @param scene Define the scene the lens flare system belongs to
  115588. */
  115589. constructor(
  115590. /**
  115591. * Define the name of the lens flare system
  115592. */
  115593. name: string, emitter: any, scene: Scene);
  115594. /**
  115595. * Define if the lens flare system is enabled.
  115596. */
  115597. isEnabled: boolean;
  115598. /**
  115599. * Get the scene the effects belongs to.
  115600. * @returns the scene holding the lens flare system
  115601. */
  115602. getScene(): Scene;
  115603. /**
  115604. * Get the emitter of the lens flare system.
  115605. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115606. * @returns the emitter of the lens flare system
  115607. */
  115608. getEmitter(): any;
  115609. /**
  115610. * Set the emitter of the lens flare system.
  115611. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115612. * @param newEmitter Define the new emitter of the system
  115613. */
  115614. setEmitter(newEmitter: any): void;
  115615. /**
  115616. * Get the lens flare system emitter position.
  115617. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  115618. * @returns the position
  115619. */
  115620. getEmitterPosition(): Vector3;
  115621. /**
  115622. * @hidden
  115623. */
  115624. computeEffectivePosition(globalViewport: Viewport): boolean;
  115625. /** @hidden */
  115626. _isVisible(): boolean;
  115627. /**
  115628. * @hidden
  115629. */
  115630. render(): boolean;
  115631. /**
  115632. * Dispose and release the lens flare with its associated resources.
  115633. */
  115634. dispose(): void;
  115635. /**
  115636. * Parse a lens flare system from a JSON repressentation
  115637. * @param parsedLensFlareSystem Define the JSON to parse
  115638. * @param scene Define the scene the parsed system should be instantiated in
  115639. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  115640. * @returns the parsed system
  115641. */
  115642. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  115643. /**
  115644. * Serialize the current Lens Flare System into a JSON representation.
  115645. * @returns the serialized JSON
  115646. */
  115647. serialize(): any;
  115648. }
  115649. }
  115650. declare module BABYLON {
  115651. /**
  115652. * This represents one of the lens effect in a `lensFlareSystem`.
  115653. * It controls one of the indiviual texture used in the effect.
  115654. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115655. */
  115656. export class LensFlare {
  115657. /**
  115658. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115659. */
  115660. size: number;
  115661. /**
  115662. * 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.
  115663. */
  115664. position: number;
  115665. /**
  115666. * Define the lens color.
  115667. */
  115668. color: Color3;
  115669. /**
  115670. * Define the lens texture.
  115671. */
  115672. texture: Nullable<Texture>;
  115673. /**
  115674. * Define the alpha mode to render this particular lens.
  115675. */
  115676. alphaMode: number;
  115677. private _system;
  115678. /**
  115679. * Creates a new Lens Flare.
  115680. * This represents one of the lens effect in a `lensFlareSystem`.
  115681. * It controls one of the indiviual texture used in the effect.
  115682. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115683. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  115684. * @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.
  115685. * @param color Define the lens color
  115686. * @param imgUrl Define the lens texture url
  115687. * @param system Define the `lensFlareSystem` this flare is part of
  115688. * @returns The newly created Lens Flare
  115689. */
  115690. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  115691. /**
  115692. * Instantiates a new Lens Flare.
  115693. * This represents one of the lens effect in a `lensFlareSystem`.
  115694. * It controls one of the indiviual texture used in the effect.
  115695. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115696. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  115697. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  115698. * @param color Define the lens color
  115699. * @param imgUrl Define the lens texture url
  115700. * @param system Define the `lensFlareSystem` this flare is part of
  115701. */
  115702. constructor(
  115703. /**
  115704. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115705. */
  115706. size: number,
  115707. /**
  115708. * 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.
  115709. */
  115710. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  115711. /**
  115712. * Dispose and release the lens flare with its associated resources.
  115713. */
  115714. dispose(): void;
  115715. }
  115716. }
  115717. declare module BABYLON {
  115718. interface AbstractScene {
  115719. /**
  115720. * The list of lens flare system added to the scene
  115721. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115722. */
  115723. lensFlareSystems: Array<LensFlareSystem>;
  115724. /**
  115725. * Removes the given lens flare system from this scene.
  115726. * @param toRemove The lens flare system to remove
  115727. * @returns The index of the removed lens flare system
  115728. */
  115729. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  115730. /**
  115731. * Adds the given lens flare system to this scene
  115732. * @param newLensFlareSystem The lens flare system to add
  115733. */
  115734. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  115735. /**
  115736. * Gets a lens flare system using its name
  115737. * @param name defines the name to look for
  115738. * @returns the lens flare system or null if not found
  115739. */
  115740. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  115741. /**
  115742. * Gets a lens flare system using its id
  115743. * @param id defines the id to look for
  115744. * @returns the lens flare system or null if not found
  115745. */
  115746. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  115747. }
  115748. /**
  115749. * Defines the lens flare scene component responsible to manage any lens flares
  115750. * in a given scene.
  115751. */
  115752. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  115753. /**
  115754. * The component name helpfull to identify the component in the list of scene components.
  115755. */
  115756. readonly name: string;
  115757. /**
  115758. * The scene the component belongs to.
  115759. */
  115760. scene: Scene;
  115761. /**
  115762. * Creates a new instance of the component for the given scene
  115763. * @param scene Defines the scene to register the component in
  115764. */
  115765. constructor(scene: Scene);
  115766. /**
  115767. * Registers the component in a given scene
  115768. */
  115769. register(): void;
  115770. /**
  115771. * Rebuilds the elements related to this component in case of
  115772. * context lost for instance.
  115773. */
  115774. rebuild(): void;
  115775. /**
  115776. * Adds all the elements from the container to the scene
  115777. * @param container the container holding the elements
  115778. */
  115779. addFromContainer(container: AbstractScene): void;
  115780. /**
  115781. * Removes all the elements in the container from the scene
  115782. * @param container contains the elements to remove
  115783. * @param dispose if the removed element should be disposed (default: false)
  115784. */
  115785. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115786. /**
  115787. * Serializes the component data to the specified json object
  115788. * @param serializationObject The object to serialize to
  115789. */
  115790. serialize(serializationObject: any): void;
  115791. /**
  115792. * Disposes the component and the associated ressources.
  115793. */
  115794. dispose(): void;
  115795. private _draw;
  115796. }
  115797. }
  115798. declare module BABYLON {
  115799. /**
  115800. * Defines the shadow generator component responsible to manage any shadow generators
  115801. * in a given scene.
  115802. */
  115803. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  115804. /**
  115805. * The component name helpfull to identify the component in the list of scene components.
  115806. */
  115807. readonly name: string;
  115808. /**
  115809. * The scene the component belongs to.
  115810. */
  115811. scene: Scene;
  115812. /**
  115813. * Creates a new instance of the component for the given scene
  115814. * @param scene Defines the scene to register the component in
  115815. */
  115816. constructor(scene: Scene);
  115817. /**
  115818. * Registers the component in a given scene
  115819. */
  115820. register(): void;
  115821. /**
  115822. * Rebuilds the elements related to this component in case of
  115823. * context lost for instance.
  115824. */
  115825. rebuild(): void;
  115826. /**
  115827. * Serializes the component data to the specified json object
  115828. * @param serializationObject The object to serialize to
  115829. */
  115830. serialize(serializationObject: any): void;
  115831. /**
  115832. * Adds all the elements from the container to the scene
  115833. * @param container the container holding the elements
  115834. */
  115835. addFromContainer(container: AbstractScene): void;
  115836. /**
  115837. * Removes all the elements in the container from the scene
  115838. * @param container contains the elements to remove
  115839. * @param dispose if the removed element should be disposed (default: false)
  115840. */
  115841. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115842. /**
  115843. * Rebuilds the elements related to this component in case of
  115844. * context lost for instance.
  115845. */
  115846. dispose(): void;
  115847. private _gatherRenderTargets;
  115848. }
  115849. }
  115850. declare module BABYLON {
  115851. /**
  115852. * A point light is a light defined by an unique point in world space.
  115853. * The light is emitted in every direction from this point.
  115854. * A good example of a point light is a standard light bulb.
  115855. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115856. */
  115857. export class PointLight extends ShadowLight {
  115858. private _shadowAngle;
  115859. /**
  115860. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115861. * This specifies what angle the shadow will use to be created.
  115862. *
  115863. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115864. */
  115865. /**
  115866. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115867. * This specifies what angle the shadow will use to be created.
  115868. *
  115869. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115870. */
  115871. shadowAngle: number;
  115872. /**
  115873. * Gets the direction if it has been set.
  115874. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115875. */
  115876. /**
  115877. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115878. */
  115879. direction: Vector3;
  115880. /**
  115881. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  115882. * A PointLight emits the light in every direction.
  115883. * It can cast shadows.
  115884. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  115885. * ```javascript
  115886. * var pointLight = new PointLight("pl", camera.position, scene);
  115887. * ```
  115888. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115889. * @param name The light friendly name
  115890. * @param position The position of the point light in the scene
  115891. * @param scene The scene the lights belongs to
  115892. */
  115893. constructor(name: string, position: Vector3, scene: Scene);
  115894. /**
  115895. * Returns the string "PointLight"
  115896. * @returns the class name
  115897. */
  115898. getClassName(): string;
  115899. /**
  115900. * Returns the integer 0.
  115901. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115902. */
  115903. getTypeID(): number;
  115904. /**
  115905. * Specifies wether or not the shadowmap should be a cube texture.
  115906. * @returns true if the shadowmap needs to be a cube texture.
  115907. */
  115908. needCube(): boolean;
  115909. /**
  115910. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  115911. * @param faceIndex The index of the face we are computed the direction to generate shadow
  115912. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  115913. */
  115914. getShadowDirection(faceIndex?: number): Vector3;
  115915. /**
  115916. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  115917. * - fov = PI / 2
  115918. * - aspect ratio : 1.0
  115919. * - z-near and far equal to the active camera minZ and maxZ.
  115920. * Returns the PointLight.
  115921. */
  115922. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115923. protected _buildUniformLayout(): void;
  115924. /**
  115925. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  115926. * @param effect The effect to update
  115927. * @param lightIndex The index of the light in the effect to update
  115928. * @returns The point light
  115929. */
  115930. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  115931. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  115932. /**
  115933. * Prepares the list of defines specific to the light type.
  115934. * @param defines the list of defines
  115935. * @param lightIndex defines the index of the light for the effect
  115936. */
  115937. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115938. }
  115939. }
  115940. declare module BABYLON {
  115941. /**
  115942. * Header information of HDR texture files.
  115943. */
  115944. export interface HDRInfo {
  115945. /**
  115946. * The height of the texture in pixels.
  115947. */
  115948. height: number;
  115949. /**
  115950. * The width of the texture in pixels.
  115951. */
  115952. width: number;
  115953. /**
  115954. * The index of the beginning of the data in the binary file.
  115955. */
  115956. dataPosition: number;
  115957. }
  115958. /**
  115959. * This groups tools to convert HDR texture to native colors array.
  115960. */
  115961. export class HDRTools {
  115962. private static Ldexp;
  115963. private static Rgbe2float;
  115964. private static readStringLine;
  115965. /**
  115966. * Reads header information from an RGBE texture stored in a native array.
  115967. * More information on this format are available here:
  115968. * https://en.wikipedia.org/wiki/RGBE_image_format
  115969. *
  115970. * @param uint8array The binary file stored in native array.
  115971. * @return The header information.
  115972. */
  115973. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  115974. /**
  115975. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  115976. * This RGBE texture needs to store the information as a panorama.
  115977. *
  115978. * More information on this format are available here:
  115979. * https://en.wikipedia.org/wiki/RGBE_image_format
  115980. *
  115981. * @param buffer The binary file stored in an array buffer.
  115982. * @param size The expected size of the extracted cubemap.
  115983. * @return The Cube Map information.
  115984. */
  115985. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  115986. /**
  115987. * Returns the pixels data extracted from an RGBE texture.
  115988. * This pixels will be stored left to right up to down in the R G B order in one array.
  115989. *
  115990. * More information on this format are available here:
  115991. * https://en.wikipedia.org/wiki/RGBE_image_format
  115992. *
  115993. * @param uint8array The binary file stored in an array buffer.
  115994. * @param hdrInfo The header information of the file.
  115995. * @return The pixels data in RGB right to left up to down order.
  115996. */
  115997. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  115998. private static RGBE_ReadPixels_RLE;
  115999. }
  116000. }
  116001. declare module BABYLON {
  116002. /**
  116003. * This represents a texture coming from an HDR input.
  116004. *
  116005. * The only supported format is currently panorama picture stored in RGBE format.
  116006. * Example of such files can be found on HDRLib: http://hdrlib.com/
  116007. */
  116008. export class HDRCubeTexture extends BaseTexture {
  116009. private static _facesMapping;
  116010. private _generateHarmonics;
  116011. private _noMipmap;
  116012. private _textureMatrix;
  116013. private _size;
  116014. private _onLoad;
  116015. private _onError;
  116016. /**
  116017. * The texture URL.
  116018. */
  116019. url: string;
  116020. /**
  116021. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  116022. */
  116023. coordinatesMode: number;
  116024. protected _isBlocking: boolean;
  116025. /**
  116026. * Sets wether or not the texture is blocking during loading.
  116027. */
  116028. /**
  116029. * Gets wether or not the texture is blocking during loading.
  116030. */
  116031. isBlocking: boolean;
  116032. protected _rotationY: number;
  116033. /**
  116034. * Sets texture matrix rotation angle around Y axis in radians.
  116035. */
  116036. /**
  116037. * Gets texture matrix rotation angle around Y axis radians.
  116038. */
  116039. rotationY: number;
  116040. /**
  116041. * Gets or sets the center of the bounding box associated with the cube texture
  116042. * It must define where the camera used to render the texture was set
  116043. */
  116044. boundingBoxPosition: Vector3;
  116045. private _boundingBoxSize;
  116046. /**
  116047. * Gets or sets the size of the bounding box associated with the cube texture
  116048. * When defined, the cubemap will switch to local mode
  116049. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  116050. * @example https://www.babylonjs-playground.com/#RNASML
  116051. */
  116052. boundingBoxSize: Vector3;
  116053. /**
  116054. * Instantiates an HDRTexture from the following parameters.
  116055. *
  116056. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  116057. * @param scene The scene the texture will be used in
  116058. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  116059. * @param noMipmap Forces to not generate the mipmap if true
  116060. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  116061. * @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)
  116062. * @param reserved Reserved flag for internal use.
  116063. */
  116064. 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>);
  116065. /**
  116066. * Get the current class name of the texture useful for serialization or dynamic coding.
  116067. * @returns "HDRCubeTexture"
  116068. */
  116069. getClassName(): string;
  116070. /**
  116071. * Occurs when the file is raw .hdr file.
  116072. */
  116073. private loadTexture;
  116074. clone(): HDRCubeTexture;
  116075. delayLoad(): void;
  116076. /**
  116077. * Get the texture reflection matrix used to rotate/transform the reflection.
  116078. * @returns the reflection matrix
  116079. */
  116080. getReflectionTextureMatrix(): Matrix;
  116081. /**
  116082. * Set the texture reflection matrix used to rotate/transform the reflection.
  116083. * @param value Define the reflection matrix to set
  116084. */
  116085. setReflectionTextureMatrix(value: Matrix): void;
  116086. /**
  116087. * Parses a JSON representation of an HDR Texture in order to create the texture
  116088. * @param parsedTexture Define the JSON representation
  116089. * @param scene Define the scene the texture should be created in
  116090. * @param rootUrl Define the root url in case we need to load relative dependencies
  116091. * @returns the newly created texture after parsing
  116092. */
  116093. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  116094. serialize(): any;
  116095. }
  116096. }
  116097. declare module BABYLON {
  116098. /**
  116099. * Class used to control physics engine
  116100. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116101. */
  116102. export class PhysicsEngine implements IPhysicsEngine {
  116103. private _physicsPlugin;
  116104. /**
  116105. * Global value used to control the smallest number supported by the simulation
  116106. */
  116107. static Epsilon: number;
  116108. private _impostors;
  116109. private _joints;
  116110. /**
  116111. * Gets the gravity vector used by the simulation
  116112. */
  116113. gravity: Vector3;
  116114. /**
  116115. * Factory used to create the default physics plugin.
  116116. * @returns The default physics plugin
  116117. */
  116118. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  116119. /**
  116120. * Creates a new Physics Engine
  116121. * @param gravity defines the gravity vector used by the simulation
  116122. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  116123. */
  116124. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  116125. /**
  116126. * Sets the gravity vector used by the simulation
  116127. * @param gravity defines the gravity vector to use
  116128. */
  116129. setGravity(gravity: Vector3): void;
  116130. /**
  116131. * Set the time step of the physics engine.
  116132. * Default is 1/60.
  116133. * To slow it down, enter 1/600 for example.
  116134. * To speed it up, 1/30
  116135. * @param newTimeStep defines the new timestep to apply to this world.
  116136. */
  116137. setTimeStep(newTimeStep?: number): void;
  116138. /**
  116139. * Get the time step of the physics engine.
  116140. * @returns the current time step
  116141. */
  116142. getTimeStep(): number;
  116143. /**
  116144. * Release all resources
  116145. */
  116146. dispose(): void;
  116147. /**
  116148. * Gets the name of the current physics plugin
  116149. * @returns the name of the plugin
  116150. */
  116151. getPhysicsPluginName(): string;
  116152. /**
  116153. * Adding a new impostor for the impostor tracking.
  116154. * This will be done by the impostor itself.
  116155. * @param impostor the impostor to add
  116156. */
  116157. addImpostor(impostor: PhysicsImpostor): void;
  116158. /**
  116159. * Remove an impostor from the engine.
  116160. * This impostor and its mesh will not longer be updated by the physics engine.
  116161. * @param impostor the impostor to remove
  116162. */
  116163. removeImpostor(impostor: PhysicsImpostor): void;
  116164. /**
  116165. * Add a joint to the physics engine
  116166. * @param mainImpostor defines the main impostor to which the joint is added.
  116167. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116168. * @param joint defines the joint that will connect both impostors.
  116169. */
  116170. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116171. /**
  116172. * Removes a joint from the simulation
  116173. * @param mainImpostor defines the impostor used with the joint
  116174. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116175. * @param joint defines the joint to remove
  116176. */
  116177. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116178. /**
  116179. * Called by the scene. No need to call it.
  116180. * @param delta defines the timespam between frames
  116181. */
  116182. _step(delta: number): void;
  116183. /**
  116184. * Gets the current plugin used to run the simulation
  116185. * @returns current plugin
  116186. */
  116187. getPhysicsPlugin(): IPhysicsEnginePlugin;
  116188. /**
  116189. * Gets the list of physic impostors
  116190. * @returns an array of PhysicsImpostor
  116191. */
  116192. getImpostors(): Array<PhysicsImpostor>;
  116193. /**
  116194. * Gets the impostor for a physics enabled object
  116195. * @param object defines the object impersonated by the impostor
  116196. * @returns the PhysicsImpostor or null if not found
  116197. */
  116198. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  116199. /**
  116200. * Gets the impostor for a physics body object
  116201. * @param body defines physics body used by the impostor
  116202. * @returns the PhysicsImpostor or null if not found
  116203. */
  116204. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  116205. /**
  116206. * Does a raycast in the physics world
  116207. * @param from when should the ray start?
  116208. * @param to when should the ray end?
  116209. * @returns PhysicsRaycastResult
  116210. */
  116211. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116212. }
  116213. }
  116214. declare module BABYLON {
  116215. /** @hidden */
  116216. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  116217. private _useDeltaForWorldStep;
  116218. world: any;
  116219. name: string;
  116220. private _physicsMaterials;
  116221. private _fixedTimeStep;
  116222. private _cannonRaycastResult;
  116223. private _raycastResult;
  116224. private _physicsBodysToRemoveAfterStep;
  116225. BJSCANNON: any;
  116226. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  116227. setGravity(gravity: Vector3): void;
  116228. setTimeStep(timeStep: number): void;
  116229. getTimeStep(): number;
  116230. executeStep(delta: number): void;
  116231. private _removeMarkedPhysicsBodiesFromWorld;
  116232. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116233. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116234. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116235. private _processChildMeshes;
  116236. removePhysicsBody(impostor: PhysicsImpostor): void;
  116237. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116238. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116239. private _addMaterial;
  116240. private _checkWithEpsilon;
  116241. private _createShape;
  116242. private _createHeightmap;
  116243. private _minus90X;
  116244. private _plus90X;
  116245. private _tmpPosition;
  116246. private _tmpDeltaPosition;
  116247. private _tmpUnityRotation;
  116248. private _updatePhysicsBodyTransformation;
  116249. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116250. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116251. isSupported(): boolean;
  116252. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116253. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116254. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116255. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116256. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116257. getBodyMass(impostor: PhysicsImpostor): number;
  116258. getBodyFriction(impostor: PhysicsImpostor): number;
  116259. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116260. getBodyRestitution(impostor: PhysicsImpostor): number;
  116261. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116262. sleepBody(impostor: PhysicsImpostor): void;
  116263. wakeUpBody(impostor: PhysicsImpostor): void;
  116264. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  116265. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116266. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116267. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116268. getRadius(impostor: PhysicsImpostor): number;
  116269. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116270. dispose(): void;
  116271. private _extendNamespace;
  116272. /**
  116273. * Does a raycast in the physics world
  116274. * @param from when should the ray start?
  116275. * @param to when should the ray end?
  116276. * @returns PhysicsRaycastResult
  116277. */
  116278. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116279. }
  116280. }
  116281. declare module BABYLON {
  116282. /** @hidden */
  116283. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  116284. world: any;
  116285. name: string;
  116286. BJSOIMO: any;
  116287. private _raycastResult;
  116288. constructor(iterations?: number, oimoInjection?: any);
  116289. setGravity(gravity: Vector3): void;
  116290. setTimeStep(timeStep: number): void;
  116291. getTimeStep(): number;
  116292. private _tmpImpostorsArray;
  116293. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116294. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116295. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116296. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116297. private _tmpPositionVector;
  116298. removePhysicsBody(impostor: PhysicsImpostor): void;
  116299. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116300. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116301. isSupported(): boolean;
  116302. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116303. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116304. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116305. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116306. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116307. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116308. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116309. getBodyMass(impostor: PhysicsImpostor): number;
  116310. getBodyFriction(impostor: PhysicsImpostor): number;
  116311. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116312. getBodyRestitution(impostor: PhysicsImpostor): number;
  116313. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116314. sleepBody(impostor: PhysicsImpostor): void;
  116315. wakeUpBody(impostor: PhysicsImpostor): void;
  116316. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116317. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  116318. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116319. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116320. getRadius(impostor: PhysicsImpostor): number;
  116321. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116322. dispose(): void;
  116323. /**
  116324. * Does a raycast in the physics world
  116325. * @param from when should the ray start?
  116326. * @param to when should the ray end?
  116327. * @returns PhysicsRaycastResult
  116328. */
  116329. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116330. }
  116331. }
  116332. declare module BABYLON {
  116333. /**
  116334. * Class containing static functions to help procedurally build meshes
  116335. */
  116336. export class RibbonBuilder {
  116337. /**
  116338. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116339. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116340. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116341. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116342. * * 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
  116343. * * 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
  116344. * * 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
  116345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116347. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116348. * * 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
  116349. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116350. * * 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
  116351. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116353. * @param name defines the name of the mesh
  116354. * @param options defines the options used to create the mesh
  116355. * @param scene defines the hosting scene
  116356. * @returns the ribbon mesh
  116357. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116358. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116359. */
  116360. static CreateRibbon(name: string, options: {
  116361. pathArray: Vector3[][];
  116362. closeArray?: boolean;
  116363. closePath?: boolean;
  116364. offset?: number;
  116365. updatable?: boolean;
  116366. sideOrientation?: number;
  116367. frontUVs?: Vector4;
  116368. backUVs?: Vector4;
  116369. instance?: Mesh;
  116370. invertUV?: boolean;
  116371. uvs?: Vector2[];
  116372. colors?: Color4[];
  116373. }, scene?: Nullable<Scene>): Mesh;
  116374. }
  116375. }
  116376. declare module BABYLON {
  116377. /**
  116378. * Class containing static functions to help procedurally build meshes
  116379. */
  116380. export class ShapeBuilder {
  116381. /**
  116382. * 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.
  116383. * * 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.
  116384. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116385. * * 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.
  116386. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116387. * * 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
  116388. * * 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
  116389. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116391. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116392. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116394. * @param name defines the name of the mesh
  116395. * @param options defines the options used to create the mesh
  116396. * @param scene defines the hosting scene
  116397. * @returns the extruded shape mesh
  116398. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116399. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116400. */
  116401. static ExtrudeShape(name: string, options: {
  116402. shape: Vector3[];
  116403. path: Vector3[];
  116404. scale?: number;
  116405. rotation?: number;
  116406. cap?: number;
  116407. updatable?: boolean;
  116408. sideOrientation?: number;
  116409. frontUVs?: Vector4;
  116410. backUVs?: Vector4;
  116411. instance?: Mesh;
  116412. invertUV?: boolean;
  116413. }, scene?: Nullable<Scene>): Mesh;
  116414. /**
  116415. * Creates an custom extruded shape mesh.
  116416. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116417. * * 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.
  116418. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116419. * * 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
  116420. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116421. * * 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
  116422. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116423. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116424. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116425. * * 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
  116426. * * 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
  116427. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116428. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116429. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116430. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116432. * @param name defines the name of the mesh
  116433. * @param options defines the options used to create the mesh
  116434. * @param scene defines the hosting scene
  116435. * @returns the custom extruded shape mesh
  116436. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116437. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116438. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116439. */
  116440. static ExtrudeShapeCustom(name: string, options: {
  116441. shape: Vector3[];
  116442. path: Vector3[];
  116443. scaleFunction?: any;
  116444. rotationFunction?: any;
  116445. ribbonCloseArray?: boolean;
  116446. ribbonClosePath?: boolean;
  116447. cap?: number;
  116448. updatable?: boolean;
  116449. sideOrientation?: number;
  116450. frontUVs?: Vector4;
  116451. backUVs?: Vector4;
  116452. instance?: Mesh;
  116453. invertUV?: boolean;
  116454. }, scene?: Nullable<Scene>): Mesh;
  116455. private static _ExtrudeShapeGeneric;
  116456. }
  116457. }
  116458. declare module BABYLON {
  116459. /**
  116460. * AmmoJS Physics plugin
  116461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116462. * @see https://github.com/kripken/ammo.js/
  116463. */
  116464. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  116465. private _useDeltaForWorldStep;
  116466. /**
  116467. * Reference to the Ammo library
  116468. */
  116469. bjsAMMO: any;
  116470. /**
  116471. * Created ammoJS world which physics bodies are added to
  116472. */
  116473. world: any;
  116474. /**
  116475. * Name of the plugin
  116476. */
  116477. name: string;
  116478. private _timeStep;
  116479. private _fixedTimeStep;
  116480. private _maxSteps;
  116481. private _tmpQuaternion;
  116482. private _tmpAmmoTransform;
  116483. private _tmpAmmoQuaternion;
  116484. private _tmpAmmoConcreteContactResultCallback;
  116485. private _collisionConfiguration;
  116486. private _dispatcher;
  116487. private _overlappingPairCache;
  116488. private _solver;
  116489. private _softBodySolver;
  116490. private _tmpAmmoVectorA;
  116491. private _tmpAmmoVectorB;
  116492. private _tmpAmmoVectorC;
  116493. private _tmpAmmoVectorD;
  116494. private _tmpContactCallbackResult;
  116495. private _tmpAmmoVectorRCA;
  116496. private _tmpAmmoVectorRCB;
  116497. private _raycastResult;
  116498. private static readonly DISABLE_COLLISION_FLAG;
  116499. private static readonly KINEMATIC_FLAG;
  116500. private static readonly DISABLE_DEACTIVATION_FLAG;
  116501. /**
  116502. * Initializes the ammoJS plugin
  116503. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  116504. * @param ammoInjection can be used to inject your own ammo reference
  116505. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  116506. */
  116507. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  116508. /**
  116509. * Sets the gravity of the physics world (m/(s^2))
  116510. * @param gravity Gravity to set
  116511. */
  116512. setGravity(gravity: Vector3): void;
  116513. /**
  116514. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  116515. * @param timeStep timestep to use in seconds
  116516. */
  116517. setTimeStep(timeStep: number): void;
  116518. /**
  116519. * 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)
  116520. * @param fixedTimeStep fixedTimeStep to use in seconds
  116521. */
  116522. setFixedTimeStep(fixedTimeStep: number): void;
  116523. /**
  116524. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  116525. * @param maxSteps the maximum number of steps by the physics engine per frame
  116526. */
  116527. setMaxSteps(maxSteps: number): void;
  116528. /**
  116529. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  116530. * @returns the current timestep in seconds
  116531. */
  116532. getTimeStep(): number;
  116533. private _isImpostorInContact;
  116534. private _isImpostorPairInContact;
  116535. private _stepSimulation;
  116536. /**
  116537. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  116538. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  116539. * After the step the babylon meshes are set to the position of the physics imposters
  116540. * @param delta amount of time to step forward
  116541. * @param impostors array of imposters to update before/after the step
  116542. */
  116543. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116544. /**
  116545. * Update babylon mesh to match physics world object
  116546. * @param impostor imposter to match
  116547. */
  116548. private _afterSoftStep;
  116549. /**
  116550. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116551. * @param impostor imposter to match
  116552. */
  116553. private _ropeStep;
  116554. /**
  116555. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116556. * @param impostor imposter to match
  116557. */
  116558. private _softbodyOrClothStep;
  116559. private _tmpVector;
  116560. private _tmpMatrix;
  116561. /**
  116562. * Applies an impulse on the imposter
  116563. * @param impostor imposter to apply impulse to
  116564. * @param force amount of force to be applied to the imposter
  116565. * @param contactPoint the location to apply the impulse on the imposter
  116566. */
  116567. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116568. /**
  116569. * Applies a force on the imposter
  116570. * @param impostor imposter to apply force
  116571. * @param force amount of force to be applied to the imposter
  116572. * @param contactPoint the location to apply the force on the imposter
  116573. */
  116574. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116575. /**
  116576. * Creates a physics body using the plugin
  116577. * @param impostor the imposter to create the physics body on
  116578. */
  116579. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116580. /**
  116581. * Removes the physics body from the imposter and disposes of the body's memory
  116582. * @param impostor imposter to remove the physics body from
  116583. */
  116584. removePhysicsBody(impostor: PhysicsImpostor): void;
  116585. /**
  116586. * Generates a joint
  116587. * @param impostorJoint the imposter joint to create the joint with
  116588. */
  116589. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116590. /**
  116591. * Removes a joint
  116592. * @param impostorJoint the imposter joint to remove the joint from
  116593. */
  116594. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116595. private _addMeshVerts;
  116596. /**
  116597. * Initialise the soft body vertices to match its object's (mesh) vertices
  116598. * Softbody vertices (nodes) are in world space and to match this
  116599. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  116600. * @param impostor to create the softbody for
  116601. */
  116602. private _softVertexData;
  116603. /**
  116604. * Create an impostor's soft body
  116605. * @param impostor to create the softbody for
  116606. */
  116607. private _createSoftbody;
  116608. /**
  116609. * Create cloth for an impostor
  116610. * @param impostor to create the softbody for
  116611. */
  116612. private _createCloth;
  116613. /**
  116614. * Create rope for an impostor
  116615. * @param impostor to create the softbody for
  116616. */
  116617. private _createRope;
  116618. private _addHullVerts;
  116619. private _createShape;
  116620. /**
  116621. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  116622. * @param impostor imposter containing the physics body and babylon object
  116623. */
  116624. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116625. /**
  116626. * Sets the babylon object's position/rotation from the physics body's position/rotation
  116627. * @param impostor imposter containing the physics body and babylon object
  116628. * @param newPosition new position
  116629. * @param newRotation new rotation
  116630. */
  116631. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116632. /**
  116633. * If this plugin is supported
  116634. * @returns true if its supported
  116635. */
  116636. isSupported(): boolean;
  116637. /**
  116638. * Sets the linear velocity of the physics body
  116639. * @param impostor imposter to set the velocity on
  116640. * @param velocity velocity to set
  116641. */
  116642. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116643. /**
  116644. * Sets the angular velocity of the physics body
  116645. * @param impostor imposter to set the velocity on
  116646. * @param velocity velocity to set
  116647. */
  116648. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116649. /**
  116650. * gets the linear velocity
  116651. * @param impostor imposter to get linear velocity from
  116652. * @returns linear velocity
  116653. */
  116654. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116655. /**
  116656. * gets the angular velocity
  116657. * @param impostor imposter to get angular velocity from
  116658. * @returns angular velocity
  116659. */
  116660. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116661. /**
  116662. * Sets the mass of physics body
  116663. * @param impostor imposter to set the mass on
  116664. * @param mass mass to set
  116665. */
  116666. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116667. /**
  116668. * Gets the mass of the physics body
  116669. * @param impostor imposter to get the mass from
  116670. * @returns mass
  116671. */
  116672. getBodyMass(impostor: PhysicsImpostor): number;
  116673. /**
  116674. * Gets friction of the impostor
  116675. * @param impostor impostor to get friction from
  116676. * @returns friction value
  116677. */
  116678. getBodyFriction(impostor: PhysicsImpostor): number;
  116679. /**
  116680. * Sets friction of the impostor
  116681. * @param impostor impostor to set friction on
  116682. * @param friction friction value
  116683. */
  116684. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116685. /**
  116686. * Gets restitution of the impostor
  116687. * @param impostor impostor to get restitution from
  116688. * @returns restitution value
  116689. */
  116690. getBodyRestitution(impostor: PhysicsImpostor): number;
  116691. /**
  116692. * Sets resitution of the impostor
  116693. * @param impostor impostor to set resitution on
  116694. * @param restitution resitution value
  116695. */
  116696. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116697. /**
  116698. * Gets pressure inside the impostor
  116699. * @param impostor impostor to get pressure from
  116700. * @returns pressure value
  116701. */
  116702. getBodyPressure(impostor: PhysicsImpostor): number;
  116703. /**
  116704. * Sets pressure inside a soft body impostor
  116705. * Cloth and rope must remain 0 pressure
  116706. * @param impostor impostor to set pressure on
  116707. * @param pressure pressure value
  116708. */
  116709. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  116710. /**
  116711. * Gets stiffness of the impostor
  116712. * @param impostor impostor to get stiffness from
  116713. * @returns pressure value
  116714. */
  116715. getBodyStiffness(impostor: PhysicsImpostor): number;
  116716. /**
  116717. * Sets stiffness of the impostor
  116718. * @param impostor impostor to set stiffness on
  116719. * @param stiffness stiffness value from 0 to 1
  116720. */
  116721. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  116722. /**
  116723. * Gets velocityIterations of the impostor
  116724. * @param impostor impostor to get velocity iterations from
  116725. * @returns velocityIterations value
  116726. */
  116727. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  116728. /**
  116729. * Sets velocityIterations of the impostor
  116730. * @param impostor impostor to set velocity iterations on
  116731. * @param velocityIterations velocityIterations value
  116732. */
  116733. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  116734. /**
  116735. * Gets positionIterations of the impostor
  116736. * @param impostor impostor to get position iterations from
  116737. * @returns positionIterations value
  116738. */
  116739. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  116740. /**
  116741. * Sets positionIterations of the impostor
  116742. * @param impostor impostor to set position on
  116743. * @param positionIterations positionIterations value
  116744. */
  116745. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  116746. /**
  116747. * Append an anchor to a cloth object
  116748. * @param impostor is the cloth impostor to add anchor to
  116749. * @param otherImpostor is the rigid impostor to anchor to
  116750. * @param width ratio across width from 0 to 1
  116751. * @param height ratio up height from 0 to 1
  116752. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  116753. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116754. */
  116755. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116756. /**
  116757. * Append an hook to a rope object
  116758. * @param impostor is the rope impostor to add hook to
  116759. * @param otherImpostor is the rigid impostor to hook to
  116760. * @param length ratio along the rope from 0 to 1
  116761. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  116762. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116763. */
  116764. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116765. /**
  116766. * Sleeps the physics body and stops it from being active
  116767. * @param impostor impostor to sleep
  116768. */
  116769. sleepBody(impostor: PhysicsImpostor): void;
  116770. /**
  116771. * Activates the physics body
  116772. * @param impostor impostor to activate
  116773. */
  116774. wakeUpBody(impostor: PhysicsImpostor): void;
  116775. /**
  116776. * Updates the distance parameters of the joint
  116777. * @param joint joint to update
  116778. * @param maxDistance maximum distance of the joint
  116779. * @param minDistance minimum distance of the joint
  116780. */
  116781. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116782. /**
  116783. * Sets a motor on the joint
  116784. * @param joint joint to set motor on
  116785. * @param speed speed of the motor
  116786. * @param maxForce maximum force of the motor
  116787. * @param motorIndex index of the motor
  116788. */
  116789. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116790. /**
  116791. * Sets the motors limit
  116792. * @param joint joint to set limit on
  116793. * @param upperLimit upper limit
  116794. * @param lowerLimit lower limit
  116795. */
  116796. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116797. /**
  116798. * Syncs the position and rotation of a mesh with the impostor
  116799. * @param mesh mesh to sync
  116800. * @param impostor impostor to update the mesh with
  116801. */
  116802. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116803. /**
  116804. * Gets the radius of the impostor
  116805. * @param impostor impostor to get radius from
  116806. * @returns the radius
  116807. */
  116808. getRadius(impostor: PhysicsImpostor): number;
  116809. /**
  116810. * Gets the box size of the impostor
  116811. * @param impostor impostor to get box size from
  116812. * @param result the resulting box size
  116813. */
  116814. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116815. /**
  116816. * Disposes of the impostor
  116817. */
  116818. dispose(): void;
  116819. /**
  116820. * Does a raycast in the physics world
  116821. * @param from when should the ray start?
  116822. * @param to when should the ray end?
  116823. * @returns PhysicsRaycastResult
  116824. */
  116825. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116826. }
  116827. }
  116828. declare module BABYLON {
  116829. interface AbstractScene {
  116830. /**
  116831. * The list of reflection probes added to the scene
  116832. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116833. */
  116834. reflectionProbes: Array<ReflectionProbe>;
  116835. /**
  116836. * Removes the given reflection probe from this scene.
  116837. * @param toRemove The reflection probe to remove
  116838. * @returns The index of the removed reflection probe
  116839. */
  116840. removeReflectionProbe(toRemove: ReflectionProbe): number;
  116841. /**
  116842. * Adds the given reflection probe to this scene.
  116843. * @param newReflectionProbe The reflection probe to add
  116844. */
  116845. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  116846. }
  116847. /**
  116848. * Class used to generate realtime reflection / refraction cube textures
  116849. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116850. */
  116851. export class ReflectionProbe {
  116852. /** defines the name of the probe */
  116853. name: string;
  116854. private _scene;
  116855. private _renderTargetTexture;
  116856. private _projectionMatrix;
  116857. private _viewMatrix;
  116858. private _target;
  116859. private _add;
  116860. private _attachedMesh;
  116861. private _invertYAxis;
  116862. /** Gets or sets probe position (center of the cube map) */
  116863. position: Vector3;
  116864. /**
  116865. * Creates a new reflection probe
  116866. * @param name defines the name of the probe
  116867. * @param size defines the texture resolution (for each face)
  116868. * @param scene defines the hosting scene
  116869. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  116870. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  116871. */
  116872. constructor(
  116873. /** defines the name of the probe */
  116874. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  116875. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  116876. samples: number;
  116877. /** Gets or sets the refresh rate to use (on every frame by default) */
  116878. refreshRate: number;
  116879. /**
  116880. * Gets the hosting scene
  116881. * @returns a Scene
  116882. */
  116883. getScene(): Scene;
  116884. /** Gets the internal CubeTexture used to render to */
  116885. readonly cubeTexture: RenderTargetTexture;
  116886. /** Gets the list of meshes to render */
  116887. readonly renderList: Nullable<AbstractMesh[]>;
  116888. /**
  116889. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  116890. * @param mesh defines the mesh to attach to
  116891. */
  116892. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  116893. /**
  116894. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  116895. * @param renderingGroupId The rendering group id corresponding to its index
  116896. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  116897. */
  116898. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  116899. /**
  116900. * Clean all associated resources
  116901. */
  116902. dispose(): void;
  116903. /**
  116904. * Converts the reflection probe information to a readable string for debug purpose.
  116905. * @param fullDetails Supports for multiple levels of logging within scene loading
  116906. * @returns the human readable reflection probe info
  116907. */
  116908. toString(fullDetails?: boolean): string;
  116909. /**
  116910. * Get the class name of the relfection probe.
  116911. * @returns "ReflectionProbe"
  116912. */
  116913. getClassName(): string;
  116914. /**
  116915. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  116916. * @returns The JSON representation of the texture
  116917. */
  116918. serialize(): any;
  116919. /**
  116920. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  116921. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  116922. * @param scene Define the scene the parsed reflection probe should be instantiated in
  116923. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  116924. * @returns The parsed reflection probe if successful
  116925. */
  116926. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  116927. }
  116928. }
  116929. declare module BABYLON {
  116930. /** @hidden */
  116931. export var _BabylonLoaderRegistered: boolean;
  116932. }
  116933. declare module BABYLON {
  116934. /**
  116935. * The Physically based simple base material of BJS.
  116936. *
  116937. * This enables better naming and convention enforcements on top of the pbrMaterial.
  116938. * It is used as the base class for both the specGloss and metalRough conventions.
  116939. */
  116940. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  116941. /**
  116942. * Number of Simultaneous lights allowed on the material.
  116943. */
  116944. maxSimultaneousLights: number;
  116945. /**
  116946. * If sets to true, disables all the lights affecting the material.
  116947. */
  116948. disableLighting: boolean;
  116949. /**
  116950. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  116951. */
  116952. environmentTexture: BaseTexture;
  116953. /**
  116954. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116955. */
  116956. invertNormalMapX: boolean;
  116957. /**
  116958. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116959. */
  116960. invertNormalMapY: boolean;
  116961. /**
  116962. * Normal map used in the model.
  116963. */
  116964. normalTexture: BaseTexture;
  116965. /**
  116966. * Emissivie color used to self-illuminate the model.
  116967. */
  116968. emissiveColor: Color3;
  116969. /**
  116970. * Emissivie texture used to self-illuminate the model.
  116971. */
  116972. emissiveTexture: BaseTexture;
  116973. /**
  116974. * Occlusion Channel Strenght.
  116975. */
  116976. occlusionStrength: number;
  116977. /**
  116978. * Occlusion Texture of the material (adding extra occlusion effects).
  116979. */
  116980. occlusionTexture: BaseTexture;
  116981. /**
  116982. * Defines the alpha limits in alpha test mode.
  116983. */
  116984. alphaCutOff: number;
  116985. /**
  116986. * Gets the current double sided mode.
  116987. */
  116988. /**
  116989. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116990. */
  116991. doubleSided: boolean;
  116992. /**
  116993. * Stores the pre-calculated light information of a mesh in a texture.
  116994. */
  116995. lightmapTexture: BaseTexture;
  116996. /**
  116997. * If true, the light map contains occlusion information instead of lighting info.
  116998. */
  116999. useLightmapAsShadowmap: boolean;
  117000. /**
  117001. * Instantiates a new PBRMaterial instance.
  117002. *
  117003. * @param name The material name
  117004. * @param scene The scene the material will be use in.
  117005. */
  117006. constructor(name: string, scene: Scene);
  117007. getClassName(): string;
  117008. }
  117009. }
  117010. declare module BABYLON {
  117011. /**
  117012. * The PBR material of BJS following the metal roughness convention.
  117013. *
  117014. * This fits to the PBR convention in the GLTF definition:
  117015. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  117016. */
  117017. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  117018. /**
  117019. * The base color has two different interpretations depending on the value of metalness.
  117020. * When the material is a metal, the base color is the specific measured reflectance value
  117021. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  117022. * of the material.
  117023. */
  117024. baseColor: Color3;
  117025. /**
  117026. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  117027. * well as opacity information in the alpha channel.
  117028. */
  117029. baseTexture: BaseTexture;
  117030. /**
  117031. * Specifies the metallic scalar value of the material.
  117032. * Can also be used to scale the metalness values of the metallic texture.
  117033. */
  117034. metallic: number;
  117035. /**
  117036. * Specifies the roughness scalar value of the material.
  117037. * Can also be used to scale the roughness values of the metallic texture.
  117038. */
  117039. roughness: number;
  117040. /**
  117041. * Texture containing both the metallic value in the B channel and the
  117042. * roughness value in the G channel to keep better precision.
  117043. */
  117044. metallicRoughnessTexture: BaseTexture;
  117045. /**
  117046. * Instantiates a new PBRMetalRoughnessMaterial instance.
  117047. *
  117048. * @param name The material name
  117049. * @param scene The scene the material will be use in.
  117050. */
  117051. constructor(name: string, scene: Scene);
  117052. /**
  117053. * Return the currrent class name of the material.
  117054. */
  117055. getClassName(): string;
  117056. /**
  117057. * Makes a duplicate of the current material.
  117058. * @param name - name to use for the new material.
  117059. */
  117060. clone(name: string): PBRMetallicRoughnessMaterial;
  117061. /**
  117062. * Serialize the material to a parsable JSON object.
  117063. */
  117064. serialize(): any;
  117065. /**
  117066. * Parses a JSON object correponding to the serialize function.
  117067. */
  117068. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  117069. }
  117070. }
  117071. declare module BABYLON {
  117072. /**
  117073. * The PBR material of BJS following the specular glossiness convention.
  117074. *
  117075. * This fits to the PBR convention in the GLTF definition:
  117076. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  117077. */
  117078. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  117079. /**
  117080. * Specifies the diffuse color of the material.
  117081. */
  117082. diffuseColor: Color3;
  117083. /**
  117084. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  117085. * channel.
  117086. */
  117087. diffuseTexture: BaseTexture;
  117088. /**
  117089. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  117090. */
  117091. specularColor: Color3;
  117092. /**
  117093. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  117094. */
  117095. glossiness: number;
  117096. /**
  117097. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  117098. */
  117099. specularGlossinessTexture: BaseTexture;
  117100. /**
  117101. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  117102. *
  117103. * @param name The material name
  117104. * @param scene The scene the material will be use in.
  117105. */
  117106. constructor(name: string, scene: Scene);
  117107. /**
  117108. * Return the currrent class name of the material.
  117109. */
  117110. getClassName(): string;
  117111. /**
  117112. * Makes a duplicate of the current material.
  117113. * @param name - name to use for the new material.
  117114. */
  117115. clone(name: string): PBRSpecularGlossinessMaterial;
  117116. /**
  117117. * Serialize the material to a parsable JSON object.
  117118. */
  117119. serialize(): any;
  117120. /**
  117121. * Parses a JSON object correponding to the serialize function.
  117122. */
  117123. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  117124. }
  117125. }
  117126. declare module BABYLON {
  117127. /**
  117128. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  117129. * It can help converting any input color in a desired output one. This can then be used to create effects
  117130. * from sepia, black and white to sixties or futuristic rendering...
  117131. *
  117132. * The only supported format is currently 3dl.
  117133. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  117134. */
  117135. export class ColorGradingTexture extends BaseTexture {
  117136. /**
  117137. * The current texture matrix. (will always be identity in color grading texture)
  117138. */
  117139. private _textureMatrix;
  117140. /**
  117141. * The texture URL.
  117142. */
  117143. url: string;
  117144. /**
  117145. * Empty line regex stored for GC.
  117146. */
  117147. private static _noneEmptyLineRegex;
  117148. private _engine;
  117149. /**
  117150. * Instantiates a ColorGradingTexture from the following parameters.
  117151. *
  117152. * @param url The location of the color gradind data (currently only supporting 3dl)
  117153. * @param scene The scene the texture will be used in
  117154. */
  117155. constructor(url: string, scene: Scene);
  117156. /**
  117157. * Returns the texture matrix used in most of the material.
  117158. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  117159. */
  117160. getTextureMatrix(): Matrix;
  117161. /**
  117162. * Occurs when the file being loaded is a .3dl LUT file.
  117163. */
  117164. private load3dlTexture;
  117165. /**
  117166. * Starts the loading process of the texture.
  117167. */
  117168. private loadTexture;
  117169. /**
  117170. * Clones the color gradind texture.
  117171. */
  117172. clone(): ColorGradingTexture;
  117173. /**
  117174. * Called during delayed load for textures.
  117175. */
  117176. delayLoad(): void;
  117177. /**
  117178. * Parses a color grading texture serialized by Babylon.
  117179. * @param parsedTexture The texture information being parsedTexture
  117180. * @param scene The scene to load the texture in
  117181. * @param rootUrl The root url of the data assets to load
  117182. * @return A color gradind texture
  117183. */
  117184. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  117185. /**
  117186. * Serializes the LUT texture to json format.
  117187. */
  117188. serialize(): any;
  117189. }
  117190. }
  117191. declare module BABYLON {
  117192. /**
  117193. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  117194. */
  117195. export class EquiRectangularCubeTexture extends BaseTexture {
  117196. /** The six faces of the cube. */
  117197. private static _FacesMapping;
  117198. private _noMipmap;
  117199. private _onLoad;
  117200. private _onError;
  117201. /** The size of the cubemap. */
  117202. private _size;
  117203. /** The buffer of the image. */
  117204. private _buffer;
  117205. /** The width of the input image. */
  117206. private _width;
  117207. /** The height of the input image. */
  117208. private _height;
  117209. /** The URL to the image. */
  117210. url: string;
  117211. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  117212. coordinatesMode: number;
  117213. /**
  117214. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  117215. * @param url The location of the image
  117216. * @param scene The scene the texture will be used in
  117217. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117218. * @param noMipmap Forces to not generate the mipmap if true
  117219. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  117220. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  117221. * @param onLoad — defines a callback called when texture is loaded
  117222. * @param onError — defines a callback called if there is an error
  117223. */
  117224. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  117225. /**
  117226. * Load the image data, by putting the image on a canvas and extracting its buffer.
  117227. */
  117228. private loadImage;
  117229. /**
  117230. * Convert the image buffer into a cubemap and create a CubeTexture.
  117231. */
  117232. private loadTexture;
  117233. /**
  117234. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  117235. * @param buffer The ArrayBuffer that should be converted.
  117236. * @returns The buffer as Float32Array.
  117237. */
  117238. private getFloat32ArrayFromArrayBuffer;
  117239. /**
  117240. * Get the current class name of the texture useful for serialization or dynamic coding.
  117241. * @returns "EquiRectangularCubeTexture"
  117242. */
  117243. getClassName(): string;
  117244. /**
  117245. * Create a clone of the current EquiRectangularCubeTexture and return it.
  117246. * @returns A clone of the current EquiRectangularCubeTexture.
  117247. */
  117248. clone(): EquiRectangularCubeTexture;
  117249. }
  117250. }
  117251. declare module BABYLON {
  117252. /**
  117253. * Based on jsTGALoader - Javascript loader for TGA file
  117254. * By Vincent Thibault
  117255. * @see http://blog.robrowser.com/javascript-tga-loader.html
  117256. */
  117257. export class TGATools {
  117258. private static _TYPE_INDEXED;
  117259. private static _TYPE_RGB;
  117260. private static _TYPE_GREY;
  117261. private static _TYPE_RLE_INDEXED;
  117262. private static _TYPE_RLE_RGB;
  117263. private static _TYPE_RLE_GREY;
  117264. private static _ORIGIN_MASK;
  117265. private static _ORIGIN_SHIFT;
  117266. private static _ORIGIN_BL;
  117267. private static _ORIGIN_BR;
  117268. private static _ORIGIN_UL;
  117269. private static _ORIGIN_UR;
  117270. /**
  117271. * Gets the header of a TGA file
  117272. * @param data defines the TGA data
  117273. * @returns the header
  117274. */
  117275. static GetTGAHeader(data: Uint8Array): any;
  117276. /**
  117277. * Uploads TGA content to a Babylon Texture
  117278. * @hidden
  117279. */
  117280. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  117281. /** @hidden */
  117282. 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;
  117283. /** @hidden */
  117284. 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;
  117285. /** @hidden */
  117286. 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;
  117287. /** @hidden */
  117288. 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;
  117289. /** @hidden */
  117290. 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;
  117291. /** @hidden */
  117292. 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;
  117293. }
  117294. }
  117295. declare module BABYLON {
  117296. /**
  117297. * Implementation of the TGA Texture Loader.
  117298. * @hidden
  117299. */
  117300. export class _TGATextureLoader implements IInternalTextureLoader {
  117301. /**
  117302. * Defines wether the loader supports cascade loading the different faces.
  117303. */
  117304. readonly supportCascades: boolean;
  117305. /**
  117306. * This returns if the loader support the current file information.
  117307. * @param extension defines the file extension of the file being loaded
  117308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117309. * @param fallback defines the fallback internal texture if any
  117310. * @param isBase64 defines whether the texture is encoded as a base64
  117311. * @param isBuffer defines whether the texture data are stored as a buffer
  117312. * @returns true if the loader can load the specified file
  117313. */
  117314. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117315. /**
  117316. * Transform the url before loading if required.
  117317. * @param rootUrl the url of the texture
  117318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117319. * @returns the transformed texture
  117320. */
  117321. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117322. /**
  117323. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117324. * @param rootUrl the url of the texture
  117325. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117326. * @returns the fallback texture
  117327. */
  117328. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117329. /**
  117330. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117331. * @param data contains the texture data
  117332. * @param texture defines the BabylonJS internal texture
  117333. * @param createPolynomials will be true if polynomials have been requested
  117334. * @param onLoad defines the callback to trigger once the texture is ready
  117335. * @param onError defines the callback to trigger in case of error
  117336. */
  117337. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117338. /**
  117339. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117340. * @param data contains the texture data
  117341. * @param texture defines the BabylonJS internal texture
  117342. * @param callback defines the method to call once ready to upload
  117343. */
  117344. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117345. }
  117346. }
  117347. declare module BABYLON {
  117348. /**
  117349. * Info about the .basis files
  117350. */
  117351. class BasisFileInfo {
  117352. /**
  117353. * If the file has alpha
  117354. */
  117355. hasAlpha: boolean;
  117356. /**
  117357. * Info about each image of the basis file
  117358. */
  117359. images: Array<{
  117360. levels: Array<{
  117361. width: number;
  117362. height: number;
  117363. transcodedPixels: ArrayBufferView;
  117364. }>;
  117365. }>;
  117366. }
  117367. /**
  117368. * Result of transcoding a basis file
  117369. */
  117370. class TranscodeResult {
  117371. /**
  117372. * Info about the .basis file
  117373. */
  117374. fileInfo: BasisFileInfo;
  117375. /**
  117376. * Format to use when loading the file
  117377. */
  117378. format: number;
  117379. }
  117380. /**
  117381. * Configuration options for the Basis transcoder
  117382. */
  117383. export class BasisTranscodeConfiguration {
  117384. /**
  117385. * Supported compression formats used to determine the supported output format of the transcoder
  117386. */
  117387. supportedCompressionFormats?: {
  117388. /**
  117389. * etc1 compression format
  117390. */
  117391. etc1?: boolean;
  117392. /**
  117393. * s3tc compression format
  117394. */
  117395. s3tc?: boolean;
  117396. /**
  117397. * pvrtc compression format
  117398. */
  117399. pvrtc?: boolean;
  117400. /**
  117401. * etc2 compression format
  117402. */
  117403. etc2?: boolean;
  117404. };
  117405. /**
  117406. * If mipmap levels should be loaded for transcoded images (Default: true)
  117407. */
  117408. loadMipmapLevels?: boolean;
  117409. /**
  117410. * Index of a single image to load (Default: all images)
  117411. */
  117412. loadSingleImage?: number;
  117413. }
  117414. /**
  117415. * Used to load .Basis files
  117416. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  117417. */
  117418. export class BasisTools {
  117419. private static _IgnoreSupportedFormats;
  117420. /**
  117421. * URL to use when loading the basis transcoder
  117422. */
  117423. static JSModuleURL: string;
  117424. /**
  117425. * URL to use when loading the wasm module for the transcoder
  117426. */
  117427. static WasmModuleURL: string;
  117428. /**
  117429. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  117430. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  117431. * @returns internal format corresponding to the Basis format
  117432. */
  117433. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  117434. private static _WorkerPromise;
  117435. private static _Worker;
  117436. private static _actionId;
  117437. private static _CreateWorkerAsync;
  117438. /**
  117439. * Transcodes a loaded image file to compressed pixel data
  117440. * @param imageData image data to transcode
  117441. * @param config configuration options for the transcoding
  117442. * @returns a promise resulting in the transcoded image
  117443. */
  117444. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  117445. /**
  117446. * Loads a texture from the transcode result
  117447. * @param texture texture load to
  117448. * @param transcodeResult the result of transcoding the basis file to load from
  117449. */
  117450. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  117451. }
  117452. }
  117453. declare module BABYLON {
  117454. /**
  117455. * Loader for .basis file format
  117456. */
  117457. export class _BasisTextureLoader implements IInternalTextureLoader {
  117458. /**
  117459. * Defines whether the loader supports cascade loading the different faces.
  117460. */
  117461. readonly supportCascades: boolean;
  117462. /**
  117463. * This returns if the loader support the current file information.
  117464. * @param extension defines the file extension of the file being loaded
  117465. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117466. * @param fallback defines the fallback internal texture if any
  117467. * @param isBase64 defines whether the texture is encoded as a base64
  117468. * @param isBuffer defines whether the texture data are stored as a buffer
  117469. * @returns true if the loader can load the specified file
  117470. */
  117471. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117472. /**
  117473. * Transform the url before loading if required.
  117474. * @param rootUrl the url of the texture
  117475. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117476. * @returns the transformed texture
  117477. */
  117478. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117479. /**
  117480. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117481. * @param rootUrl the url of the texture
  117482. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117483. * @returns the fallback texture
  117484. */
  117485. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117486. /**
  117487. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  117488. * @param data contains the texture data
  117489. * @param texture defines the BabylonJS internal texture
  117490. * @param createPolynomials will be true if polynomials have been requested
  117491. * @param onLoad defines the callback to trigger once the texture is ready
  117492. * @param onError defines the callback to trigger in case of error
  117493. */
  117494. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117495. /**
  117496. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117497. * @param data contains the texture data
  117498. * @param texture defines the BabylonJS internal texture
  117499. * @param callback defines the method to call once ready to upload
  117500. */
  117501. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117502. }
  117503. }
  117504. declare module BABYLON {
  117505. /**
  117506. * 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.
  117507. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117508. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117509. */
  117510. export class CustomProceduralTexture extends ProceduralTexture {
  117511. private _animate;
  117512. private _time;
  117513. private _config;
  117514. private _texturePath;
  117515. /**
  117516. * Instantiates a new Custom Procedural Texture.
  117517. * 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.
  117518. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117519. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117520. * @param name Define the name of the texture
  117521. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  117522. * @param size Define the size of the texture to create
  117523. * @param scene Define the scene the texture belongs to
  117524. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  117525. * @param generateMipMaps Define if the texture should creates mip maps or not
  117526. */
  117527. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117528. private _loadJson;
  117529. /**
  117530. * Is the texture ready to be used ? (rendered at least once)
  117531. * @returns true if ready, otherwise, false.
  117532. */
  117533. isReady(): boolean;
  117534. /**
  117535. * Render the texture to its associated render target.
  117536. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  117537. */
  117538. render(useCameraPostProcess?: boolean): void;
  117539. /**
  117540. * Update the list of dependant textures samplers in the shader.
  117541. */
  117542. updateTextures(): void;
  117543. /**
  117544. * Update the uniform values of the procedural texture in the shader.
  117545. */
  117546. updateShaderUniforms(): void;
  117547. /**
  117548. * Define if the texture animates or not.
  117549. */
  117550. animate: boolean;
  117551. }
  117552. }
  117553. declare module BABYLON {
  117554. /** @hidden */
  117555. export var noisePixelShader: {
  117556. name: string;
  117557. shader: string;
  117558. };
  117559. }
  117560. declare module BABYLON {
  117561. /**
  117562. * Class used to generate noise procedural textures
  117563. */
  117564. export class NoiseProceduralTexture extends ProceduralTexture {
  117565. private _time;
  117566. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  117567. brightness: number;
  117568. /** Defines the number of octaves to process */
  117569. octaves: number;
  117570. /** Defines the level of persistence (0.8 by default) */
  117571. persistence: number;
  117572. /** Gets or sets animation speed factor (default is 1) */
  117573. animationSpeedFactor: number;
  117574. /**
  117575. * Creates a new NoiseProceduralTexture
  117576. * @param name defines the name fo the texture
  117577. * @param size defines the size of the texture (default is 256)
  117578. * @param scene defines the hosting scene
  117579. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  117580. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  117581. */
  117582. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117583. private _updateShaderUniforms;
  117584. protected _getDefines(): string;
  117585. /** Generate the current state of the procedural texture */
  117586. render(useCameraPostProcess?: boolean): void;
  117587. /**
  117588. * Serializes this noise procedural texture
  117589. * @returns a serialized noise procedural texture object
  117590. */
  117591. serialize(): any;
  117592. /**
  117593. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  117594. * @param parsedTexture defines parsed texture data
  117595. * @param scene defines the current scene
  117596. * @param rootUrl defines the root URL containing noise procedural texture information
  117597. * @returns a parsed NoiseProceduralTexture
  117598. */
  117599. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  117600. }
  117601. }
  117602. declare module BABYLON {
  117603. /**
  117604. * Raw cube texture where the raw buffers are passed in
  117605. */
  117606. export class RawCubeTexture extends CubeTexture {
  117607. /**
  117608. * Creates a cube texture where the raw buffers are passed in.
  117609. * @param scene defines the scene the texture is attached to
  117610. * @param data defines the array of data to use to create each face
  117611. * @param size defines the size of the textures
  117612. * @param format defines the format of the data
  117613. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  117614. * @param generateMipMaps defines if the engine should generate the mip levels
  117615. * @param invertY defines if data must be stored with Y axis inverted
  117616. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  117617. * @param compression defines the compression used (null by default)
  117618. */
  117619. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  117620. /**
  117621. * Updates the raw cube texture.
  117622. * @param data defines the data to store
  117623. * @param format defines the data format
  117624. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  117625. * @param invertY defines if data must be stored with Y axis inverted
  117626. * @param compression defines the compression used (null by default)
  117627. * @param level defines which level of the texture to update
  117628. */
  117629. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  117630. /**
  117631. * Updates a raw cube texture with RGBD encoded data.
  117632. * @param data defines the array of data [mipmap][face] to use to create each face
  117633. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  117634. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117635. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117636. * @returns a promsie that resolves when the operation is complete
  117637. */
  117638. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  117639. /**
  117640. * Clones the raw cube texture.
  117641. * @return a new cube texture
  117642. */
  117643. clone(): CubeTexture;
  117644. /** @hidden */
  117645. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117646. }
  117647. }
  117648. declare module BABYLON {
  117649. /**
  117650. * Class used to store 3D textures containing user data
  117651. */
  117652. export class RawTexture3D extends Texture {
  117653. /** Gets or sets the texture format to use */
  117654. format: number;
  117655. private _engine;
  117656. /**
  117657. * Create a new RawTexture3D
  117658. * @param data defines the data of the texture
  117659. * @param width defines the width of the texture
  117660. * @param height defines the height of the texture
  117661. * @param depth defines the depth of the texture
  117662. * @param format defines the texture format to use
  117663. * @param scene defines the hosting scene
  117664. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  117665. * @param invertY defines if texture must be stored with Y axis inverted
  117666. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  117667. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  117668. */
  117669. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  117670. /** Gets or sets the texture format to use */
  117671. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  117672. /**
  117673. * Update the texture with new data
  117674. * @param data defines the data to store in the texture
  117675. */
  117676. update(data: ArrayBufferView): void;
  117677. }
  117678. }
  117679. declare module BABYLON {
  117680. /**
  117681. * Creates a refraction texture used by refraction channel of the standard material.
  117682. * It is like a mirror but to see through a material.
  117683. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117684. */
  117685. export class RefractionTexture extends RenderTargetTexture {
  117686. /**
  117687. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  117688. * 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.
  117689. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117690. */
  117691. refractionPlane: Plane;
  117692. /**
  117693. * Define how deep under the surface we should see.
  117694. */
  117695. depth: number;
  117696. /**
  117697. * Creates a refraction texture used by refraction channel of the standard material.
  117698. * It is like a mirror but to see through a material.
  117699. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117700. * @param name Define the texture name
  117701. * @param size Define the size of the underlying texture
  117702. * @param scene Define the scene the refraction belongs to
  117703. * @param generateMipMaps Define if we need to generate mips level for the refraction
  117704. */
  117705. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  117706. /**
  117707. * Clone the refraction texture.
  117708. * @returns the cloned texture
  117709. */
  117710. clone(): RefractionTexture;
  117711. /**
  117712. * Serialize the texture to a JSON representation you could use in Parse later on
  117713. * @returns the serialized JSON representation
  117714. */
  117715. serialize(): any;
  117716. }
  117717. }
  117718. declare module BABYLON {
  117719. /**
  117720. * Defines the options related to the creation of an HtmlElementTexture
  117721. */
  117722. export interface IHtmlElementTextureOptions {
  117723. /**
  117724. * Defines wether mip maps should be created or not.
  117725. */
  117726. generateMipMaps?: boolean;
  117727. /**
  117728. * Defines the sampling mode of the texture.
  117729. */
  117730. samplingMode?: number;
  117731. /**
  117732. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  117733. */
  117734. engine: Nullable<Engine>;
  117735. /**
  117736. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  117737. */
  117738. scene: Nullable<Scene>;
  117739. }
  117740. /**
  117741. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  117742. * To be as efficient as possible depending on your constraints nothing aside the first upload
  117743. * is automatically managed.
  117744. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  117745. * in your application.
  117746. *
  117747. * As the update is not automatic, you need to call them manually.
  117748. */
  117749. export class HtmlElementTexture extends BaseTexture {
  117750. /**
  117751. * The texture URL.
  117752. */
  117753. element: HTMLVideoElement | HTMLCanvasElement;
  117754. private static readonly DefaultOptions;
  117755. private _textureMatrix;
  117756. private _engine;
  117757. private _isVideo;
  117758. private _generateMipMaps;
  117759. private _samplingMode;
  117760. /**
  117761. * Instantiates a HtmlElementTexture from the following parameters.
  117762. *
  117763. * @param name Defines the name of the texture
  117764. * @param element Defines the video or canvas the texture is filled with
  117765. * @param options Defines the other none mandatory texture creation options
  117766. */
  117767. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  117768. private _createInternalTexture;
  117769. /**
  117770. * Returns the texture matrix used in most of the material.
  117771. */
  117772. getTextureMatrix(): Matrix;
  117773. /**
  117774. * Updates the content of the texture.
  117775. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  117776. */
  117777. update(invertY?: Nullable<boolean>): void;
  117778. }
  117779. }
  117780. declare module BABYLON {
  117781. /**
  117782. * Enum used to define the target of a block
  117783. */
  117784. export enum NodeMaterialBlockTargets {
  117785. /** Vertex shader */
  117786. Vertex = 1,
  117787. /** Fragment shader */
  117788. Fragment = 2,
  117789. /** Neutral */
  117790. Neutral = 4,
  117791. /** Vertex and Fragment */
  117792. VertexAndFragment = 3
  117793. }
  117794. }
  117795. declare module BABYLON {
  117796. /**
  117797. * Defines the kind of connection point for node based material
  117798. */
  117799. export enum NodeMaterialBlockConnectionPointTypes {
  117800. /** Float */
  117801. Float = 1,
  117802. /** Int */
  117803. Int = 2,
  117804. /** Vector2 */
  117805. Vector2 = 4,
  117806. /** Vector3 */
  117807. Vector3 = 8,
  117808. /** Vector4 */
  117809. Vector4 = 16,
  117810. /** Color3 */
  117811. Color3 = 32,
  117812. /** Color4 */
  117813. Color4 = 64,
  117814. /** Matrix */
  117815. Matrix = 128,
  117816. /** Detect type based on connection */
  117817. AutoDetect = 1024,
  117818. /** Output type that will be defined by input type */
  117819. BasedOnInput = 2048
  117820. }
  117821. }
  117822. declare module BABYLON {
  117823. /**
  117824. * Root class for all node material optimizers
  117825. */
  117826. export class NodeMaterialOptimizer {
  117827. /**
  117828. * Function used to optimize a NodeMaterial graph
  117829. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  117830. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  117831. */
  117832. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  117833. }
  117834. }
  117835. declare module BABYLON {
  117836. /**
  117837. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  117838. */
  117839. export class TransformBlock extends NodeMaterialBlock {
  117840. /**
  117841. * Defines the value to use to complement W value to transform it to a Vector4
  117842. */
  117843. complementW: number;
  117844. /**
  117845. * Defines the value to use to complement z value to transform it to a Vector4
  117846. */
  117847. complementZ: number;
  117848. /**
  117849. * Creates a new TransformBlock
  117850. * @param name defines the block name
  117851. */
  117852. constructor(name: string);
  117853. /**
  117854. * Gets the current class name
  117855. * @returns the class name
  117856. */
  117857. getClassName(): string;
  117858. /**
  117859. * Gets the vector input
  117860. */
  117861. readonly vector: NodeMaterialConnectionPoint;
  117862. /**
  117863. * Gets the output component
  117864. */
  117865. readonly output: NodeMaterialConnectionPoint;
  117866. /**
  117867. * Gets the matrix transform input
  117868. */
  117869. readonly transform: NodeMaterialConnectionPoint;
  117870. protected _buildBlock(state: NodeMaterialBuildState): this;
  117871. serialize(): any;
  117872. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117873. protected _dumpPropertiesCode(): string;
  117874. }
  117875. }
  117876. declare module BABYLON {
  117877. /**
  117878. * Block used to output the vertex position
  117879. */
  117880. export class VertexOutputBlock extends NodeMaterialBlock {
  117881. /**
  117882. * Creates a new VertexOutputBlock
  117883. * @param name defines the block name
  117884. */
  117885. constructor(name: string);
  117886. /**
  117887. * Gets the current class name
  117888. * @returns the class name
  117889. */
  117890. getClassName(): string;
  117891. /**
  117892. * Gets the vector input component
  117893. */
  117894. readonly vector: NodeMaterialConnectionPoint;
  117895. protected _buildBlock(state: NodeMaterialBuildState): this;
  117896. }
  117897. }
  117898. declare module BABYLON {
  117899. /**
  117900. * Block used to output the final color
  117901. */
  117902. export class FragmentOutputBlock extends NodeMaterialBlock {
  117903. /**
  117904. * Create a new FragmentOutputBlock
  117905. * @param name defines the block name
  117906. */
  117907. constructor(name: string);
  117908. /**
  117909. * Gets the current class name
  117910. * @returns the class name
  117911. */
  117912. getClassName(): string;
  117913. /**
  117914. * Gets the rgba input component
  117915. */
  117916. readonly rgba: NodeMaterialConnectionPoint;
  117917. /**
  117918. * Gets the rgb input component
  117919. */
  117920. readonly rgb: NodeMaterialConnectionPoint;
  117921. /**
  117922. * Gets the a input component
  117923. */
  117924. readonly a: NodeMaterialConnectionPoint;
  117925. protected _buildBlock(state: NodeMaterialBuildState): this;
  117926. }
  117927. }
  117928. declare module BABYLON {
  117929. /**
  117930. * Enum used to define system values e.g. values automatically provided by the system
  117931. */
  117932. export enum NodeMaterialSystemValues {
  117933. /** World */
  117934. World = 1,
  117935. /** View */
  117936. View = 2,
  117937. /** Projection */
  117938. Projection = 3,
  117939. /** ViewProjection */
  117940. ViewProjection = 4,
  117941. /** WorldView */
  117942. WorldView = 5,
  117943. /** WorldViewProjection */
  117944. WorldViewProjection = 6,
  117945. /** CameraPosition */
  117946. CameraPosition = 7,
  117947. /** Fog Color */
  117948. FogColor = 8
  117949. }
  117950. }
  117951. declare module BABYLON {
  117952. /**
  117953. * Block used to read a reflection texture from a sampler
  117954. */
  117955. export class ReflectionTextureBlock extends NodeMaterialBlock {
  117956. private _define3DName;
  117957. private _defineCubicName;
  117958. private _defineExplicitName;
  117959. private _defineProjectionName;
  117960. private _defineLocalCubicName;
  117961. private _defineSphericalName;
  117962. private _definePlanarName;
  117963. private _defineEquirectangularName;
  117964. private _defineMirroredEquirectangularFixedName;
  117965. private _defineEquirectangularFixedName;
  117966. private _defineSkyboxName;
  117967. private _cubeSamplerName;
  117968. private _2DSamplerName;
  117969. private _positionUVWName;
  117970. private _directionWName;
  117971. private _reflectionCoordsName;
  117972. private _reflection2DCoordsName;
  117973. private _reflectionColorName;
  117974. private _reflectionMatrixName;
  117975. /**
  117976. * Gets or sets the texture associated with the node
  117977. */
  117978. texture: Nullable<BaseTexture>;
  117979. /**
  117980. * Create a new TextureBlock
  117981. * @param name defines the block name
  117982. */
  117983. constructor(name: string);
  117984. /**
  117985. * Gets the current class name
  117986. * @returns the class name
  117987. */
  117988. getClassName(): string;
  117989. /**
  117990. * Gets the world position input component
  117991. */
  117992. readonly position: NodeMaterialConnectionPoint;
  117993. /**
  117994. * Gets the world position input component
  117995. */
  117996. readonly worldPosition: NodeMaterialConnectionPoint;
  117997. /**
  117998. * Gets the world normal input component
  117999. */
  118000. readonly worldNormal: NodeMaterialConnectionPoint;
  118001. /**
  118002. * Gets the world input component
  118003. */
  118004. readonly world: NodeMaterialConnectionPoint;
  118005. /**
  118006. * Gets the camera (or eye) position component
  118007. */
  118008. readonly cameraPosition: NodeMaterialConnectionPoint;
  118009. /**
  118010. * Gets the view input component
  118011. */
  118012. readonly view: NodeMaterialConnectionPoint;
  118013. /**
  118014. * Gets the rgb output component
  118015. */
  118016. readonly rgb: NodeMaterialConnectionPoint;
  118017. /**
  118018. * Gets the r output component
  118019. */
  118020. readonly r: NodeMaterialConnectionPoint;
  118021. /**
  118022. * Gets the g output component
  118023. */
  118024. readonly g: NodeMaterialConnectionPoint;
  118025. /**
  118026. * Gets the b output component
  118027. */
  118028. readonly b: NodeMaterialConnectionPoint;
  118029. autoConfigure(material: NodeMaterial): void;
  118030. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118031. isReady(): boolean;
  118032. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118033. private _injectVertexCode;
  118034. private _writeOutput;
  118035. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118036. serialize(): any;
  118037. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118038. }
  118039. }
  118040. declare module BABYLON {
  118041. /**
  118042. * Interface used to configure the node material editor
  118043. */
  118044. export interface INodeMaterialEditorOptions {
  118045. /** Define the URl to load node editor script */
  118046. editorURL?: string;
  118047. }
  118048. /** @hidden */
  118049. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  118050. /** BONES */
  118051. NUM_BONE_INFLUENCERS: number;
  118052. BonesPerMesh: number;
  118053. BONETEXTURE: boolean;
  118054. /** MORPH TARGETS */
  118055. MORPHTARGETS: boolean;
  118056. MORPHTARGETS_NORMAL: boolean;
  118057. MORPHTARGETS_TANGENT: boolean;
  118058. MORPHTARGETS_UV: boolean;
  118059. NUM_MORPH_INFLUENCERS: number;
  118060. /** IMAGE PROCESSING */
  118061. IMAGEPROCESSING: boolean;
  118062. VIGNETTE: boolean;
  118063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  118064. VIGNETTEBLENDMODEOPAQUE: boolean;
  118065. TONEMAPPING: boolean;
  118066. TONEMAPPING_ACES: boolean;
  118067. CONTRAST: boolean;
  118068. EXPOSURE: boolean;
  118069. COLORCURVES: boolean;
  118070. COLORGRADING: boolean;
  118071. COLORGRADING3D: boolean;
  118072. SAMPLER3DGREENDEPTH: boolean;
  118073. SAMPLER3DBGRMAP: boolean;
  118074. IMAGEPROCESSINGPOSTPROCESS: boolean;
  118075. /** MISC. */
  118076. BUMPDIRECTUV: number;
  118077. constructor();
  118078. setValue(name: string, value: boolean): void;
  118079. }
  118080. /**
  118081. * Class used to configure NodeMaterial
  118082. */
  118083. export interface INodeMaterialOptions {
  118084. /**
  118085. * Defines if blocks should emit comments
  118086. */
  118087. emitComments: boolean;
  118088. }
  118089. /**
  118090. * Class used to create a node based material built by assembling shader blocks
  118091. */
  118092. export class NodeMaterial extends PushMaterial {
  118093. private static _BuildIdGenerator;
  118094. private _options;
  118095. private _vertexCompilationState;
  118096. private _fragmentCompilationState;
  118097. private _sharedData;
  118098. private _buildId;
  118099. private _buildWasSuccessful;
  118100. private _cachedWorldViewMatrix;
  118101. private _cachedWorldViewProjectionMatrix;
  118102. private _optimizers;
  118103. private _animationFrame;
  118104. /** Define the URl to load node editor script */
  118105. static EditorURL: string;
  118106. private BJSNODEMATERIALEDITOR;
  118107. /** Get the inspector from bundle or global */
  118108. private _getGlobalNodeMaterialEditor;
  118109. /**
  118110. * 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)
  118111. */
  118112. ignoreAlpha: boolean;
  118113. /**
  118114. * Defines the maximum number of lights that can be used in the material
  118115. */
  118116. maxSimultaneousLights: number;
  118117. /**
  118118. * Observable raised when the material is built
  118119. */
  118120. onBuildObservable: Observable<NodeMaterial>;
  118121. /**
  118122. * Gets or sets the root nodes of the material vertex shader
  118123. */
  118124. _vertexOutputNodes: NodeMaterialBlock[];
  118125. /**
  118126. * Gets or sets the root nodes of the material fragment (pixel) shader
  118127. */
  118128. _fragmentOutputNodes: NodeMaterialBlock[];
  118129. /** Gets or sets options to control the node material overall behavior */
  118130. options: INodeMaterialOptions;
  118131. /**
  118132. * Default configuration related to image processing available in the standard Material.
  118133. */
  118134. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118135. /**
  118136. * Gets the image processing configuration used either in this material.
  118137. */
  118138. /**
  118139. * Sets the Default image processing configuration used either in the this material.
  118140. *
  118141. * If sets to null, the scene one is in use.
  118142. */
  118143. imageProcessingConfiguration: ImageProcessingConfiguration;
  118144. /**
  118145. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  118146. */
  118147. attachedBlocks: NodeMaterialBlock[];
  118148. /**
  118149. * Create a new node based material
  118150. * @param name defines the material name
  118151. * @param scene defines the hosting scene
  118152. * @param options defines creation option
  118153. */
  118154. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  118155. /**
  118156. * Gets the current class name of the material e.g. "NodeMaterial"
  118157. * @returns the class name
  118158. */
  118159. getClassName(): string;
  118160. /**
  118161. * Keep track of the image processing observer to allow dispose and replace.
  118162. */
  118163. private _imageProcessingObserver;
  118164. /**
  118165. * Attaches a new image processing configuration to the Standard Material.
  118166. * @param configuration
  118167. */
  118168. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118169. /**
  118170. * Get a block by its name
  118171. * @param name defines the name of the block to retrieve
  118172. * @returns the required block or null if not found
  118173. */
  118174. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  118175. /**
  118176. * Get a block by its name
  118177. * @param predicate defines the predicate used to find the good candidate
  118178. * @returns the required block or null if not found
  118179. */
  118180. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  118181. /**
  118182. * Get an input block by its name
  118183. * @param predicate defines the predicate used to find the good candidate
  118184. * @returns the required input block or null if not found
  118185. */
  118186. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  118187. /**
  118188. * Gets the list of input blocks attached to this material
  118189. * @returns an array of InputBlocks
  118190. */
  118191. getInputBlocks(): InputBlock[];
  118192. /**
  118193. * Adds a new optimizer to the list of optimizers
  118194. * @param optimizer defines the optimizers to add
  118195. * @returns the current material
  118196. */
  118197. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118198. /**
  118199. * Remove an optimizer from the list of optimizers
  118200. * @param optimizer defines the optimizers to remove
  118201. * @returns the current material
  118202. */
  118203. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118204. /**
  118205. * Add a new block to the list of output nodes
  118206. * @param node defines the node to add
  118207. * @returns the current material
  118208. */
  118209. addOutputNode(node: NodeMaterialBlock): this;
  118210. /**
  118211. * Remove a block from the list of root nodes
  118212. * @param node defines the node to remove
  118213. * @returns the current material
  118214. */
  118215. removeOutputNode(node: NodeMaterialBlock): this;
  118216. private _addVertexOutputNode;
  118217. private _removeVertexOutputNode;
  118218. private _addFragmentOutputNode;
  118219. private _removeFragmentOutputNode;
  118220. /**
  118221. * Specifies if the material will require alpha blending
  118222. * @returns a boolean specifying if alpha blending is needed
  118223. */
  118224. needAlphaBlending(): boolean;
  118225. /**
  118226. * Specifies if this material should be rendered in alpha test mode
  118227. * @returns a boolean specifying if an alpha test is needed.
  118228. */
  118229. needAlphaTesting(): boolean;
  118230. private _initializeBlock;
  118231. private _resetDualBlocks;
  118232. /**
  118233. * Build the material and generates the inner effect
  118234. * @param verbose defines if the build should log activity
  118235. */
  118236. build(verbose?: boolean): void;
  118237. /**
  118238. * Runs an otpimization phase to try to improve the shader code
  118239. */
  118240. optimize(): void;
  118241. private _prepareDefinesForAttributes;
  118242. /**
  118243. * Get if the submesh is ready to be used and all its information available.
  118244. * Child classes can use it to update shaders
  118245. * @param mesh defines the mesh to check
  118246. * @param subMesh defines which submesh to check
  118247. * @param useInstances specifies that instances should be used
  118248. * @returns a boolean indicating that the submesh is ready or not
  118249. */
  118250. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118251. /**
  118252. * Get a string representing the shaders built by the current node graph
  118253. */
  118254. readonly compiledShaders: string;
  118255. /**
  118256. * Binds the world matrix to the material
  118257. * @param world defines the world transformation matrix
  118258. */
  118259. bindOnlyWorldMatrix(world: Matrix): void;
  118260. /**
  118261. * Binds the submesh to this material by preparing the effect and shader to draw
  118262. * @param world defines the world transformation matrix
  118263. * @param mesh defines the mesh containing the submesh
  118264. * @param subMesh defines the submesh to bind the material to
  118265. */
  118266. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118267. /**
  118268. * Gets the active textures from the material
  118269. * @returns an array of textures
  118270. */
  118271. getActiveTextures(): BaseTexture[];
  118272. /**
  118273. * Gets the list of texture blocks
  118274. * @returns an array of texture blocks
  118275. */
  118276. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  118277. /**
  118278. * Specifies if the material uses a texture
  118279. * @param texture defines the texture to check against the material
  118280. * @returns a boolean specifying if the material uses the texture
  118281. */
  118282. hasTexture(texture: BaseTexture): boolean;
  118283. /**
  118284. * Disposes the material
  118285. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  118286. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  118287. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  118288. */
  118289. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  118290. /** Creates the node editor window. */
  118291. private _createNodeEditor;
  118292. /**
  118293. * Launch the node material editor
  118294. * @param config Define the configuration of the editor
  118295. * @return a promise fulfilled when the node editor is visible
  118296. */
  118297. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  118298. /**
  118299. * Clear the current material
  118300. */
  118301. clear(): void;
  118302. /**
  118303. * Clear the current material and set it to a default state
  118304. */
  118305. setToDefault(): void;
  118306. /**
  118307. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  118308. * @param url defines the url to load from
  118309. * @returns a promise that will fullfil when the material is fully loaded
  118310. */
  118311. loadAsync(url: string): Promise<unknown>;
  118312. private _gatherBlocks;
  118313. /**
  118314. * Generate a string containing the code declaration required to create an equivalent of this material
  118315. * @returns a string
  118316. */
  118317. generateCode(): string;
  118318. /**
  118319. * Serializes this material in a JSON representation
  118320. * @returns the serialized material object
  118321. */
  118322. serialize(): any;
  118323. private _restoreConnections;
  118324. /**
  118325. * Clear the current graph and load a new one from a serialization object
  118326. * @param source defines the JSON representation of the material
  118327. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118328. */
  118329. loadFromSerialization(source: any, rootUrl?: string): void;
  118330. /**
  118331. * Creates a node material from parsed material data
  118332. * @param source defines the JSON representation of the material
  118333. * @param scene defines the hosting scene
  118334. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118335. * @returns a new node material
  118336. */
  118337. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  118338. /**
  118339. * Creates a new node material set to default basic configuration
  118340. * @param name defines the name of the material
  118341. * @param scene defines the hosting scene
  118342. * @returns a new NodeMaterial
  118343. */
  118344. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  118345. }
  118346. }
  118347. declare module BABYLON {
  118348. /**
  118349. * Block used to read a texture from a sampler
  118350. */
  118351. export class TextureBlock extends NodeMaterialBlock {
  118352. private _defineName;
  118353. private _samplerName;
  118354. private _transformedUVName;
  118355. private _textureTransformName;
  118356. private _textureInfoName;
  118357. private _mainUVName;
  118358. private _mainUVDefineName;
  118359. /**
  118360. * Gets or sets the texture associated with the node
  118361. */
  118362. texture: Nullable<Texture>;
  118363. /**
  118364. * Create a new TextureBlock
  118365. * @param name defines the block name
  118366. */
  118367. constructor(name: string);
  118368. /**
  118369. * Gets the current class name
  118370. * @returns the class name
  118371. */
  118372. getClassName(): string;
  118373. /**
  118374. * Gets the uv input component
  118375. */
  118376. readonly uv: NodeMaterialConnectionPoint;
  118377. /**
  118378. * Gets the rgba output component
  118379. */
  118380. readonly rgba: NodeMaterialConnectionPoint;
  118381. /**
  118382. * Gets the rgb output component
  118383. */
  118384. readonly rgb: NodeMaterialConnectionPoint;
  118385. /**
  118386. * Gets the r output component
  118387. */
  118388. readonly r: NodeMaterialConnectionPoint;
  118389. /**
  118390. * Gets the g output component
  118391. */
  118392. readonly g: NodeMaterialConnectionPoint;
  118393. /**
  118394. * Gets the b output component
  118395. */
  118396. readonly b: NodeMaterialConnectionPoint;
  118397. /**
  118398. * Gets the a output component
  118399. */
  118400. readonly a: NodeMaterialConnectionPoint;
  118401. readonly target: NodeMaterialBlockTargets;
  118402. autoConfigure(material: NodeMaterial): void;
  118403. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118404. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118405. isReady(): boolean;
  118406. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118407. private readonly _isMixed;
  118408. private _injectVertexCode;
  118409. private _writeOutput;
  118410. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118411. protected _dumpPropertiesCode(): string;
  118412. serialize(): any;
  118413. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118414. }
  118415. }
  118416. declare module BABYLON {
  118417. /**
  118418. * Class used to store shared data between 2 NodeMaterialBuildState
  118419. */
  118420. export class NodeMaterialBuildStateSharedData {
  118421. /**
  118422. * Gets the list of emitted varyings
  118423. */
  118424. temps: string[];
  118425. /**
  118426. * Gets the list of emitted varyings
  118427. */
  118428. varyings: string[];
  118429. /**
  118430. * Gets the varying declaration string
  118431. */
  118432. varyingDeclaration: string;
  118433. /**
  118434. * Input blocks
  118435. */
  118436. inputBlocks: InputBlock[];
  118437. /**
  118438. * Input blocks
  118439. */
  118440. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  118441. /**
  118442. * Bindable blocks (Blocks that need to set data to the effect)
  118443. */
  118444. bindableBlocks: NodeMaterialBlock[];
  118445. /**
  118446. * List of blocks that can provide a compilation fallback
  118447. */
  118448. blocksWithFallbacks: NodeMaterialBlock[];
  118449. /**
  118450. * List of blocks that can provide a define update
  118451. */
  118452. blocksWithDefines: NodeMaterialBlock[];
  118453. /**
  118454. * List of blocks that can provide a repeatable content
  118455. */
  118456. repeatableContentBlocks: NodeMaterialBlock[];
  118457. /**
  118458. * List of blocks that can provide a dynamic list of uniforms
  118459. */
  118460. dynamicUniformBlocks: NodeMaterialBlock[];
  118461. /**
  118462. * List of blocks that can block the isReady function for the material
  118463. */
  118464. blockingBlocks: NodeMaterialBlock[];
  118465. /**
  118466. * Gets the list of animated inputs
  118467. */
  118468. animatedInputs: InputBlock[];
  118469. /**
  118470. * Build Id used to avoid multiple recompilations
  118471. */
  118472. buildId: number;
  118473. /** List of emitted variables */
  118474. variableNames: {
  118475. [key: string]: number;
  118476. };
  118477. /** List of emitted defines */
  118478. defineNames: {
  118479. [key: string]: number;
  118480. };
  118481. /** Should emit comments? */
  118482. emitComments: boolean;
  118483. /** Emit build activity */
  118484. verbose: boolean;
  118485. /** Gets or sets the hosting scene */
  118486. scene: Scene;
  118487. /**
  118488. * Gets the compilation hints emitted at compilation time
  118489. */
  118490. hints: {
  118491. needWorldViewMatrix: boolean;
  118492. needWorldViewProjectionMatrix: boolean;
  118493. needAlphaBlending: boolean;
  118494. needAlphaTesting: boolean;
  118495. };
  118496. /**
  118497. * List of compilation checks
  118498. */
  118499. checks: {
  118500. emitVertex: boolean;
  118501. emitFragment: boolean;
  118502. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  118503. };
  118504. /** Creates a new shared data */
  118505. constructor();
  118506. /**
  118507. * Emits console errors and exceptions if there is a failing check
  118508. */
  118509. emitErrors(): void;
  118510. }
  118511. }
  118512. declare module BABYLON {
  118513. /**
  118514. * Class used to store node based material build state
  118515. */
  118516. export class NodeMaterialBuildState {
  118517. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  118518. supportUniformBuffers: boolean;
  118519. /**
  118520. * Gets the list of emitted attributes
  118521. */
  118522. attributes: string[];
  118523. /**
  118524. * Gets the list of emitted uniforms
  118525. */
  118526. uniforms: string[];
  118527. /**
  118528. * Gets the list of emitted uniform buffers
  118529. */
  118530. uniformBuffers: string[];
  118531. /**
  118532. * Gets the list of emitted samplers
  118533. */
  118534. samplers: string[];
  118535. /**
  118536. * Gets the list of emitted functions
  118537. */
  118538. functions: {
  118539. [key: string]: string;
  118540. };
  118541. /**
  118542. * Gets the list of emitted extensions
  118543. */
  118544. extensions: {
  118545. [key: string]: string;
  118546. };
  118547. /**
  118548. * Gets the target of the compilation state
  118549. */
  118550. target: NodeMaterialBlockTargets;
  118551. /**
  118552. * Gets the list of emitted counters
  118553. */
  118554. counters: {
  118555. [key: string]: number;
  118556. };
  118557. /**
  118558. * Shared data between multiple NodeMaterialBuildState instances
  118559. */
  118560. sharedData: NodeMaterialBuildStateSharedData;
  118561. /** @hidden */
  118562. _vertexState: NodeMaterialBuildState;
  118563. /** @hidden */
  118564. _attributeDeclaration: string;
  118565. /** @hidden */
  118566. _uniformDeclaration: string;
  118567. /** @hidden */
  118568. _samplerDeclaration: string;
  118569. /** @hidden */
  118570. _varyingTransfer: string;
  118571. private _repeatableContentAnchorIndex;
  118572. /** @hidden */
  118573. _builtCompilationString: string;
  118574. /**
  118575. * Gets the emitted compilation strings
  118576. */
  118577. compilationString: string;
  118578. /**
  118579. * Finalize the compilation strings
  118580. * @param state defines the current compilation state
  118581. */
  118582. finalize(state: NodeMaterialBuildState): void;
  118583. /** @hidden */
  118584. readonly _repeatableContentAnchor: string;
  118585. /** @hidden */
  118586. _getFreeVariableName(prefix: string): string;
  118587. /** @hidden */
  118588. _getFreeDefineName(prefix: string): string;
  118589. /** @hidden */
  118590. _excludeVariableName(name: string): void;
  118591. /** @hidden */
  118592. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  118593. /** @hidden */
  118594. _emitExtension(name: string, extension: string): void;
  118595. /** @hidden */
  118596. _emitFunction(name: string, code: string, comments: string): void;
  118597. /** @hidden */
  118598. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  118599. replaceStrings?: {
  118600. search: RegExp;
  118601. replace: string;
  118602. }[];
  118603. repeatKey?: string;
  118604. }): string;
  118605. /** @hidden */
  118606. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  118607. repeatKey?: string;
  118608. removeAttributes?: boolean;
  118609. removeUniforms?: boolean;
  118610. removeVaryings?: boolean;
  118611. removeIfDef?: boolean;
  118612. replaceStrings?: {
  118613. search: RegExp;
  118614. replace: string;
  118615. }[];
  118616. }, storeKey?: string): void;
  118617. /** @hidden */
  118618. _registerTempVariable(name: string): boolean;
  118619. /** @hidden */
  118620. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  118621. /** @hidden */
  118622. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  118623. }
  118624. }
  118625. declare module BABYLON {
  118626. /**
  118627. * Defines a block that can be used inside a node based material
  118628. */
  118629. export class NodeMaterialBlock {
  118630. private _buildId;
  118631. private _buildTarget;
  118632. private _target;
  118633. private _isFinalMerger;
  118634. private _isInput;
  118635. /** @hidden */
  118636. _codeVariableName: string;
  118637. /** @hidden */
  118638. _inputs: NodeMaterialConnectionPoint[];
  118639. /** @hidden */
  118640. _outputs: NodeMaterialConnectionPoint[];
  118641. /** @hidden */
  118642. _preparationId: number;
  118643. /**
  118644. * Gets or sets the name of the block
  118645. */
  118646. name: string;
  118647. /**
  118648. * Gets or sets the unique id of the node
  118649. */
  118650. uniqueId: number;
  118651. /**
  118652. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  118653. */
  118654. readonly isFinalMerger: boolean;
  118655. /**
  118656. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  118657. */
  118658. readonly isInput: boolean;
  118659. /**
  118660. * Gets or sets the build Id
  118661. */
  118662. buildId: number;
  118663. /**
  118664. * Gets or sets the target of the block
  118665. */
  118666. target: NodeMaterialBlockTargets;
  118667. /**
  118668. * Gets the list of input points
  118669. */
  118670. readonly inputs: NodeMaterialConnectionPoint[];
  118671. /** Gets the list of output points */
  118672. readonly outputs: NodeMaterialConnectionPoint[];
  118673. /**
  118674. * Find an input by its name
  118675. * @param name defines the name of the input to look for
  118676. * @returns the input or null if not found
  118677. */
  118678. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118679. /**
  118680. * Find an output by its name
  118681. * @param name defines the name of the outputto look for
  118682. * @returns the output or null if not found
  118683. */
  118684. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118685. /**
  118686. * Creates a new NodeMaterialBlock
  118687. * @param name defines the block name
  118688. * @param target defines the target of that block (Vertex by default)
  118689. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  118690. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  118691. */
  118692. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  118693. /**
  118694. * Initialize the block and prepare the context for build
  118695. * @param state defines the state that will be used for the build
  118696. */
  118697. initialize(state: NodeMaterialBuildState): void;
  118698. /**
  118699. * Bind data to effect. Will only be called for blocks with isBindable === true
  118700. * @param effect defines the effect to bind data to
  118701. * @param nodeMaterial defines the hosting NodeMaterial
  118702. * @param mesh defines the mesh that will be rendered
  118703. */
  118704. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118705. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  118706. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  118707. protected _writeFloat(value: number): string;
  118708. /**
  118709. * Gets the current class name e.g. "NodeMaterialBlock"
  118710. * @returns the class name
  118711. */
  118712. getClassName(): string;
  118713. /**
  118714. * Register a new input. Must be called inside a block constructor
  118715. * @param name defines the connection point name
  118716. * @param type defines the connection point type
  118717. * @param isOptional defines a boolean indicating that this input can be omitted
  118718. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118719. * @returns the current block
  118720. */
  118721. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  118722. /**
  118723. * Register a new output. Must be called inside a block constructor
  118724. * @param name defines the connection point name
  118725. * @param type defines the connection point type
  118726. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118727. * @returns the current block
  118728. */
  118729. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  118730. /**
  118731. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  118732. * @param forOutput defines an optional connection point to check compatibility with
  118733. * @returns the first available input or null
  118734. */
  118735. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  118736. /**
  118737. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  118738. * @param forBlock defines an optional block to check compatibility with
  118739. * @returns the first available input or null
  118740. */
  118741. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  118742. /**
  118743. * Gets the sibling of the given output
  118744. * @param current defines the current output
  118745. * @returns the next output in the list or null
  118746. */
  118747. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  118748. /**
  118749. * Connect current block with another block
  118750. * @param other defines the block to connect with
  118751. * @param options define the various options to help pick the right connections
  118752. * @returns the current block
  118753. */
  118754. connectTo(other: NodeMaterialBlock, options?: {
  118755. input?: string;
  118756. output?: string;
  118757. outputSwizzle?: string;
  118758. }): this | undefined;
  118759. protected _buildBlock(state: NodeMaterialBuildState): void;
  118760. /**
  118761. * Add uniforms, samplers and uniform buffers at compilation time
  118762. * @param state defines the state to update
  118763. * @param nodeMaterial defines the node material requesting the update
  118764. * @param defines defines the material defines to update
  118765. */
  118766. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118767. /**
  118768. * Add potential fallbacks if shader compilation fails
  118769. * @param mesh defines the mesh to be rendered
  118770. * @param fallbacks defines the current prioritized list of fallbacks
  118771. */
  118772. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118773. /**
  118774. * Initialize defines for shader compilation
  118775. * @param mesh defines the mesh to be rendered
  118776. * @param nodeMaterial defines the node material requesting the update
  118777. * @param defines defines the material defines to update
  118778. * @param useInstances specifies that instances should be used
  118779. */
  118780. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118781. /**
  118782. * Update defines for shader compilation
  118783. * @param mesh defines the mesh to be rendered
  118784. * @param nodeMaterial defines the node material requesting the update
  118785. * @param defines defines the material defines to update
  118786. * @param useInstances specifies that instances should be used
  118787. */
  118788. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118789. /**
  118790. * Lets the block try to connect some inputs automatically
  118791. * @param material defines the hosting NodeMaterial
  118792. */
  118793. autoConfigure(material: NodeMaterial): void;
  118794. /**
  118795. * Function called when a block is declared as repeatable content generator
  118796. * @param vertexShaderState defines the current compilation state for the vertex shader
  118797. * @param fragmentShaderState defines the current compilation state for the fragment shader
  118798. * @param mesh defines the mesh to be rendered
  118799. * @param defines defines the material defines to update
  118800. */
  118801. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118802. /**
  118803. * Checks if the block is ready
  118804. * @param mesh defines the mesh to be rendered
  118805. * @param nodeMaterial defines the node material requesting the update
  118806. * @param defines defines the material defines to update
  118807. * @param useInstances specifies that instances should be used
  118808. * @returns true if the block is ready
  118809. */
  118810. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  118811. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  118812. private _processBuild;
  118813. /**
  118814. * Compile the current node and generate the shader code
  118815. * @param state defines the current compilation state (uniforms, samplers, current string)
  118816. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  118817. * @returns true if already built
  118818. */
  118819. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  118820. protected _inputRename(name: string): string;
  118821. protected _outputRename(name: string): string;
  118822. protected _dumpPropertiesCode(): string;
  118823. /** @hidden */
  118824. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  118825. /**
  118826. * Clone the current block to a new identical block
  118827. * @param scene defines the hosting scene
  118828. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118829. * @returns a copy of the current block
  118830. */
  118831. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  118832. /**
  118833. * Serializes this block in a JSON representation
  118834. * @returns the serialized block object
  118835. */
  118836. serialize(): any;
  118837. /** @hidden */
  118838. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118839. }
  118840. }
  118841. declare module BABYLON {
  118842. /**
  118843. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  118844. */
  118845. export enum NodeMaterialBlockConnectionPointMode {
  118846. /** Value is an uniform */
  118847. Uniform = 0,
  118848. /** Value is a mesh attribute */
  118849. Attribute = 1,
  118850. /** Value is a varying between vertex and fragment shaders */
  118851. Varying = 2,
  118852. /** Mode is undefined */
  118853. Undefined = 3
  118854. }
  118855. }
  118856. declare module BABYLON {
  118857. /**
  118858. * Enum defining the type of animations supported by InputBlock
  118859. */
  118860. export enum AnimatedInputBlockTypes {
  118861. /** No animation */
  118862. None = 0,
  118863. /** Time based animation. Will only work for floats */
  118864. Time = 1
  118865. }
  118866. }
  118867. declare module BABYLON {
  118868. /**
  118869. * Block used to expose an input value
  118870. */
  118871. export class InputBlock extends NodeMaterialBlock {
  118872. private _mode;
  118873. private _associatedVariableName;
  118874. private _storedValue;
  118875. private _valueCallback;
  118876. private _type;
  118877. private _animationType;
  118878. /** Gets or set a value used to limit the range of float values */
  118879. min: number;
  118880. /** Gets or set a value used to limit the range of float values */
  118881. max: number;
  118882. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  118883. matrixMode: number;
  118884. /** @hidden */
  118885. _systemValue: Nullable<NodeMaterialSystemValues>;
  118886. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  118887. visibleInInspector: boolean;
  118888. /**
  118889. * Gets or sets the connection point type (default is float)
  118890. */
  118891. readonly type: NodeMaterialBlockConnectionPointTypes;
  118892. /**
  118893. * Creates a new InputBlock
  118894. * @param name defines the block name
  118895. * @param target defines the target of that block (Vertex by default)
  118896. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  118897. */
  118898. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  118899. /**
  118900. * Gets the output component
  118901. */
  118902. readonly output: NodeMaterialConnectionPoint;
  118903. /**
  118904. * Set the source of this connection point to a vertex attribute
  118905. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  118906. * @returns the current connection point
  118907. */
  118908. setAsAttribute(attributeName?: string): InputBlock;
  118909. /**
  118910. * Set the source of this connection point to a system value
  118911. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  118912. * @returns the current connection point
  118913. */
  118914. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  118915. /**
  118916. * Gets or sets the value of that point.
  118917. * Please note that this value will be ignored if valueCallback is defined
  118918. */
  118919. value: any;
  118920. /**
  118921. * Gets or sets a callback used to get the value of that point.
  118922. * Please note that setting this value will force the connection point to ignore the value property
  118923. */
  118924. valueCallback: () => any;
  118925. /**
  118926. * Gets or sets the associated variable name in the shader
  118927. */
  118928. associatedVariableName: string;
  118929. /** Gets or sets the type of animation applied to the input */
  118930. animationType: AnimatedInputBlockTypes;
  118931. /**
  118932. * Gets a boolean indicating that this connection point not defined yet
  118933. */
  118934. readonly isUndefined: boolean;
  118935. /**
  118936. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  118937. * In this case the connection point name must be the name of the uniform to use.
  118938. * Can only be set on inputs
  118939. */
  118940. isUniform: boolean;
  118941. /**
  118942. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  118943. * In this case the connection point name must be the name of the attribute to use
  118944. * Can only be set on inputs
  118945. */
  118946. isAttribute: boolean;
  118947. /**
  118948. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  118949. * Can only be set on exit points
  118950. */
  118951. isVarying: boolean;
  118952. /**
  118953. * Gets a boolean indicating that the current connection point is a system value
  118954. */
  118955. readonly isSystemValue: boolean;
  118956. /**
  118957. * Gets or sets the current well known value or null if not defined as a system value
  118958. */
  118959. systemValue: Nullable<NodeMaterialSystemValues>;
  118960. /**
  118961. * Gets the current class name
  118962. * @returns the class name
  118963. */
  118964. getClassName(): string;
  118965. /**
  118966. * Animate the input if animationType !== None
  118967. * @param scene defines the rendering scene
  118968. */
  118969. animate(scene: Scene): void;
  118970. private _emitDefine;
  118971. initialize(state: NodeMaterialBuildState): void;
  118972. /**
  118973. * Set the input block to its default value (based on its type)
  118974. */
  118975. setDefaultValue(): void;
  118976. protected _dumpPropertiesCode(): string;
  118977. private _emit;
  118978. /** @hidden */
  118979. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  118980. /** @hidden */
  118981. _transmit(effect: Effect, scene: Scene): void;
  118982. protected _buildBlock(state: NodeMaterialBuildState): void;
  118983. serialize(): any;
  118984. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118985. }
  118986. }
  118987. declare module BABYLON {
  118988. /**
  118989. * Defines a connection point for a block
  118990. */
  118991. export class NodeMaterialConnectionPoint {
  118992. /** @hidden */
  118993. _ownerBlock: NodeMaterialBlock;
  118994. /** @hidden */
  118995. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  118996. private _endpoints;
  118997. private _associatedVariableName;
  118998. /** @hidden */
  118999. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119000. /** @hidden */
  119001. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119002. private _type;
  119003. /** @hidden */
  119004. _enforceAssociatedVariableName: boolean;
  119005. /**
  119006. * Gets or sets the additional types supported byt this connection point
  119007. */
  119008. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119009. /**
  119010. * Gets or sets the associated variable name in the shader
  119011. */
  119012. associatedVariableName: string;
  119013. /**
  119014. * Gets or sets the connection point type (default is float)
  119015. */
  119016. type: NodeMaterialBlockConnectionPointTypes;
  119017. /**
  119018. * Gets or sets the connection point name
  119019. */
  119020. name: string;
  119021. /**
  119022. * Gets or sets a boolean indicating that this connection point can be omitted
  119023. */
  119024. isOptional: boolean;
  119025. /**
  119026. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  119027. */
  119028. define: string;
  119029. /** Gets or sets the target of that connection point */
  119030. target: NodeMaterialBlockTargets;
  119031. /**
  119032. * Gets a boolean indicating that the current point is connected
  119033. */
  119034. readonly isConnected: boolean;
  119035. /**
  119036. * Gets a boolean indicating that the current point is connected to an input block
  119037. */
  119038. readonly isConnectedToInputBlock: boolean;
  119039. /**
  119040. * Gets a the connected input block (if any)
  119041. */
  119042. readonly connectInputBlock: Nullable<InputBlock>;
  119043. /** Get the other side of the connection (if any) */
  119044. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119045. /** Get the block that owns this connection point */
  119046. readonly ownerBlock: NodeMaterialBlock;
  119047. /** Get the block connected on the other side of this connection (if any) */
  119048. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  119049. /** Get the block connected on the endpoints of this connection (if any) */
  119050. readonly connectedBlocks: Array<NodeMaterialBlock>;
  119051. /** Gets the list of connected endpoints */
  119052. readonly endpoints: NodeMaterialConnectionPoint[];
  119053. /** Gets a boolean indicating if that output point is connected to at least one input */
  119054. readonly hasEndpoints: boolean;
  119055. /**
  119056. * Creates a new connection point
  119057. * @param name defines the connection point name
  119058. * @param ownerBlock defines the block hosting this connection point
  119059. */
  119060. constructor(name: string, ownerBlock: NodeMaterialBlock);
  119061. /**
  119062. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  119063. * @returns the class name
  119064. */
  119065. getClassName(): string;
  119066. /**
  119067. * Gets an boolean indicating if the current point can be connected to another point
  119068. * @param connectionPoint defines the other connection point
  119069. * @returns true if the connection is possible
  119070. */
  119071. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  119072. /**
  119073. * Connect this point to another connection point
  119074. * @param connectionPoint defines the other connection point
  119075. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  119076. * @returns the current connection point
  119077. */
  119078. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  119079. /**
  119080. * Disconnect this point from one of his endpoint
  119081. * @param endpoint defines the other connection point
  119082. * @returns the current connection point
  119083. */
  119084. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  119085. /**
  119086. * Serializes this point in a JSON representation
  119087. * @returns the serialized point object
  119088. */
  119089. serialize(): any;
  119090. }
  119091. }
  119092. declare module BABYLON {
  119093. /**
  119094. * Block used to add support for vertex skinning (bones)
  119095. */
  119096. export class BonesBlock extends NodeMaterialBlock {
  119097. /**
  119098. * Creates a new BonesBlock
  119099. * @param name defines the block name
  119100. */
  119101. constructor(name: string);
  119102. /**
  119103. * Initialize the block and prepare the context for build
  119104. * @param state defines the state that will be used for the build
  119105. */
  119106. initialize(state: NodeMaterialBuildState): void;
  119107. /**
  119108. * Gets the current class name
  119109. * @returns the class name
  119110. */
  119111. getClassName(): string;
  119112. /**
  119113. * Gets the matrix indices input component
  119114. */
  119115. readonly matricesIndices: NodeMaterialConnectionPoint;
  119116. /**
  119117. * Gets the matrix weights input component
  119118. */
  119119. readonly matricesWeights: NodeMaterialConnectionPoint;
  119120. /**
  119121. * Gets the extra matrix indices input component
  119122. */
  119123. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  119124. /**
  119125. * Gets the extra matrix weights input component
  119126. */
  119127. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  119128. /**
  119129. * Gets the world input component
  119130. */
  119131. readonly world: NodeMaterialConnectionPoint;
  119132. /**
  119133. * Gets the output component
  119134. */
  119135. readonly output: NodeMaterialConnectionPoint;
  119136. autoConfigure(material: NodeMaterial): void;
  119137. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  119138. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119140. protected _buildBlock(state: NodeMaterialBuildState): this;
  119141. }
  119142. }
  119143. declare module BABYLON {
  119144. /**
  119145. * Block used to add support for instances
  119146. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  119147. */
  119148. export class InstancesBlock extends NodeMaterialBlock {
  119149. /**
  119150. * Creates a new InstancesBlock
  119151. * @param name defines the block name
  119152. */
  119153. constructor(name: string);
  119154. /**
  119155. * Gets the current class name
  119156. * @returns the class name
  119157. */
  119158. getClassName(): string;
  119159. /**
  119160. * Gets the first world row input component
  119161. */
  119162. readonly world0: NodeMaterialConnectionPoint;
  119163. /**
  119164. * Gets the second world row input component
  119165. */
  119166. readonly world1: NodeMaterialConnectionPoint;
  119167. /**
  119168. * Gets the third world row input component
  119169. */
  119170. readonly world2: NodeMaterialConnectionPoint;
  119171. /**
  119172. * Gets the forth world row input component
  119173. */
  119174. readonly world3: NodeMaterialConnectionPoint;
  119175. /**
  119176. * Gets the world input component
  119177. */
  119178. readonly world: NodeMaterialConnectionPoint;
  119179. /**
  119180. * Gets the output component
  119181. */
  119182. readonly output: NodeMaterialConnectionPoint;
  119183. autoConfigure(material: NodeMaterial): void;
  119184. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119185. protected _buildBlock(state: NodeMaterialBuildState): this;
  119186. }
  119187. }
  119188. declare module BABYLON {
  119189. /**
  119190. * Block used to add morph targets support to vertex shader
  119191. */
  119192. export class MorphTargetsBlock extends NodeMaterialBlock {
  119193. private _repeatableContentAnchor;
  119194. private _repeatebleContentGenerated;
  119195. /**
  119196. * Create a new MorphTargetsBlock
  119197. * @param name defines the block name
  119198. */
  119199. constructor(name: string);
  119200. /**
  119201. * Gets the current class name
  119202. * @returns the class name
  119203. */
  119204. getClassName(): string;
  119205. /**
  119206. * Gets the position input component
  119207. */
  119208. readonly position: NodeMaterialConnectionPoint;
  119209. /**
  119210. * Gets the normal input component
  119211. */
  119212. readonly normal: NodeMaterialConnectionPoint;
  119213. /**
  119214. * Gets the tangent input component
  119215. */
  119216. readonly tangent: NodeMaterialConnectionPoint;
  119217. /**
  119218. * Gets the tangent input component
  119219. */
  119220. readonly uv: NodeMaterialConnectionPoint;
  119221. /**
  119222. * Gets the position output component
  119223. */
  119224. readonly positionOutput: NodeMaterialConnectionPoint;
  119225. /**
  119226. * Gets the normal output component
  119227. */
  119228. readonly normalOutput: NodeMaterialConnectionPoint;
  119229. /**
  119230. * Gets the tangent output component
  119231. */
  119232. readonly tangentOutput: NodeMaterialConnectionPoint;
  119233. /**
  119234. * Gets the tangent output component
  119235. */
  119236. readonly uvOutput: NodeMaterialConnectionPoint;
  119237. initialize(state: NodeMaterialBuildState): void;
  119238. autoConfigure(material: NodeMaterial): void;
  119239. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119240. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119241. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  119242. protected _buildBlock(state: NodeMaterialBuildState): this;
  119243. }
  119244. }
  119245. declare module BABYLON {
  119246. /**
  119247. * Block used to get data information from a light
  119248. */
  119249. export class LightInformationBlock extends NodeMaterialBlock {
  119250. private _lightDataUniformName;
  119251. private _lightColorUniformName;
  119252. /**
  119253. * Gets or sets the light associated with this block
  119254. */
  119255. light: Nullable<Light>;
  119256. /**
  119257. * Creates a new LightInformationBlock
  119258. * @param name defines the block name
  119259. */
  119260. constructor(name: string);
  119261. /**
  119262. * Gets the current class name
  119263. * @returns the class name
  119264. */
  119265. getClassName(): string;
  119266. /**
  119267. * Gets the world position input component
  119268. */
  119269. readonly worldPosition: NodeMaterialConnectionPoint;
  119270. /**
  119271. * Gets the direction output component
  119272. */
  119273. readonly direction: NodeMaterialConnectionPoint;
  119274. /**
  119275. * Gets the direction output component
  119276. */
  119277. readonly color: NodeMaterialConnectionPoint;
  119278. /**
  119279. * Gets the direction output component
  119280. */
  119281. readonly intensity: NodeMaterialConnectionPoint;
  119282. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119283. protected _buildBlock(state: NodeMaterialBuildState): this;
  119284. serialize(): any;
  119285. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119286. }
  119287. }
  119288. declare module BABYLON {
  119289. /**
  119290. * Block used to add an alpha test in the fragment shader
  119291. */
  119292. export class AlphaTestBlock extends NodeMaterialBlock {
  119293. /**
  119294. * Gets or sets the alpha value where alpha testing happens
  119295. */
  119296. alphaCutOff: number;
  119297. /**
  119298. * Create a new AlphaTestBlock
  119299. * @param name defines the block name
  119300. */
  119301. constructor(name: string);
  119302. /**
  119303. * Gets the current class name
  119304. * @returns the class name
  119305. */
  119306. getClassName(): string;
  119307. /**
  119308. * Gets the color input component
  119309. */
  119310. readonly color: NodeMaterialConnectionPoint;
  119311. /**
  119312. * Gets the alpha input component
  119313. */
  119314. readonly alpha: NodeMaterialConnectionPoint;
  119315. protected _buildBlock(state: NodeMaterialBuildState): this;
  119316. protected _dumpPropertiesCode(): string;
  119317. serialize(): any;
  119318. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119319. }
  119320. }
  119321. declare module BABYLON {
  119322. /**
  119323. * Block used to add image processing support to fragment shader
  119324. */
  119325. export class ImageProcessingBlock extends NodeMaterialBlock {
  119326. /**
  119327. * Create a new ImageProcessingBlock
  119328. * @param name defines the block name
  119329. */
  119330. constructor(name: string);
  119331. /**
  119332. * Gets the current class name
  119333. * @returns the class name
  119334. */
  119335. getClassName(): string;
  119336. /**
  119337. * Gets the color input component
  119338. */
  119339. readonly color: NodeMaterialConnectionPoint;
  119340. /**
  119341. * Gets the output component
  119342. */
  119343. readonly output: NodeMaterialConnectionPoint;
  119344. /**
  119345. * Initialize the block and prepare the context for build
  119346. * @param state defines the state that will be used for the build
  119347. */
  119348. initialize(state: NodeMaterialBuildState): void;
  119349. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  119350. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119351. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119352. protected _buildBlock(state: NodeMaterialBuildState): this;
  119353. }
  119354. }
  119355. declare module BABYLON {
  119356. /**
  119357. * Block used to pertub normals based on a normal map
  119358. */
  119359. export class PerturbNormalBlock extends NodeMaterialBlock {
  119360. private _tangentSpaceParameterName;
  119361. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  119362. invertX: boolean;
  119363. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  119364. invertY: boolean;
  119365. /**
  119366. * Create a new PerturbNormalBlock
  119367. * @param name defines the block name
  119368. */
  119369. constructor(name: string);
  119370. /**
  119371. * Gets the current class name
  119372. * @returns the class name
  119373. */
  119374. getClassName(): string;
  119375. /**
  119376. * Gets the world position input component
  119377. */
  119378. readonly worldPosition: NodeMaterialConnectionPoint;
  119379. /**
  119380. * Gets the world normal input component
  119381. */
  119382. readonly worldNormal: NodeMaterialConnectionPoint;
  119383. /**
  119384. * Gets the uv input component
  119385. */
  119386. readonly uv: NodeMaterialConnectionPoint;
  119387. /**
  119388. * Gets the normal map color input component
  119389. */
  119390. readonly normalMapColor: NodeMaterialConnectionPoint;
  119391. /**
  119392. * Gets the strength input component
  119393. */
  119394. readonly strength: NodeMaterialConnectionPoint;
  119395. /**
  119396. * Gets the output component
  119397. */
  119398. readonly output: NodeMaterialConnectionPoint;
  119399. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119400. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119401. autoConfigure(material: NodeMaterial): void;
  119402. protected _buildBlock(state: NodeMaterialBuildState): this;
  119403. protected _dumpPropertiesCode(): string;
  119404. serialize(): any;
  119405. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119406. }
  119407. }
  119408. declare module BABYLON {
  119409. /**
  119410. * Block used to add support for scene fog
  119411. */
  119412. export class FogBlock extends NodeMaterialBlock {
  119413. private _fogDistanceName;
  119414. private _fogParameters;
  119415. /**
  119416. * Create a new FogBlock
  119417. * @param name defines the block name
  119418. */
  119419. constructor(name: string);
  119420. /**
  119421. * Gets the current class name
  119422. * @returns the class name
  119423. */
  119424. getClassName(): string;
  119425. /**
  119426. * Gets the world position input component
  119427. */
  119428. readonly worldPosition: NodeMaterialConnectionPoint;
  119429. /**
  119430. * Gets the view input component
  119431. */
  119432. readonly view: NodeMaterialConnectionPoint;
  119433. /**
  119434. * Gets the color input component
  119435. */
  119436. readonly input: NodeMaterialConnectionPoint;
  119437. /**
  119438. * Gets the fog color input component
  119439. */
  119440. readonly fogColor: NodeMaterialConnectionPoint;
  119441. /**
  119442. * Gets the output component
  119443. */
  119444. readonly output: NodeMaterialConnectionPoint;
  119445. autoConfigure(material: NodeMaterial): void;
  119446. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119447. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119448. protected _buildBlock(state: NodeMaterialBuildState): this;
  119449. }
  119450. }
  119451. declare module BABYLON {
  119452. /**
  119453. * Block used to add light in the fragment shader
  119454. */
  119455. export class LightBlock extends NodeMaterialBlock {
  119456. private _lightId;
  119457. /**
  119458. * Gets or sets the light associated with this block
  119459. */
  119460. light: Nullable<Light>;
  119461. /**
  119462. * Create a new LightBlock
  119463. * @param name defines the block name
  119464. */
  119465. constructor(name: string);
  119466. /**
  119467. * Gets the current class name
  119468. * @returns the class name
  119469. */
  119470. getClassName(): string;
  119471. /**
  119472. * Gets the world position input component
  119473. */
  119474. readonly worldPosition: NodeMaterialConnectionPoint;
  119475. /**
  119476. * Gets the world normal input component
  119477. */
  119478. readonly worldNormal: NodeMaterialConnectionPoint;
  119479. /**
  119480. * Gets the camera (or eye) position component
  119481. */
  119482. readonly cameraPosition: NodeMaterialConnectionPoint;
  119483. /**
  119484. * Gets the diffuse output component
  119485. */
  119486. readonly diffuseOutput: NodeMaterialConnectionPoint;
  119487. /**
  119488. * Gets the specular output component
  119489. */
  119490. readonly specularOutput: NodeMaterialConnectionPoint;
  119491. autoConfigure(material: NodeMaterial): void;
  119492. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119493. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119494. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119495. private _injectVertexCode;
  119496. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119497. serialize(): any;
  119498. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119499. }
  119500. }
  119501. declare module BABYLON {
  119502. /**
  119503. * Block used to multiply 2 values
  119504. */
  119505. export class MultiplyBlock extends NodeMaterialBlock {
  119506. /**
  119507. * Creates a new MultiplyBlock
  119508. * @param name defines the block name
  119509. */
  119510. constructor(name: string);
  119511. /**
  119512. * Gets the current class name
  119513. * @returns the class name
  119514. */
  119515. getClassName(): string;
  119516. /**
  119517. * Gets the left operand input component
  119518. */
  119519. readonly left: NodeMaterialConnectionPoint;
  119520. /**
  119521. * Gets the right operand input component
  119522. */
  119523. readonly right: NodeMaterialConnectionPoint;
  119524. /**
  119525. * Gets the output component
  119526. */
  119527. readonly output: NodeMaterialConnectionPoint;
  119528. protected _buildBlock(state: NodeMaterialBuildState): this;
  119529. }
  119530. }
  119531. declare module BABYLON {
  119532. /**
  119533. * Block used to add 2 vectors
  119534. */
  119535. export class AddBlock extends NodeMaterialBlock {
  119536. /**
  119537. * Creates a new AddBlock
  119538. * @param name defines the block name
  119539. */
  119540. constructor(name: string);
  119541. /**
  119542. * Gets the current class name
  119543. * @returns the class name
  119544. */
  119545. getClassName(): string;
  119546. /**
  119547. * Gets the left operand input component
  119548. */
  119549. readonly left: NodeMaterialConnectionPoint;
  119550. /**
  119551. * Gets the right operand input component
  119552. */
  119553. readonly right: NodeMaterialConnectionPoint;
  119554. /**
  119555. * Gets the output component
  119556. */
  119557. readonly output: NodeMaterialConnectionPoint;
  119558. protected _buildBlock(state: NodeMaterialBuildState): this;
  119559. }
  119560. }
  119561. declare module BABYLON {
  119562. /**
  119563. * Block used to scale a vector by a float
  119564. */
  119565. export class ScaleBlock extends NodeMaterialBlock {
  119566. /**
  119567. * Creates a new ScaleBlock
  119568. * @param name defines the block name
  119569. */
  119570. constructor(name: string);
  119571. /**
  119572. * Gets the current class name
  119573. * @returns the class name
  119574. */
  119575. getClassName(): string;
  119576. /**
  119577. * Gets the input component
  119578. */
  119579. readonly input: NodeMaterialConnectionPoint;
  119580. /**
  119581. * Gets the factor input component
  119582. */
  119583. readonly factor: NodeMaterialConnectionPoint;
  119584. /**
  119585. * Gets the output component
  119586. */
  119587. readonly output: NodeMaterialConnectionPoint;
  119588. protected _buildBlock(state: NodeMaterialBuildState): this;
  119589. }
  119590. }
  119591. declare module BABYLON {
  119592. /**
  119593. * Block used to clamp a float
  119594. */
  119595. export class ClampBlock extends NodeMaterialBlock {
  119596. /** Gets or sets the minimum range */
  119597. minimum: number;
  119598. /** Gets or sets the maximum range */
  119599. maximum: number;
  119600. /**
  119601. * Creates a new ClampBlock
  119602. * @param name defines the block name
  119603. */
  119604. constructor(name: string);
  119605. /**
  119606. * Gets the current class name
  119607. * @returns the class name
  119608. */
  119609. getClassName(): string;
  119610. /**
  119611. * Gets the value input component
  119612. */
  119613. readonly value: NodeMaterialConnectionPoint;
  119614. /**
  119615. * Gets the output component
  119616. */
  119617. readonly output: NodeMaterialConnectionPoint;
  119618. protected _buildBlock(state: NodeMaterialBuildState): this;
  119619. protected _dumpPropertiesCode(): string;
  119620. serialize(): any;
  119621. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119622. }
  119623. }
  119624. declare module BABYLON {
  119625. /**
  119626. * Block used to apply a cross product between 2 vectors
  119627. */
  119628. export class CrossBlock extends NodeMaterialBlock {
  119629. /**
  119630. * Creates a new CrossBlock
  119631. * @param name defines the block name
  119632. */
  119633. constructor(name: string);
  119634. /**
  119635. * Gets the current class name
  119636. * @returns the class name
  119637. */
  119638. getClassName(): string;
  119639. /**
  119640. * Gets the left operand input component
  119641. */
  119642. readonly left: NodeMaterialConnectionPoint;
  119643. /**
  119644. * Gets the right operand input component
  119645. */
  119646. readonly right: NodeMaterialConnectionPoint;
  119647. /**
  119648. * Gets the output component
  119649. */
  119650. readonly output: NodeMaterialConnectionPoint;
  119651. protected _buildBlock(state: NodeMaterialBuildState): this;
  119652. }
  119653. }
  119654. declare module BABYLON {
  119655. /**
  119656. * Block used to apply a dot product between 2 vectors
  119657. */
  119658. export class DotBlock extends NodeMaterialBlock {
  119659. /**
  119660. * Creates a new DotBlock
  119661. * @param name defines the block name
  119662. */
  119663. constructor(name: string);
  119664. /**
  119665. * Gets the current class name
  119666. * @returns the class name
  119667. */
  119668. getClassName(): string;
  119669. /**
  119670. * Gets the left operand input component
  119671. */
  119672. readonly left: NodeMaterialConnectionPoint;
  119673. /**
  119674. * Gets the right operand input component
  119675. */
  119676. readonly right: NodeMaterialConnectionPoint;
  119677. /**
  119678. * Gets the output component
  119679. */
  119680. readonly output: NodeMaterialConnectionPoint;
  119681. protected _buildBlock(state: NodeMaterialBuildState): this;
  119682. }
  119683. }
  119684. declare module BABYLON {
  119685. /**
  119686. * Block used to remap a float from a range to a new one
  119687. */
  119688. export class RemapBlock extends NodeMaterialBlock {
  119689. /**
  119690. * Gets or sets the source range
  119691. */
  119692. sourceRange: Vector2;
  119693. /**
  119694. * Gets or sets the target range
  119695. */
  119696. targetRange: Vector2;
  119697. /**
  119698. * Creates a new RemapBlock
  119699. * @param name defines the block name
  119700. */
  119701. constructor(name: string);
  119702. /**
  119703. * Gets the current class name
  119704. * @returns the class name
  119705. */
  119706. getClassName(): string;
  119707. /**
  119708. * Gets the input component
  119709. */
  119710. readonly input: NodeMaterialConnectionPoint;
  119711. /**
  119712. * Gets the source min input component
  119713. */
  119714. readonly sourceMin: NodeMaterialConnectionPoint;
  119715. /**
  119716. * Gets the source max input component
  119717. */
  119718. readonly sourceMax: NodeMaterialConnectionPoint;
  119719. /**
  119720. * Gets the target min input component
  119721. */
  119722. readonly targetMin: NodeMaterialConnectionPoint;
  119723. /**
  119724. * Gets the target max input component
  119725. */
  119726. readonly targetMax: NodeMaterialConnectionPoint;
  119727. /**
  119728. * Gets the output component
  119729. */
  119730. readonly output: NodeMaterialConnectionPoint;
  119731. protected _buildBlock(state: NodeMaterialBuildState): this;
  119732. protected _dumpPropertiesCode(): string;
  119733. serialize(): any;
  119734. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119735. }
  119736. }
  119737. declare module BABYLON {
  119738. /**
  119739. * Block used to normalize a vector
  119740. */
  119741. export class NormalizeBlock extends NodeMaterialBlock {
  119742. /**
  119743. * Creates a new NormalizeBlock
  119744. * @param name defines the block name
  119745. */
  119746. constructor(name: string);
  119747. /**
  119748. * Gets the current class name
  119749. * @returns the class name
  119750. */
  119751. getClassName(): string;
  119752. /**
  119753. * Gets the input component
  119754. */
  119755. readonly input: NodeMaterialConnectionPoint;
  119756. /**
  119757. * Gets the output component
  119758. */
  119759. readonly output: NodeMaterialConnectionPoint;
  119760. protected _buildBlock(state: NodeMaterialBuildState): this;
  119761. }
  119762. }
  119763. declare module BABYLON {
  119764. /**
  119765. * Operations supported by the Trigonometry block
  119766. */
  119767. export enum TrigonometryBlockOperations {
  119768. /** Cos */
  119769. Cos = 0,
  119770. /** Sin */
  119771. Sin = 1,
  119772. /** Abs */
  119773. Abs = 2,
  119774. /** Exp */
  119775. Exp = 3,
  119776. /** Exp2 */
  119777. Exp2 = 4,
  119778. /** Round */
  119779. Round = 5,
  119780. /** Floor */
  119781. Floor = 6,
  119782. /** Ceiling */
  119783. Ceiling = 7,
  119784. /** Square root */
  119785. Sqrt = 8
  119786. }
  119787. /**
  119788. * Block used to apply trigonometry operation to floats
  119789. */
  119790. export class TrigonometryBlock extends NodeMaterialBlock {
  119791. /**
  119792. * Gets or sets the operation applied by the block
  119793. */
  119794. operation: TrigonometryBlockOperations;
  119795. /**
  119796. * Creates a new TrigonometryBlock
  119797. * @param name defines the block name
  119798. */
  119799. constructor(name: string);
  119800. /**
  119801. * Gets the current class name
  119802. * @returns the class name
  119803. */
  119804. getClassName(): string;
  119805. /**
  119806. * Gets the input component
  119807. */
  119808. readonly input: NodeMaterialConnectionPoint;
  119809. /**
  119810. * Gets the output component
  119811. */
  119812. readonly output: NodeMaterialConnectionPoint;
  119813. protected _buildBlock(state: NodeMaterialBuildState): this;
  119814. serialize(): any;
  119815. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119816. }
  119817. }
  119818. declare module BABYLON {
  119819. /**
  119820. * Block used to create a Color3/4 out of individual inputs (one for each component)
  119821. */
  119822. export class ColorMergerBlock extends NodeMaterialBlock {
  119823. /**
  119824. * Create a new ColorMergerBlock
  119825. * @param name defines the block name
  119826. */
  119827. constructor(name: string);
  119828. /**
  119829. * Gets the current class name
  119830. * @returns the class name
  119831. */
  119832. getClassName(): string;
  119833. /**
  119834. * Gets the r component (input)
  119835. */
  119836. readonly r: NodeMaterialConnectionPoint;
  119837. /**
  119838. * Gets the g component (input)
  119839. */
  119840. readonly g: NodeMaterialConnectionPoint;
  119841. /**
  119842. * Gets the b component (input)
  119843. */
  119844. readonly b: NodeMaterialConnectionPoint;
  119845. /**
  119846. * Gets the a component (input)
  119847. */
  119848. readonly a: NodeMaterialConnectionPoint;
  119849. /**
  119850. * Gets the rgba component (output)
  119851. */
  119852. readonly rgba: NodeMaterialConnectionPoint;
  119853. /**
  119854. * Gets the rgb component (output)
  119855. */
  119856. readonly rgb: NodeMaterialConnectionPoint;
  119857. protected _buildBlock(state: NodeMaterialBuildState): this;
  119858. }
  119859. }
  119860. declare module BABYLON {
  119861. /**
  119862. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  119863. */
  119864. export class VectorMergerBlock extends NodeMaterialBlock {
  119865. /**
  119866. * Create a new VectorMergerBlock
  119867. * @param name defines the block name
  119868. */
  119869. constructor(name: string);
  119870. /**
  119871. * Gets the current class name
  119872. * @returns the class name
  119873. */
  119874. getClassName(): string;
  119875. /**
  119876. * Gets the x component (input)
  119877. */
  119878. readonly x: NodeMaterialConnectionPoint;
  119879. /**
  119880. * Gets the y component (input)
  119881. */
  119882. readonly y: NodeMaterialConnectionPoint;
  119883. /**
  119884. * Gets the z component (input)
  119885. */
  119886. readonly z: NodeMaterialConnectionPoint;
  119887. /**
  119888. * Gets the w component (input)
  119889. */
  119890. readonly w: NodeMaterialConnectionPoint;
  119891. /**
  119892. * Gets the xyzw component (output)
  119893. */
  119894. readonly xyzw: NodeMaterialConnectionPoint;
  119895. /**
  119896. * Gets the xyz component (output)
  119897. */
  119898. readonly xyz: NodeMaterialConnectionPoint;
  119899. /**
  119900. * Gets the xy component (output)
  119901. */
  119902. readonly xy: NodeMaterialConnectionPoint;
  119903. protected _buildBlock(state: NodeMaterialBuildState): this;
  119904. }
  119905. }
  119906. declare module BABYLON {
  119907. /**
  119908. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  119909. */
  119910. export class ColorSplitterBlock extends NodeMaterialBlock {
  119911. /**
  119912. * Create a new ColorSplitterBlock
  119913. * @param name defines the block name
  119914. */
  119915. constructor(name: string);
  119916. /**
  119917. * Gets the current class name
  119918. * @returns the class name
  119919. */
  119920. getClassName(): string;
  119921. /**
  119922. * Gets the rgba component (input)
  119923. */
  119924. readonly rgba: NodeMaterialConnectionPoint;
  119925. /**
  119926. * Gets the rgb component (input)
  119927. */
  119928. readonly rgbIn: NodeMaterialConnectionPoint;
  119929. /**
  119930. * Gets the rgb component (output)
  119931. */
  119932. readonly rgbOut: NodeMaterialConnectionPoint;
  119933. /**
  119934. * Gets the r component (output)
  119935. */
  119936. readonly r: NodeMaterialConnectionPoint;
  119937. /**
  119938. * Gets the g component (output)
  119939. */
  119940. readonly g: NodeMaterialConnectionPoint;
  119941. /**
  119942. * Gets the b component (output)
  119943. */
  119944. readonly b: NodeMaterialConnectionPoint;
  119945. /**
  119946. * Gets the a component (output)
  119947. */
  119948. readonly a: NodeMaterialConnectionPoint;
  119949. protected _inputRename(name: string): string;
  119950. protected _outputRename(name: string): string;
  119951. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119952. }
  119953. }
  119954. declare module BABYLON {
  119955. /**
  119956. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  119957. */
  119958. export class VectorSplitterBlock extends NodeMaterialBlock {
  119959. /**
  119960. * Create a new VectorSplitterBlock
  119961. * @param name defines the block name
  119962. */
  119963. constructor(name: string);
  119964. /**
  119965. * Gets the current class name
  119966. * @returns the class name
  119967. */
  119968. getClassName(): string;
  119969. /**
  119970. * Gets the xyzw component (input)
  119971. */
  119972. readonly xyzw: NodeMaterialConnectionPoint;
  119973. /**
  119974. * Gets the xyz component (input)
  119975. */
  119976. readonly xyzIn: NodeMaterialConnectionPoint;
  119977. /**
  119978. * Gets the xy component (input)
  119979. */
  119980. readonly xyIn: NodeMaterialConnectionPoint;
  119981. /**
  119982. * Gets the xyz component (output)
  119983. */
  119984. readonly xyzOut: NodeMaterialConnectionPoint;
  119985. /**
  119986. * Gets the xy component (output)
  119987. */
  119988. readonly xyOut: NodeMaterialConnectionPoint;
  119989. /**
  119990. * Gets the x component (output)
  119991. */
  119992. readonly x: NodeMaterialConnectionPoint;
  119993. /**
  119994. * Gets the y component (output)
  119995. */
  119996. readonly y: NodeMaterialConnectionPoint;
  119997. /**
  119998. * Gets the z component (output)
  119999. */
  120000. readonly z: NodeMaterialConnectionPoint;
  120001. /**
  120002. * Gets the w component (output)
  120003. */
  120004. readonly w: NodeMaterialConnectionPoint;
  120005. protected _inputRename(name: string): string;
  120006. protected _outputRename(name: string): string;
  120007. protected _buildBlock(state: NodeMaterialBuildState): this;
  120008. }
  120009. }
  120010. declare module BABYLON {
  120011. /**
  120012. * Block used to lerp 2 values
  120013. */
  120014. export class LerpBlock extends NodeMaterialBlock {
  120015. /**
  120016. * Creates a new LerpBlock
  120017. * @param name defines the block name
  120018. */
  120019. constructor(name: string);
  120020. /**
  120021. * Gets the current class name
  120022. * @returns the class name
  120023. */
  120024. getClassName(): string;
  120025. /**
  120026. * Gets the left operand input component
  120027. */
  120028. readonly left: NodeMaterialConnectionPoint;
  120029. /**
  120030. * Gets the right operand input component
  120031. */
  120032. readonly right: NodeMaterialConnectionPoint;
  120033. /**
  120034. * Gets the gradient operand input component
  120035. */
  120036. readonly gradient: NodeMaterialConnectionPoint;
  120037. /**
  120038. * Gets the output component
  120039. */
  120040. readonly output: NodeMaterialConnectionPoint;
  120041. protected _buildBlock(state: NodeMaterialBuildState): this;
  120042. }
  120043. }
  120044. declare module BABYLON {
  120045. /**
  120046. * Block used to divide 2 vectors
  120047. */
  120048. export class DivideBlock extends NodeMaterialBlock {
  120049. /**
  120050. * Creates a new DivideBlock
  120051. * @param name defines the block name
  120052. */
  120053. constructor(name: string);
  120054. /**
  120055. * Gets the current class name
  120056. * @returns the class name
  120057. */
  120058. getClassName(): string;
  120059. /**
  120060. * Gets the left operand input component
  120061. */
  120062. readonly left: NodeMaterialConnectionPoint;
  120063. /**
  120064. * Gets the right operand input component
  120065. */
  120066. readonly right: NodeMaterialConnectionPoint;
  120067. /**
  120068. * Gets the output component
  120069. */
  120070. readonly output: NodeMaterialConnectionPoint;
  120071. protected _buildBlock(state: NodeMaterialBuildState): this;
  120072. }
  120073. }
  120074. declare module BABYLON {
  120075. /**
  120076. * Block used to subtract 2 vectors
  120077. */
  120078. export class SubtractBlock extends NodeMaterialBlock {
  120079. /**
  120080. * Creates a new SubtractBlock
  120081. * @param name defines the block name
  120082. */
  120083. constructor(name: string);
  120084. /**
  120085. * Gets the current class name
  120086. * @returns the class name
  120087. */
  120088. getClassName(): string;
  120089. /**
  120090. * Gets the left operand input component
  120091. */
  120092. readonly left: NodeMaterialConnectionPoint;
  120093. /**
  120094. * Gets the right operand input component
  120095. */
  120096. readonly right: NodeMaterialConnectionPoint;
  120097. /**
  120098. * Gets the output component
  120099. */
  120100. readonly output: NodeMaterialConnectionPoint;
  120101. protected _buildBlock(state: NodeMaterialBuildState): this;
  120102. }
  120103. }
  120104. declare module BABYLON {
  120105. /**
  120106. * Block used to step a value
  120107. */
  120108. export class StepBlock extends NodeMaterialBlock {
  120109. /**
  120110. * Creates a new AddBlock
  120111. * @param name defines the block name
  120112. */
  120113. constructor(name: string);
  120114. /**
  120115. * Gets the current class name
  120116. * @returns the class name
  120117. */
  120118. getClassName(): string;
  120119. /**
  120120. * Gets the value operand input component
  120121. */
  120122. readonly value: NodeMaterialConnectionPoint;
  120123. /**
  120124. * Gets the edge operand input component
  120125. */
  120126. readonly edge: NodeMaterialConnectionPoint;
  120127. /**
  120128. * Gets the output component
  120129. */
  120130. readonly output: NodeMaterialConnectionPoint;
  120131. protected _buildBlock(state: NodeMaterialBuildState): this;
  120132. }
  120133. }
  120134. declare module BABYLON {
  120135. /**
  120136. * Block used to get the opposite (1 - x) of a value
  120137. */
  120138. export class OneMinusBlock extends NodeMaterialBlock {
  120139. /**
  120140. * Creates a new OneMinusBlock
  120141. * @param name defines the block name
  120142. */
  120143. constructor(name: string);
  120144. /**
  120145. * Gets the current class name
  120146. * @returns the class name
  120147. */
  120148. getClassName(): string;
  120149. /**
  120150. * Gets the input component
  120151. */
  120152. readonly input: NodeMaterialConnectionPoint;
  120153. /**
  120154. * Gets the output component
  120155. */
  120156. readonly output: NodeMaterialConnectionPoint;
  120157. protected _buildBlock(state: NodeMaterialBuildState): this;
  120158. }
  120159. }
  120160. declare module BABYLON {
  120161. /**
  120162. * Block used to get the view direction
  120163. */
  120164. export class ViewDirectionBlock extends NodeMaterialBlock {
  120165. /**
  120166. * Creates a new ViewDirectionBlock
  120167. * @param name defines the block name
  120168. */
  120169. constructor(name: string);
  120170. /**
  120171. * Gets the current class name
  120172. * @returns the class name
  120173. */
  120174. getClassName(): string;
  120175. /**
  120176. * Gets the world position component
  120177. */
  120178. readonly worldPosition: NodeMaterialConnectionPoint;
  120179. /**
  120180. * Gets the camera position component
  120181. */
  120182. readonly cameraPosition: NodeMaterialConnectionPoint;
  120183. /**
  120184. * Gets the output component
  120185. */
  120186. readonly output: NodeMaterialConnectionPoint;
  120187. autoConfigure(material: NodeMaterial): void;
  120188. protected _buildBlock(state: NodeMaterialBuildState): this;
  120189. }
  120190. }
  120191. declare module BABYLON {
  120192. /**
  120193. * Block used to compute fresnel value
  120194. */
  120195. export class FresnelBlock extends NodeMaterialBlock {
  120196. /**
  120197. * Create a new FresnelBlock
  120198. * @param name defines the block name
  120199. */
  120200. constructor(name: string);
  120201. /**
  120202. * Gets the current class name
  120203. * @returns the class name
  120204. */
  120205. getClassName(): string;
  120206. /**
  120207. * Gets the world normal input component
  120208. */
  120209. readonly worldNormal: NodeMaterialConnectionPoint;
  120210. /**
  120211. * Gets the view direction input component
  120212. */
  120213. readonly viewDirection: NodeMaterialConnectionPoint;
  120214. /**
  120215. * Gets the bias input component
  120216. */
  120217. readonly bias: NodeMaterialConnectionPoint;
  120218. /**
  120219. * Gets the camera (or eye) position component
  120220. */
  120221. readonly power: NodeMaterialConnectionPoint;
  120222. /**
  120223. * Gets the fresnel output component
  120224. */
  120225. readonly fresnel: NodeMaterialConnectionPoint;
  120226. autoConfigure(material: NodeMaterial): void;
  120227. protected _buildBlock(state: NodeMaterialBuildState): this;
  120228. }
  120229. }
  120230. declare module BABYLON {
  120231. /**
  120232. * Block used to get the max of 2 values
  120233. */
  120234. export class MaxBlock extends NodeMaterialBlock {
  120235. /**
  120236. * Creates a new MaxBlock
  120237. * @param name defines the block name
  120238. */
  120239. constructor(name: string);
  120240. /**
  120241. * Gets the current class name
  120242. * @returns the class name
  120243. */
  120244. getClassName(): string;
  120245. /**
  120246. * Gets the left operand input component
  120247. */
  120248. readonly left: NodeMaterialConnectionPoint;
  120249. /**
  120250. * Gets the right operand input component
  120251. */
  120252. readonly right: NodeMaterialConnectionPoint;
  120253. /**
  120254. * Gets the output component
  120255. */
  120256. readonly output: NodeMaterialConnectionPoint;
  120257. protected _buildBlock(state: NodeMaterialBuildState): this;
  120258. }
  120259. }
  120260. declare module BABYLON {
  120261. /**
  120262. * Block used to get the min of 2 values
  120263. */
  120264. export class MinBlock extends NodeMaterialBlock {
  120265. /**
  120266. * Creates a new MinBlock
  120267. * @param name defines the block name
  120268. */
  120269. constructor(name: string);
  120270. /**
  120271. * Gets the current class name
  120272. * @returns the class name
  120273. */
  120274. getClassName(): string;
  120275. /**
  120276. * Gets the left operand input component
  120277. */
  120278. readonly left: NodeMaterialConnectionPoint;
  120279. /**
  120280. * Gets the right operand input component
  120281. */
  120282. readonly right: NodeMaterialConnectionPoint;
  120283. /**
  120284. * Gets the output component
  120285. */
  120286. readonly output: NodeMaterialConnectionPoint;
  120287. protected _buildBlock(state: NodeMaterialBuildState): this;
  120288. }
  120289. }
  120290. declare module BABYLON {
  120291. /**
  120292. * Block used to get the distance between 2 values
  120293. */
  120294. export class DistanceBlock extends NodeMaterialBlock {
  120295. /**
  120296. * Creates a new DistanceBlock
  120297. * @param name defines the block name
  120298. */
  120299. constructor(name: string);
  120300. /**
  120301. * Gets the current class name
  120302. * @returns the class name
  120303. */
  120304. getClassName(): string;
  120305. /**
  120306. * Gets the left operand input component
  120307. */
  120308. readonly left: NodeMaterialConnectionPoint;
  120309. /**
  120310. * Gets the right operand input component
  120311. */
  120312. readonly right: NodeMaterialConnectionPoint;
  120313. /**
  120314. * Gets the output component
  120315. */
  120316. readonly output: NodeMaterialConnectionPoint;
  120317. protected _buildBlock(state: NodeMaterialBuildState): this;
  120318. }
  120319. }
  120320. declare module BABYLON {
  120321. /**
  120322. * Block used to get the length of a vector
  120323. */
  120324. export class LengthBlock extends NodeMaterialBlock {
  120325. /**
  120326. * Creates a new LengthBlock
  120327. * @param name defines the block name
  120328. */
  120329. constructor(name: string);
  120330. /**
  120331. * Gets the current class name
  120332. * @returns the class name
  120333. */
  120334. getClassName(): string;
  120335. /**
  120336. * Gets the value input component
  120337. */
  120338. readonly value: NodeMaterialConnectionPoint;
  120339. /**
  120340. * Gets the output component
  120341. */
  120342. readonly output: NodeMaterialConnectionPoint;
  120343. protected _buildBlock(state: NodeMaterialBuildState): this;
  120344. }
  120345. }
  120346. declare module BABYLON {
  120347. /**
  120348. * Block used to get negative version of a value (i.e. x * -1)
  120349. */
  120350. export class NegateBlock extends NodeMaterialBlock {
  120351. /**
  120352. * Creates a new NegateBlock
  120353. * @param name defines the block name
  120354. */
  120355. constructor(name: string);
  120356. /**
  120357. * Gets the current class name
  120358. * @returns the class name
  120359. */
  120360. getClassName(): string;
  120361. /**
  120362. * Gets the value input component
  120363. */
  120364. readonly value: NodeMaterialConnectionPoint;
  120365. /**
  120366. * Gets the output component
  120367. */
  120368. readonly output: NodeMaterialConnectionPoint;
  120369. protected _buildBlock(state: NodeMaterialBuildState): this;
  120370. }
  120371. }
  120372. declare module BABYLON {
  120373. /**
  120374. * Block used to get the value of the first parameter raised to the power of the second
  120375. */
  120376. export class PowBlock extends NodeMaterialBlock {
  120377. /**
  120378. * Creates a new PowBlock
  120379. * @param name defines the block name
  120380. */
  120381. constructor(name: string);
  120382. /**
  120383. * Gets the current class name
  120384. * @returns the class name
  120385. */
  120386. getClassName(): string;
  120387. /**
  120388. * Gets the value operand input component
  120389. */
  120390. readonly value: NodeMaterialConnectionPoint;
  120391. /**
  120392. * Gets the power operand input component
  120393. */
  120394. readonly power: NodeMaterialConnectionPoint;
  120395. /**
  120396. * Gets the output component
  120397. */
  120398. readonly output: NodeMaterialConnectionPoint;
  120399. protected _buildBlock(state: NodeMaterialBuildState): this;
  120400. }
  120401. }
  120402. declare module BABYLON {
  120403. /**
  120404. * Effect Render Options
  120405. */
  120406. export interface IEffectRendererOptions {
  120407. /**
  120408. * Defines the vertices positions.
  120409. */
  120410. positions?: number[];
  120411. /**
  120412. * Defines the indices.
  120413. */
  120414. indices?: number[];
  120415. }
  120416. /**
  120417. * Helper class to render one or more effects
  120418. */
  120419. export class EffectRenderer {
  120420. private engine;
  120421. private static _DefaultOptions;
  120422. private _vertexBuffers;
  120423. private _indexBuffer;
  120424. private _ringBufferIndex;
  120425. private _ringScreenBuffer;
  120426. private _fullscreenViewport;
  120427. private _getNextFrameBuffer;
  120428. /**
  120429. * Creates an effect renderer
  120430. * @param engine the engine to use for rendering
  120431. * @param options defines the options of the effect renderer
  120432. */
  120433. constructor(engine: Engine, options?: IEffectRendererOptions);
  120434. /**
  120435. * Sets the current viewport in normalized coordinates 0-1
  120436. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  120437. */
  120438. setViewport(viewport?: Viewport): void;
  120439. /**
  120440. * Binds the embedded attributes buffer to the effect.
  120441. * @param effect Defines the effect to bind the attributes for
  120442. */
  120443. bindBuffers(effect: Effect): void;
  120444. /**
  120445. * Sets the current effect wrapper to use during draw.
  120446. * The effect needs to be ready before calling this api.
  120447. * This also sets the default full screen position attribute.
  120448. * @param effectWrapper Defines the effect to draw with
  120449. */
  120450. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  120451. /**
  120452. * Draws a full screen quad.
  120453. */
  120454. draw(): void;
  120455. /**
  120456. * renders one or more effects to a specified texture
  120457. * @param effectWrappers list of effects to renderer
  120458. * @param outputTexture texture to draw to, if null it will render to the screen
  120459. */
  120460. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  120461. /**
  120462. * Disposes of the effect renderer
  120463. */
  120464. dispose(): void;
  120465. }
  120466. /**
  120467. * Options to create an EffectWrapper
  120468. */
  120469. interface EffectWrapperCreationOptions {
  120470. /**
  120471. * Engine to use to create the effect
  120472. */
  120473. engine: Engine;
  120474. /**
  120475. * Fragment shader for the effect
  120476. */
  120477. fragmentShader: string;
  120478. /**
  120479. * Vertex shader for the effect
  120480. */
  120481. vertexShader?: string;
  120482. /**
  120483. * Attributes to use in the shader
  120484. */
  120485. attributeNames?: Array<string>;
  120486. /**
  120487. * Uniforms to use in the shader
  120488. */
  120489. uniformNames?: Array<string>;
  120490. /**
  120491. * Texture sampler names to use in the shader
  120492. */
  120493. samplerNames?: Array<string>;
  120494. /**
  120495. * The friendly name of the effect displayed in Spector.
  120496. */
  120497. name?: string;
  120498. }
  120499. /**
  120500. * Wraps an effect to be used for rendering
  120501. */
  120502. export class EffectWrapper {
  120503. /**
  120504. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  120505. */
  120506. onApplyObservable: Observable<{}>;
  120507. /**
  120508. * The underlying effect
  120509. */
  120510. effect: Effect;
  120511. /**
  120512. * Creates an effect to be renderer
  120513. * @param creationOptions options to create the effect
  120514. */
  120515. constructor(creationOptions: EffectWrapperCreationOptions);
  120516. /**
  120517. * Disposes of the effect wrapper
  120518. */
  120519. dispose(): void;
  120520. }
  120521. }
  120522. declare module BABYLON {
  120523. /**
  120524. * Helper class to push actions to a pool of workers.
  120525. */
  120526. export class WorkerPool implements IDisposable {
  120527. private _workerInfos;
  120528. private _pendingActions;
  120529. /**
  120530. * Constructor
  120531. * @param workers Array of workers to use for actions
  120532. */
  120533. constructor(workers: Array<Worker>);
  120534. /**
  120535. * Terminates all workers and clears any pending actions.
  120536. */
  120537. dispose(): void;
  120538. /**
  120539. * Pushes an action to the worker pool. If all the workers are active, the action will be
  120540. * pended until a worker has completed its action.
  120541. * @param action The action to perform. Call onComplete when the action is complete.
  120542. */
  120543. push(action: (worker: Worker, onComplete: () => void) => void): void;
  120544. private _execute;
  120545. }
  120546. }
  120547. declare module BABYLON {
  120548. /**
  120549. * Configuration for Draco compression
  120550. */
  120551. export interface IDracoCompressionConfiguration {
  120552. /**
  120553. * Configuration for the decoder.
  120554. */
  120555. decoder: {
  120556. /**
  120557. * The url to the WebAssembly module.
  120558. */
  120559. wasmUrl?: string;
  120560. /**
  120561. * The url to the WebAssembly binary.
  120562. */
  120563. wasmBinaryUrl?: string;
  120564. /**
  120565. * The url to the fallback JavaScript module.
  120566. */
  120567. fallbackUrl?: string;
  120568. };
  120569. }
  120570. /**
  120571. * Draco compression (https://google.github.io/draco/)
  120572. *
  120573. * This class wraps the Draco module.
  120574. *
  120575. * **Encoder**
  120576. *
  120577. * The encoder is not currently implemented.
  120578. *
  120579. * **Decoder**
  120580. *
  120581. * 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.
  120582. *
  120583. * To update the configuration, use the following code:
  120584. * ```javascript
  120585. * DracoCompression.Configuration = {
  120586. * decoder: {
  120587. * wasmUrl: "<url to the WebAssembly library>",
  120588. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  120589. * fallbackUrl: "<url to the fallback JavaScript library>",
  120590. * }
  120591. * };
  120592. * ```
  120593. *
  120594. * 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.
  120595. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  120596. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  120597. *
  120598. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  120599. * ```javascript
  120600. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  120601. * ```
  120602. *
  120603. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  120604. */
  120605. export class DracoCompression implements IDisposable {
  120606. private _workerPoolPromise?;
  120607. private _decoderModulePromise?;
  120608. /**
  120609. * The configuration. Defaults to the following urls:
  120610. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  120611. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  120612. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  120613. */
  120614. static Configuration: IDracoCompressionConfiguration;
  120615. /**
  120616. * Returns true if the decoder configuration is available.
  120617. */
  120618. static readonly DecoderAvailable: boolean;
  120619. /**
  120620. * Default number of workers to create when creating the draco compression object.
  120621. */
  120622. static DefaultNumWorkers: number;
  120623. private static GetDefaultNumWorkers;
  120624. private static _Default;
  120625. /**
  120626. * Default instance for the draco compression object.
  120627. */
  120628. static readonly Default: DracoCompression;
  120629. /**
  120630. * Constructor
  120631. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  120632. */
  120633. constructor(numWorkers?: number);
  120634. /**
  120635. * Stop all async operations and release resources.
  120636. */
  120637. dispose(): void;
  120638. /**
  120639. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  120640. * @returns a promise that resolves when ready
  120641. */
  120642. whenReadyAsync(): Promise<void>;
  120643. /**
  120644. * Decode Draco compressed mesh data to vertex data.
  120645. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  120646. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  120647. * @returns A promise that resolves with the decoded vertex data
  120648. */
  120649. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  120650. [kind: string]: number;
  120651. }): Promise<VertexData>;
  120652. }
  120653. }
  120654. declare module BABYLON {
  120655. /**
  120656. * Class for building Constructive Solid Geometry
  120657. */
  120658. export class CSG {
  120659. private polygons;
  120660. /**
  120661. * The world matrix
  120662. */
  120663. matrix: Matrix;
  120664. /**
  120665. * Stores the position
  120666. */
  120667. position: Vector3;
  120668. /**
  120669. * Stores the rotation
  120670. */
  120671. rotation: Vector3;
  120672. /**
  120673. * Stores the rotation quaternion
  120674. */
  120675. rotationQuaternion: Nullable<Quaternion>;
  120676. /**
  120677. * Stores the scaling vector
  120678. */
  120679. scaling: Vector3;
  120680. /**
  120681. * Convert the Mesh to CSG
  120682. * @param mesh The Mesh to convert to CSG
  120683. * @returns A new CSG from the Mesh
  120684. */
  120685. static FromMesh(mesh: Mesh): CSG;
  120686. /**
  120687. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  120688. * @param polygons Polygons used to construct a CSG solid
  120689. */
  120690. private static FromPolygons;
  120691. /**
  120692. * Clones, or makes a deep copy, of the CSG
  120693. * @returns A new CSG
  120694. */
  120695. clone(): CSG;
  120696. /**
  120697. * Unions this CSG with another CSG
  120698. * @param csg The CSG to union against this CSG
  120699. * @returns The unioned CSG
  120700. */
  120701. union(csg: CSG): CSG;
  120702. /**
  120703. * Unions this CSG with another CSG in place
  120704. * @param csg The CSG to union against this CSG
  120705. */
  120706. unionInPlace(csg: CSG): void;
  120707. /**
  120708. * Subtracts this CSG with another CSG
  120709. * @param csg The CSG to subtract against this CSG
  120710. * @returns A new CSG
  120711. */
  120712. subtract(csg: CSG): CSG;
  120713. /**
  120714. * Subtracts this CSG with another CSG in place
  120715. * @param csg The CSG to subtact against this CSG
  120716. */
  120717. subtractInPlace(csg: CSG): void;
  120718. /**
  120719. * Intersect this CSG with another CSG
  120720. * @param csg The CSG to intersect against this CSG
  120721. * @returns A new CSG
  120722. */
  120723. intersect(csg: CSG): CSG;
  120724. /**
  120725. * Intersects this CSG with another CSG in place
  120726. * @param csg The CSG to intersect against this CSG
  120727. */
  120728. intersectInPlace(csg: CSG): void;
  120729. /**
  120730. * Return a new CSG solid with solid and empty space switched. This solid is
  120731. * not modified.
  120732. * @returns A new CSG solid with solid and empty space switched
  120733. */
  120734. inverse(): CSG;
  120735. /**
  120736. * Inverses the CSG in place
  120737. */
  120738. inverseInPlace(): void;
  120739. /**
  120740. * This is used to keep meshes transformations so they can be restored
  120741. * when we build back a Babylon Mesh
  120742. * NB : All CSG operations are performed in world coordinates
  120743. * @param csg The CSG to copy the transform attributes from
  120744. * @returns This CSG
  120745. */
  120746. copyTransformAttributes(csg: CSG): CSG;
  120747. /**
  120748. * Build Raw mesh from CSG
  120749. * Coordinates here are in world space
  120750. * @param name The name of the mesh geometry
  120751. * @param scene The Scene
  120752. * @param keepSubMeshes Specifies if the submeshes should be kept
  120753. * @returns A new Mesh
  120754. */
  120755. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120756. /**
  120757. * Build Mesh from CSG taking material and transforms into account
  120758. * @param name The name of the Mesh
  120759. * @param material The material of the Mesh
  120760. * @param scene The Scene
  120761. * @param keepSubMeshes Specifies if submeshes should be kept
  120762. * @returns The new Mesh
  120763. */
  120764. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120765. }
  120766. }
  120767. declare module BABYLON {
  120768. /**
  120769. * Class used to create a trail following a mesh
  120770. */
  120771. export class TrailMesh extends Mesh {
  120772. private _generator;
  120773. private _autoStart;
  120774. private _running;
  120775. private _diameter;
  120776. private _length;
  120777. private _sectionPolygonPointsCount;
  120778. private _sectionVectors;
  120779. private _sectionNormalVectors;
  120780. private _beforeRenderObserver;
  120781. /**
  120782. * @constructor
  120783. * @param name The value used by scene.getMeshByName() to do a lookup.
  120784. * @param generator The mesh to generate a trail.
  120785. * @param scene The scene to add this mesh to.
  120786. * @param diameter Diameter of trailing mesh. Default is 1.
  120787. * @param length Length of trailing mesh. Default is 60.
  120788. * @param autoStart Automatically start trailing mesh. Default true.
  120789. */
  120790. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  120791. /**
  120792. * "TrailMesh"
  120793. * @returns "TrailMesh"
  120794. */
  120795. getClassName(): string;
  120796. private _createMesh;
  120797. /**
  120798. * Start trailing mesh.
  120799. */
  120800. start(): void;
  120801. /**
  120802. * Stop trailing mesh.
  120803. */
  120804. stop(): void;
  120805. /**
  120806. * Update trailing mesh geometry.
  120807. */
  120808. update(): void;
  120809. /**
  120810. * Returns a new TrailMesh object.
  120811. * @param name is a string, the name given to the new mesh
  120812. * @param newGenerator use new generator object for cloned trail mesh
  120813. * @returns a new mesh
  120814. */
  120815. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  120816. /**
  120817. * Serializes this trail mesh
  120818. * @param serializationObject object to write serialization to
  120819. */
  120820. serialize(serializationObject: any): void;
  120821. /**
  120822. * Parses a serialized trail mesh
  120823. * @param parsedMesh the serialized mesh
  120824. * @param scene the scene to create the trail mesh in
  120825. * @returns the created trail mesh
  120826. */
  120827. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  120828. }
  120829. }
  120830. declare module BABYLON {
  120831. /**
  120832. * Class containing static functions to help procedurally build meshes
  120833. */
  120834. export class TiledBoxBuilder {
  120835. /**
  120836. * Creates a box mesh
  120837. * 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)
  120838. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120842. * @param name defines the name of the mesh
  120843. * @param options defines the options used to create the mesh
  120844. * @param scene defines the hosting scene
  120845. * @returns the box mesh
  120846. */
  120847. static CreateTiledBox(name: string, options: {
  120848. pattern?: number;
  120849. width?: number;
  120850. height?: number;
  120851. depth?: number;
  120852. tileSize?: number;
  120853. tileWidth?: number;
  120854. tileHeight?: number;
  120855. alignHorizontal?: number;
  120856. alignVertical?: number;
  120857. faceUV?: Vector4[];
  120858. faceColors?: Color4[];
  120859. sideOrientation?: number;
  120860. updatable?: boolean;
  120861. }, scene?: Nullable<Scene>): Mesh;
  120862. }
  120863. }
  120864. declare module BABYLON {
  120865. /**
  120866. * Class containing static functions to help procedurally build meshes
  120867. */
  120868. export class TorusKnotBuilder {
  120869. /**
  120870. * Creates a torus knot mesh
  120871. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  120872. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  120873. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  120874. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  120875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120878. * @param name defines the name of the mesh
  120879. * @param options defines the options used to create the mesh
  120880. * @param scene defines the hosting scene
  120881. * @returns the torus knot mesh
  120882. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  120883. */
  120884. static CreateTorusKnot(name: string, options: {
  120885. radius?: number;
  120886. tube?: number;
  120887. radialSegments?: number;
  120888. tubularSegments?: number;
  120889. p?: number;
  120890. q?: number;
  120891. updatable?: boolean;
  120892. sideOrientation?: number;
  120893. frontUVs?: Vector4;
  120894. backUVs?: Vector4;
  120895. }, scene: any): Mesh;
  120896. }
  120897. }
  120898. declare module BABYLON {
  120899. /**
  120900. * Polygon
  120901. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  120902. */
  120903. export class Polygon {
  120904. /**
  120905. * Creates a rectangle
  120906. * @param xmin bottom X coord
  120907. * @param ymin bottom Y coord
  120908. * @param xmax top X coord
  120909. * @param ymax top Y coord
  120910. * @returns points that make the resulting rectation
  120911. */
  120912. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  120913. /**
  120914. * Creates a circle
  120915. * @param radius radius of circle
  120916. * @param cx scale in x
  120917. * @param cy scale in y
  120918. * @param numberOfSides number of sides that make up the circle
  120919. * @returns points that make the resulting circle
  120920. */
  120921. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  120922. /**
  120923. * Creates a polygon from input string
  120924. * @param input Input polygon data
  120925. * @returns the parsed points
  120926. */
  120927. static Parse(input: string): Vector2[];
  120928. /**
  120929. * Starts building a polygon from x and y coordinates
  120930. * @param x x coordinate
  120931. * @param y y coordinate
  120932. * @returns the started path2
  120933. */
  120934. static StartingAt(x: number, y: number): Path2;
  120935. }
  120936. /**
  120937. * Builds a polygon
  120938. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  120939. */
  120940. export class PolygonMeshBuilder {
  120941. private _points;
  120942. private _outlinepoints;
  120943. private _holes;
  120944. private _name;
  120945. private _scene;
  120946. private _epoints;
  120947. private _eholes;
  120948. private _addToepoint;
  120949. /**
  120950. * Babylon reference to the earcut plugin.
  120951. */
  120952. bjsEarcut: any;
  120953. /**
  120954. * Creates a PolygonMeshBuilder
  120955. * @param name name of the builder
  120956. * @param contours Path of the polygon
  120957. * @param scene scene to add to when creating the mesh
  120958. * @param earcutInjection can be used to inject your own earcut reference
  120959. */
  120960. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  120961. /**
  120962. * Adds a whole within the polygon
  120963. * @param hole Array of points defining the hole
  120964. * @returns this
  120965. */
  120966. addHole(hole: Vector2[]): PolygonMeshBuilder;
  120967. /**
  120968. * Creates the polygon
  120969. * @param updatable If the mesh should be updatable
  120970. * @param depth The depth of the mesh created
  120971. * @returns the created mesh
  120972. */
  120973. build(updatable?: boolean, depth?: number): Mesh;
  120974. /**
  120975. * Creates the polygon
  120976. * @param depth The depth of the mesh created
  120977. * @returns the created VertexData
  120978. */
  120979. buildVertexData(depth?: number): VertexData;
  120980. /**
  120981. * Adds a side to the polygon
  120982. * @param positions points that make the polygon
  120983. * @param normals normals of the polygon
  120984. * @param uvs uvs of the polygon
  120985. * @param indices indices of the polygon
  120986. * @param bounds bounds of the polygon
  120987. * @param points points of the polygon
  120988. * @param depth depth of the polygon
  120989. * @param flip flip of the polygon
  120990. */
  120991. private addSide;
  120992. }
  120993. }
  120994. declare module BABYLON {
  120995. /**
  120996. * Class containing static functions to help procedurally build meshes
  120997. */
  120998. export class PolygonBuilder {
  120999. /**
  121000. * Creates a polygon mesh
  121001. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121002. * * 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
  121003. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121006. * * Remember you can only change the shape positions, not their number when updating a polygon
  121007. * @param name defines the name of the mesh
  121008. * @param options defines the options used to create the mesh
  121009. * @param scene defines the hosting scene
  121010. * @param earcutInjection can be used to inject your own earcut reference
  121011. * @returns the polygon mesh
  121012. */
  121013. static CreatePolygon(name: string, options: {
  121014. shape: Vector3[];
  121015. holes?: Vector3[][];
  121016. depth?: number;
  121017. faceUV?: Vector4[];
  121018. faceColors?: Color4[];
  121019. updatable?: boolean;
  121020. sideOrientation?: number;
  121021. frontUVs?: Vector4;
  121022. backUVs?: Vector4;
  121023. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121024. /**
  121025. * Creates an extruded polygon mesh, with depth in the Y direction.
  121026. * * 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)
  121027. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121028. * @param name defines the name of the mesh
  121029. * @param options defines the options used to create the mesh
  121030. * @param scene defines the hosting scene
  121031. * @param earcutInjection can be used to inject your own earcut reference
  121032. * @returns the polygon mesh
  121033. */
  121034. static ExtrudePolygon(name: string, options: {
  121035. shape: Vector3[];
  121036. holes?: Vector3[][];
  121037. depth?: number;
  121038. faceUV?: Vector4[];
  121039. faceColors?: Color4[];
  121040. updatable?: boolean;
  121041. sideOrientation?: number;
  121042. frontUVs?: Vector4;
  121043. backUVs?: Vector4;
  121044. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121045. }
  121046. }
  121047. declare module BABYLON {
  121048. /**
  121049. * Class containing static functions to help procedurally build meshes
  121050. */
  121051. export class LatheBuilder {
  121052. /**
  121053. * Creates lathe mesh.
  121054. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121055. * * 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
  121056. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121057. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121058. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121059. * * 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
  121060. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121061. * * 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
  121062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121064. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121066. * @param name defines the name of the mesh
  121067. * @param options defines the options used to create the mesh
  121068. * @param scene defines the hosting scene
  121069. * @returns the lathe mesh
  121070. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121071. */
  121072. static CreateLathe(name: string, options: {
  121073. shape: Vector3[];
  121074. radius?: number;
  121075. tessellation?: number;
  121076. clip?: number;
  121077. arc?: number;
  121078. closed?: boolean;
  121079. updatable?: boolean;
  121080. sideOrientation?: number;
  121081. frontUVs?: Vector4;
  121082. backUVs?: Vector4;
  121083. cap?: number;
  121084. invertUV?: boolean;
  121085. }, scene?: Nullable<Scene>): Mesh;
  121086. }
  121087. }
  121088. declare module BABYLON {
  121089. /**
  121090. * Class containing static functions to help procedurally build meshes
  121091. */
  121092. export class TiledPlaneBuilder {
  121093. /**
  121094. * Creates a tiled plane mesh
  121095. * * The parameter `pattern` will, depending on value, do nothing or
  121096. * * * flip (reflect about central vertical) alternate tiles across and up
  121097. * * * flip every tile on alternate rows
  121098. * * * rotate (180 degs) alternate tiles across and up
  121099. * * * rotate every tile on alternate rows
  121100. * * * flip and rotate alternate tiles across and up
  121101. * * * flip and rotate every tile on alternate rows
  121102. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  121103. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  121104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121105. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121106. * * 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)
  121107. * * 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)
  121108. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121109. * @param name defines the name of the mesh
  121110. * @param options defines the options used to create the mesh
  121111. * @param scene defines the hosting scene
  121112. * @returns the box mesh
  121113. */
  121114. static CreateTiledPlane(name: string, options: {
  121115. pattern?: number;
  121116. tileSize?: number;
  121117. tileWidth?: number;
  121118. tileHeight?: number;
  121119. size?: number;
  121120. width?: number;
  121121. height?: number;
  121122. alignHorizontal?: number;
  121123. alignVertical?: number;
  121124. sideOrientation?: number;
  121125. frontUVs?: Vector4;
  121126. backUVs?: Vector4;
  121127. updatable?: boolean;
  121128. }, scene?: Nullable<Scene>): Mesh;
  121129. }
  121130. }
  121131. declare module BABYLON {
  121132. /**
  121133. * Class containing static functions to help procedurally build meshes
  121134. */
  121135. export class TubeBuilder {
  121136. /**
  121137. * Creates a tube mesh.
  121138. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121139. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121140. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121141. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121142. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121143. * * 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)
  121144. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121145. * * 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
  121146. * * 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
  121147. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121148. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121149. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121151. * @param name defines the name of the mesh
  121152. * @param options defines the options used to create the mesh
  121153. * @param scene defines the hosting scene
  121154. * @returns the tube mesh
  121155. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121156. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121157. */
  121158. static CreateTube(name: string, options: {
  121159. path: Vector3[];
  121160. radius?: number;
  121161. tessellation?: number;
  121162. radiusFunction?: {
  121163. (i: number, distance: number): number;
  121164. };
  121165. cap?: number;
  121166. arc?: number;
  121167. updatable?: boolean;
  121168. sideOrientation?: number;
  121169. frontUVs?: Vector4;
  121170. backUVs?: Vector4;
  121171. instance?: Mesh;
  121172. invertUV?: boolean;
  121173. }, scene?: Nullable<Scene>): Mesh;
  121174. }
  121175. }
  121176. declare module BABYLON {
  121177. /**
  121178. * Class containing static functions to help procedurally build meshes
  121179. */
  121180. export class IcoSphereBuilder {
  121181. /**
  121182. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121183. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121184. * * 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`)
  121185. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121186. * * 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
  121187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121190. * @param name defines the name of the mesh
  121191. * @param options defines the options used to create the mesh
  121192. * @param scene defines the hosting scene
  121193. * @returns the icosahedron mesh
  121194. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121195. */
  121196. static CreateIcoSphere(name: string, options: {
  121197. radius?: number;
  121198. radiusX?: number;
  121199. radiusY?: number;
  121200. radiusZ?: number;
  121201. flat?: boolean;
  121202. subdivisions?: number;
  121203. sideOrientation?: number;
  121204. frontUVs?: Vector4;
  121205. backUVs?: Vector4;
  121206. updatable?: boolean;
  121207. }, scene?: Nullable<Scene>): Mesh;
  121208. }
  121209. }
  121210. declare module BABYLON {
  121211. /**
  121212. * Class containing static functions to help procedurally build meshes
  121213. */
  121214. export class DecalBuilder {
  121215. /**
  121216. * Creates a decal mesh.
  121217. * 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
  121218. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121219. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121220. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121221. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121222. * @param name defines the name of the mesh
  121223. * @param sourceMesh defines the mesh where the decal must be applied
  121224. * @param options defines the options used to create the mesh
  121225. * @param scene defines the hosting scene
  121226. * @returns the decal mesh
  121227. * @see https://doc.babylonjs.com/how_to/decals
  121228. */
  121229. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121230. position?: Vector3;
  121231. normal?: Vector3;
  121232. size?: Vector3;
  121233. angle?: number;
  121234. }): Mesh;
  121235. }
  121236. }
  121237. declare module BABYLON {
  121238. /**
  121239. * Class containing static functions to help procedurally build meshes
  121240. */
  121241. export class MeshBuilder {
  121242. /**
  121243. * Creates a box mesh
  121244. * * The parameter `size` sets the size (float) of each box side (default 1)
  121245. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  121246. * * 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)
  121247. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121251. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121252. * @param name defines the name of the mesh
  121253. * @param options defines the options used to create the mesh
  121254. * @param scene defines the hosting scene
  121255. * @returns the box mesh
  121256. */
  121257. static CreateBox(name: string, options: {
  121258. size?: number;
  121259. width?: number;
  121260. height?: number;
  121261. depth?: number;
  121262. faceUV?: Vector4[];
  121263. faceColors?: Color4[];
  121264. sideOrientation?: number;
  121265. frontUVs?: Vector4;
  121266. backUVs?: Vector4;
  121267. updatable?: boolean;
  121268. }, scene?: Nullable<Scene>): Mesh;
  121269. /**
  121270. * Creates a tiled box mesh
  121271. * * faceTiles sets the pattern, tile size and number of tiles for a face
  121272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121273. * @param name defines the name of the mesh
  121274. * @param options defines the options used to create the mesh
  121275. * @param scene defines the hosting scene
  121276. * @returns the tiled box mesh
  121277. */
  121278. static CreateTiledBox(name: string, options: {
  121279. pattern?: number;
  121280. size?: number;
  121281. width?: number;
  121282. height?: number;
  121283. depth: number;
  121284. tileSize?: number;
  121285. tileWidth?: number;
  121286. tileHeight?: number;
  121287. faceUV?: Vector4[];
  121288. faceColors?: Color4[];
  121289. alignHorizontal?: number;
  121290. alignVertical?: number;
  121291. sideOrientation?: number;
  121292. updatable?: boolean;
  121293. }, scene?: Nullable<Scene>): Mesh;
  121294. /**
  121295. * Creates a sphere mesh
  121296. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  121297. * * 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`)
  121298. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  121299. * * 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
  121300. * * 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)
  121301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121302. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121304. * @param name defines the name of the mesh
  121305. * @param options defines the options used to create the mesh
  121306. * @param scene defines the hosting scene
  121307. * @returns the sphere mesh
  121308. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  121309. */
  121310. static CreateSphere(name: string, options: {
  121311. segments?: number;
  121312. diameter?: number;
  121313. diameterX?: number;
  121314. diameterY?: number;
  121315. diameterZ?: number;
  121316. arc?: number;
  121317. slice?: number;
  121318. sideOrientation?: number;
  121319. frontUVs?: Vector4;
  121320. backUVs?: Vector4;
  121321. updatable?: boolean;
  121322. }, scene?: Nullable<Scene>): Mesh;
  121323. /**
  121324. * Creates a plane polygonal mesh. By default, this is a disc
  121325. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  121326. * * 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
  121327. * * 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
  121328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121331. * @param name defines the name of the mesh
  121332. * @param options defines the options used to create the mesh
  121333. * @param scene defines the hosting scene
  121334. * @returns the plane polygonal mesh
  121335. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  121336. */
  121337. static CreateDisc(name: string, options: {
  121338. radius?: number;
  121339. tessellation?: number;
  121340. arc?: number;
  121341. updatable?: boolean;
  121342. sideOrientation?: number;
  121343. frontUVs?: Vector4;
  121344. backUVs?: Vector4;
  121345. }, scene?: Nullable<Scene>): Mesh;
  121346. /**
  121347. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121348. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121349. * * 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`)
  121350. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121351. * * 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
  121352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121355. * @param name defines the name of the mesh
  121356. * @param options defines the options used to create the mesh
  121357. * @param scene defines the hosting scene
  121358. * @returns the icosahedron mesh
  121359. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121360. */
  121361. static CreateIcoSphere(name: string, options: {
  121362. radius?: number;
  121363. radiusX?: number;
  121364. radiusY?: number;
  121365. radiusZ?: number;
  121366. flat?: boolean;
  121367. subdivisions?: number;
  121368. sideOrientation?: number;
  121369. frontUVs?: Vector4;
  121370. backUVs?: Vector4;
  121371. updatable?: boolean;
  121372. }, scene?: Nullable<Scene>): Mesh;
  121373. /**
  121374. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121375. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121376. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121377. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121378. * * 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
  121379. * * 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
  121380. * * 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
  121381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121383. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121384. * * 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
  121385. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121386. * * 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
  121387. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121389. * @param name defines the name of the mesh
  121390. * @param options defines the options used to create the mesh
  121391. * @param scene defines the hosting scene
  121392. * @returns the ribbon mesh
  121393. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121394. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121395. */
  121396. static CreateRibbon(name: string, options: {
  121397. pathArray: Vector3[][];
  121398. closeArray?: boolean;
  121399. closePath?: boolean;
  121400. offset?: number;
  121401. updatable?: boolean;
  121402. sideOrientation?: number;
  121403. frontUVs?: Vector4;
  121404. backUVs?: Vector4;
  121405. instance?: Mesh;
  121406. invertUV?: boolean;
  121407. uvs?: Vector2[];
  121408. colors?: Color4[];
  121409. }, scene?: Nullable<Scene>): Mesh;
  121410. /**
  121411. * Creates a cylinder or a cone mesh
  121412. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  121413. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  121414. * * 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.
  121415. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  121416. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  121417. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  121418. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  121419. * * 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).
  121420. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  121421. * * 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).
  121422. * * 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
  121423. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  121424. * * 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
  121425. * * 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.
  121426. * * If `enclose` is false, a ring surface is one element.
  121427. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  121428. * * 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
  121429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121432. * @param name defines the name of the mesh
  121433. * @param options defines the options used to create the mesh
  121434. * @param scene defines the hosting scene
  121435. * @returns the cylinder mesh
  121436. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  121437. */
  121438. static CreateCylinder(name: string, options: {
  121439. height?: number;
  121440. diameterTop?: number;
  121441. diameterBottom?: number;
  121442. diameter?: number;
  121443. tessellation?: number;
  121444. subdivisions?: number;
  121445. arc?: number;
  121446. faceColors?: Color4[];
  121447. faceUV?: Vector4[];
  121448. updatable?: boolean;
  121449. hasRings?: boolean;
  121450. enclose?: boolean;
  121451. cap?: number;
  121452. sideOrientation?: number;
  121453. frontUVs?: Vector4;
  121454. backUVs?: Vector4;
  121455. }, scene?: Nullable<Scene>): Mesh;
  121456. /**
  121457. * Creates a torus mesh
  121458. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  121459. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  121460. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  121461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121464. * @param name defines the name of the mesh
  121465. * @param options defines the options used to create the mesh
  121466. * @param scene defines the hosting scene
  121467. * @returns the torus mesh
  121468. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  121469. */
  121470. static CreateTorus(name: string, options: {
  121471. diameter?: number;
  121472. thickness?: number;
  121473. tessellation?: number;
  121474. updatable?: boolean;
  121475. sideOrientation?: number;
  121476. frontUVs?: Vector4;
  121477. backUVs?: Vector4;
  121478. }, scene?: Nullable<Scene>): Mesh;
  121479. /**
  121480. * Creates a torus knot mesh
  121481. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121482. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121483. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121484. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121488. * @param name defines the name of the mesh
  121489. * @param options defines the options used to create the mesh
  121490. * @param scene defines the hosting scene
  121491. * @returns the torus knot mesh
  121492. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121493. */
  121494. static CreateTorusKnot(name: string, options: {
  121495. radius?: number;
  121496. tube?: number;
  121497. radialSegments?: number;
  121498. tubularSegments?: number;
  121499. p?: number;
  121500. q?: number;
  121501. updatable?: boolean;
  121502. sideOrientation?: number;
  121503. frontUVs?: Vector4;
  121504. backUVs?: Vector4;
  121505. }, scene?: Nullable<Scene>): Mesh;
  121506. /**
  121507. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121508. * * 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
  121509. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121510. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121511. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121512. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121513. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121514. * * 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
  121515. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121517. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121518. * @param name defines the name of the new line system
  121519. * @param options defines the options used to create the line system
  121520. * @param scene defines the hosting scene
  121521. * @returns a new line system mesh
  121522. */
  121523. static CreateLineSystem(name: string, options: {
  121524. lines: Vector3[][];
  121525. updatable?: boolean;
  121526. instance?: Nullable<LinesMesh>;
  121527. colors?: Nullable<Color4[][]>;
  121528. useVertexAlpha?: boolean;
  121529. }, scene: Nullable<Scene>): LinesMesh;
  121530. /**
  121531. * Creates a line mesh
  121532. * 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
  121533. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121534. * * The parameter `points` is an array successive Vector3
  121535. * * 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
  121536. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121537. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121538. * * When updating an instance, remember that only point positions can change, not the number of points
  121539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121540. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121541. * @param name defines the name of the new line system
  121542. * @param options defines the options used to create the line system
  121543. * @param scene defines the hosting scene
  121544. * @returns a new line mesh
  121545. */
  121546. static CreateLines(name: string, options: {
  121547. points: Vector3[];
  121548. updatable?: boolean;
  121549. instance?: Nullable<LinesMesh>;
  121550. colors?: Color4[];
  121551. useVertexAlpha?: boolean;
  121552. }, scene?: Nullable<Scene>): LinesMesh;
  121553. /**
  121554. * Creates a dashed line mesh
  121555. * * 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
  121556. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121557. * * The parameter `points` is an array successive Vector3
  121558. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121559. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121560. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121561. * * 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
  121562. * * When updating an instance, remember that only point positions can change, not the number of points
  121563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121564. * @param name defines the name of the mesh
  121565. * @param options defines the options used to create the mesh
  121566. * @param scene defines the hosting scene
  121567. * @returns the dashed line mesh
  121568. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121569. */
  121570. static CreateDashedLines(name: string, options: {
  121571. points: Vector3[];
  121572. dashSize?: number;
  121573. gapSize?: number;
  121574. dashNb?: number;
  121575. updatable?: boolean;
  121576. instance?: LinesMesh;
  121577. }, scene?: Nullable<Scene>): LinesMesh;
  121578. /**
  121579. * 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.
  121580. * * 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.
  121581. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121582. * * 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.
  121583. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121584. * * 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
  121585. * * 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
  121586. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121589. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121591. * @param name defines the name of the mesh
  121592. * @param options defines the options used to create the mesh
  121593. * @param scene defines the hosting scene
  121594. * @returns the extruded shape mesh
  121595. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121596. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121597. */
  121598. static ExtrudeShape(name: string, options: {
  121599. shape: Vector3[];
  121600. path: Vector3[];
  121601. scale?: number;
  121602. rotation?: number;
  121603. cap?: number;
  121604. updatable?: boolean;
  121605. sideOrientation?: number;
  121606. frontUVs?: Vector4;
  121607. backUVs?: Vector4;
  121608. instance?: Mesh;
  121609. invertUV?: boolean;
  121610. }, scene?: Nullable<Scene>): Mesh;
  121611. /**
  121612. * Creates an custom extruded shape mesh.
  121613. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121614. * * 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.
  121615. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121616. * * 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
  121617. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121618. * * 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
  121619. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121620. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121621. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121622. * * 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
  121623. * * 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
  121624. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121626. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121627. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121629. * @param name defines the name of the mesh
  121630. * @param options defines the options used to create the mesh
  121631. * @param scene defines the hosting scene
  121632. * @returns the custom extruded shape mesh
  121633. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121634. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121636. */
  121637. static ExtrudeShapeCustom(name: string, options: {
  121638. shape: Vector3[];
  121639. path: Vector3[];
  121640. scaleFunction?: any;
  121641. rotationFunction?: any;
  121642. ribbonCloseArray?: boolean;
  121643. ribbonClosePath?: boolean;
  121644. cap?: number;
  121645. updatable?: boolean;
  121646. sideOrientation?: number;
  121647. frontUVs?: Vector4;
  121648. backUVs?: Vector4;
  121649. instance?: Mesh;
  121650. invertUV?: boolean;
  121651. }, scene?: Nullable<Scene>): Mesh;
  121652. /**
  121653. * Creates lathe mesh.
  121654. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121655. * * 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
  121656. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121657. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121658. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121659. * * 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
  121660. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121661. * * 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
  121662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121663. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121664. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121666. * @param name defines the name of the mesh
  121667. * @param options defines the options used to create the mesh
  121668. * @param scene defines the hosting scene
  121669. * @returns the lathe mesh
  121670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121671. */
  121672. static CreateLathe(name: string, options: {
  121673. shape: Vector3[];
  121674. radius?: number;
  121675. tessellation?: number;
  121676. clip?: number;
  121677. arc?: number;
  121678. closed?: boolean;
  121679. updatable?: boolean;
  121680. sideOrientation?: number;
  121681. frontUVs?: Vector4;
  121682. backUVs?: Vector4;
  121683. cap?: number;
  121684. invertUV?: boolean;
  121685. }, scene?: Nullable<Scene>): Mesh;
  121686. /**
  121687. * Creates a tiled plane mesh
  121688. * * You can set a limited pattern arrangement with the tiles
  121689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121692. * @param name defines the name of the mesh
  121693. * @param options defines the options used to create the mesh
  121694. * @param scene defines the hosting scene
  121695. * @returns the plane mesh
  121696. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121697. */
  121698. static CreateTiledPlane(name: string, options: {
  121699. pattern?: number;
  121700. tileSize?: number;
  121701. tileWidth?: number;
  121702. tileHeight?: number;
  121703. size?: number;
  121704. width?: number;
  121705. height?: number;
  121706. alignHorizontal?: number;
  121707. alignVertical?: number;
  121708. sideOrientation?: number;
  121709. frontUVs?: Vector4;
  121710. backUVs?: Vector4;
  121711. updatable?: boolean;
  121712. }, scene?: Nullable<Scene>): Mesh;
  121713. /**
  121714. * Creates a plane mesh
  121715. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  121716. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  121717. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  121718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121719. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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 plane mesh
  121725. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121726. */
  121727. static CreatePlane(name: string, options: {
  121728. size?: number;
  121729. width?: number;
  121730. height?: number;
  121731. sideOrientation?: number;
  121732. frontUVs?: Vector4;
  121733. backUVs?: Vector4;
  121734. updatable?: boolean;
  121735. sourcePlane?: Plane;
  121736. }, scene?: Nullable<Scene>): Mesh;
  121737. /**
  121738. * Creates a ground mesh
  121739. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  121740. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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 ground mesh
  121746. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  121747. */
  121748. static CreateGround(name: string, options: {
  121749. width?: number;
  121750. height?: number;
  121751. subdivisions?: number;
  121752. subdivisionsX?: number;
  121753. subdivisionsY?: number;
  121754. updatable?: boolean;
  121755. }, scene?: Nullable<Scene>): Mesh;
  121756. /**
  121757. * Creates a tiled ground mesh
  121758. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  121759. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  121760. * * 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
  121761. * * 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
  121762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121763. * @param name defines the name of the mesh
  121764. * @param options defines the options used to create the mesh
  121765. * @param scene defines the hosting scene
  121766. * @returns the tiled ground mesh
  121767. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  121768. */
  121769. static CreateTiledGround(name: string, options: {
  121770. xmin: number;
  121771. zmin: number;
  121772. xmax: number;
  121773. zmax: number;
  121774. subdivisions?: {
  121775. w: number;
  121776. h: number;
  121777. };
  121778. precision?: {
  121779. w: number;
  121780. h: number;
  121781. };
  121782. updatable?: boolean;
  121783. }, scene?: Nullable<Scene>): Mesh;
  121784. /**
  121785. * Creates a ground mesh from a height map
  121786. * * The parameter `url` sets the URL of the height map image resource.
  121787. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  121788. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  121789. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  121790. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  121791. * * 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.
  121792. * * 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).
  121793. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  121794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121795. * @param name defines the name of the mesh
  121796. * @param url defines the url to the height map
  121797. * @param options defines the options used to create the mesh
  121798. * @param scene defines the hosting scene
  121799. * @returns the ground mesh
  121800. * @see https://doc.babylonjs.com/babylon101/height_map
  121801. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  121802. */
  121803. static CreateGroundFromHeightMap(name: string, url: string, options: {
  121804. width?: number;
  121805. height?: number;
  121806. subdivisions?: number;
  121807. minHeight?: number;
  121808. maxHeight?: number;
  121809. colorFilter?: Color3;
  121810. alphaFilter?: number;
  121811. updatable?: boolean;
  121812. onReady?: (mesh: GroundMesh) => void;
  121813. }, scene?: Nullable<Scene>): GroundMesh;
  121814. /**
  121815. * Creates a polygon mesh
  121816. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121817. * * 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
  121818. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121821. * * Remember you can only change the shape positions, not their number when updating a polygon
  121822. * @param name defines the name of the mesh
  121823. * @param options defines the options used to create the mesh
  121824. * @param scene defines the hosting scene
  121825. * @param earcutInjection can be used to inject your own earcut reference
  121826. * @returns the polygon mesh
  121827. */
  121828. static CreatePolygon(name: string, options: {
  121829. shape: Vector3[];
  121830. holes?: Vector3[][];
  121831. depth?: number;
  121832. faceUV?: Vector4[];
  121833. faceColors?: Color4[];
  121834. updatable?: boolean;
  121835. sideOrientation?: number;
  121836. frontUVs?: Vector4;
  121837. backUVs?: Vector4;
  121838. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121839. /**
  121840. * Creates an extruded polygon mesh, with depth in the Y direction.
  121841. * * 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)
  121842. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121843. * @param name defines the name of the mesh
  121844. * @param options defines the options used to create the mesh
  121845. * @param scene defines the hosting scene
  121846. * @param earcutInjection can be used to inject your own earcut reference
  121847. * @returns the polygon mesh
  121848. */
  121849. static ExtrudePolygon(name: string, options: {
  121850. shape: Vector3[];
  121851. holes?: Vector3[][];
  121852. depth?: number;
  121853. faceUV?: Vector4[];
  121854. faceColors?: Color4[];
  121855. updatable?: boolean;
  121856. sideOrientation?: number;
  121857. frontUVs?: Vector4;
  121858. backUVs?: Vector4;
  121859. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121860. /**
  121861. * Creates a tube mesh.
  121862. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121863. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121864. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121865. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121866. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121867. * * 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)
  121868. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121869. * * 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
  121870. * * 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
  121871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121873. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121875. * @param name defines the name of the mesh
  121876. * @param options defines the options used to create the mesh
  121877. * @param scene defines the hosting scene
  121878. * @returns the tube mesh
  121879. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121880. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121881. */
  121882. static CreateTube(name: string, options: {
  121883. path: Vector3[];
  121884. radius?: number;
  121885. tessellation?: number;
  121886. radiusFunction?: {
  121887. (i: number, distance: number): number;
  121888. };
  121889. cap?: number;
  121890. arc?: number;
  121891. updatable?: boolean;
  121892. sideOrientation?: number;
  121893. frontUVs?: Vector4;
  121894. backUVs?: Vector4;
  121895. instance?: Mesh;
  121896. invertUV?: boolean;
  121897. }, scene?: Nullable<Scene>): Mesh;
  121898. /**
  121899. * Creates a polyhedron mesh
  121900. * * 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
  121901. * * The parameter `size` (positive float, default 1) sets the polygon size
  121902. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121903. * * 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`
  121904. * * 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
  121905. * * 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)`)
  121906. * * 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
  121907. * * 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
  121908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121911. * @param name defines the name of the mesh
  121912. * @param options defines the options used to create the mesh
  121913. * @param scene defines the hosting scene
  121914. * @returns the polyhedron mesh
  121915. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121916. */
  121917. static CreatePolyhedron(name: string, options: {
  121918. type?: number;
  121919. size?: number;
  121920. sizeX?: number;
  121921. sizeY?: number;
  121922. sizeZ?: number;
  121923. custom?: any;
  121924. faceUV?: Vector4[];
  121925. faceColors?: Color4[];
  121926. flat?: boolean;
  121927. updatable?: boolean;
  121928. sideOrientation?: number;
  121929. frontUVs?: Vector4;
  121930. backUVs?: Vector4;
  121931. }, scene?: Nullable<Scene>): Mesh;
  121932. /**
  121933. * Creates a decal mesh.
  121934. * 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
  121935. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121936. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121937. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121938. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121939. * @param name defines the name of the mesh
  121940. * @param sourceMesh defines the mesh where the decal must be applied
  121941. * @param options defines the options used to create the mesh
  121942. * @param scene defines the hosting scene
  121943. * @returns the decal mesh
  121944. * @see https://doc.babylonjs.com/how_to/decals
  121945. */
  121946. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121947. position?: Vector3;
  121948. normal?: Vector3;
  121949. size?: Vector3;
  121950. angle?: number;
  121951. }): Mesh;
  121952. }
  121953. }
  121954. declare module BABYLON {
  121955. /**
  121956. * A simplifier interface for future simplification implementations
  121957. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121958. */
  121959. export interface ISimplifier {
  121960. /**
  121961. * Simplification of a given mesh according to the given settings.
  121962. * Since this requires computation, it is assumed that the function runs async.
  121963. * @param settings The settings of the simplification, including quality and distance
  121964. * @param successCallback A callback that will be called after the mesh was simplified.
  121965. * @param errorCallback in case of an error, this callback will be called. optional.
  121966. */
  121967. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  121968. }
  121969. /**
  121970. * Expected simplification settings.
  121971. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  121972. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121973. */
  121974. export interface ISimplificationSettings {
  121975. /**
  121976. * Gets or sets the expected quality
  121977. */
  121978. quality: number;
  121979. /**
  121980. * Gets or sets the distance when this optimized version should be used
  121981. */
  121982. distance: number;
  121983. /**
  121984. * Gets an already optimized mesh
  121985. */
  121986. optimizeMesh?: boolean;
  121987. }
  121988. /**
  121989. * Class used to specify simplification options
  121990. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121991. */
  121992. export class SimplificationSettings implements ISimplificationSettings {
  121993. /** expected quality */
  121994. quality: number;
  121995. /** distance when this optimized version should be used */
  121996. distance: number;
  121997. /** already optimized mesh */
  121998. optimizeMesh?: boolean | undefined;
  121999. /**
  122000. * Creates a SimplificationSettings
  122001. * @param quality expected quality
  122002. * @param distance distance when this optimized version should be used
  122003. * @param optimizeMesh already optimized mesh
  122004. */
  122005. constructor(
  122006. /** expected quality */
  122007. quality: number,
  122008. /** distance when this optimized version should be used */
  122009. distance: number,
  122010. /** already optimized mesh */
  122011. optimizeMesh?: boolean | undefined);
  122012. }
  122013. /**
  122014. * Interface used to define a simplification task
  122015. */
  122016. export interface ISimplificationTask {
  122017. /**
  122018. * Array of settings
  122019. */
  122020. settings: Array<ISimplificationSettings>;
  122021. /**
  122022. * Simplification type
  122023. */
  122024. simplificationType: SimplificationType;
  122025. /**
  122026. * Mesh to simplify
  122027. */
  122028. mesh: Mesh;
  122029. /**
  122030. * Callback called on success
  122031. */
  122032. successCallback?: () => void;
  122033. /**
  122034. * Defines if parallel processing can be used
  122035. */
  122036. parallelProcessing: boolean;
  122037. }
  122038. /**
  122039. * Queue used to order the simplification tasks
  122040. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122041. */
  122042. export class SimplificationQueue {
  122043. private _simplificationArray;
  122044. /**
  122045. * Gets a boolean indicating that the process is still running
  122046. */
  122047. running: boolean;
  122048. /**
  122049. * Creates a new queue
  122050. */
  122051. constructor();
  122052. /**
  122053. * Adds a new simplification task
  122054. * @param task defines a task to add
  122055. */
  122056. addTask(task: ISimplificationTask): void;
  122057. /**
  122058. * Execute next task
  122059. */
  122060. executeNext(): void;
  122061. /**
  122062. * Execute a simplification task
  122063. * @param task defines the task to run
  122064. */
  122065. runSimplification(task: ISimplificationTask): void;
  122066. private getSimplifier;
  122067. }
  122068. /**
  122069. * The implemented types of simplification
  122070. * At the moment only Quadratic Error Decimation is implemented
  122071. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122072. */
  122073. export enum SimplificationType {
  122074. /** Quadratic error decimation */
  122075. QUADRATIC = 0
  122076. }
  122077. }
  122078. declare module BABYLON {
  122079. interface Scene {
  122080. /** @hidden (Backing field) */
  122081. _simplificationQueue: SimplificationQueue;
  122082. /**
  122083. * Gets or sets the simplification queue attached to the scene
  122084. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122085. */
  122086. simplificationQueue: SimplificationQueue;
  122087. }
  122088. interface Mesh {
  122089. /**
  122090. * Simplify the mesh according to the given array of settings.
  122091. * Function will return immediately and will simplify async
  122092. * @param settings a collection of simplification settings
  122093. * @param parallelProcessing should all levels calculate parallel or one after the other
  122094. * @param simplificationType the type of simplification to run
  122095. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  122096. * @returns the current mesh
  122097. */
  122098. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  122099. }
  122100. /**
  122101. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  122102. * created in a scene
  122103. */
  122104. export class SimplicationQueueSceneComponent implements ISceneComponent {
  122105. /**
  122106. * The component name helpfull to identify the component in the list of scene components.
  122107. */
  122108. readonly name: string;
  122109. /**
  122110. * The scene the component belongs to.
  122111. */
  122112. scene: Scene;
  122113. /**
  122114. * Creates a new instance of the component for the given scene
  122115. * @param scene Defines the scene to register the component in
  122116. */
  122117. constructor(scene: Scene);
  122118. /**
  122119. * Registers the component in a given scene
  122120. */
  122121. register(): void;
  122122. /**
  122123. * Rebuilds the elements related to this component in case of
  122124. * context lost for instance.
  122125. */
  122126. rebuild(): void;
  122127. /**
  122128. * Disposes the component and the associated ressources
  122129. */
  122130. dispose(): void;
  122131. private _beforeCameraUpdate;
  122132. }
  122133. }
  122134. declare module BABYLON {
  122135. /**
  122136. * Navigation plugin interface to add navigation constrained by a navigation mesh
  122137. */
  122138. export interface INavigationEnginePlugin {
  122139. /**
  122140. * plugin name
  122141. */
  122142. name: string;
  122143. /**
  122144. * Creates a navigation mesh
  122145. * @param meshes array of all the geometry used to compute the navigatio mesh
  122146. * @param parameters bunch of parameters used to filter geometry
  122147. */
  122148. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122149. /**
  122150. * Create a navigation mesh debug mesh
  122151. * @param scene is where the mesh will be added
  122152. * @returns debug display mesh
  122153. */
  122154. createDebugNavMesh(scene: Scene): Mesh;
  122155. /**
  122156. * Get a navigation mesh constrained position, closest to the parameter position
  122157. * @param position world position
  122158. * @returns the closest point to position constrained by the navigation mesh
  122159. */
  122160. getClosestPoint(position: Vector3): Vector3;
  122161. /**
  122162. * Get a navigation mesh constrained position, within a particular radius
  122163. * @param position world position
  122164. * @param maxRadius the maximum distance to the constrained world position
  122165. * @returns the closest point to position constrained by the navigation mesh
  122166. */
  122167. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122168. /**
  122169. * Compute the final position from a segment made of destination-position
  122170. * @param position world position
  122171. * @param destination world position
  122172. * @returns the resulting point along the navmesh
  122173. */
  122174. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122175. /**
  122176. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122177. * @param start world position
  122178. * @param end world position
  122179. * @returns array containing world position composing the path
  122180. */
  122181. computePath(start: Vector3, end: Vector3): Vector3[];
  122182. /**
  122183. * If this plugin is supported
  122184. * @returns true if plugin is supported
  122185. */
  122186. isSupported(): boolean;
  122187. /**
  122188. * Create a new Crowd so you can add agents
  122189. * @param maxAgents the maximum agent count in the crowd
  122190. * @param maxAgentRadius the maximum radius an agent can have
  122191. * @param scene to attach the crowd to
  122192. * @returns the crowd you can add agents to
  122193. */
  122194. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122195. /**
  122196. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122197. * The queries will try to find a solution within those bounds
  122198. * default is (1,1,1)
  122199. * @param extent x,y,z value that define the extent around the queries point of reference
  122200. */
  122201. setDefaultQueryExtent(extent: Vector3): void;
  122202. /**
  122203. * Get the Bounding box extent specified by setDefaultQueryExtent
  122204. * @returns the box extent values
  122205. */
  122206. getDefaultQueryExtent(): Vector3;
  122207. /**
  122208. * Release all resources
  122209. */
  122210. dispose(): void;
  122211. }
  122212. /**
  122213. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  122214. */
  122215. export interface ICrowd {
  122216. /**
  122217. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122218. * You can attach anything to that node. The node position is updated in the scene update tick.
  122219. * @param pos world position that will be constrained by the navigation mesh
  122220. * @param parameters agent parameters
  122221. * @param transform hooked to the agent that will be update by the scene
  122222. * @returns agent index
  122223. */
  122224. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122225. /**
  122226. * Returns the agent position in world space
  122227. * @param index agent index returned by addAgent
  122228. * @returns world space position
  122229. */
  122230. getAgentPosition(index: number): Vector3;
  122231. /**
  122232. * Gets the agent velocity in world space
  122233. * @param index agent index returned by addAgent
  122234. * @returns world space velocity
  122235. */
  122236. getAgentVelocity(index: number): Vector3;
  122237. /**
  122238. * remove a particular agent previously created
  122239. * @param index agent index returned by addAgent
  122240. */
  122241. removeAgent(index: number): void;
  122242. /**
  122243. * get the list of all agents attached to this crowd
  122244. * @returns list of agent indices
  122245. */
  122246. getAgents(): number[];
  122247. /**
  122248. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122249. * @param deltaTime in seconds
  122250. */
  122251. update(deltaTime: number): void;
  122252. /**
  122253. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122254. * @param index agent index returned by addAgent
  122255. * @param destination targeted world position
  122256. */
  122257. agentGoto(index: number, destination: Vector3): void;
  122258. /**
  122259. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122260. * The queries will try to find a solution within those bounds
  122261. * default is (1,1,1)
  122262. * @param extent x,y,z value that define the extent around the queries point of reference
  122263. */
  122264. setDefaultQueryExtent(extent: Vector3): void;
  122265. /**
  122266. * Get the Bounding box extent specified by setDefaultQueryExtent
  122267. * @returns the box extent values
  122268. */
  122269. getDefaultQueryExtent(): Vector3;
  122270. /**
  122271. * Release all resources
  122272. */
  122273. dispose(): void;
  122274. }
  122275. /**
  122276. * Configures an agent
  122277. */
  122278. export interface IAgentParameters {
  122279. /**
  122280. * Agent radius. [Limit: >= 0]
  122281. */
  122282. radius: number;
  122283. /**
  122284. * Agent height. [Limit: > 0]
  122285. */
  122286. height: number;
  122287. /**
  122288. * Maximum allowed acceleration. [Limit: >= 0]
  122289. */
  122290. maxAcceleration: number;
  122291. /**
  122292. * Maximum allowed speed. [Limit: >= 0]
  122293. */
  122294. maxSpeed: number;
  122295. /**
  122296. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  122297. */
  122298. collisionQueryRange: number;
  122299. /**
  122300. * The path visibility optimization range. [Limit: > 0]
  122301. */
  122302. pathOptimizationRange: number;
  122303. /**
  122304. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  122305. */
  122306. separationWeight: number;
  122307. }
  122308. /**
  122309. * Configures the navigation mesh creation
  122310. */
  122311. export interface INavMeshParameters {
  122312. /**
  122313. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  122314. */
  122315. cs: number;
  122316. /**
  122317. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  122318. */
  122319. ch: number;
  122320. /**
  122321. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  122322. */
  122323. walkableSlopeAngle: number;
  122324. /**
  122325. * Minimum floor to 'ceiling' height that will still allow the floor area to
  122326. * be considered walkable. [Limit: >= 3] [Units: vx]
  122327. */
  122328. walkableHeight: number;
  122329. /**
  122330. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  122331. */
  122332. walkableClimb: number;
  122333. /**
  122334. * The distance to erode/shrink the walkable area of the heightfield away from
  122335. * obstructions. [Limit: >=0] [Units: vx]
  122336. */
  122337. walkableRadius: number;
  122338. /**
  122339. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  122340. */
  122341. maxEdgeLen: number;
  122342. /**
  122343. * The maximum distance a simplfied contour's border edges should deviate
  122344. * the original raw contour. [Limit: >=0] [Units: vx]
  122345. */
  122346. maxSimplificationError: number;
  122347. /**
  122348. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  122349. */
  122350. minRegionArea: number;
  122351. /**
  122352. * Any regions with a span count smaller than this value will, if possible,
  122353. * be merged with larger regions. [Limit: >=0] [Units: vx]
  122354. */
  122355. mergeRegionArea: number;
  122356. /**
  122357. * The maximum number of vertices allowed for polygons generated during the
  122358. * contour to polygon conversion process. [Limit: >= 3]
  122359. */
  122360. maxVertsPerPoly: number;
  122361. /**
  122362. * Sets the sampling distance to use when generating the detail mesh.
  122363. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  122364. */
  122365. detailSampleDist: number;
  122366. /**
  122367. * The maximum distance the detail mesh surface should deviate from heightfield
  122368. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  122369. */
  122370. detailSampleMaxError: number;
  122371. }
  122372. }
  122373. declare module BABYLON {
  122374. /**
  122375. * RecastJS navigation plugin
  122376. */
  122377. export class RecastJSPlugin implements INavigationEnginePlugin {
  122378. /**
  122379. * Reference to the Recast library
  122380. */
  122381. bjsRECAST: any;
  122382. /**
  122383. * plugin name
  122384. */
  122385. name: string;
  122386. /**
  122387. * the first navmesh created. We might extend this to support multiple navmeshes
  122388. */
  122389. navMesh: any;
  122390. /**
  122391. * Initializes the recastJS plugin
  122392. * @param recastInjection can be used to inject your own recast reference
  122393. */
  122394. constructor(recastInjection?: any);
  122395. /**
  122396. * Creates a navigation mesh
  122397. * @param meshes array of all the geometry used to compute the navigatio mesh
  122398. * @param parameters bunch of parameters used to filter geometry
  122399. */
  122400. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122401. /**
  122402. * Create a navigation mesh debug mesh
  122403. * @param scene is where the mesh will be added
  122404. * @returns debug display mesh
  122405. */
  122406. createDebugNavMesh(scene: Scene): Mesh;
  122407. /**
  122408. * Get a navigation mesh constrained position, closest to the parameter position
  122409. * @param position world position
  122410. * @returns the closest point to position constrained by the navigation mesh
  122411. */
  122412. getClosestPoint(position: Vector3): Vector3;
  122413. /**
  122414. * Get a navigation mesh constrained position, within a particular radius
  122415. * @param position world position
  122416. * @param maxRadius the maximum distance to the constrained world position
  122417. * @returns the closest point to position constrained by the navigation mesh
  122418. */
  122419. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122420. /**
  122421. * Compute the final position from a segment made of destination-position
  122422. * @param position world position
  122423. * @param destination world position
  122424. * @returns the resulting point along the navmesh
  122425. */
  122426. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122427. /**
  122428. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122429. * @param start world position
  122430. * @param end world position
  122431. * @returns array containing world position composing the path
  122432. */
  122433. computePath(start: Vector3, end: Vector3): Vector3[];
  122434. /**
  122435. * Create a new Crowd so you can add agents
  122436. * @param maxAgents the maximum agent count in the crowd
  122437. * @param maxAgentRadius the maximum radius an agent can have
  122438. * @param scene to attach the crowd to
  122439. * @returns the crowd you can add agents to
  122440. */
  122441. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122442. /**
  122443. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122444. * The queries will try to find a solution within those bounds
  122445. * default is (1,1,1)
  122446. * @param extent x,y,z value that define the extent around the queries point of reference
  122447. */
  122448. setDefaultQueryExtent(extent: Vector3): void;
  122449. /**
  122450. * Get the Bounding box extent specified by setDefaultQueryExtent
  122451. * @returns the box extent values
  122452. */
  122453. getDefaultQueryExtent(): Vector3;
  122454. /**
  122455. * Disposes
  122456. */
  122457. dispose(): void;
  122458. /**
  122459. * If this plugin is supported
  122460. * @returns true if plugin is supported
  122461. */
  122462. isSupported(): boolean;
  122463. }
  122464. /**
  122465. * Recast detour crowd implementation
  122466. */
  122467. export class RecastJSCrowd implements ICrowd {
  122468. /**
  122469. * Recast/detour plugin
  122470. */
  122471. bjsRECASTPlugin: RecastJSPlugin;
  122472. /**
  122473. * Link to the detour crowd
  122474. */
  122475. recastCrowd: any;
  122476. /**
  122477. * One transform per agent
  122478. */
  122479. transforms: TransformNode[];
  122480. /**
  122481. * All agents created
  122482. */
  122483. agents: number[];
  122484. /**
  122485. * Link to the scene is kept to unregister the crowd from the scene
  122486. */
  122487. private _scene;
  122488. /**
  122489. * Observer for crowd updates
  122490. */
  122491. private _onBeforeAnimationsObserver;
  122492. /**
  122493. * Constructor
  122494. * @param plugin recastJS plugin
  122495. * @param maxAgents the maximum agent count in the crowd
  122496. * @param maxAgentRadius the maximum radius an agent can have
  122497. * @param scene to attach the crowd to
  122498. * @returns the crowd you can add agents to
  122499. */
  122500. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  122501. /**
  122502. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122503. * You can attach anything to that node. The node position is updated in the scene update tick.
  122504. * @param pos world position that will be constrained by the navigation mesh
  122505. * @param parameters agent parameters
  122506. * @param transform hooked to the agent that will be update by the scene
  122507. * @returns agent index
  122508. */
  122509. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122510. /**
  122511. * Returns the agent position in world space
  122512. * @param index agent index returned by addAgent
  122513. * @returns world space position
  122514. */
  122515. getAgentPosition(index: number): Vector3;
  122516. /**
  122517. * Returns the agent velocity in world space
  122518. * @param index agent index returned by addAgent
  122519. * @returns world space velocity
  122520. */
  122521. getAgentVelocity(index: number): Vector3;
  122522. /**
  122523. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122524. * @param index agent index returned by addAgent
  122525. * @param destination targeted world position
  122526. */
  122527. agentGoto(index: number, destination: Vector3): void;
  122528. /**
  122529. * remove a particular agent previously created
  122530. * @param index agent index returned by addAgent
  122531. */
  122532. removeAgent(index: number): void;
  122533. /**
  122534. * get the list of all agents attached to this crowd
  122535. * @returns list of agent indices
  122536. */
  122537. getAgents(): number[];
  122538. /**
  122539. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122540. * @param deltaTime in seconds
  122541. */
  122542. update(deltaTime: number): void;
  122543. /**
  122544. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122545. * The queries will try to find a solution within those bounds
  122546. * default is (1,1,1)
  122547. * @param extent x,y,z value that define the extent around the queries point of reference
  122548. */
  122549. setDefaultQueryExtent(extent: Vector3): void;
  122550. /**
  122551. * Get the Bounding box extent specified by setDefaultQueryExtent
  122552. * @returns the box extent values
  122553. */
  122554. getDefaultQueryExtent(): Vector3;
  122555. /**
  122556. * Release all resources
  122557. */
  122558. dispose(): void;
  122559. }
  122560. }
  122561. declare module BABYLON {
  122562. /**
  122563. * Class used to enable access to IndexedDB
  122564. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  122565. */
  122566. export class Database implements IOfflineProvider {
  122567. private _callbackManifestChecked;
  122568. private _currentSceneUrl;
  122569. private _db;
  122570. private _enableSceneOffline;
  122571. private _enableTexturesOffline;
  122572. private _manifestVersionFound;
  122573. private _mustUpdateRessources;
  122574. private _hasReachedQuota;
  122575. private _isSupported;
  122576. private _idbFactory;
  122577. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  122578. private static IsUASupportingBlobStorage;
  122579. /**
  122580. * Gets a boolean indicating if Database storate is enabled (off by default)
  122581. */
  122582. static IDBStorageEnabled: boolean;
  122583. /**
  122584. * Gets a boolean indicating if scene must be saved in the database
  122585. */
  122586. readonly enableSceneOffline: boolean;
  122587. /**
  122588. * Gets a boolean indicating if textures must be saved in the database
  122589. */
  122590. readonly enableTexturesOffline: boolean;
  122591. /**
  122592. * Creates a new Database
  122593. * @param urlToScene defines the url to load the scene
  122594. * @param callbackManifestChecked defines the callback to use when manifest is checked
  122595. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  122596. */
  122597. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  122598. private static _ParseURL;
  122599. private static _ReturnFullUrlLocation;
  122600. private _checkManifestFile;
  122601. /**
  122602. * Open the database and make it available
  122603. * @param successCallback defines the callback to call on success
  122604. * @param errorCallback defines the callback to call on error
  122605. */
  122606. open(successCallback: () => void, errorCallback: () => void): void;
  122607. /**
  122608. * Loads an image from the database
  122609. * @param url defines the url to load from
  122610. * @param image defines the target DOM image
  122611. */
  122612. loadImage(url: string, image: HTMLImageElement): void;
  122613. private _loadImageFromDBAsync;
  122614. private _saveImageIntoDBAsync;
  122615. private _checkVersionFromDB;
  122616. private _loadVersionFromDBAsync;
  122617. private _saveVersionIntoDBAsync;
  122618. /**
  122619. * Loads a file from database
  122620. * @param url defines the URL to load from
  122621. * @param sceneLoaded defines a callback to call on success
  122622. * @param progressCallBack defines a callback to call when progress changed
  122623. * @param errorCallback defines a callback to call on error
  122624. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  122625. */
  122626. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  122627. private _loadFileAsync;
  122628. private _saveFileAsync;
  122629. /**
  122630. * Validates if xhr data is correct
  122631. * @param xhr defines the request to validate
  122632. * @param dataType defines the expected data type
  122633. * @returns true if data is correct
  122634. */
  122635. private static _ValidateXHRData;
  122636. }
  122637. }
  122638. declare module BABYLON {
  122639. /** @hidden */
  122640. export var gpuUpdateParticlesPixelShader: {
  122641. name: string;
  122642. shader: string;
  122643. };
  122644. }
  122645. declare module BABYLON {
  122646. /** @hidden */
  122647. export var gpuUpdateParticlesVertexShader: {
  122648. name: string;
  122649. shader: string;
  122650. };
  122651. }
  122652. declare module BABYLON {
  122653. /** @hidden */
  122654. export var clipPlaneFragmentDeclaration2: {
  122655. name: string;
  122656. shader: string;
  122657. };
  122658. }
  122659. declare module BABYLON {
  122660. /** @hidden */
  122661. export var gpuRenderParticlesPixelShader: {
  122662. name: string;
  122663. shader: string;
  122664. };
  122665. }
  122666. declare module BABYLON {
  122667. /** @hidden */
  122668. export var clipPlaneVertexDeclaration2: {
  122669. name: string;
  122670. shader: string;
  122671. };
  122672. }
  122673. declare module BABYLON {
  122674. /** @hidden */
  122675. export var gpuRenderParticlesVertexShader: {
  122676. name: string;
  122677. shader: string;
  122678. };
  122679. }
  122680. declare module BABYLON {
  122681. /**
  122682. * This represents a GPU particle system in Babylon
  122683. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  122684. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  122685. */
  122686. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  122687. /**
  122688. * The layer mask we are rendering the particles through.
  122689. */
  122690. layerMask: number;
  122691. private _capacity;
  122692. private _activeCount;
  122693. private _currentActiveCount;
  122694. private _accumulatedCount;
  122695. private _renderEffect;
  122696. private _updateEffect;
  122697. private _buffer0;
  122698. private _buffer1;
  122699. private _spriteBuffer;
  122700. private _updateVAO;
  122701. private _renderVAO;
  122702. private _targetIndex;
  122703. private _sourceBuffer;
  122704. private _targetBuffer;
  122705. private _engine;
  122706. private _currentRenderId;
  122707. private _started;
  122708. private _stopped;
  122709. private _timeDelta;
  122710. private _randomTexture;
  122711. private _randomTexture2;
  122712. private _attributesStrideSize;
  122713. private _updateEffectOptions;
  122714. private _randomTextureSize;
  122715. private _actualFrame;
  122716. private readonly _rawTextureWidth;
  122717. /**
  122718. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  122719. */
  122720. static readonly IsSupported: boolean;
  122721. /**
  122722. * An event triggered when the system is disposed.
  122723. */
  122724. onDisposeObservable: Observable<GPUParticleSystem>;
  122725. /**
  122726. * Gets the maximum number of particles active at the same time.
  122727. * @returns The max number of active particles.
  122728. */
  122729. getCapacity(): number;
  122730. /**
  122731. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  122732. * to override the particles.
  122733. */
  122734. forceDepthWrite: boolean;
  122735. /**
  122736. * Gets or set the number of active particles
  122737. */
  122738. activeParticleCount: number;
  122739. private _preWarmDone;
  122740. /**
  122741. * Is this system ready to be used/rendered
  122742. * @return true if the system is ready
  122743. */
  122744. isReady(): boolean;
  122745. /**
  122746. * Gets if the system has been started. (Note: this will still be true after stop is called)
  122747. * @returns True if it has been started, otherwise false.
  122748. */
  122749. isStarted(): boolean;
  122750. /**
  122751. * Starts the particle system and begins to emit
  122752. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  122753. */
  122754. start(delay?: number): void;
  122755. /**
  122756. * Stops the particle system.
  122757. */
  122758. stop(): void;
  122759. /**
  122760. * Remove all active particles
  122761. */
  122762. reset(): void;
  122763. /**
  122764. * Returns the string "GPUParticleSystem"
  122765. * @returns a string containing the class name
  122766. */
  122767. getClassName(): string;
  122768. private _colorGradientsTexture;
  122769. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  122770. /**
  122771. * Adds a new color gradient
  122772. * @param gradient defines the gradient to use (between 0 and 1)
  122773. * @param color1 defines the color to affect to the specified gradient
  122774. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  122775. * @returns the current particle system
  122776. */
  122777. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  122778. /**
  122779. * Remove a specific color gradient
  122780. * @param gradient defines the gradient to remove
  122781. * @returns the current particle system
  122782. */
  122783. removeColorGradient(gradient: number): GPUParticleSystem;
  122784. private _angularSpeedGradientsTexture;
  122785. private _sizeGradientsTexture;
  122786. private _velocityGradientsTexture;
  122787. private _limitVelocityGradientsTexture;
  122788. private _dragGradientsTexture;
  122789. private _addFactorGradient;
  122790. /**
  122791. * Adds a new size gradient
  122792. * @param gradient defines the gradient to use (between 0 and 1)
  122793. * @param factor defines the size factor to affect to the specified gradient
  122794. * @returns the current particle system
  122795. */
  122796. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  122797. /**
  122798. * Remove a specific size gradient
  122799. * @param gradient defines the gradient to remove
  122800. * @returns the current particle system
  122801. */
  122802. removeSizeGradient(gradient: number): GPUParticleSystem;
  122803. /**
  122804. * Adds a new angular speed gradient
  122805. * @param gradient defines the gradient to use (between 0 and 1)
  122806. * @param factor defines the angular speed to affect to the specified gradient
  122807. * @returns the current particle system
  122808. */
  122809. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  122810. /**
  122811. * Remove a specific angular speed gradient
  122812. * @param gradient defines the gradient to remove
  122813. * @returns the current particle system
  122814. */
  122815. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  122816. /**
  122817. * Adds a new velocity gradient
  122818. * @param gradient defines the gradient to use (between 0 and 1)
  122819. * @param factor defines the velocity to affect to the specified gradient
  122820. * @returns the current particle system
  122821. */
  122822. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122823. /**
  122824. * Remove a specific velocity gradient
  122825. * @param gradient defines the gradient to remove
  122826. * @returns the current particle system
  122827. */
  122828. removeVelocityGradient(gradient: number): GPUParticleSystem;
  122829. /**
  122830. * Adds a new limit velocity gradient
  122831. * @param gradient defines the gradient to use (between 0 and 1)
  122832. * @param factor defines the limit velocity value to affect to the specified gradient
  122833. * @returns the current particle system
  122834. */
  122835. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122836. /**
  122837. * Remove a specific limit velocity gradient
  122838. * @param gradient defines the gradient to remove
  122839. * @returns the current particle system
  122840. */
  122841. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  122842. /**
  122843. * Adds a new drag gradient
  122844. * @param gradient defines the gradient to use (between 0 and 1)
  122845. * @param factor defines the drag value to affect to the specified gradient
  122846. * @returns the current particle system
  122847. */
  122848. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  122849. /**
  122850. * Remove a specific drag gradient
  122851. * @param gradient defines the gradient to remove
  122852. * @returns the current particle system
  122853. */
  122854. removeDragGradient(gradient: number): GPUParticleSystem;
  122855. /**
  122856. * Not supported by GPUParticleSystem
  122857. * @param gradient defines the gradient to use (between 0 and 1)
  122858. * @param factor defines the emit rate value to affect to the specified gradient
  122859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122860. * @returns the current particle system
  122861. */
  122862. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122863. /**
  122864. * Not supported by GPUParticleSystem
  122865. * @param gradient defines the gradient to remove
  122866. * @returns the current particle system
  122867. */
  122868. removeEmitRateGradient(gradient: number): IParticleSystem;
  122869. /**
  122870. * Not supported by GPUParticleSystem
  122871. * @param gradient defines the gradient to use (between 0 and 1)
  122872. * @param factor defines the start size value to affect to the specified gradient
  122873. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122874. * @returns the current particle system
  122875. */
  122876. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122877. /**
  122878. * Not supported by GPUParticleSystem
  122879. * @param gradient defines the gradient to remove
  122880. * @returns the current particle system
  122881. */
  122882. removeStartSizeGradient(gradient: number): IParticleSystem;
  122883. /**
  122884. * Not supported by GPUParticleSystem
  122885. * @param gradient defines the gradient to use (between 0 and 1)
  122886. * @param min defines the color remap minimal range
  122887. * @param max defines the color remap maximal range
  122888. * @returns the current particle system
  122889. */
  122890. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122891. /**
  122892. * Not supported by GPUParticleSystem
  122893. * @param gradient defines the gradient to remove
  122894. * @returns the current particle system
  122895. */
  122896. removeColorRemapGradient(): IParticleSystem;
  122897. /**
  122898. * Not supported by GPUParticleSystem
  122899. * @param gradient defines the gradient to use (between 0 and 1)
  122900. * @param min defines the alpha remap minimal range
  122901. * @param max defines the alpha remap maximal range
  122902. * @returns the current particle system
  122903. */
  122904. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122905. /**
  122906. * Not supported by GPUParticleSystem
  122907. * @param gradient defines the gradient to remove
  122908. * @returns the current particle system
  122909. */
  122910. removeAlphaRemapGradient(): IParticleSystem;
  122911. /**
  122912. * Not supported by GPUParticleSystem
  122913. * @param gradient defines the gradient to use (between 0 and 1)
  122914. * @param color defines the color to affect to the specified gradient
  122915. * @returns the current particle system
  122916. */
  122917. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  122918. /**
  122919. * Not supported by GPUParticleSystem
  122920. * @param gradient defines the gradient to remove
  122921. * @returns the current particle system
  122922. */
  122923. removeRampGradient(): IParticleSystem;
  122924. /**
  122925. * Not supported by GPUParticleSystem
  122926. * @returns the list of ramp gradients
  122927. */
  122928. getRampGradients(): Nullable<Array<Color3Gradient>>;
  122929. /**
  122930. * Not supported by GPUParticleSystem
  122931. * Gets or sets a boolean indicating that ramp gradients must be used
  122932. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  122933. */
  122934. useRampGradients: boolean;
  122935. /**
  122936. * Not supported by GPUParticleSystem
  122937. * @param gradient defines the gradient to use (between 0 and 1)
  122938. * @param factor defines the life time factor to affect to the specified gradient
  122939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122940. * @returns the current particle system
  122941. */
  122942. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122943. /**
  122944. * Not supported by GPUParticleSystem
  122945. * @param gradient defines the gradient to remove
  122946. * @returns the current particle system
  122947. */
  122948. removeLifeTimeGradient(gradient: number): IParticleSystem;
  122949. /**
  122950. * Instantiates a GPU particle system.
  122951. * 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.
  122952. * @param name The name of the particle system
  122953. * @param options The options used to create the system
  122954. * @param scene The scene the particle system belongs to
  122955. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  122956. */
  122957. constructor(name: string, options: Partial<{
  122958. capacity: number;
  122959. randomTextureSize: number;
  122960. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  122961. protected _reset(): void;
  122962. private _createUpdateVAO;
  122963. private _createRenderVAO;
  122964. private _initialize;
  122965. /** @hidden */
  122966. _recreateUpdateEffect(): void;
  122967. /** @hidden */
  122968. _recreateRenderEffect(): void;
  122969. /**
  122970. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  122971. * @param preWarm defines if we are in the pre-warmimg phase
  122972. */
  122973. animate(preWarm?: boolean): void;
  122974. private _createFactorGradientTexture;
  122975. private _createSizeGradientTexture;
  122976. private _createAngularSpeedGradientTexture;
  122977. private _createVelocityGradientTexture;
  122978. private _createLimitVelocityGradientTexture;
  122979. private _createDragGradientTexture;
  122980. private _createColorGradientTexture;
  122981. /**
  122982. * Renders the particle system in its current state
  122983. * @param preWarm defines if the system should only update the particles but not render them
  122984. * @returns the current number of particles
  122985. */
  122986. render(preWarm?: boolean): number;
  122987. /**
  122988. * Rebuilds the particle system
  122989. */
  122990. rebuild(): void;
  122991. private _releaseBuffers;
  122992. private _releaseVAOs;
  122993. /**
  122994. * Disposes the particle system and free the associated resources
  122995. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  122996. */
  122997. dispose(disposeTexture?: boolean): void;
  122998. /**
  122999. * Clones the particle system.
  123000. * @param name The name of the cloned object
  123001. * @param newEmitter The new emitter to use
  123002. * @returns the cloned particle system
  123003. */
  123004. clone(name: string, newEmitter: any): GPUParticleSystem;
  123005. /**
  123006. * Serializes the particle system to a JSON object.
  123007. * @returns the JSON object
  123008. */
  123009. serialize(): any;
  123010. /**
  123011. * Parses a JSON object to create a GPU particle system.
  123012. * @param parsedParticleSystem The JSON object to parse
  123013. * @param scene The scene to create the particle system in
  123014. * @param rootUrl The root url to use to load external dependencies like texture
  123015. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  123016. * @returns the parsed GPU particle system
  123017. */
  123018. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  123019. }
  123020. }
  123021. declare module BABYLON {
  123022. /**
  123023. * Represents a set of particle systems working together to create a specific effect
  123024. */
  123025. export class ParticleSystemSet implements IDisposable {
  123026. private _emitterCreationOptions;
  123027. private _emitterNode;
  123028. /**
  123029. * Gets the particle system list
  123030. */
  123031. systems: IParticleSystem[];
  123032. /**
  123033. * Gets the emitter node used with this set
  123034. */
  123035. readonly emitterNode: Nullable<TransformNode>;
  123036. /**
  123037. * Creates a new emitter mesh as a sphere
  123038. * @param options defines the options used to create the sphere
  123039. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  123040. * @param scene defines the hosting scene
  123041. */
  123042. setEmitterAsSphere(options: {
  123043. diameter: number;
  123044. segments: number;
  123045. color: Color3;
  123046. }, renderingGroupId: number, scene: Scene): void;
  123047. /**
  123048. * Starts all particle systems of the set
  123049. * @param emitter defines an optional mesh to use as emitter for the particle systems
  123050. */
  123051. start(emitter?: AbstractMesh): void;
  123052. /**
  123053. * Release all associated resources
  123054. */
  123055. dispose(): void;
  123056. /**
  123057. * Serialize the set into a JSON compatible object
  123058. * @returns a JSON compatible representation of the set
  123059. */
  123060. serialize(): any;
  123061. /**
  123062. * Parse a new ParticleSystemSet from a serialized source
  123063. * @param data defines a JSON compatible representation of the set
  123064. * @param scene defines the hosting scene
  123065. * @param gpu defines if we want GPU particles or CPU particles
  123066. * @returns a new ParticleSystemSet
  123067. */
  123068. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  123069. }
  123070. }
  123071. declare module BABYLON {
  123072. /**
  123073. * This class is made for on one-liner static method to help creating particle system set.
  123074. */
  123075. export class ParticleHelper {
  123076. /**
  123077. * Gets or sets base Assets URL
  123078. */
  123079. static BaseAssetsUrl: string;
  123080. /**
  123081. * Create a default particle system that you can tweak
  123082. * @param emitter defines the emitter to use
  123083. * @param capacity defines the system capacity (default is 500 particles)
  123084. * @param scene defines the hosting scene
  123085. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  123086. * @returns the new Particle system
  123087. */
  123088. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  123089. /**
  123090. * This is the main static method (one-liner) of this helper to create different particle systems
  123091. * @param type This string represents the type to the particle system to create
  123092. * @param scene The scene where the particle system should live
  123093. * @param gpu If the system will use gpu
  123094. * @returns the ParticleSystemSet created
  123095. */
  123096. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  123097. /**
  123098. * Static function used to export a particle system to a ParticleSystemSet variable.
  123099. * Please note that the emitter shape is not exported
  123100. * @param systems defines the particle systems to export
  123101. * @returns the created particle system set
  123102. */
  123103. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  123104. }
  123105. }
  123106. declare module BABYLON {
  123107. interface Engine {
  123108. /**
  123109. * Create an effect to use with particle systems.
  123110. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  123111. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  123112. * @param uniformsNames defines a list of attribute names
  123113. * @param samplers defines an array of string used to represent textures
  123114. * @param defines defines the string containing the defines to use to compile the shaders
  123115. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  123116. * @param onCompiled defines a function to call when the effect creation is successful
  123117. * @param onError defines a function to call when the effect creation has failed
  123118. * @returns the new Effect
  123119. */
  123120. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  123121. }
  123122. interface Mesh {
  123123. /**
  123124. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  123125. * @returns an array of IParticleSystem
  123126. */
  123127. getEmittedParticleSystems(): IParticleSystem[];
  123128. /**
  123129. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  123130. * @returns an array of IParticleSystem
  123131. */
  123132. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  123133. }
  123134. /**
  123135. * @hidden
  123136. */
  123137. export var _IDoNeedToBeInTheBuild: number;
  123138. }
  123139. declare module BABYLON {
  123140. interface Scene {
  123141. /** @hidden (Backing field) */
  123142. _physicsEngine: Nullable<IPhysicsEngine>;
  123143. /**
  123144. * Gets the current physics engine
  123145. * @returns a IPhysicsEngine or null if none attached
  123146. */
  123147. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  123148. /**
  123149. * Enables physics to the current scene
  123150. * @param gravity defines the scene's gravity for the physics engine
  123151. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  123152. * @return a boolean indicating if the physics engine was initialized
  123153. */
  123154. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  123155. /**
  123156. * Disables and disposes the physics engine associated with the scene
  123157. */
  123158. disablePhysicsEngine(): void;
  123159. /**
  123160. * Gets a boolean indicating if there is an active physics engine
  123161. * @returns a boolean indicating if there is an active physics engine
  123162. */
  123163. isPhysicsEnabled(): boolean;
  123164. /**
  123165. * Deletes a physics compound impostor
  123166. * @param compound defines the compound to delete
  123167. */
  123168. deleteCompoundImpostor(compound: any): void;
  123169. /**
  123170. * An event triggered when physic simulation is about to be run
  123171. */
  123172. onBeforePhysicsObservable: Observable<Scene>;
  123173. /**
  123174. * An event triggered when physic simulation has been done
  123175. */
  123176. onAfterPhysicsObservable: Observable<Scene>;
  123177. }
  123178. interface AbstractMesh {
  123179. /** @hidden */
  123180. _physicsImpostor: Nullable<PhysicsImpostor>;
  123181. /**
  123182. * Gets or sets impostor used for physic simulation
  123183. * @see http://doc.babylonjs.com/features/physics_engine
  123184. */
  123185. physicsImpostor: Nullable<PhysicsImpostor>;
  123186. /**
  123187. * Gets the current physics impostor
  123188. * @see http://doc.babylonjs.com/features/physics_engine
  123189. * @returns a physics impostor or null
  123190. */
  123191. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  123192. /** Apply a physic impulse to the mesh
  123193. * @param force defines the force to apply
  123194. * @param contactPoint defines where to apply the force
  123195. * @returns the current mesh
  123196. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123197. */
  123198. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  123199. /**
  123200. * Creates a physic joint between two meshes
  123201. * @param otherMesh defines the other mesh to use
  123202. * @param pivot1 defines the pivot to use on this mesh
  123203. * @param pivot2 defines the pivot to use on the other mesh
  123204. * @param options defines additional options (can be plugin dependent)
  123205. * @returns the current mesh
  123206. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  123207. */
  123208. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  123209. /** @hidden */
  123210. _disposePhysicsObserver: Nullable<Observer<Node>>;
  123211. }
  123212. /**
  123213. * Defines the physics engine scene component responsible to manage a physics engine
  123214. */
  123215. export class PhysicsEngineSceneComponent implements ISceneComponent {
  123216. /**
  123217. * The component name helpful to identify the component in the list of scene components.
  123218. */
  123219. readonly name: string;
  123220. /**
  123221. * The scene the component belongs to.
  123222. */
  123223. scene: Scene;
  123224. /**
  123225. * Creates a new instance of the component for the given scene
  123226. * @param scene Defines the scene to register the component in
  123227. */
  123228. constructor(scene: Scene);
  123229. /**
  123230. * Registers the component in a given scene
  123231. */
  123232. register(): void;
  123233. /**
  123234. * Rebuilds the elements related to this component in case of
  123235. * context lost for instance.
  123236. */
  123237. rebuild(): void;
  123238. /**
  123239. * Disposes the component and the associated ressources
  123240. */
  123241. dispose(): void;
  123242. }
  123243. }
  123244. declare module BABYLON {
  123245. /**
  123246. * A helper for physics simulations
  123247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123248. */
  123249. export class PhysicsHelper {
  123250. private _scene;
  123251. private _physicsEngine;
  123252. /**
  123253. * Initializes the Physics helper
  123254. * @param scene Babylon.js scene
  123255. */
  123256. constructor(scene: Scene);
  123257. /**
  123258. * Applies a radial explosion impulse
  123259. * @param origin the origin of the explosion
  123260. * @param radiusOrEventOptions the radius or the options of radial explosion
  123261. * @param strength the explosion strength
  123262. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123263. * @returns A physics radial explosion event, or null
  123264. */
  123265. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123266. /**
  123267. * Applies a radial explosion force
  123268. * @param origin the origin of the explosion
  123269. * @param radiusOrEventOptions the radius or the options of radial explosion
  123270. * @param strength the explosion strength
  123271. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123272. * @returns A physics radial explosion event, or null
  123273. */
  123274. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123275. /**
  123276. * Creates a gravitational field
  123277. * @param origin the origin of the explosion
  123278. * @param radiusOrEventOptions the radius or the options of radial explosion
  123279. * @param strength the explosion strength
  123280. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123281. * @returns A physics gravitational field event, or null
  123282. */
  123283. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  123284. /**
  123285. * Creates a physics updraft event
  123286. * @param origin the origin of the updraft
  123287. * @param radiusOrEventOptions the radius or the options of the updraft
  123288. * @param strength the strength of the updraft
  123289. * @param height the height of the updraft
  123290. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  123291. * @returns A physics updraft event, or null
  123292. */
  123293. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  123294. /**
  123295. * Creates a physics vortex event
  123296. * @param origin the of the vortex
  123297. * @param radiusOrEventOptions the radius or the options of the vortex
  123298. * @param strength the strength of the vortex
  123299. * @param height the height of the vortex
  123300. * @returns a Physics vortex event, or null
  123301. * A physics vortex event or null
  123302. */
  123303. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  123304. }
  123305. /**
  123306. * Represents a physics radial explosion event
  123307. */
  123308. class PhysicsRadialExplosionEvent {
  123309. private _scene;
  123310. private _options;
  123311. private _sphere;
  123312. private _dataFetched;
  123313. /**
  123314. * Initializes a radial explosioin event
  123315. * @param _scene BabylonJS scene
  123316. * @param _options The options for the vortex event
  123317. */
  123318. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  123319. /**
  123320. * Returns the data related to the radial explosion event (sphere).
  123321. * @returns The radial explosion event data
  123322. */
  123323. getData(): PhysicsRadialExplosionEventData;
  123324. /**
  123325. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  123326. * @param impostor A physics imposter
  123327. * @param origin the origin of the explosion
  123328. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  123329. */
  123330. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  123331. /**
  123332. * Triggers affecterd impostors callbacks
  123333. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  123334. */
  123335. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  123336. /**
  123337. * Disposes the sphere.
  123338. * @param force Specifies if the sphere should be disposed by force
  123339. */
  123340. dispose(force?: boolean): void;
  123341. /*** Helpers ***/
  123342. private _prepareSphere;
  123343. private _intersectsWithSphere;
  123344. }
  123345. /**
  123346. * Represents a gravitational field event
  123347. */
  123348. class PhysicsGravitationalFieldEvent {
  123349. private _physicsHelper;
  123350. private _scene;
  123351. private _origin;
  123352. private _options;
  123353. private _tickCallback;
  123354. private _sphere;
  123355. private _dataFetched;
  123356. /**
  123357. * Initializes the physics gravitational field event
  123358. * @param _physicsHelper A physics helper
  123359. * @param _scene BabylonJS scene
  123360. * @param _origin The origin position of the gravitational field event
  123361. * @param _options The options for the vortex event
  123362. */
  123363. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  123364. /**
  123365. * Returns the data related to the gravitational field event (sphere).
  123366. * @returns A gravitational field event
  123367. */
  123368. getData(): PhysicsGravitationalFieldEventData;
  123369. /**
  123370. * Enables the gravitational field.
  123371. */
  123372. enable(): void;
  123373. /**
  123374. * Disables the gravitational field.
  123375. */
  123376. disable(): void;
  123377. /**
  123378. * Disposes the sphere.
  123379. * @param force The force to dispose from the gravitational field event
  123380. */
  123381. dispose(force?: boolean): void;
  123382. private _tick;
  123383. }
  123384. /**
  123385. * Represents a physics updraft event
  123386. */
  123387. class PhysicsUpdraftEvent {
  123388. private _scene;
  123389. private _origin;
  123390. private _options;
  123391. private _physicsEngine;
  123392. private _originTop;
  123393. private _originDirection;
  123394. private _tickCallback;
  123395. private _cylinder;
  123396. private _cylinderPosition;
  123397. private _dataFetched;
  123398. /**
  123399. * Initializes the physics updraft event
  123400. * @param _scene BabylonJS scene
  123401. * @param _origin The origin position of the updraft
  123402. * @param _options The options for the updraft event
  123403. */
  123404. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  123405. /**
  123406. * Returns the data related to the updraft event (cylinder).
  123407. * @returns A physics updraft event
  123408. */
  123409. getData(): PhysicsUpdraftEventData;
  123410. /**
  123411. * Enables the updraft.
  123412. */
  123413. enable(): void;
  123414. /**
  123415. * Disables the updraft.
  123416. */
  123417. disable(): void;
  123418. /**
  123419. * Disposes the cylinder.
  123420. * @param force Specifies if the updraft should be disposed by force
  123421. */
  123422. dispose(force?: boolean): void;
  123423. private getImpostorHitData;
  123424. private _tick;
  123425. /*** Helpers ***/
  123426. private _prepareCylinder;
  123427. private _intersectsWithCylinder;
  123428. }
  123429. /**
  123430. * Represents a physics vortex event
  123431. */
  123432. class PhysicsVortexEvent {
  123433. private _scene;
  123434. private _origin;
  123435. private _options;
  123436. private _physicsEngine;
  123437. private _originTop;
  123438. private _tickCallback;
  123439. private _cylinder;
  123440. private _cylinderPosition;
  123441. private _dataFetched;
  123442. /**
  123443. * Initializes the physics vortex event
  123444. * @param _scene The BabylonJS scene
  123445. * @param _origin The origin position of the vortex
  123446. * @param _options The options for the vortex event
  123447. */
  123448. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  123449. /**
  123450. * Returns the data related to the vortex event (cylinder).
  123451. * @returns The physics vortex event data
  123452. */
  123453. getData(): PhysicsVortexEventData;
  123454. /**
  123455. * Enables the vortex.
  123456. */
  123457. enable(): void;
  123458. /**
  123459. * Disables the cortex.
  123460. */
  123461. disable(): void;
  123462. /**
  123463. * Disposes the sphere.
  123464. * @param force
  123465. */
  123466. dispose(force?: boolean): void;
  123467. private getImpostorHitData;
  123468. private _tick;
  123469. /*** Helpers ***/
  123470. private _prepareCylinder;
  123471. private _intersectsWithCylinder;
  123472. }
  123473. /**
  123474. * Options fot the radial explosion event
  123475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123476. */
  123477. export class PhysicsRadialExplosionEventOptions {
  123478. /**
  123479. * The radius of the sphere for the radial explosion.
  123480. */
  123481. radius: number;
  123482. /**
  123483. * The strenth of the explosion.
  123484. */
  123485. strength: number;
  123486. /**
  123487. * The strenght of the force in correspondence to the distance of the affected object
  123488. */
  123489. falloff: PhysicsRadialImpulseFalloff;
  123490. /**
  123491. * Sphere options for the radial explosion.
  123492. */
  123493. sphere: {
  123494. segments: number;
  123495. diameter: number;
  123496. };
  123497. /**
  123498. * Sphere options for the radial explosion.
  123499. */
  123500. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  123501. }
  123502. /**
  123503. * Options fot the updraft event
  123504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123505. */
  123506. export class PhysicsUpdraftEventOptions {
  123507. /**
  123508. * The radius of the cylinder for the vortex
  123509. */
  123510. radius: number;
  123511. /**
  123512. * The strenth of the updraft.
  123513. */
  123514. strength: number;
  123515. /**
  123516. * The height of the cylinder for the updraft.
  123517. */
  123518. height: number;
  123519. /**
  123520. * The mode for the the updraft.
  123521. */
  123522. updraftMode: PhysicsUpdraftMode;
  123523. }
  123524. /**
  123525. * Options fot the vortex event
  123526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123527. */
  123528. export class PhysicsVortexEventOptions {
  123529. /**
  123530. * The radius of the cylinder for the vortex
  123531. */
  123532. radius: number;
  123533. /**
  123534. * The strenth of the vortex.
  123535. */
  123536. strength: number;
  123537. /**
  123538. * The height of the cylinder for the vortex.
  123539. */
  123540. height: number;
  123541. /**
  123542. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  123543. */
  123544. centripetalForceThreshold: number;
  123545. /**
  123546. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  123547. */
  123548. centripetalForceMultiplier: number;
  123549. /**
  123550. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  123551. */
  123552. centrifugalForceMultiplier: number;
  123553. /**
  123554. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  123555. */
  123556. updraftForceMultiplier: number;
  123557. }
  123558. /**
  123559. * The strenght of the force in correspondence to the distance of the affected object
  123560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123561. */
  123562. export enum PhysicsRadialImpulseFalloff {
  123563. /** Defines that impulse is constant in strength across it's whole radius */
  123564. Constant = 0,
  123565. /** Defines that impulse gets weaker if it's further from the origin */
  123566. Linear = 1
  123567. }
  123568. /**
  123569. * The strength of the force in correspondence to the distance of the affected object
  123570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123571. */
  123572. export enum PhysicsUpdraftMode {
  123573. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  123574. Center = 0,
  123575. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  123576. Perpendicular = 1
  123577. }
  123578. /**
  123579. * Interface for a physics hit data
  123580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123581. */
  123582. export interface PhysicsHitData {
  123583. /**
  123584. * The force applied at the contact point
  123585. */
  123586. force: Vector3;
  123587. /**
  123588. * The contact point
  123589. */
  123590. contactPoint: Vector3;
  123591. /**
  123592. * The distance from the origin to the contact point
  123593. */
  123594. distanceFromOrigin: number;
  123595. }
  123596. /**
  123597. * Interface for radial explosion event data
  123598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123599. */
  123600. export interface PhysicsRadialExplosionEventData {
  123601. /**
  123602. * A sphere used for the radial explosion event
  123603. */
  123604. sphere: Mesh;
  123605. }
  123606. /**
  123607. * Interface for gravitational field event data
  123608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123609. */
  123610. export interface PhysicsGravitationalFieldEventData {
  123611. /**
  123612. * A sphere mesh used for the gravitational field event
  123613. */
  123614. sphere: Mesh;
  123615. }
  123616. /**
  123617. * Interface for updraft event data
  123618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123619. */
  123620. export interface PhysicsUpdraftEventData {
  123621. /**
  123622. * A cylinder used for the updraft event
  123623. */
  123624. cylinder: Mesh;
  123625. }
  123626. /**
  123627. * Interface for vortex event data
  123628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123629. */
  123630. export interface PhysicsVortexEventData {
  123631. /**
  123632. * A cylinder used for the vortex event
  123633. */
  123634. cylinder: Mesh;
  123635. }
  123636. /**
  123637. * Interface for an affected physics impostor
  123638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123639. */
  123640. export interface PhysicsAffectedImpostorWithData {
  123641. /**
  123642. * The impostor affected by the effect
  123643. */
  123644. impostor: PhysicsImpostor;
  123645. /**
  123646. * The data about the hit/horce from the explosion
  123647. */
  123648. hitData: PhysicsHitData;
  123649. }
  123650. }
  123651. declare module BABYLON {
  123652. /** @hidden */
  123653. export var blackAndWhitePixelShader: {
  123654. name: string;
  123655. shader: string;
  123656. };
  123657. }
  123658. declare module BABYLON {
  123659. /**
  123660. * Post process used to render in black and white
  123661. */
  123662. export class BlackAndWhitePostProcess extends PostProcess {
  123663. /**
  123664. * Linear about to convert he result to black and white (default: 1)
  123665. */
  123666. degree: number;
  123667. /**
  123668. * Creates a black and white post process
  123669. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  123670. * @param name The name of the effect.
  123671. * @param options The required width/height ratio to downsize to before computing the render pass.
  123672. * @param camera The camera to apply the render pass to.
  123673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123674. * @param engine The engine which the post process will be applied. (default: current engine)
  123675. * @param reusable If the post process can be reused on the same frame. (default: false)
  123676. */
  123677. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123678. }
  123679. }
  123680. declare module BABYLON {
  123681. /**
  123682. * This represents a set of one or more post processes in Babylon.
  123683. * A post process can be used to apply a shader to a texture after it is rendered.
  123684. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123685. */
  123686. export class PostProcessRenderEffect {
  123687. private _postProcesses;
  123688. private _getPostProcesses;
  123689. private _singleInstance;
  123690. private _cameras;
  123691. private _indicesForCamera;
  123692. /**
  123693. * Name of the effect
  123694. * @hidden
  123695. */
  123696. _name: string;
  123697. /**
  123698. * Instantiates a post process render effect.
  123699. * A post process can be used to apply a shader to a texture after it is rendered.
  123700. * @param engine The engine the effect is tied to
  123701. * @param name The name of the effect
  123702. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  123703. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  123704. */
  123705. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  123706. /**
  123707. * Checks if all the post processes in the effect are supported.
  123708. */
  123709. readonly isSupported: boolean;
  123710. /**
  123711. * Updates the current state of the effect
  123712. * @hidden
  123713. */
  123714. _update(): void;
  123715. /**
  123716. * Attaches the effect on cameras
  123717. * @param cameras The camera to attach to.
  123718. * @hidden
  123719. */
  123720. _attachCameras(cameras: Camera): void;
  123721. /**
  123722. * Attaches the effect on cameras
  123723. * @param cameras The camera to attach to.
  123724. * @hidden
  123725. */
  123726. _attachCameras(cameras: Camera[]): void;
  123727. /**
  123728. * Detaches the effect on cameras
  123729. * @param cameras The camera to detatch from.
  123730. * @hidden
  123731. */
  123732. _detachCameras(cameras: Camera): void;
  123733. /**
  123734. * Detatches the effect on cameras
  123735. * @param cameras The camera to detatch from.
  123736. * @hidden
  123737. */
  123738. _detachCameras(cameras: Camera[]): void;
  123739. /**
  123740. * Enables the effect on given cameras
  123741. * @param cameras The camera to enable.
  123742. * @hidden
  123743. */
  123744. _enable(cameras: Camera): void;
  123745. /**
  123746. * Enables the effect on given cameras
  123747. * @param cameras The camera to enable.
  123748. * @hidden
  123749. */
  123750. _enable(cameras: Nullable<Camera[]>): void;
  123751. /**
  123752. * Disables the effect on the given cameras
  123753. * @param cameras The camera to disable.
  123754. * @hidden
  123755. */
  123756. _disable(cameras: Camera): void;
  123757. /**
  123758. * Disables the effect on the given cameras
  123759. * @param cameras The camera to disable.
  123760. * @hidden
  123761. */
  123762. _disable(cameras: Nullable<Camera[]>): void;
  123763. /**
  123764. * Gets a list of the post processes contained in the effect.
  123765. * @param camera The camera to get the post processes on.
  123766. * @returns The list of the post processes in the effect.
  123767. */
  123768. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  123769. }
  123770. }
  123771. declare module BABYLON {
  123772. /** @hidden */
  123773. export var extractHighlightsPixelShader: {
  123774. name: string;
  123775. shader: string;
  123776. };
  123777. }
  123778. declare module BABYLON {
  123779. /**
  123780. * 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.
  123781. */
  123782. export class ExtractHighlightsPostProcess extends PostProcess {
  123783. /**
  123784. * The luminance threshold, pixels below this value will be set to black.
  123785. */
  123786. threshold: number;
  123787. /** @hidden */
  123788. _exposure: number;
  123789. /**
  123790. * Post process which has the input texture to be used when performing highlight extraction
  123791. * @hidden
  123792. */
  123793. _inputPostProcess: Nullable<PostProcess>;
  123794. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123795. }
  123796. }
  123797. declare module BABYLON {
  123798. /** @hidden */
  123799. export var bloomMergePixelShader: {
  123800. name: string;
  123801. shader: string;
  123802. };
  123803. }
  123804. declare module BABYLON {
  123805. /**
  123806. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123807. */
  123808. export class BloomMergePostProcess extends PostProcess {
  123809. /** Weight of the bloom to be added to the original input. */
  123810. weight: number;
  123811. /**
  123812. * Creates a new instance of @see BloomMergePostProcess
  123813. * @param name The name of the effect.
  123814. * @param originalFromInput Post process which's input will be used for the merge.
  123815. * @param blurred Blurred highlights post process which's output will be used.
  123816. * @param weight Weight of the bloom to be added to the original input.
  123817. * @param options The required width/height ratio to downsize to before computing the render pass.
  123818. * @param camera The camera to apply the render pass to.
  123819. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123820. * @param engine The engine which the post process will be applied. (default: current engine)
  123821. * @param reusable If the post process can be reused on the same frame. (default: false)
  123822. * @param textureType Type of textures used when performing the post process. (default: 0)
  123823. * @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)
  123824. */
  123825. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  123826. /** Weight of the bloom to be added to the original input. */
  123827. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123828. }
  123829. }
  123830. declare module BABYLON {
  123831. /**
  123832. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  123833. */
  123834. export class BloomEffect extends PostProcessRenderEffect {
  123835. private bloomScale;
  123836. /**
  123837. * @hidden Internal
  123838. */
  123839. _effects: Array<PostProcess>;
  123840. /**
  123841. * @hidden Internal
  123842. */
  123843. _downscale: ExtractHighlightsPostProcess;
  123844. private _blurX;
  123845. private _blurY;
  123846. private _merge;
  123847. /**
  123848. * The luminance threshold to find bright areas of the image to bloom.
  123849. */
  123850. threshold: number;
  123851. /**
  123852. * The strength of the bloom.
  123853. */
  123854. weight: number;
  123855. /**
  123856. * Specifies the size of the bloom blur kernel, relative to the final output size
  123857. */
  123858. kernel: number;
  123859. /**
  123860. * Creates a new instance of @see BloomEffect
  123861. * @param scene The scene the effect belongs to.
  123862. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  123863. * @param bloomKernel The size of the kernel to be used when applying the blur.
  123864. * @param bloomWeight The the strength of bloom.
  123865. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123866. * @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)
  123867. */
  123868. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  123869. /**
  123870. * Disposes each of the internal effects for a given camera.
  123871. * @param camera The camera to dispose the effect on.
  123872. */
  123873. disposeEffects(camera: Camera): void;
  123874. /**
  123875. * @hidden Internal
  123876. */
  123877. _updateEffects(): void;
  123878. /**
  123879. * Internal
  123880. * @returns if all the contained post processes are ready.
  123881. * @hidden
  123882. */
  123883. _isReady(): boolean;
  123884. }
  123885. }
  123886. declare module BABYLON {
  123887. /** @hidden */
  123888. export var chromaticAberrationPixelShader: {
  123889. name: string;
  123890. shader: string;
  123891. };
  123892. }
  123893. declare module BABYLON {
  123894. /**
  123895. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  123896. */
  123897. export class ChromaticAberrationPostProcess extends PostProcess {
  123898. /**
  123899. * The amount of seperation of rgb channels (default: 30)
  123900. */
  123901. aberrationAmount: number;
  123902. /**
  123903. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  123904. */
  123905. radialIntensity: number;
  123906. /**
  123907. * 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))
  123908. */
  123909. direction: Vector2;
  123910. /**
  123911. * 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))
  123912. */
  123913. centerPosition: Vector2;
  123914. /**
  123915. * Creates a new instance ChromaticAberrationPostProcess
  123916. * @param name The name of the effect.
  123917. * @param screenWidth The width of the screen to apply the effect on.
  123918. * @param screenHeight The height of the screen to apply the effect on.
  123919. * @param options The required width/height ratio to downsize to before computing the render pass.
  123920. * @param camera The camera to apply the render pass to.
  123921. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123922. * @param engine The engine which the post process will be applied. (default: current engine)
  123923. * @param reusable If the post process can be reused on the same frame. (default: false)
  123924. * @param textureType Type of textures used when performing the post process. (default: 0)
  123925. * @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)
  123926. */
  123927. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123928. }
  123929. }
  123930. declare module BABYLON {
  123931. /** @hidden */
  123932. export var circleOfConfusionPixelShader: {
  123933. name: string;
  123934. shader: string;
  123935. };
  123936. }
  123937. declare module BABYLON {
  123938. /**
  123939. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  123940. */
  123941. export class CircleOfConfusionPostProcess extends PostProcess {
  123942. /**
  123943. * 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.
  123944. */
  123945. lensSize: number;
  123946. /**
  123947. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123948. */
  123949. fStop: number;
  123950. /**
  123951. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123952. */
  123953. focusDistance: number;
  123954. /**
  123955. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  123956. */
  123957. focalLength: number;
  123958. private _depthTexture;
  123959. /**
  123960. * Creates a new instance CircleOfConfusionPostProcess
  123961. * @param name The name of the effect.
  123962. * @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.
  123963. * @param options The required width/height ratio to downsize to before computing the render pass.
  123964. * @param camera The camera to apply the render pass to.
  123965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123966. * @param engine The engine which the post process will be applied. (default: current engine)
  123967. * @param reusable If the post process can be reused on the same frame. (default: false)
  123968. * @param textureType Type of textures used when performing the post process. (default: 0)
  123969. * @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)
  123970. */
  123971. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123972. /**
  123973. * 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.
  123974. */
  123975. depthTexture: RenderTargetTexture;
  123976. }
  123977. }
  123978. declare module BABYLON {
  123979. /** @hidden */
  123980. export var colorCorrectionPixelShader: {
  123981. name: string;
  123982. shader: string;
  123983. };
  123984. }
  123985. declare module BABYLON {
  123986. /**
  123987. *
  123988. * This post-process allows the modification of rendered colors by using
  123989. * a 'look-up table' (LUT). This effect is also called Color Grading.
  123990. *
  123991. * The object needs to be provided an url to a texture containing the color
  123992. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  123993. * Use an image editing software to tweak the LUT to match your needs.
  123994. *
  123995. * For an example of a color LUT, see here:
  123996. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  123997. * For explanations on color grading, see here:
  123998. * @see http://udn.epicgames.com/Three/ColorGrading.html
  123999. *
  124000. */
  124001. export class ColorCorrectionPostProcess extends PostProcess {
  124002. private _colorTableTexture;
  124003. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124004. }
  124005. }
  124006. declare module BABYLON {
  124007. /** @hidden */
  124008. export var convolutionPixelShader: {
  124009. name: string;
  124010. shader: string;
  124011. };
  124012. }
  124013. declare module BABYLON {
  124014. /**
  124015. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  124016. * input texture to perform effects such as edge detection or sharpening
  124017. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124018. */
  124019. export class ConvolutionPostProcess extends PostProcess {
  124020. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124021. kernel: number[];
  124022. /**
  124023. * Creates a new instance ConvolutionPostProcess
  124024. * @param name The name of the effect.
  124025. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  124026. * @param options The required width/height ratio to downsize to before computing the render pass.
  124027. * @param camera The camera to apply the render pass to.
  124028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124029. * @param engine The engine which the post process will be applied. (default: current engine)
  124030. * @param reusable If the post process can be reused on the same frame. (default: false)
  124031. * @param textureType Type of textures used when performing the post process. (default: 0)
  124032. */
  124033. constructor(name: string,
  124034. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124035. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124036. /**
  124037. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124038. */
  124039. static EdgeDetect0Kernel: number[];
  124040. /**
  124041. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124042. */
  124043. static EdgeDetect1Kernel: number[];
  124044. /**
  124045. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124046. */
  124047. static EdgeDetect2Kernel: number[];
  124048. /**
  124049. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124050. */
  124051. static SharpenKernel: number[];
  124052. /**
  124053. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124054. */
  124055. static EmbossKernel: number[];
  124056. /**
  124057. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124058. */
  124059. static GaussianKernel: number[];
  124060. }
  124061. }
  124062. declare module BABYLON {
  124063. /**
  124064. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  124065. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  124066. * based on samples that have a large difference in distance than the center pixel.
  124067. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  124068. */
  124069. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  124070. direction: Vector2;
  124071. /**
  124072. * Creates a new instance CircleOfConfusionPostProcess
  124073. * @param name The name of the effect.
  124074. * @param scene The scene the effect belongs to.
  124075. * @param direction The direction the blur should be applied.
  124076. * @param kernel The size of the kernel used to blur.
  124077. * @param options The required width/height ratio to downsize to before computing the render pass.
  124078. * @param camera The camera to apply the render pass to.
  124079. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  124080. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  124081. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124082. * @param engine The engine which the post process will be applied. (default: current engine)
  124083. * @param reusable If the post process can be reused on the same frame. (default: false)
  124084. * @param textureType Type of textures used when performing the post process. (default: 0)
  124085. * @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)
  124086. */
  124087. 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);
  124088. }
  124089. }
  124090. declare module BABYLON {
  124091. /** @hidden */
  124092. export var depthOfFieldMergePixelShader: {
  124093. name: string;
  124094. shader: string;
  124095. };
  124096. }
  124097. declare module BABYLON {
  124098. /**
  124099. * Options to be set when merging outputs from the default pipeline.
  124100. */
  124101. export class DepthOfFieldMergePostProcessOptions {
  124102. /**
  124103. * The original image to merge on top of
  124104. */
  124105. originalFromInput: PostProcess;
  124106. /**
  124107. * Parameters to perform the merge of the depth of field effect
  124108. */
  124109. depthOfField?: {
  124110. circleOfConfusion: PostProcess;
  124111. blurSteps: Array<PostProcess>;
  124112. };
  124113. /**
  124114. * Parameters to perform the merge of bloom effect
  124115. */
  124116. bloom?: {
  124117. blurred: PostProcess;
  124118. weight: number;
  124119. };
  124120. }
  124121. /**
  124122. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  124123. */
  124124. export class DepthOfFieldMergePostProcess extends PostProcess {
  124125. private blurSteps;
  124126. /**
  124127. * Creates a new instance of DepthOfFieldMergePostProcess
  124128. * @param name The name of the effect.
  124129. * @param originalFromInput Post process which's input will be used for the merge.
  124130. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  124131. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  124132. * @param options The required width/height ratio to downsize to before computing the render pass.
  124133. * @param camera The camera to apply the render pass to.
  124134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124135. * @param engine The engine which the post process will be applied. (default: current engine)
  124136. * @param reusable If the post process can be reused on the same frame. (default: false)
  124137. * @param textureType Type of textures used when performing the post process. (default: 0)
  124138. * @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)
  124139. */
  124140. 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);
  124141. /**
  124142. * Updates the effect with the current post process compile time values and recompiles the shader.
  124143. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  124144. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  124145. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  124146. * @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
  124147. * @param onCompiled Called when the shader has been compiled.
  124148. * @param onError Called if there is an error when compiling a shader.
  124149. */
  124150. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  124151. }
  124152. }
  124153. declare module BABYLON {
  124154. /**
  124155. * Specifies the level of max blur that should be applied when using the depth of field effect
  124156. */
  124157. export enum DepthOfFieldEffectBlurLevel {
  124158. /**
  124159. * Subtle blur
  124160. */
  124161. Low = 0,
  124162. /**
  124163. * Medium blur
  124164. */
  124165. Medium = 1,
  124166. /**
  124167. * Large blur
  124168. */
  124169. High = 2
  124170. }
  124171. /**
  124172. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  124173. */
  124174. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  124175. private _circleOfConfusion;
  124176. /**
  124177. * @hidden Internal, blurs from high to low
  124178. */
  124179. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  124180. private _depthOfFieldBlurY;
  124181. private _dofMerge;
  124182. /**
  124183. * @hidden Internal post processes in depth of field effect
  124184. */
  124185. _effects: Array<PostProcess>;
  124186. /**
  124187. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  124188. */
  124189. focalLength: number;
  124190. /**
  124191. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124192. */
  124193. fStop: number;
  124194. /**
  124195. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124196. */
  124197. focusDistance: number;
  124198. /**
  124199. * 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.
  124200. */
  124201. lensSize: number;
  124202. /**
  124203. * Creates a new instance DepthOfFieldEffect
  124204. * @param scene The scene the effect belongs to.
  124205. * @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.
  124206. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124207. * @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)
  124208. */
  124209. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  124210. /**
  124211. * Get the current class name of the current effet
  124212. * @returns "DepthOfFieldEffect"
  124213. */
  124214. getClassName(): string;
  124215. /**
  124216. * 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.
  124217. */
  124218. depthTexture: RenderTargetTexture;
  124219. /**
  124220. * Disposes each of the internal effects for a given camera.
  124221. * @param camera The camera to dispose the effect on.
  124222. */
  124223. disposeEffects(camera: Camera): void;
  124224. /**
  124225. * @hidden Internal
  124226. */
  124227. _updateEffects(): void;
  124228. /**
  124229. * Internal
  124230. * @returns if all the contained post processes are ready.
  124231. * @hidden
  124232. */
  124233. _isReady(): boolean;
  124234. }
  124235. }
  124236. declare module BABYLON {
  124237. /** @hidden */
  124238. export var displayPassPixelShader: {
  124239. name: string;
  124240. shader: string;
  124241. };
  124242. }
  124243. declare module BABYLON {
  124244. /**
  124245. * DisplayPassPostProcess which produces an output the same as it's input
  124246. */
  124247. export class DisplayPassPostProcess extends PostProcess {
  124248. /**
  124249. * Creates the DisplayPassPostProcess
  124250. * @param name The name of the effect.
  124251. * @param options The required width/height ratio to downsize to before computing the render pass.
  124252. * @param camera The camera to apply the render pass to.
  124253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124254. * @param engine The engine which the post process will be applied. (default: current engine)
  124255. * @param reusable If the post process can be reused on the same frame. (default: false)
  124256. */
  124257. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124258. }
  124259. }
  124260. declare module BABYLON {
  124261. /** @hidden */
  124262. export var filterPixelShader: {
  124263. name: string;
  124264. shader: string;
  124265. };
  124266. }
  124267. declare module BABYLON {
  124268. /**
  124269. * Applies a kernel filter to the image
  124270. */
  124271. export class FilterPostProcess extends PostProcess {
  124272. /** The matrix to be applied to the image */
  124273. kernelMatrix: Matrix;
  124274. /**
  124275. *
  124276. * @param name The name of the effect.
  124277. * @param kernelMatrix The matrix to be applied to the image
  124278. * @param options The required width/height ratio to downsize to before computing the render pass.
  124279. * @param camera The camera to apply the render pass to.
  124280. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124281. * @param engine The engine which the post process will be applied. (default: current engine)
  124282. * @param reusable If the post process can be reused on the same frame. (default: false)
  124283. */
  124284. constructor(name: string,
  124285. /** The matrix to be applied to the image */
  124286. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124287. }
  124288. }
  124289. declare module BABYLON {
  124290. /** @hidden */
  124291. export var fxaaPixelShader: {
  124292. name: string;
  124293. shader: string;
  124294. };
  124295. }
  124296. declare module BABYLON {
  124297. /** @hidden */
  124298. export var fxaaVertexShader: {
  124299. name: string;
  124300. shader: string;
  124301. };
  124302. }
  124303. declare module BABYLON {
  124304. /**
  124305. * Fxaa post process
  124306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  124307. */
  124308. export class FxaaPostProcess extends PostProcess {
  124309. /** @hidden */
  124310. texelWidth: number;
  124311. /** @hidden */
  124312. texelHeight: number;
  124313. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124314. private _getDefines;
  124315. }
  124316. }
  124317. declare module BABYLON {
  124318. /** @hidden */
  124319. export var grainPixelShader: {
  124320. name: string;
  124321. shader: string;
  124322. };
  124323. }
  124324. declare module BABYLON {
  124325. /**
  124326. * The GrainPostProcess adds noise to the image at mid luminance levels
  124327. */
  124328. export class GrainPostProcess extends PostProcess {
  124329. /**
  124330. * The intensity of the grain added (default: 30)
  124331. */
  124332. intensity: number;
  124333. /**
  124334. * If the grain should be randomized on every frame
  124335. */
  124336. animated: boolean;
  124337. /**
  124338. * Creates a new instance of @see GrainPostProcess
  124339. * @param name The name of the effect.
  124340. * @param options The required width/height ratio to downsize to before computing the render pass.
  124341. * @param camera The camera to apply the render pass to.
  124342. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124343. * @param engine The engine which the post process will be applied. (default: current engine)
  124344. * @param reusable If the post process can be reused on the same frame. (default: false)
  124345. * @param textureType Type of textures used when performing the post process. (default: 0)
  124346. * @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)
  124347. */
  124348. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124349. }
  124350. }
  124351. declare module BABYLON {
  124352. /** @hidden */
  124353. export var highlightsPixelShader: {
  124354. name: string;
  124355. shader: string;
  124356. };
  124357. }
  124358. declare module BABYLON {
  124359. /**
  124360. * Extracts highlights from the image
  124361. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124362. */
  124363. export class HighlightsPostProcess extends PostProcess {
  124364. /**
  124365. * Extracts highlights from the image
  124366. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124367. * @param name The name of the effect.
  124368. * @param options The required width/height ratio to downsize to before computing the render pass.
  124369. * @param camera The camera to apply the render pass to.
  124370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124371. * @param engine The engine which the post process will be applied. (default: current engine)
  124372. * @param reusable If the post process can be reused on the same frame. (default: false)
  124373. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  124374. */
  124375. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124376. }
  124377. }
  124378. declare module BABYLON {
  124379. /** @hidden */
  124380. export var mrtFragmentDeclaration: {
  124381. name: string;
  124382. shader: string;
  124383. };
  124384. }
  124385. declare module BABYLON {
  124386. /** @hidden */
  124387. export var geometryPixelShader: {
  124388. name: string;
  124389. shader: string;
  124390. };
  124391. }
  124392. declare module BABYLON {
  124393. /** @hidden */
  124394. export var geometryVertexShader: {
  124395. name: string;
  124396. shader: string;
  124397. };
  124398. }
  124399. declare module BABYLON {
  124400. /** @hidden */
  124401. interface ISavedTransformationMatrix {
  124402. world: Matrix;
  124403. viewProjection: Matrix;
  124404. }
  124405. /**
  124406. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  124407. */
  124408. export class GeometryBufferRenderer {
  124409. /**
  124410. * Constant used to retrieve the position texture index in the G-Buffer textures array
  124411. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  124412. */
  124413. static readonly POSITION_TEXTURE_TYPE: number;
  124414. /**
  124415. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  124416. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  124417. */
  124418. static readonly VELOCITY_TEXTURE_TYPE: number;
  124419. /**
  124420. * Dictionary used to store the previous transformation matrices of each rendered mesh
  124421. * in order to compute objects velocities when enableVelocity is set to "true"
  124422. * @hidden
  124423. */
  124424. _previousTransformationMatrices: {
  124425. [index: number]: ISavedTransformationMatrix;
  124426. };
  124427. /**
  124428. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  124429. * in order to compute objects velocities when enableVelocity is set to "true"
  124430. * @hidden
  124431. */
  124432. _previousBonesTransformationMatrices: {
  124433. [index: number]: Float32Array;
  124434. };
  124435. /**
  124436. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  124437. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  124438. */
  124439. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  124440. private _scene;
  124441. private _multiRenderTarget;
  124442. private _ratio;
  124443. private _enablePosition;
  124444. private _enableVelocity;
  124445. private _positionIndex;
  124446. private _velocityIndex;
  124447. protected _effect: Effect;
  124448. protected _cachedDefines: string;
  124449. /**
  124450. * Set the render list (meshes to be rendered) used in the G buffer.
  124451. */
  124452. renderList: Mesh[];
  124453. /**
  124454. * Gets wether or not G buffer are supported by the running hardware.
  124455. * This requires draw buffer supports
  124456. */
  124457. readonly isSupported: boolean;
  124458. /**
  124459. * Returns the index of the given texture type in the G-Buffer textures array
  124460. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  124461. * @returns the index of the given texture type in the G-Buffer textures array
  124462. */
  124463. getTextureIndex(textureType: number): number;
  124464. /**
  124465. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  124466. */
  124467. /**
  124468. * Sets whether or not objects positions are enabled for the G buffer.
  124469. */
  124470. enablePosition: boolean;
  124471. /**
  124472. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  124473. */
  124474. /**
  124475. * Sets wether or not objects velocities are enabled for the G buffer.
  124476. */
  124477. enableVelocity: boolean;
  124478. /**
  124479. * Gets the scene associated with the buffer.
  124480. */
  124481. readonly scene: Scene;
  124482. /**
  124483. * Gets the ratio used by the buffer during its creation.
  124484. * How big is the buffer related to the main canvas.
  124485. */
  124486. readonly ratio: number;
  124487. /** @hidden */
  124488. static _SceneComponentInitialization: (scene: Scene) => void;
  124489. /**
  124490. * Creates a new G Buffer for the scene
  124491. * @param scene The scene the buffer belongs to
  124492. * @param ratio How big is the buffer related to the main canvas.
  124493. */
  124494. constructor(scene: Scene, ratio?: number);
  124495. /**
  124496. * Checks wether everything is ready to render a submesh to the G buffer.
  124497. * @param subMesh the submesh to check readiness for
  124498. * @param useInstances is the mesh drawn using instance or not
  124499. * @returns true if ready otherwise false
  124500. */
  124501. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124502. /**
  124503. * Gets the current underlying G Buffer.
  124504. * @returns the buffer
  124505. */
  124506. getGBuffer(): MultiRenderTarget;
  124507. /**
  124508. * Gets the number of samples used to render the buffer (anti aliasing).
  124509. */
  124510. /**
  124511. * Sets the number of samples used to render the buffer (anti aliasing).
  124512. */
  124513. samples: number;
  124514. /**
  124515. * Disposes the renderer and frees up associated resources.
  124516. */
  124517. dispose(): void;
  124518. protected _createRenderTargets(): void;
  124519. private _copyBonesTransformationMatrices;
  124520. }
  124521. }
  124522. declare module BABYLON {
  124523. interface Scene {
  124524. /** @hidden (Backing field) */
  124525. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124526. /**
  124527. * Gets or Sets the current geometry buffer associated to the scene.
  124528. */
  124529. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124530. /**
  124531. * Enables a GeometryBufferRender and associates it with the scene
  124532. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  124533. * @returns the GeometryBufferRenderer
  124534. */
  124535. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  124536. /**
  124537. * Disables the GeometryBufferRender associated with the scene
  124538. */
  124539. disableGeometryBufferRenderer(): void;
  124540. }
  124541. /**
  124542. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  124543. * in several rendering techniques.
  124544. */
  124545. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  124546. /**
  124547. * The component name helpful to identify the component in the list of scene components.
  124548. */
  124549. readonly name: string;
  124550. /**
  124551. * The scene the component belongs to.
  124552. */
  124553. scene: Scene;
  124554. /**
  124555. * Creates a new instance of the component for the given scene
  124556. * @param scene Defines the scene to register the component in
  124557. */
  124558. constructor(scene: Scene);
  124559. /**
  124560. * Registers the component in a given scene
  124561. */
  124562. register(): void;
  124563. /**
  124564. * Rebuilds the elements related to this component in case of
  124565. * context lost for instance.
  124566. */
  124567. rebuild(): void;
  124568. /**
  124569. * Disposes the component and the associated ressources
  124570. */
  124571. dispose(): void;
  124572. private _gatherRenderTargets;
  124573. }
  124574. }
  124575. declare module BABYLON {
  124576. /** @hidden */
  124577. export var motionBlurPixelShader: {
  124578. name: string;
  124579. shader: string;
  124580. };
  124581. }
  124582. declare module BABYLON {
  124583. /**
  124584. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124585. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124586. * As an example, all you have to do is to create the post-process:
  124587. * var mb = new BABYLON.MotionBlurPostProcess(
  124588. * 'mb', // The name of the effect.
  124589. * scene, // The scene containing the objects to blur according to their velocity.
  124590. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124591. * camera // The camera to apply the render pass to.
  124592. * );
  124593. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124594. */
  124595. export class MotionBlurPostProcess extends PostProcess {
  124596. /**
  124597. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124598. */
  124599. motionStrength: number;
  124600. /**
  124601. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124602. */
  124603. /**
  124604. * Sets the number of iterations to be used for motion blur quality
  124605. */
  124606. motionBlurSamples: number;
  124607. private _motionBlurSamples;
  124608. private _geometryBufferRenderer;
  124609. /**
  124610. * Creates a new instance MotionBlurPostProcess
  124611. * @param name The name of the effect.
  124612. * @param scene The scene containing the objects to blur according to their velocity.
  124613. * @param options The required width/height ratio to downsize to before computing the render pass.
  124614. * @param camera The camera to apply the render pass to.
  124615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124616. * @param engine The engine which the post process will be applied. (default: current engine)
  124617. * @param reusable If the post process can be reused on the same frame. (default: false)
  124618. * @param textureType Type of textures used when performing the post process. (default: 0)
  124619. * @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)
  124620. */
  124621. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124622. /**
  124623. * Excludes the given skinned mesh from computing bones velocities.
  124624. * 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.
  124625. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  124626. */
  124627. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124628. /**
  124629. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  124630. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  124631. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  124632. */
  124633. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124634. /**
  124635. * Disposes the post process.
  124636. * @param camera The camera to dispose the post process on.
  124637. */
  124638. dispose(camera?: Camera): void;
  124639. }
  124640. }
  124641. declare module BABYLON {
  124642. /** @hidden */
  124643. export var refractionPixelShader: {
  124644. name: string;
  124645. shader: string;
  124646. };
  124647. }
  124648. declare module BABYLON {
  124649. /**
  124650. * Post process which applies a refractin texture
  124651. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124652. */
  124653. export class RefractionPostProcess extends PostProcess {
  124654. /** the base color of the refraction (used to taint the rendering) */
  124655. color: Color3;
  124656. /** simulated refraction depth */
  124657. depth: number;
  124658. /** the coefficient of the base color (0 to remove base color tainting) */
  124659. colorLevel: number;
  124660. private _refTexture;
  124661. private _ownRefractionTexture;
  124662. /**
  124663. * Gets or sets the refraction texture
  124664. * Please note that you are responsible for disposing the texture if you set it manually
  124665. */
  124666. refractionTexture: Texture;
  124667. /**
  124668. * Initializes the RefractionPostProcess
  124669. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124670. * @param name The name of the effect.
  124671. * @param refractionTextureUrl Url of the refraction texture to use
  124672. * @param color the base color of the refraction (used to taint the rendering)
  124673. * @param depth simulated refraction depth
  124674. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  124675. * @param camera The camera to apply the render pass to.
  124676. * @param options The required width/height ratio to downsize to before computing the render pass.
  124677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124678. * @param engine The engine which the post process will be applied. (default: current engine)
  124679. * @param reusable If the post process can be reused on the same frame. (default: false)
  124680. */
  124681. constructor(name: string, refractionTextureUrl: string,
  124682. /** the base color of the refraction (used to taint the rendering) */
  124683. color: Color3,
  124684. /** simulated refraction depth */
  124685. depth: number,
  124686. /** the coefficient of the base color (0 to remove base color tainting) */
  124687. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124688. /**
  124689. * Disposes of the post process
  124690. * @param camera Camera to dispose post process on
  124691. */
  124692. dispose(camera: Camera): void;
  124693. }
  124694. }
  124695. declare module BABYLON {
  124696. /** @hidden */
  124697. export var sharpenPixelShader: {
  124698. name: string;
  124699. shader: string;
  124700. };
  124701. }
  124702. declare module BABYLON {
  124703. /**
  124704. * The SharpenPostProcess applies a sharpen kernel to every pixel
  124705. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124706. */
  124707. export class SharpenPostProcess extends PostProcess {
  124708. /**
  124709. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  124710. */
  124711. colorAmount: number;
  124712. /**
  124713. * How much sharpness should be applied (default: 0.3)
  124714. */
  124715. edgeAmount: number;
  124716. /**
  124717. * Creates a new instance ConvolutionPostProcess
  124718. * @param name The name of the effect.
  124719. * @param options The required width/height ratio to downsize to before computing the render pass.
  124720. * @param camera The camera to apply the render pass to.
  124721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124722. * @param engine The engine which the post process will be applied. (default: current engine)
  124723. * @param reusable If the post process can be reused on the same frame. (default: false)
  124724. * @param textureType Type of textures used when performing the post process. (default: 0)
  124725. * @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)
  124726. */
  124727. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124728. }
  124729. }
  124730. declare module BABYLON {
  124731. /**
  124732. * PostProcessRenderPipeline
  124733. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124734. */
  124735. export class PostProcessRenderPipeline {
  124736. private engine;
  124737. private _renderEffects;
  124738. private _renderEffectsForIsolatedPass;
  124739. /**
  124740. * List of inspectable custom properties (used by the Inspector)
  124741. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  124742. */
  124743. inspectableCustomProperties: IInspectable[];
  124744. /**
  124745. * @hidden
  124746. */
  124747. protected _cameras: Camera[];
  124748. /** @hidden */
  124749. _name: string;
  124750. /**
  124751. * Gets pipeline name
  124752. */
  124753. readonly name: string;
  124754. /**
  124755. * Initializes a PostProcessRenderPipeline
  124756. * @param engine engine to add the pipeline to
  124757. * @param name name of the pipeline
  124758. */
  124759. constructor(engine: Engine, name: string);
  124760. /**
  124761. * Gets the class name
  124762. * @returns "PostProcessRenderPipeline"
  124763. */
  124764. getClassName(): string;
  124765. /**
  124766. * If all the render effects in the pipeline are supported
  124767. */
  124768. readonly isSupported: boolean;
  124769. /**
  124770. * Adds an effect to the pipeline
  124771. * @param renderEffect the effect to add
  124772. */
  124773. addEffect(renderEffect: PostProcessRenderEffect): void;
  124774. /** @hidden */
  124775. _rebuild(): void;
  124776. /** @hidden */
  124777. _enableEffect(renderEffectName: string, cameras: Camera): void;
  124778. /** @hidden */
  124779. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  124780. /** @hidden */
  124781. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124782. /** @hidden */
  124783. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124784. /** @hidden */
  124785. _attachCameras(cameras: Camera, unique: boolean): void;
  124786. /** @hidden */
  124787. _attachCameras(cameras: Camera[], unique: boolean): void;
  124788. /** @hidden */
  124789. _detachCameras(cameras: Camera): void;
  124790. /** @hidden */
  124791. _detachCameras(cameras: Nullable<Camera[]>): void;
  124792. /** @hidden */
  124793. _update(): void;
  124794. /** @hidden */
  124795. _reset(): void;
  124796. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  124797. /**
  124798. * Disposes of the pipeline
  124799. */
  124800. dispose(): void;
  124801. }
  124802. }
  124803. declare module BABYLON {
  124804. /**
  124805. * PostProcessRenderPipelineManager class
  124806. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124807. */
  124808. export class PostProcessRenderPipelineManager {
  124809. private _renderPipelines;
  124810. /**
  124811. * Initializes a PostProcessRenderPipelineManager
  124812. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124813. */
  124814. constructor();
  124815. /**
  124816. * Gets the list of supported render pipelines
  124817. */
  124818. readonly supportedPipelines: PostProcessRenderPipeline[];
  124819. /**
  124820. * Adds a pipeline to the manager
  124821. * @param renderPipeline The pipeline to add
  124822. */
  124823. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  124824. /**
  124825. * Attaches a camera to the pipeline
  124826. * @param renderPipelineName The name of the pipeline to attach to
  124827. * @param cameras the camera to attach
  124828. * @param unique if the camera can be attached multiple times to the pipeline
  124829. */
  124830. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  124831. /**
  124832. * Detaches a camera from the pipeline
  124833. * @param renderPipelineName The name of the pipeline to detach from
  124834. * @param cameras the camera to detach
  124835. */
  124836. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  124837. /**
  124838. * Enables an effect by name on a pipeline
  124839. * @param renderPipelineName the name of the pipeline to enable the effect in
  124840. * @param renderEffectName the name of the effect to enable
  124841. * @param cameras the cameras that the effect should be enabled on
  124842. */
  124843. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124844. /**
  124845. * Disables an effect by name on a pipeline
  124846. * @param renderPipelineName the name of the pipeline to disable the effect in
  124847. * @param renderEffectName the name of the effect to disable
  124848. * @param cameras the cameras that the effect should be disabled on
  124849. */
  124850. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124851. /**
  124852. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  124853. */
  124854. update(): void;
  124855. /** @hidden */
  124856. _rebuild(): void;
  124857. /**
  124858. * Disposes of the manager and pipelines
  124859. */
  124860. dispose(): void;
  124861. }
  124862. }
  124863. declare module BABYLON {
  124864. interface Scene {
  124865. /** @hidden (Backing field) */
  124866. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124867. /**
  124868. * Gets the postprocess render pipeline manager
  124869. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124870. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124871. */
  124872. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124873. }
  124874. /**
  124875. * Defines the Render Pipeline scene component responsible to rendering pipelines
  124876. */
  124877. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  124878. /**
  124879. * The component name helpfull to identify the component in the list of scene components.
  124880. */
  124881. readonly name: string;
  124882. /**
  124883. * The scene the component belongs to.
  124884. */
  124885. scene: Scene;
  124886. /**
  124887. * Creates a new instance of the component for the given scene
  124888. * @param scene Defines the scene to register the component in
  124889. */
  124890. constructor(scene: Scene);
  124891. /**
  124892. * Registers the component in a given scene
  124893. */
  124894. register(): void;
  124895. /**
  124896. * Rebuilds the elements related to this component in case of
  124897. * context lost for instance.
  124898. */
  124899. rebuild(): void;
  124900. /**
  124901. * Disposes the component and the associated ressources
  124902. */
  124903. dispose(): void;
  124904. private _gatherRenderTargets;
  124905. }
  124906. }
  124907. declare module BABYLON {
  124908. /**
  124909. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  124910. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124911. */
  124912. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  124913. private _scene;
  124914. private _camerasToBeAttached;
  124915. /**
  124916. * ID of the sharpen post process,
  124917. */
  124918. private readonly SharpenPostProcessId;
  124919. /**
  124920. * @ignore
  124921. * ID of the image processing post process;
  124922. */
  124923. readonly ImageProcessingPostProcessId: string;
  124924. /**
  124925. * @ignore
  124926. * ID of the Fast Approximate Anti-Aliasing post process;
  124927. */
  124928. readonly FxaaPostProcessId: string;
  124929. /**
  124930. * ID of the chromatic aberration post process,
  124931. */
  124932. private readonly ChromaticAberrationPostProcessId;
  124933. /**
  124934. * ID of the grain post process
  124935. */
  124936. private readonly GrainPostProcessId;
  124937. /**
  124938. * Sharpen post process which will apply a sharpen convolution to enhance edges
  124939. */
  124940. sharpen: SharpenPostProcess;
  124941. private _sharpenEffect;
  124942. private bloom;
  124943. /**
  124944. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  124945. */
  124946. depthOfField: DepthOfFieldEffect;
  124947. /**
  124948. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  124949. */
  124950. fxaa: FxaaPostProcess;
  124951. /**
  124952. * Image post processing pass used to perform operations such as tone mapping or color grading.
  124953. */
  124954. imageProcessing: ImageProcessingPostProcess;
  124955. /**
  124956. * Chromatic aberration post process which will shift rgb colors in the image
  124957. */
  124958. chromaticAberration: ChromaticAberrationPostProcess;
  124959. private _chromaticAberrationEffect;
  124960. /**
  124961. * Grain post process which add noise to the image
  124962. */
  124963. grain: GrainPostProcess;
  124964. private _grainEffect;
  124965. /**
  124966. * Glow post process which adds a glow to emissive areas of the image
  124967. */
  124968. private _glowLayer;
  124969. /**
  124970. * Animations which can be used to tweak settings over a period of time
  124971. */
  124972. animations: Animation[];
  124973. private _imageProcessingConfigurationObserver;
  124974. private _sharpenEnabled;
  124975. private _bloomEnabled;
  124976. private _depthOfFieldEnabled;
  124977. private _depthOfFieldBlurLevel;
  124978. private _fxaaEnabled;
  124979. private _imageProcessingEnabled;
  124980. private _defaultPipelineTextureType;
  124981. private _bloomScale;
  124982. private _chromaticAberrationEnabled;
  124983. private _grainEnabled;
  124984. private _buildAllowed;
  124985. /**
  124986. * Gets active scene
  124987. */
  124988. readonly scene: Scene;
  124989. /**
  124990. * Enable or disable the sharpen process from the pipeline
  124991. */
  124992. sharpenEnabled: boolean;
  124993. private _resizeObserver;
  124994. private _hardwareScaleLevel;
  124995. private _bloomKernel;
  124996. /**
  124997. * Specifies the size of the bloom blur kernel, relative to the final output size
  124998. */
  124999. bloomKernel: number;
  125000. /**
  125001. * Specifies the weight of the bloom in the final rendering
  125002. */
  125003. private _bloomWeight;
  125004. /**
  125005. * Specifies the luma threshold for the area that will be blurred by the bloom
  125006. */
  125007. private _bloomThreshold;
  125008. private _hdr;
  125009. /**
  125010. * The strength of the bloom.
  125011. */
  125012. bloomWeight: number;
  125013. /**
  125014. * The strength of the bloom.
  125015. */
  125016. bloomThreshold: number;
  125017. /**
  125018. * The scale of the bloom, lower value will provide better performance.
  125019. */
  125020. bloomScale: number;
  125021. /**
  125022. * Enable or disable the bloom from the pipeline
  125023. */
  125024. bloomEnabled: boolean;
  125025. private _rebuildBloom;
  125026. /**
  125027. * If the depth of field is enabled.
  125028. */
  125029. depthOfFieldEnabled: boolean;
  125030. /**
  125031. * Blur level of the depth of field effect. (Higher blur will effect performance)
  125032. */
  125033. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  125034. /**
  125035. * If the anti aliasing is enabled.
  125036. */
  125037. fxaaEnabled: boolean;
  125038. private _samples;
  125039. /**
  125040. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125041. */
  125042. samples: number;
  125043. /**
  125044. * If image processing is enabled.
  125045. */
  125046. imageProcessingEnabled: boolean;
  125047. /**
  125048. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  125049. */
  125050. glowLayerEnabled: boolean;
  125051. /**
  125052. * Gets the glow layer (or null if not defined)
  125053. */
  125054. readonly glowLayer: Nullable<GlowLayer>;
  125055. /**
  125056. * Enable or disable the chromaticAberration process from the pipeline
  125057. */
  125058. chromaticAberrationEnabled: boolean;
  125059. /**
  125060. * Enable or disable the grain process from the pipeline
  125061. */
  125062. grainEnabled: boolean;
  125063. /**
  125064. * @constructor
  125065. * @param name - The rendering pipeline name (default: "")
  125066. * @param hdr - If high dynamic range textures should be used (default: true)
  125067. * @param scene - The scene linked to this pipeline (default: the last created scene)
  125068. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  125069. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  125070. */
  125071. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  125072. /**
  125073. * Get the class name
  125074. * @returns "DefaultRenderingPipeline"
  125075. */
  125076. getClassName(): string;
  125077. /**
  125078. * Force the compilation of the entire pipeline.
  125079. */
  125080. prepare(): void;
  125081. private _hasCleared;
  125082. private _prevPostProcess;
  125083. private _prevPrevPostProcess;
  125084. private _setAutoClearAndTextureSharing;
  125085. private _depthOfFieldSceneObserver;
  125086. private _buildPipeline;
  125087. private _disposePostProcesses;
  125088. /**
  125089. * Adds a camera to the pipeline
  125090. * @param camera the camera to be added
  125091. */
  125092. addCamera(camera: Camera): void;
  125093. /**
  125094. * Removes a camera from the pipeline
  125095. * @param camera the camera to remove
  125096. */
  125097. removeCamera(camera: Camera): void;
  125098. /**
  125099. * Dispose of the pipeline and stop all post processes
  125100. */
  125101. dispose(): void;
  125102. /**
  125103. * Serialize the rendering pipeline (Used when exporting)
  125104. * @returns the serialized object
  125105. */
  125106. serialize(): any;
  125107. /**
  125108. * Parse the serialized pipeline
  125109. * @param source Source pipeline.
  125110. * @param scene The scene to load the pipeline to.
  125111. * @param rootUrl The URL of the serialized pipeline.
  125112. * @returns An instantiated pipeline from the serialized object.
  125113. */
  125114. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  125115. }
  125116. }
  125117. declare module BABYLON {
  125118. /** @hidden */
  125119. export var lensHighlightsPixelShader: {
  125120. name: string;
  125121. shader: string;
  125122. };
  125123. }
  125124. declare module BABYLON {
  125125. /** @hidden */
  125126. export var depthOfFieldPixelShader: {
  125127. name: string;
  125128. shader: string;
  125129. };
  125130. }
  125131. declare module BABYLON {
  125132. /**
  125133. * BABYLON.JS Chromatic Aberration GLSL Shader
  125134. * Author: Olivier Guyot
  125135. * Separates very slightly R, G and B colors on the edges of the screen
  125136. * Inspired by Francois Tarlier & Martins Upitis
  125137. */
  125138. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  125139. /**
  125140. * @ignore
  125141. * The chromatic aberration PostProcess id in the pipeline
  125142. */
  125143. LensChromaticAberrationEffect: string;
  125144. /**
  125145. * @ignore
  125146. * The highlights enhancing PostProcess id in the pipeline
  125147. */
  125148. HighlightsEnhancingEffect: string;
  125149. /**
  125150. * @ignore
  125151. * The depth-of-field PostProcess id in the pipeline
  125152. */
  125153. LensDepthOfFieldEffect: string;
  125154. private _scene;
  125155. private _depthTexture;
  125156. private _grainTexture;
  125157. private _chromaticAberrationPostProcess;
  125158. private _highlightsPostProcess;
  125159. private _depthOfFieldPostProcess;
  125160. private _edgeBlur;
  125161. private _grainAmount;
  125162. private _chromaticAberration;
  125163. private _distortion;
  125164. private _highlightsGain;
  125165. private _highlightsThreshold;
  125166. private _dofDistance;
  125167. private _dofAperture;
  125168. private _dofDarken;
  125169. private _dofPentagon;
  125170. private _blurNoise;
  125171. /**
  125172. * @constructor
  125173. *
  125174. * Effect parameters are as follow:
  125175. * {
  125176. * chromatic_aberration: number; // from 0 to x (1 for realism)
  125177. * edge_blur: number; // from 0 to x (1 for realism)
  125178. * distortion: number; // from 0 to x (1 for realism)
  125179. * grain_amount: number; // from 0 to 1
  125180. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  125181. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  125182. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  125183. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  125184. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  125185. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  125186. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  125187. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  125188. * }
  125189. * Note: if an effect parameter is unset, effect is disabled
  125190. *
  125191. * @param name The rendering pipeline name
  125192. * @param parameters - An object containing all parameters (see above)
  125193. * @param scene The scene linked to this pipeline
  125194. * @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)
  125195. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125196. */
  125197. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  125198. /**
  125199. * Get the class name
  125200. * @returns "LensRenderingPipeline"
  125201. */
  125202. getClassName(): string;
  125203. /**
  125204. * Gets associated scene
  125205. */
  125206. readonly scene: Scene;
  125207. /**
  125208. * Gets or sets the edge blur
  125209. */
  125210. edgeBlur: number;
  125211. /**
  125212. * Gets or sets the grain amount
  125213. */
  125214. grainAmount: number;
  125215. /**
  125216. * Gets or sets the chromatic aberration amount
  125217. */
  125218. chromaticAberration: number;
  125219. /**
  125220. * Gets or sets the depth of field aperture
  125221. */
  125222. dofAperture: number;
  125223. /**
  125224. * Gets or sets the edge distortion
  125225. */
  125226. edgeDistortion: number;
  125227. /**
  125228. * Gets or sets the depth of field distortion
  125229. */
  125230. dofDistortion: number;
  125231. /**
  125232. * Gets or sets the darken out of focus amount
  125233. */
  125234. darkenOutOfFocus: number;
  125235. /**
  125236. * Gets or sets a boolean indicating if blur noise is enabled
  125237. */
  125238. blurNoise: boolean;
  125239. /**
  125240. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  125241. */
  125242. pentagonBokeh: boolean;
  125243. /**
  125244. * Gets or sets the highlight grain amount
  125245. */
  125246. highlightsGain: number;
  125247. /**
  125248. * Gets or sets the highlight threshold
  125249. */
  125250. highlightsThreshold: number;
  125251. /**
  125252. * Sets the amount of blur at the edges
  125253. * @param amount blur amount
  125254. */
  125255. setEdgeBlur(amount: number): void;
  125256. /**
  125257. * Sets edge blur to 0
  125258. */
  125259. disableEdgeBlur(): void;
  125260. /**
  125261. * Sets the amout of grain
  125262. * @param amount Amount of grain
  125263. */
  125264. setGrainAmount(amount: number): void;
  125265. /**
  125266. * Set grain amount to 0
  125267. */
  125268. disableGrain(): void;
  125269. /**
  125270. * Sets the chromatic aberration amount
  125271. * @param amount amount of chromatic aberration
  125272. */
  125273. setChromaticAberration(amount: number): void;
  125274. /**
  125275. * Sets chromatic aberration amount to 0
  125276. */
  125277. disableChromaticAberration(): void;
  125278. /**
  125279. * Sets the EdgeDistortion amount
  125280. * @param amount amount of EdgeDistortion
  125281. */
  125282. setEdgeDistortion(amount: number): void;
  125283. /**
  125284. * Sets edge distortion to 0
  125285. */
  125286. disableEdgeDistortion(): void;
  125287. /**
  125288. * Sets the FocusDistance amount
  125289. * @param amount amount of FocusDistance
  125290. */
  125291. setFocusDistance(amount: number): void;
  125292. /**
  125293. * Disables depth of field
  125294. */
  125295. disableDepthOfField(): void;
  125296. /**
  125297. * Sets the Aperture amount
  125298. * @param amount amount of Aperture
  125299. */
  125300. setAperture(amount: number): void;
  125301. /**
  125302. * Sets the DarkenOutOfFocus amount
  125303. * @param amount amount of DarkenOutOfFocus
  125304. */
  125305. setDarkenOutOfFocus(amount: number): void;
  125306. private _pentagonBokehIsEnabled;
  125307. /**
  125308. * Creates a pentagon bokeh effect
  125309. */
  125310. enablePentagonBokeh(): void;
  125311. /**
  125312. * Disables the pentagon bokeh effect
  125313. */
  125314. disablePentagonBokeh(): void;
  125315. /**
  125316. * Enables noise blur
  125317. */
  125318. enableNoiseBlur(): void;
  125319. /**
  125320. * Disables noise blur
  125321. */
  125322. disableNoiseBlur(): void;
  125323. /**
  125324. * Sets the HighlightsGain amount
  125325. * @param amount amount of HighlightsGain
  125326. */
  125327. setHighlightsGain(amount: number): void;
  125328. /**
  125329. * Sets the HighlightsThreshold amount
  125330. * @param amount amount of HighlightsThreshold
  125331. */
  125332. setHighlightsThreshold(amount: number): void;
  125333. /**
  125334. * Disables highlights
  125335. */
  125336. disableHighlights(): void;
  125337. /**
  125338. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  125339. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  125340. */
  125341. dispose(disableDepthRender?: boolean): void;
  125342. private _createChromaticAberrationPostProcess;
  125343. private _createHighlightsPostProcess;
  125344. private _createDepthOfFieldPostProcess;
  125345. private _createGrainTexture;
  125346. }
  125347. }
  125348. declare module BABYLON {
  125349. /** @hidden */
  125350. export var ssao2PixelShader: {
  125351. name: string;
  125352. shader: string;
  125353. };
  125354. }
  125355. declare module BABYLON {
  125356. /** @hidden */
  125357. export var ssaoCombinePixelShader: {
  125358. name: string;
  125359. shader: string;
  125360. };
  125361. }
  125362. declare module BABYLON {
  125363. /**
  125364. * Render pipeline to produce ssao effect
  125365. */
  125366. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  125367. /**
  125368. * @ignore
  125369. * The PassPostProcess id in the pipeline that contains the original scene color
  125370. */
  125371. SSAOOriginalSceneColorEffect: string;
  125372. /**
  125373. * @ignore
  125374. * The SSAO PostProcess id in the pipeline
  125375. */
  125376. SSAORenderEffect: string;
  125377. /**
  125378. * @ignore
  125379. * The horizontal blur PostProcess id in the pipeline
  125380. */
  125381. SSAOBlurHRenderEffect: string;
  125382. /**
  125383. * @ignore
  125384. * The vertical blur PostProcess id in the pipeline
  125385. */
  125386. SSAOBlurVRenderEffect: string;
  125387. /**
  125388. * @ignore
  125389. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125390. */
  125391. SSAOCombineRenderEffect: string;
  125392. /**
  125393. * The output strength of the SSAO post-process. Default value is 1.0.
  125394. */
  125395. totalStrength: number;
  125396. /**
  125397. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  125398. */
  125399. maxZ: number;
  125400. /**
  125401. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  125402. */
  125403. minZAspect: number;
  125404. private _samples;
  125405. /**
  125406. * Number of samples used for the SSAO calculations. Default value is 8
  125407. */
  125408. samples: number;
  125409. private _textureSamples;
  125410. /**
  125411. * Number of samples to use for antialiasing
  125412. */
  125413. textureSamples: number;
  125414. /**
  125415. * Ratio object used for SSAO ratio and blur ratio
  125416. */
  125417. private _ratio;
  125418. /**
  125419. * Dynamically generated sphere sampler.
  125420. */
  125421. private _sampleSphere;
  125422. /**
  125423. * Blur filter offsets
  125424. */
  125425. private _samplerOffsets;
  125426. private _expensiveBlur;
  125427. /**
  125428. * If bilateral blur should be used
  125429. */
  125430. expensiveBlur: boolean;
  125431. /**
  125432. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  125433. */
  125434. radius: number;
  125435. /**
  125436. * The base color of the SSAO post-process
  125437. * The final result is "base + ssao" between [0, 1]
  125438. */
  125439. base: number;
  125440. /**
  125441. * Support test.
  125442. */
  125443. static readonly IsSupported: boolean;
  125444. private _scene;
  125445. private _depthTexture;
  125446. private _normalTexture;
  125447. private _randomTexture;
  125448. private _originalColorPostProcess;
  125449. private _ssaoPostProcess;
  125450. private _blurHPostProcess;
  125451. private _blurVPostProcess;
  125452. private _ssaoCombinePostProcess;
  125453. private _firstUpdate;
  125454. /**
  125455. * Gets active scene
  125456. */
  125457. readonly scene: Scene;
  125458. /**
  125459. * @constructor
  125460. * @param name The rendering pipeline name
  125461. * @param scene The scene linked to this pipeline
  125462. * @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 }
  125463. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125464. */
  125465. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125466. /**
  125467. * Get the class name
  125468. * @returns "SSAO2RenderingPipeline"
  125469. */
  125470. getClassName(): string;
  125471. /**
  125472. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125473. */
  125474. dispose(disableGeometryBufferRenderer?: boolean): void;
  125475. private _createBlurPostProcess;
  125476. /** @hidden */
  125477. _rebuild(): void;
  125478. private _bits;
  125479. private _radicalInverse_VdC;
  125480. private _hammersley;
  125481. private _hemisphereSample_uniform;
  125482. private _generateHemisphere;
  125483. private _createSSAOPostProcess;
  125484. private _createSSAOCombinePostProcess;
  125485. private _createRandomTexture;
  125486. /**
  125487. * Serialize the rendering pipeline (Used when exporting)
  125488. * @returns the serialized object
  125489. */
  125490. serialize(): any;
  125491. /**
  125492. * Parse the serialized pipeline
  125493. * @param source Source pipeline.
  125494. * @param scene The scene to load the pipeline to.
  125495. * @param rootUrl The URL of the serialized pipeline.
  125496. * @returns An instantiated pipeline from the serialized object.
  125497. */
  125498. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  125499. }
  125500. }
  125501. declare module BABYLON {
  125502. /** @hidden */
  125503. export var ssaoPixelShader: {
  125504. name: string;
  125505. shader: string;
  125506. };
  125507. }
  125508. declare module BABYLON {
  125509. /**
  125510. * Render pipeline to produce ssao effect
  125511. */
  125512. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  125513. /**
  125514. * @ignore
  125515. * The PassPostProcess id in the pipeline that contains the original scene color
  125516. */
  125517. SSAOOriginalSceneColorEffect: string;
  125518. /**
  125519. * @ignore
  125520. * The SSAO PostProcess id in the pipeline
  125521. */
  125522. SSAORenderEffect: string;
  125523. /**
  125524. * @ignore
  125525. * The horizontal blur PostProcess id in the pipeline
  125526. */
  125527. SSAOBlurHRenderEffect: string;
  125528. /**
  125529. * @ignore
  125530. * The vertical blur PostProcess id in the pipeline
  125531. */
  125532. SSAOBlurVRenderEffect: string;
  125533. /**
  125534. * @ignore
  125535. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125536. */
  125537. SSAOCombineRenderEffect: string;
  125538. /**
  125539. * The output strength of the SSAO post-process. Default value is 1.0.
  125540. */
  125541. totalStrength: number;
  125542. /**
  125543. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  125544. */
  125545. radius: number;
  125546. /**
  125547. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  125548. * Must not be equal to fallOff and superior to fallOff.
  125549. * Default value is 0.0075
  125550. */
  125551. area: number;
  125552. /**
  125553. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  125554. * Must not be equal to area and inferior to area.
  125555. * Default value is 0.000001
  125556. */
  125557. fallOff: number;
  125558. /**
  125559. * The base color of the SSAO post-process
  125560. * The final result is "base + ssao" between [0, 1]
  125561. */
  125562. base: number;
  125563. private _scene;
  125564. private _depthTexture;
  125565. private _randomTexture;
  125566. private _originalColorPostProcess;
  125567. private _ssaoPostProcess;
  125568. private _blurHPostProcess;
  125569. private _blurVPostProcess;
  125570. private _ssaoCombinePostProcess;
  125571. private _firstUpdate;
  125572. /**
  125573. * Gets active scene
  125574. */
  125575. readonly scene: Scene;
  125576. /**
  125577. * @constructor
  125578. * @param name - The rendering pipeline name
  125579. * @param scene - The scene linked to this pipeline
  125580. * @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 }
  125581. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  125582. */
  125583. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125584. /**
  125585. * Get the class name
  125586. * @returns "SSAORenderingPipeline"
  125587. */
  125588. getClassName(): string;
  125589. /**
  125590. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125591. */
  125592. dispose(disableDepthRender?: boolean): void;
  125593. private _createBlurPostProcess;
  125594. /** @hidden */
  125595. _rebuild(): void;
  125596. private _createSSAOPostProcess;
  125597. private _createSSAOCombinePostProcess;
  125598. private _createRandomTexture;
  125599. }
  125600. }
  125601. declare module BABYLON {
  125602. /** @hidden */
  125603. export var standardPixelShader: {
  125604. name: string;
  125605. shader: string;
  125606. };
  125607. }
  125608. declare module BABYLON {
  125609. /**
  125610. * Standard rendering pipeline
  125611. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125612. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  125613. */
  125614. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125615. /**
  125616. * Public members
  125617. */
  125618. /**
  125619. * Post-process which contains the original scene color before the pipeline applies all the effects
  125620. */
  125621. originalPostProcess: Nullable<PostProcess>;
  125622. /**
  125623. * Post-process used to down scale an image x4
  125624. */
  125625. downSampleX4PostProcess: Nullable<PostProcess>;
  125626. /**
  125627. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  125628. */
  125629. brightPassPostProcess: Nullable<PostProcess>;
  125630. /**
  125631. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  125632. */
  125633. blurHPostProcesses: PostProcess[];
  125634. /**
  125635. * Post-process array storing all the vertical blur post-processes used by the pipeline
  125636. */
  125637. blurVPostProcesses: PostProcess[];
  125638. /**
  125639. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  125640. */
  125641. textureAdderPostProcess: Nullable<PostProcess>;
  125642. /**
  125643. * Post-process used to create volumetric lighting effect
  125644. */
  125645. volumetricLightPostProcess: Nullable<PostProcess>;
  125646. /**
  125647. * Post-process used to smooth the previous volumetric light post-process on the X axis
  125648. */
  125649. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  125650. /**
  125651. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  125652. */
  125653. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  125654. /**
  125655. * Post-process used to merge the volumetric light effect and the real scene color
  125656. */
  125657. volumetricLightMergePostProces: Nullable<PostProcess>;
  125658. /**
  125659. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  125660. */
  125661. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  125662. /**
  125663. * Base post-process used to calculate the average luminance of the final image for HDR
  125664. */
  125665. luminancePostProcess: Nullable<PostProcess>;
  125666. /**
  125667. * Post-processes used to create down sample post-processes in order to get
  125668. * the average luminance of the final image for HDR
  125669. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  125670. */
  125671. luminanceDownSamplePostProcesses: PostProcess[];
  125672. /**
  125673. * Post-process used to create a HDR effect (light adaptation)
  125674. */
  125675. hdrPostProcess: Nullable<PostProcess>;
  125676. /**
  125677. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  125678. */
  125679. textureAdderFinalPostProcess: Nullable<PostProcess>;
  125680. /**
  125681. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  125682. */
  125683. lensFlareFinalPostProcess: Nullable<PostProcess>;
  125684. /**
  125685. * Post-process used to merge the final HDR post-process and the real scene color
  125686. */
  125687. hdrFinalPostProcess: Nullable<PostProcess>;
  125688. /**
  125689. * Post-process used to create a lens flare effect
  125690. */
  125691. lensFlarePostProcess: Nullable<PostProcess>;
  125692. /**
  125693. * Post-process that merges the result of the lens flare post-process and the real scene color
  125694. */
  125695. lensFlareComposePostProcess: Nullable<PostProcess>;
  125696. /**
  125697. * Post-process used to create a motion blur effect
  125698. */
  125699. motionBlurPostProcess: Nullable<PostProcess>;
  125700. /**
  125701. * Post-process used to create a depth of field effect
  125702. */
  125703. depthOfFieldPostProcess: Nullable<PostProcess>;
  125704. /**
  125705. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125706. */
  125707. fxaaPostProcess: Nullable<FxaaPostProcess>;
  125708. /**
  125709. * Represents the brightness threshold in order to configure the illuminated surfaces
  125710. */
  125711. brightThreshold: number;
  125712. /**
  125713. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  125714. */
  125715. blurWidth: number;
  125716. /**
  125717. * Sets if the blur for highlighted surfaces must be only horizontal
  125718. */
  125719. horizontalBlur: boolean;
  125720. /**
  125721. * Gets the overall exposure used by the pipeline
  125722. */
  125723. /**
  125724. * Sets the overall exposure used by the pipeline
  125725. */
  125726. exposure: number;
  125727. /**
  125728. * Texture used typically to simulate "dirty" on camera lens
  125729. */
  125730. lensTexture: Nullable<Texture>;
  125731. /**
  125732. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  125733. */
  125734. volumetricLightCoefficient: number;
  125735. /**
  125736. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  125737. */
  125738. volumetricLightPower: number;
  125739. /**
  125740. * Used the set the blur intensity to smooth the volumetric lights
  125741. */
  125742. volumetricLightBlurScale: number;
  125743. /**
  125744. * Light (spot or directional) used to generate the volumetric lights rays
  125745. * The source light must have a shadow generate so the pipeline can get its
  125746. * depth map
  125747. */
  125748. sourceLight: Nullable<SpotLight | DirectionalLight>;
  125749. /**
  125750. * For eye adaptation, represents the minimum luminance the eye can see
  125751. */
  125752. hdrMinimumLuminance: number;
  125753. /**
  125754. * For eye adaptation, represents the decrease luminance speed
  125755. */
  125756. hdrDecreaseRate: number;
  125757. /**
  125758. * For eye adaptation, represents the increase luminance speed
  125759. */
  125760. hdrIncreaseRate: number;
  125761. /**
  125762. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125763. */
  125764. /**
  125765. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125766. */
  125767. hdrAutoExposure: boolean;
  125768. /**
  125769. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  125770. */
  125771. lensColorTexture: Nullable<Texture>;
  125772. /**
  125773. * The overall strengh for the lens flare effect
  125774. */
  125775. lensFlareStrength: number;
  125776. /**
  125777. * Dispersion coefficient for lens flare ghosts
  125778. */
  125779. lensFlareGhostDispersal: number;
  125780. /**
  125781. * Main lens flare halo width
  125782. */
  125783. lensFlareHaloWidth: number;
  125784. /**
  125785. * Based on the lens distortion effect, defines how much the lens flare result
  125786. * is distorted
  125787. */
  125788. lensFlareDistortionStrength: number;
  125789. /**
  125790. * Configures the blur intensity used for for lens flare (halo)
  125791. */
  125792. lensFlareBlurWidth: number;
  125793. /**
  125794. * Lens star texture must be used to simulate rays on the flares and is available
  125795. * in the documentation
  125796. */
  125797. lensStarTexture: Nullable<Texture>;
  125798. /**
  125799. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  125800. * flare effect by taking account of the dirt texture
  125801. */
  125802. lensFlareDirtTexture: Nullable<Texture>;
  125803. /**
  125804. * Represents the focal length for the depth of field effect
  125805. */
  125806. depthOfFieldDistance: number;
  125807. /**
  125808. * Represents the blur intensity for the blurred part of the depth of field effect
  125809. */
  125810. depthOfFieldBlurWidth: number;
  125811. /**
  125812. * Gets how much the image is blurred by the movement while using the motion blur post-process
  125813. */
  125814. /**
  125815. * Sets how much the image is blurred by the movement while using the motion blur post-process
  125816. */
  125817. motionStrength: number;
  125818. /**
  125819. * Gets wether or not the motion blur post-process is object based or screen based.
  125820. */
  125821. /**
  125822. * Sets wether or not the motion blur post-process should be object based or screen based
  125823. */
  125824. objectBasedMotionBlur: boolean;
  125825. /**
  125826. * List of animations for the pipeline (IAnimatable implementation)
  125827. */
  125828. animations: Animation[];
  125829. /**
  125830. * Private members
  125831. */
  125832. private _scene;
  125833. private _currentDepthOfFieldSource;
  125834. private _basePostProcess;
  125835. private _fixedExposure;
  125836. private _currentExposure;
  125837. private _hdrAutoExposure;
  125838. private _hdrCurrentLuminance;
  125839. private _motionStrength;
  125840. private _isObjectBasedMotionBlur;
  125841. private _floatTextureType;
  125842. private _camerasToBeAttached;
  125843. private _ratio;
  125844. private _bloomEnabled;
  125845. private _depthOfFieldEnabled;
  125846. private _vlsEnabled;
  125847. private _lensFlareEnabled;
  125848. private _hdrEnabled;
  125849. private _motionBlurEnabled;
  125850. private _fxaaEnabled;
  125851. private _motionBlurSamples;
  125852. private _volumetricLightStepsCount;
  125853. private _samples;
  125854. /**
  125855. * @ignore
  125856. * Specifies if the bloom pipeline is enabled
  125857. */
  125858. BloomEnabled: boolean;
  125859. /**
  125860. * @ignore
  125861. * Specifies if the depth of field pipeline is enabed
  125862. */
  125863. DepthOfFieldEnabled: boolean;
  125864. /**
  125865. * @ignore
  125866. * Specifies if the lens flare pipeline is enabed
  125867. */
  125868. LensFlareEnabled: boolean;
  125869. /**
  125870. * @ignore
  125871. * Specifies if the HDR pipeline is enabled
  125872. */
  125873. HDREnabled: boolean;
  125874. /**
  125875. * @ignore
  125876. * Specifies if the volumetric lights scattering effect is enabled
  125877. */
  125878. VLSEnabled: boolean;
  125879. /**
  125880. * @ignore
  125881. * Specifies if the motion blur effect is enabled
  125882. */
  125883. MotionBlurEnabled: boolean;
  125884. /**
  125885. * Specifies if anti-aliasing is enabled
  125886. */
  125887. fxaaEnabled: boolean;
  125888. /**
  125889. * Specifies the number of steps used to calculate the volumetric lights
  125890. * Typically in interval [50, 200]
  125891. */
  125892. volumetricLightStepsCount: number;
  125893. /**
  125894. * Specifies the number of samples used for the motion blur effect
  125895. * Typically in interval [16, 64]
  125896. */
  125897. motionBlurSamples: number;
  125898. /**
  125899. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125900. */
  125901. samples: number;
  125902. /**
  125903. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125904. * @constructor
  125905. * @param name The rendering pipeline name
  125906. * @param scene The scene linked to this pipeline
  125907. * @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)
  125908. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  125909. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125910. */
  125911. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  125912. private _buildPipeline;
  125913. private _createDownSampleX4PostProcess;
  125914. private _createBrightPassPostProcess;
  125915. private _createBlurPostProcesses;
  125916. private _createTextureAdderPostProcess;
  125917. private _createVolumetricLightPostProcess;
  125918. private _createLuminancePostProcesses;
  125919. private _createHdrPostProcess;
  125920. private _createLensFlarePostProcess;
  125921. private _createDepthOfFieldPostProcess;
  125922. private _createMotionBlurPostProcess;
  125923. private _getDepthTexture;
  125924. private _disposePostProcesses;
  125925. /**
  125926. * Dispose of the pipeline and stop all post processes
  125927. */
  125928. dispose(): void;
  125929. /**
  125930. * Serialize the rendering pipeline (Used when exporting)
  125931. * @returns the serialized object
  125932. */
  125933. serialize(): any;
  125934. /**
  125935. * Parse the serialized pipeline
  125936. * @param source Source pipeline.
  125937. * @param scene The scene to load the pipeline to.
  125938. * @param rootUrl The URL of the serialized pipeline.
  125939. * @returns An instantiated pipeline from the serialized object.
  125940. */
  125941. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  125942. /**
  125943. * Luminance steps
  125944. */
  125945. static LuminanceSteps: number;
  125946. }
  125947. }
  125948. declare module BABYLON {
  125949. /** @hidden */
  125950. export var tonemapPixelShader: {
  125951. name: string;
  125952. shader: string;
  125953. };
  125954. }
  125955. declare module BABYLON {
  125956. /** Defines operator used for tonemapping */
  125957. export enum TonemappingOperator {
  125958. /** Hable */
  125959. Hable = 0,
  125960. /** Reinhard */
  125961. Reinhard = 1,
  125962. /** HejiDawson */
  125963. HejiDawson = 2,
  125964. /** Photographic */
  125965. Photographic = 3
  125966. }
  125967. /**
  125968. * Defines a post process to apply tone mapping
  125969. */
  125970. export class TonemapPostProcess extends PostProcess {
  125971. private _operator;
  125972. /** Defines the required exposure adjustement */
  125973. exposureAdjustment: number;
  125974. /**
  125975. * Creates a new TonemapPostProcess
  125976. * @param name defines the name of the postprocess
  125977. * @param _operator defines the operator to use
  125978. * @param exposureAdjustment defines the required exposure adjustement
  125979. * @param camera defines the camera to use (can be null)
  125980. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  125981. * @param engine defines the hosting engine (can be ignore if camera is set)
  125982. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125983. */
  125984. constructor(name: string, _operator: TonemappingOperator,
  125985. /** Defines the required exposure adjustement */
  125986. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  125987. }
  125988. }
  125989. declare module BABYLON {
  125990. /** @hidden */
  125991. export var depthVertexShader: {
  125992. name: string;
  125993. shader: string;
  125994. };
  125995. }
  125996. declare module BABYLON {
  125997. /** @hidden */
  125998. export var volumetricLightScatteringPixelShader: {
  125999. name: string;
  126000. shader: string;
  126001. };
  126002. }
  126003. declare module BABYLON {
  126004. /** @hidden */
  126005. export var volumetricLightScatteringPassVertexShader: {
  126006. name: string;
  126007. shader: string;
  126008. };
  126009. }
  126010. declare module BABYLON {
  126011. /** @hidden */
  126012. export var volumetricLightScatteringPassPixelShader: {
  126013. name: string;
  126014. shader: string;
  126015. };
  126016. }
  126017. declare module BABYLON {
  126018. /**
  126019. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  126020. */
  126021. export class VolumetricLightScatteringPostProcess extends PostProcess {
  126022. private _volumetricLightScatteringPass;
  126023. private _volumetricLightScatteringRTT;
  126024. private _viewPort;
  126025. private _screenCoordinates;
  126026. private _cachedDefines;
  126027. /**
  126028. * If not undefined, the mesh position is computed from the attached node position
  126029. */
  126030. attachedNode: {
  126031. position: Vector3;
  126032. };
  126033. /**
  126034. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  126035. */
  126036. customMeshPosition: Vector3;
  126037. /**
  126038. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  126039. */
  126040. useCustomMeshPosition: boolean;
  126041. /**
  126042. * If the post-process should inverse the light scattering direction
  126043. */
  126044. invert: boolean;
  126045. /**
  126046. * The internal mesh used by the post-process
  126047. */
  126048. mesh: Mesh;
  126049. /**
  126050. * @hidden
  126051. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  126052. */
  126053. useDiffuseColor: boolean;
  126054. /**
  126055. * Array containing the excluded meshes not rendered in the internal pass
  126056. */
  126057. excludedMeshes: AbstractMesh[];
  126058. /**
  126059. * Controls the overall intensity of the post-process
  126060. */
  126061. exposure: number;
  126062. /**
  126063. * Dissipates each sample's contribution in range [0, 1]
  126064. */
  126065. decay: number;
  126066. /**
  126067. * Controls the overall intensity of each sample
  126068. */
  126069. weight: number;
  126070. /**
  126071. * Controls the density of each sample
  126072. */
  126073. density: number;
  126074. /**
  126075. * @constructor
  126076. * @param name The post-process name
  126077. * @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)
  126078. * @param camera The camera that the post-process will be attached to
  126079. * @param mesh The mesh used to create the light scattering
  126080. * @param samples The post-process quality, default 100
  126081. * @param samplingModeThe post-process filtering mode
  126082. * @param engine The babylon engine
  126083. * @param reusable If the post-process is reusable
  126084. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  126085. */
  126086. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  126087. /**
  126088. * Returns the string "VolumetricLightScatteringPostProcess"
  126089. * @returns "VolumetricLightScatteringPostProcess"
  126090. */
  126091. getClassName(): string;
  126092. private _isReady;
  126093. /**
  126094. * Sets the new light position for light scattering effect
  126095. * @param position The new custom light position
  126096. */
  126097. setCustomMeshPosition(position: Vector3): void;
  126098. /**
  126099. * Returns the light position for light scattering effect
  126100. * @return Vector3 The custom light position
  126101. */
  126102. getCustomMeshPosition(): Vector3;
  126103. /**
  126104. * Disposes the internal assets and detaches the post-process from the camera
  126105. */
  126106. dispose(camera: Camera): void;
  126107. /**
  126108. * Returns the render target texture used by the post-process
  126109. * @return the render target texture used by the post-process
  126110. */
  126111. getPass(): RenderTargetTexture;
  126112. private _meshExcluded;
  126113. private _createPass;
  126114. private _updateMeshScreenCoordinates;
  126115. /**
  126116. * Creates a default mesh for the Volumeric Light Scattering post-process
  126117. * @param name The mesh name
  126118. * @param scene The scene where to create the mesh
  126119. * @return the default mesh
  126120. */
  126121. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  126122. }
  126123. }
  126124. declare module BABYLON {
  126125. interface Scene {
  126126. /** @hidden (Backing field) */
  126127. _boundingBoxRenderer: BoundingBoxRenderer;
  126128. /** @hidden (Backing field) */
  126129. _forceShowBoundingBoxes: boolean;
  126130. /**
  126131. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  126132. */
  126133. forceShowBoundingBoxes: boolean;
  126134. /**
  126135. * Gets the bounding box renderer associated with the scene
  126136. * @returns a BoundingBoxRenderer
  126137. */
  126138. getBoundingBoxRenderer(): BoundingBoxRenderer;
  126139. }
  126140. interface AbstractMesh {
  126141. /** @hidden (Backing field) */
  126142. _showBoundingBox: boolean;
  126143. /**
  126144. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  126145. */
  126146. showBoundingBox: boolean;
  126147. }
  126148. /**
  126149. * Component responsible of rendering the bounding box of the meshes in a scene.
  126150. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  126151. */
  126152. export class BoundingBoxRenderer implements ISceneComponent {
  126153. /**
  126154. * The component name helpfull to identify the component in the list of scene components.
  126155. */
  126156. readonly name: string;
  126157. /**
  126158. * The scene the component belongs to.
  126159. */
  126160. scene: Scene;
  126161. /**
  126162. * Color of the bounding box lines placed in front of an object
  126163. */
  126164. frontColor: Color3;
  126165. /**
  126166. * Color of the bounding box lines placed behind an object
  126167. */
  126168. backColor: Color3;
  126169. /**
  126170. * Defines if the renderer should show the back lines or not
  126171. */
  126172. showBackLines: boolean;
  126173. /**
  126174. * @hidden
  126175. */
  126176. renderList: SmartArray<BoundingBox>;
  126177. private _colorShader;
  126178. private _vertexBuffers;
  126179. private _indexBuffer;
  126180. private _fillIndexBuffer;
  126181. private _fillIndexData;
  126182. /**
  126183. * Instantiates a new bounding box renderer in a scene.
  126184. * @param scene the scene the renderer renders in
  126185. */
  126186. constructor(scene: Scene);
  126187. /**
  126188. * Registers the component in a given scene
  126189. */
  126190. register(): void;
  126191. private _evaluateSubMesh;
  126192. private _activeMesh;
  126193. private _prepareRessources;
  126194. private _createIndexBuffer;
  126195. /**
  126196. * Rebuilds the elements related to this component in case of
  126197. * context lost for instance.
  126198. */
  126199. rebuild(): void;
  126200. /**
  126201. * @hidden
  126202. */
  126203. reset(): void;
  126204. /**
  126205. * Render the bounding boxes of a specific rendering group
  126206. * @param renderingGroupId defines the rendering group to render
  126207. */
  126208. render(renderingGroupId: number): void;
  126209. /**
  126210. * In case of occlusion queries, we can render the occlusion bounding box through this method
  126211. * @param mesh Define the mesh to render the occlusion bounding box for
  126212. */
  126213. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  126214. /**
  126215. * Dispose and release the resources attached to this renderer.
  126216. */
  126217. dispose(): void;
  126218. }
  126219. }
  126220. declare module BABYLON {
  126221. /** @hidden */
  126222. export var depthPixelShader: {
  126223. name: string;
  126224. shader: string;
  126225. };
  126226. }
  126227. declare module BABYLON {
  126228. /**
  126229. * This represents a depth renderer in Babylon.
  126230. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126231. */
  126232. export class DepthRenderer {
  126233. private _scene;
  126234. private _depthMap;
  126235. private _effect;
  126236. private readonly _storeNonLinearDepth;
  126237. private readonly _clearColor;
  126238. /** Get if the depth renderer is using packed depth or not */
  126239. readonly isPacked: boolean;
  126240. private _cachedDefines;
  126241. private _camera;
  126242. /**
  126243. * Specifiess that the depth renderer will only be used within
  126244. * the camera it is created for.
  126245. * This can help forcing its rendering during the camera processing.
  126246. */
  126247. useOnlyInActiveCamera: boolean;
  126248. /** @hidden */
  126249. static _SceneComponentInitialization: (scene: Scene) => void;
  126250. /**
  126251. * Instantiates a depth renderer
  126252. * @param scene The scene the renderer belongs to
  126253. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126254. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126255. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126256. */
  126257. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126258. /**
  126259. * Creates the depth rendering effect and checks if the effect is ready.
  126260. * @param subMesh The submesh to be used to render the depth map of
  126261. * @param useInstances If multiple world instances should be used
  126262. * @returns if the depth renderer is ready to render the depth map
  126263. */
  126264. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126265. /**
  126266. * Gets the texture which the depth map will be written to.
  126267. * @returns The depth map texture
  126268. */
  126269. getDepthMap(): RenderTargetTexture;
  126270. /**
  126271. * Disposes of the depth renderer.
  126272. */
  126273. dispose(): void;
  126274. }
  126275. }
  126276. declare module BABYLON {
  126277. interface Scene {
  126278. /** @hidden (Backing field) */
  126279. _depthRenderer: {
  126280. [id: string]: DepthRenderer;
  126281. };
  126282. /**
  126283. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  126284. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  126285. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126286. * @returns the created depth renderer
  126287. */
  126288. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  126289. /**
  126290. * Disables a depth renderer for a given camera
  126291. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  126292. */
  126293. disableDepthRenderer(camera?: Nullable<Camera>): void;
  126294. }
  126295. /**
  126296. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  126297. * in several rendering techniques.
  126298. */
  126299. export class DepthRendererSceneComponent implements ISceneComponent {
  126300. /**
  126301. * The component name helpfull to identify the component in the list of scene components.
  126302. */
  126303. readonly name: string;
  126304. /**
  126305. * The scene the component belongs to.
  126306. */
  126307. scene: Scene;
  126308. /**
  126309. * Creates a new instance of the component for the given scene
  126310. * @param scene Defines the scene to register the component in
  126311. */
  126312. constructor(scene: Scene);
  126313. /**
  126314. * Registers the component in a given scene
  126315. */
  126316. register(): void;
  126317. /**
  126318. * Rebuilds the elements related to this component in case of
  126319. * context lost for instance.
  126320. */
  126321. rebuild(): void;
  126322. /**
  126323. * Disposes the component and the associated ressources
  126324. */
  126325. dispose(): void;
  126326. private _gatherRenderTargets;
  126327. private _gatherActiveCameraRenderTargets;
  126328. }
  126329. }
  126330. declare module BABYLON {
  126331. /** @hidden */
  126332. export var outlinePixelShader: {
  126333. name: string;
  126334. shader: string;
  126335. };
  126336. }
  126337. declare module BABYLON {
  126338. /** @hidden */
  126339. export var outlineVertexShader: {
  126340. name: string;
  126341. shader: string;
  126342. };
  126343. }
  126344. declare module BABYLON {
  126345. interface Scene {
  126346. /** @hidden */
  126347. _outlineRenderer: OutlineRenderer;
  126348. /**
  126349. * Gets the outline renderer associated with the scene
  126350. * @returns a OutlineRenderer
  126351. */
  126352. getOutlineRenderer(): OutlineRenderer;
  126353. }
  126354. interface AbstractMesh {
  126355. /** @hidden (Backing field) */
  126356. _renderOutline: boolean;
  126357. /**
  126358. * Gets or sets a boolean indicating if the outline must be rendered as well
  126359. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  126360. */
  126361. renderOutline: boolean;
  126362. /** @hidden (Backing field) */
  126363. _renderOverlay: boolean;
  126364. /**
  126365. * Gets or sets a boolean indicating if the overlay must be rendered as well
  126366. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  126367. */
  126368. renderOverlay: boolean;
  126369. }
  126370. /**
  126371. * This class is responsible to draw bothe outline/overlay of meshes.
  126372. * It should not be used directly but through the available method on mesh.
  126373. */
  126374. export class OutlineRenderer implements ISceneComponent {
  126375. /**
  126376. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  126377. */
  126378. private static _StencilReference;
  126379. /**
  126380. * The name of the component. Each component must have a unique name.
  126381. */
  126382. name: string;
  126383. /**
  126384. * The scene the component belongs to.
  126385. */
  126386. scene: Scene;
  126387. /**
  126388. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  126389. */
  126390. zOffset: number;
  126391. private _engine;
  126392. private _effect;
  126393. private _cachedDefines;
  126394. private _savedDepthWrite;
  126395. /**
  126396. * Instantiates a new outline renderer. (There could be only one per scene).
  126397. * @param scene Defines the scene it belongs to
  126398. */
  126399. constructor(scene: Scene);
  126400. /**
  126401. * Register the component to one instance of a scene.
  126402. */
  126403. register(): void;
  126404. /**
  126405. * Rebuilds the elements related to this component in case of
  126406. * context lost for instance.
  126407. */
  126408. rebuild(): void;
  126409. /**
  126410. * Disposes the component and the associated ressources.
  126411. */
  126412. dispose(): void;
  126413. /**
  126414. * Renders the outline in the canvas.
  126415. * @param subMesh Defines the sumesh to render
  126416. * @param batch Defines the batch of meshes in case of instances
  126417. * @param useOverlay Defines if the rendering is for the overlay or the outline
  126418. */
  126419. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  126420. /**
  126421. * Returns whether or not the outline renderer is ready for a given submesh.
  126422. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  126423. * @param subMesh Defines the submesh to check readyness for
  126424. * @param useInstances Defines wheter wee are trying to render instances or not
  126425. * @returns true if ready otherwise false
  126426. */
  126427. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126428. private _beforeRenderingMesh;
  126429. private _afterRenderingMesh;
  126430. }
  126431. }
  126432. declare module BABYLON {
  126433. /**
  126434. * Class used to manage multiple sprites of different sizes on the same spritesheet
  126435. * @see http://doc.babylonjs.com/babylon101/sprites
  126436. */
  126437. export class SpritePackedManager extends SpriteManager {
  126438. /** defines the packed manager's name */
  126439. name: string;
  126440. /**
  126441. * Creates a new sprite manager from a packed sprite sheet
  126442. * @param name defines the manager's name
  126443. * @param imgUrl defines the sprite sheet url
  126444. * @param capacity defines the maximum allowed number of sprites
  126445. * @param scene defines the hosting scene
  126446. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  126447. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  126448. * @param samplingMode defines the smapling mode to use with spritesheet
  126449. * @param fromPacked set to true; do not alter
  126450. */
  126451. constructor(
  126452. /** defines the packed manager's name */
  126453. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  126454. }
  126455. }
  126456. declare module BABYLON {
  126457. /**
  126458. * Defines the list of states available for a task inside a AssetsManager
  126459. */
  126460. export enum AssetTaskState {
  126461. /**
  126462. * Initialization
  126463. */
  126464. INIT = 0,
  126465. /**
  126466. * Running
  126467. */
  126468. RUNNING = 1,
  126469. /**
  126470. * Done
  126471. */
  126472. DONE = 2,
  126473. /**
  126474. * Error
  126475. */
  126476. ERROR = 3
  126477. }
  126478. /**
  126479. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  126480. */
  126481. export abstract class AbstractAssetTask {
  126482. /**
  126483. * Task name
  126484. */ name: string;
  126485. /**
  126486. * Callback called when the task is successful
  126487. */
  126488. onSuccess: (task: any) => void;
  126489. /**
  126490. * Callback called when the task is not successful
  126491. */
  126492. onError: (task: any, message?: string, exception?: any) => void;
  126493. /**
  126494. * Creates a new AssetsManager
  126495. * @param name defines the name of the task
  126496. */
  126497. constructor(
  126498. /**
  126499. * Task name
  126500. */ name: string);
  126501. private _isCompleted;
  126502. private _taskState;
  126503. private _errorObject;
  126504. /**
  126505. * Get if the task is completed
  126506. */
  126507. readonly isCompleted: boolean;
  126508. /**
  126509. * Gets the current state of the task
  126510. */
  126511. readonly taskState: AssetTaskState;
  126512. /**
  126513. * Gets the current error object (if task is in error)
  126514. */
  126515. readonly errorObject: {
  126516. message?: string;
  126517. exception?: any;
  126518. };
  126519. /**
  126520. * Internal only
  126521. * @hidden
  126522. */
  126523. _setErrorObject(message?: string, exception?: any): void;
  126524. /**
  126525. * Execute the current task
  126526. * @param scene defines the scene where you want your assets to be loaded
  126527. * @param onSuccess is a callback called when the task is successfully executed
  126528. * @param onError is a callback called if an error occurs
  126529. */
  126530. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126531. /**
  126532. * Execute the current task
  126533. * @param scene defines the scene where you want your assets to be loaded
  126534. * @param onSuccess is a callback called when the task is successfully executed
  126535. * @param onError is a callback called if an error occurs
  126536. */
  126537. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126538. /**
  126539. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  126540. * This can be used with failed tasks that have the reason for failure fixed.
  126541. */
  126542. reset(): void;
  126543. private onErrorCallback;
  126544. private onDoneCallback;
  126545. }
  126546. /**
  126547. * Define the interface used by progress events raised during assets loading
  126548. */
  126549. export interface IAssetsProgressEvent {
  126550. /**
  126551. * Defines the number of remaining tasks to process
  126552. */
  126553. remainingCount: number;
  126554. /**
  126555. * Defines the total number of tasks
  126556. */
  126557. totalCount: number;
  126558. /**
  126559. * Defines the task that was just processed
  126560. */
  126561. task: AbstractAssetTask;
  126562. }
  126563. /**
  126564. * Class used to share progress information about assets loading
  126565. */
  126566. export class AssetsProgressEvent implements IAssetsProgressEvent {
  126567. /**
  126568. * Defines the number of remaining tasks to process
  126569. */
  126570. remainingCount: number;
  126571. /**
  126572. * Defines the total number of tasks
  126573. */
  126574. totalCount: number;
  126575. /**
  126576. * Defines the task that was just processed
  126577. */
  126578. task: AbstractAssetTask;
  126579. /**
  126580. * Creates a AssetsProgressEvent
  126581. * @param remainingCount defines the number of remaining tasks to process
  126582. * @param totalCount defines the total number of tasks
  126583. * @param task defines the task that was just processed
  126584. */
  126585. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  126586. }
  126587. /**
  126588. * Define a task used by AssetsManager to load meshes
  126589. */
  126590. export class MeshAssetTask extends AbstractAssetTask {
  126591. /**
  126592. * Defines the name of the task
  126593. */
  126594. name: string;
  126595. /**
  126596. * Defines the list of mesh's names you want to load
  126597. */
  126598. meshesNames: any;
  126599. /**
  126600. * Defines the root url to use as a base to load your meshes and associated resources
  126601. */
  126602. rootUrl: string;
  126603. /**
  126604. * Defines the filename of the scene to load from
  126605. */
  126606. sceneFilename: string;
  126607. /**
  126608. * Gets the list of loaded meshes
  126609. */
  126610. loadedMeshes: Array<AbstractMesh>;
  126611. /**
  126612. * Gets the list of loaded particle systems
  126613. */
  126614. loadedParticleSystems: Array<IParticleSystem>;
  126615. /**
  126616. * Gets the list of loaded skeletons
  126617. */
  126618. loadedSkeletons: Array<Skeleton>;
  126619. /**
  126620. * Gets the list of loaded animation groups
  126621. */
  126622. loadedAnimationGroups: Array<AnimationGroup>;
  126623. /**
  126624. * Callback called when the task is successful
  126625. */
  126626. onSuccess: (task: MeshAssetTask) => void;
  126627. /**
  126628. * Callback called when the task is successful
  126629. */
  126630. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  126631. /**
  126632. * Creates a new MeshAssetTask
  126633. * @param name defines the name of the task
  126634. * @param meshesNames defines the list of mesh's names you want to load
  126635. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  126636. * @param sceneFilename defines the filename of the scene to load from
  126637. */
  126638. constructor(
  126639. /**
  126640. * Defines the name of the task
  126641. */
  126642. name: string,
  126643. /**
  126644. * Defines the list of mesh's names you want to load
  126645. */
  126646. meshesNames: any,
  126647. /**
  126648. * Defines the root url to use as a base to load your meshes and associated resources
  126649. */
  126650. rootUrl: string,
  126651. /**
  126652. * Defines the filename of the scene to load from
  126653. */
  126654. sceneFilename: string);
  126655. /**
  126656. * Execute the current task
  126657. * @param scene defines the scene where you want your assets to be loaded
  126658. * @param onSuccess is a callback called when the task is successfully executed
  126659. * @param onError is a callback called if an error occurs
  126660. */
  126661. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126662. }
  126663. /**
  126664. * Define a task used by AssetsManager to load text content
  126665. */
  126666. export class TextFileAssetTask extends AbstractAssetTask {
  126667. /**
  126668. * Defines the name of the task
  126669. */
  126670. name: string;
  126671. /**
  126672. * Defines the location of the file to load
  126673. */
  126674. url: string;
  126675. /**
  126676. * Gets the loaded text string
  126677. */
  126678. text: string;
  126679. /**
  126680. * Callback called when the task is successful
  126681. */
  126682. onSuccess: (task: TextFileAssetTask) => void;
  126683. /**
  126684. * Callback called when the task is successful
  126685. */
  126686. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  126687. /**
  126688. * Creates a new TextFileAssetTask object
  126689. * @param name defines the name of the task
  126690. * @param url defines the location of the file to load
  126691. */
  126692. constructor(
  126693. /**
  126694. * Defines the name of the task
  126695. */
  126696. name: string,
  126697. /**
  126698. * Defines the location of the file to load
  126699. */
  126700. url: string);
  126701. /**
  126702. * Execute the current task
  126703. * @param scene defines the scene where you want your assets to be loaded
  126704. * @param onSuccess is a callback called when the task is successfully executed
  126705. * @param onError is a callback called if an error occurs
  126706. */
  126707. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126708. }
  126709. /**
  126710. * Define a task used by AssetsManager to load binary data
  126711. */
  126712. export class BinaryFileAssetTask extends AbstractAssetTask {
  126713. /**
  126714. * Defines the name of the task
  126715. */
  126716. name: string;
  126717. /**
  126718. * Defines the location of the file to load
  126719. */
  126720. url: string;
  126721. /**
  126722. * Gets the lodaded data (as an array buffer)
  126723. */
  126724. data: ArrayBuffer;
  126725. /**
  126726. * Callback called when the task is successful
  126727. */
  126728. onSuccess: (task: BinaryFileAssetTask) => void;
  126729. /**
  126730. * Callback called when the task is successful
  126731. */
  126732. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  126733. /**
  126734. * Creates a new BinaryFileAssetTask object
  126735. * @param name defines the name of the new task
  126736. * @param url defines the location of the file to load
  126737. */
  126738. constructor(
  126739. /**
  126740. * Defines the name of the task
  126741. */
  126742. name: string,
  126743. /**
  126744. * Defines the location of the file to load
  126745. */
  126746. url: string);
  126747. /**
  126748. * Execute the current task
  126749. * @param scene defines the scene where you want your assets to be loaded
  126750. * @param onSuccess is a callback called when the task is successfully executed
  126751. * @param onError is a callback called if an error occurs
  126752. */
  126753. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126754. }
  126755. /**
  126756. * Define a task used by AssetsManager to load images
  126757. */
  126758. export class ImageAssetTask extends AbstractAssetTask {
  126759. /**
  126760. * Defines the name of the task
  126761. */
  126762. name: string;
  126763. /**
  126764. * Defines the location of the image to load
  126765. */
  126766. url: string;
  126767. /**
  126768. * Gets the loaded images
  126769. */
  126770. image: HTMLImageElement;
  126771. /**
  126772. * Callback called when the task is successful
  126773. */
  126774. onSuccess: (task: ImageAssetTask) => void;
  126775. /**
  126776. * Callback called when the task is successful
  126777. */
  126778. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  126779. /**
  126780. * Creates a new ImageAssetTask
  126781. * @param name defines the name of the task
  126782. * @param url defines the location of the image to load
  126783. */
  126784. constructor(
  126785. /**
  126786. * Defines the name of the task
  126787. */
  126788. name: string,
  126789. /**
  126790. * Defines the location of the image to load
  126791. */
  126792. url: string);
  126793. /**
  126794. * Execute the current task
  126795. * @param scene defines the scene where you want your assets to be loaded
  126796. * @param onSuccess is a callback called when the task is successfully executed
  126797. * @param onError is a callback called if an error occurs
  126798. */
  126799. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126800. }
  126801. /**
  126802. * Defines the interface used by texture loading tasks
  126803. */
  126804. export interface ITextureAssetTask<TEX extends BaseTexture> {
  126805. /**
  126806. * Gets the loaded texture
  126807. */
  126808. texture: TEX;
  126809. }
  126810. /**
  126811. * Define a task used by AssetsManager to load 2D textures
  126812. */
  126813. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  126814. /**
  126815. * Defines the name of the task
  126816. */
  126817. name: string;
  126818. /**
  126819. * Defines the location of the file to load
  126820. */
  126821. url: string;
  126822. /**
  126823. * Defines if mipmap should not be generated (default is false)
  126824. */
  126825. noMipmap?: boolean | undefined;
  126826. /**
  126827. * Defines if texture must be inverted on Y axis (default is false)
  126828. */
  126829. invertY?: boolean | undefined;
  126830. /**
  126831. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126832. */
  126833. samplingMode: number;
  126834. /**
  126835. * Gets the loaded texture
  126836. */
  126837. texture: Texture;
  126838. /**
  126839. * Callback called when the task is successful
  126840. */
  126841. onSuccess: (task: TextureAssetTask) => void;
  126842. /**
  126843. * Callback called when the task is successful
  126844. */
  126845. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  126846. /**
  126847. * Creates a new TextureAssetTask object
  126848. * @param name defines the name of the task
  126849. * @param url defines the location of the file to load
  126850. * @param noMipmap defines if mipmap should not be generated (default is false)
  126851. * @param invertY defines if texture must be inverted on Y axis (default is false)
  126852. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126853. */
  126854. constructor(
  126855. /**
  126856. * Defines the name of the task
  126857. */
  126858. name: string,
  126859. /**
  126860. * Defines the location of the file to load
  126861. */
  126862. url: string,
  126863. /**
  126864. * Defines if mipmap should not be generated (default is false)
  126865. */
  126866. noMipmap?: boolean | undefined,
  126867. /**
  126868. * Defines if texture must be inverted on Y axis (default is false)
  126869. */
  126870. invertY?: boolean | undefined,
  126871. /**
  126872. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126873. */
  126874. samplingMode?: number);
  126875. /**
  126876. * Execute the current task
  126877. * @param scene defines the scene where you want your assets to be loaded
  126878. * @param onSuccess is a callback called when the task is successfully executed
  126879. * @param onError is a callback called if an error occurs
  126880. */
  126881. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126882. }
  126883. /**
  126884. * Define a task used by AssetsManager to load cube textures
  126885. */
  126886. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  126887. /**
  126888. * Defines the name of the task
  126889. */
  126890. name: string;
  126891. /**
  126892. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126893. */
  126894. url: string;
  126895. /**
  126896. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126897. */
  126898. extensions?: string[] | undefined;
  126899. /**
  126900. * Defines if mipmaps should not be generated (default is false)
  126901. */
  126902. noMipmap?: boolean | undefined;
  126903. /**
  126904. * Defines the explicit list of files (undefined by default)
  126905. */
  126906. files?: string[] | undefined;
  126907. /**
  126908. * Gets the loaded texture
  126909. */
  126910. texture: CubeTexture;
  126911. /**
  126912. * Callback called when the task is successful
  126913. */
  126914. onSuccess: (task: CubeTextureAssetTask) => void;
  126915. /**
  126916. * Callback called when the task is successful
  126917. */
  126918. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  126919. /**
  126920. * Creates a new CubeTextureAssetTask
  126921. * @param name defines the name of the task
  126922. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126923. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126924. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126925. * @param files defines the explicit list of files (undefined by default)
  126926. */
  126927. constructor(
  126928. /**
  126929. * Defines the name of the task
  126930. */
  126931. name: string,
  126932. /**
  126933. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126934. */
  126935. url: string,
  126936. /**
  126937. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126938. */
  126939. extensions?: string[] | undefined,
  126940. /**
  126941. * Defines if mipmaps should not be generated (default is false)
  126942. */
  126943. noMipmap?: boolean | undefined,
  126944. /**
  126945. * Defines the explicit list of files (undefined by default)
  126946. */
  126947. files?: string[] | undefined);
  126948. /**
  126949. * Execute the current task
  126950. * @param scene defines the scene where you want your assets to be loaded
  126951. * @param onSuccess is a callback called when the task is successfully executed
  126952. * @param onError is a callback called if an error occurs
  126953. */
  126954. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126955. }
  126956. /**
  126957. * Define a task used by AssetsManager to load HDR cube textures
  126958. */
  126959. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  126960. /**
  126961. * Defines the name of the task
  126962. */
  126963. name: string;
  126964. /**
  126965. * Defines the location of the file to load
  126966. */
  126967. url: string;
  126968. /**
  126969. * Defines the desired size (the more it increases the longer the generation will be)
  126970. */
  126971. size: number;
  126972. /**
  126973. * Defines if mipmaps should not be generated (default is false)
  126974. */
  126975. noMipmap: boolean;
  126976. /**
  126977. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126978. */
  126979. generateHarmonics: boolean;
  126980. /**
  126981. * 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)
  126982. */
  126983. gammaSpace: boolean;
  126984. /**
  126985. * Internal Use Only
  126986. */
  126987. reserved: boolean;
  126988. /**
  126989. * Gets the loaded texture
  126990. */
  126991. texture: HDRCubeTexture;
  126992. /**
  126993. * Callback called when the task is successful
  126994. */
  126995. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  126996. /**
  126997. * Callback called when the task is successful
  126998. */
  126999. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  127000. /**
  127001. * Creates a new HDRCubeTextureAssetTask object
  127002. * @param name defines the name of the task
  127003. * @param url defines the location of the file to load
  127004. * @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.
  127005. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127006. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127007. * @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)
  127008. * @param reserved Internal use only
  127009. */
  127010. constructor(
  127011. /**
  127012. * Defines the name of the task
  127013. */
  127014. name: string,
  127015. /**
  127016. * Defines the location of the file to load
  127017. */
  127018. url: string,
  127019. /**
  127020. * Defines the desired size (the more it increases the longer the generation will be)
  127021. */
  127022. size: number,
  127023. /**
  127024. * Defines if mipmaps should not be generated (default is false)
  127025. */
  127026. noMipmap?: boolean,
  127027. /**
  127028. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127029. */
  127030. generateHarmonics?: boolean,
  127031. /**
  127032. * 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)
  127033. */
  127034. gammaSpace?: boolean,
  127035. /**
  127036. * Internal Use Only
  127037. */
  127038. reserved?: boolean);
  127039. /**
  127040. * Execute the current task
  127041. * @param scene defines the scene where you want your assets to be loaded
  127042. * @param onSuccess is a callback called when the task is successfully executed
  127043. * @param onError is a callback called if an error occurs
  127044. */
  127045. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127046. }
  127047. /**
  127048. * Define a task used by AssetsManager to load Equirectangular cube textures
  127049. */
  127050. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  127051. /**
  127052. * Defines the name of the task
  127053. */
  127054. name: string;
  127055. /**
  127056. * Defines the location of the file to load
  127057. */
  127058. url: string;
  127059. /**
  127060. * Defines the desired size (the more it increases the longer the generation will be)
  127061. */
  127062. size: number;
  127063. /**
  127064. * Defines if mipmaps should not be generated (default is false)
  127065. */
  127066. noMipmap: boolean;
  127067. /**
  127068. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127069. * but the standard material would require them in Gamma space) (default is true)
  127070. */
  127071. gammaSpace: boolean;
  127072. /**
  127073. * Gets the loaded texture
  127074. */
  127075. texture: EquiRectangularCubeTexture;
  127076. /**
  127077. * Callback called when the task is successful
  127078. */
  127079. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  127080. /**
  127081. * Callback called when the task is successful
  127082. */
  127083. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  127084. /**
  127085. * Creates a new EquiRectangularCubeTextureAssetTask object
  127086. * @param name defines the name of the task
  127087. * @param url defines the location of the file to load
  127088. * @param size defines the desired size (the more it increases the longer the generation will be)
  127089. * If the size is omitted this implies you are using a preprocessed cubemap.
  127090. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127091. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  127092. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  127093. * (default is true)
  127094. */
  127095. constructor(
  127096. /**
  127097. * Defines the name of the task
  127098. */
  127099. name: string,
  127100. /**
  127101. * Defines the location of the file to load
  127102. */
  127103. url: string,
  127104. /**
  127105. * Defines the desired size (the more it increases the longer the generation will be)
  127106. */
  127107. size: number,
  127108. /**
  127109. * Defines if mipmaps should not be generated (default is false)
  127110. */
  127111. noMipmap?: boolean,
  127112. /**
  127113. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127114. * but the standard material would require them in Gamma space) (default is true)
  127115. */
  127116. gammaSpace?: boolean);
  127117. /**
  127118. * Execute the current task
  127119. * @param scene defines the scene where you want your assets to be loaded
  127120. * @param onSuccess is a callback called when the task is successfully executed
  127121. * @param onError is a callback called if an error occurs
  127122. */
  127123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127124. }
  127125. /**
  127126. * This class can be used to easily import assets into a scene
  127127. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  127128. */
  127129. export class AssetsManager {
  127130. private _scene;
  127131. private _isLoading;
  127132. protected _tasks: AbstractAssetTask[];
  127133. protected _waitingTasksCount: number;
  127134. protected _totalTasksCount: number;
  127135. /**
  127136. * Callback called when all tasks are processed
  127137. */
  127138. onFinish: (tasks: AbstractAssetTask[]) => void;
  127139. /**
  127140. * Callback called when a task is successful
  127141. */
  127142. onTaskSuccess: (task: AbstractAssetTask) => void;
  127143. /**
  127144. * Callback called when a task had an error
  127145. */
  127146. onTaskError: (task: AbstractAssetTask) => void;
  127147. /**
  127148. * Callback called when a task is done (whatever the result is)
  127149. */
  127150. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  127151. /**
  127152. * Observable called when all tasks are processed
  127153. */
  127154. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  127155. /**
  127156. * Observable called when a task had an error
  127157. */
  127158. onTaskErrorObservable: Observable<AbstractAssetTask>;
  127159. /**
  127160. * Observable called when all tasks were executed
  127161. */
  127162. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  127163. /**
  127164. * Observable called when a task is done (whatever the result is)
  127165. */
  127166. onProgressObservable: Observable<IAssetsProgressEvent>;
  127167. /**
  127168. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  127169. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127170. */
  127171. useDefaultLoadingScreen: boolean;
  127172. /**
  127173. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  127174. * when all assets have been downloaded.
  127175. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  127176. */
  127177. autoHideLoadingUI: boolean;
  127178. /**
  127179. * Creates a new AssetsManager
  127180. * @param scene defines the scene to work on
  127181. */
  127182. constructor(scene: Scene);
  127183. /**
  127184. * Add a MeshAssetTask to the list of active tasks
  127185. * @param taskName defines the name of the new task
  127186. * @param meshesNames defines the name of meshes to load
  127187. * @param rootUrl defines the root url to use to locate files
  127188. * @param sceneFilename defines the filename of the scene file
  127189. * @returns a new MeshAssetTask object
  127190. */
  127191. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  127192. /**
  127193. * Add a TextFileAssetTask to the list of active tasks
  127194. * @param taskName defines the name of the new task
  127195. * @param url defines the url of the file to load
  127196. * @returns a new TextFileAssetTask object
  127197. */
  127198. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  127199. /**
  127200. * Add a BinaryFileAssetTask to the list of active tasks
  127201. * @param taskName defines the name of the new task
  127202. * @param url defines the url of the file to load
  127203. * @returns a new BinaryFileAssetTask object
  127204. */
  127205. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  127206. /**
  127207. * Add a ImageAssetTask to the list of active tasks
  127208. * @param taskName defines the name of the new task
  127209. * @param url defines the url of the file to load
  127210. * @returns a new ImageAssetTask object
  127211. */
  127212. addImageTask(taskName: string, url: string): ImageAssetTask;
  127213. /**
  127214. * Add a TextureAssetTask to the list of active tasks
  127215. * @param taskName defines the name of the new task
  127216. * @param url defines the url of the file to load
  127217. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127218. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  127219. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  127220. * @returns a new TextureAssetTask object
  127221. */
  127222. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  127223. /**
  127224. * Add a CubeTextureAssetTask to the list of active tasks
  127225. * @param taskName defines the name of the new task
  127226. * @param url defines the url of the file to load
  127227. * @param extensions defines the extension to use to load the cube map (can be null)
  127228. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127229. * @param files defines the list of files to load (can be null)
  127230. * @returns a new CubeTextureAssetTask object
  127231. */
  127232. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  127233. /**
  127234. *
  127235. * Add a HDRCubeTextureAssetTask to the list of active tasks
  127236. * @param taskName defines the name of the new task
  127237. * @param url defines the url of the file to load
  127238. * @param size defines the size you want for the cubemap (can be null)
  127239. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127240. * @param generateHarmonics defines if you want to automatically generate (true by default)
  127241. * @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)
  127242. * @param reserved Internal use only
  127243. * @returns a new HDRCubeTextureAssetTask object
  127244. */
  127245. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  127246. /**
  127247. *
  127248. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  127249. * @param taskName defines the name of the new task
  127250. * @param url defines the url of the file to load
  127251. * @param size defines the size you want for the cubemap (can be null)
  127252. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127253. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  127254. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  127255. * @returns a new EquiRectangularCubeTextureAssetTask object
  127256. */
  127257. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  127258. /**
  127259. * Remove a task from the assets manager.
  127260. * @param task the task to remove
  127261. */
  127262. removeTask(task: AbstractAssetTask): void;
  127263. private _decreaseWaitingTasksCount;
  127264. private _runTask;
  127265. /**
  127266. * Reset the AssetsManager and remove all tasks
  127267. * @return the current instance of the AssetsManager
  127268. */
  127269. reset(): AssetsManager;
  127270. /**
  127271. * Start the loading process
  127272. * @return the current instance of the AssetsManager
  127273. */
  127274. load(): AssetsManager;
  127275. /**
  127276. * Start the loading process as an async operation
  127277. * @return a promise returning the list of failed tasks
  127278. */
  127279. loadAsync(): Promise<void>;
  127280. }
  127281. }
  127282. declare module BABYLON {
  127283. /**
  127284. * Wrapper class for promise with external resolve and reject.
  127285. */
  127286. export class Deferred<T> {
  127287. /**
  127288. * The promise associated with this deferred object.
  127289. */
  127290. readonly promise: Promise<T>;
  127291. private _resolve;
  127292. private _reject;
  127293. /**
  127294. * The resolve method of the promise associated with this deferred object.
  127295. */
  127296. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  127297. /**
  127298. * The reject method of the promise associated with this deferred object.
  127299. */
  127300. readonly reject: (reason?: any) => void;
  127301. /**
  127302. * Constructor for this deferred object.
  127303. */
  127304. constructor();
  127305. }
  127306. }
  127307. declare module BABYLON {
  127308. /**
  127309. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  127310. */
  127311. export class MeshExploder {
  127312. private _centerMesh;
  127313. private _meshes;
  127314. private _meshesOrigins;
  127315. private _toCenterVectors;
  127316. private _scaledDirection;
  127317. private _newPosition;
  127318. private _centerPosition;
  127319. /**
  127320. * Explodes meshes from a center mesh.
  127321. * @param meshes The meshes to explode.
  127322. * @param centerMesh The mesh to be center of explosion.
  127323. */
  127324. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  127325. private _setCenterMesh;
  127326. /**
  127327. * Get class name
  127328. * @returns "MeshExploder"
  127329. */
  127330. getClassName(): string;
  127331. /**
  127332. * "Exploded meshes"
  127333. * @returns Array of meshes with the centerMesh at index 0.
  127334. */
  127335. getMeshes(): Array<Mesh>;
  127336. /**
  127337. * Explodes meshes giving a specific direction
  127338. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  127339. */
  127340. explode(direction?: number): void;
  127341. }
  127342. }
  127343. declare module BABYLON {
  127344. /**
  127345. * Class used to help managing file picking and drag'n'drop
  127346. */
  127347. export class FilesInput {
  127348. /**
  127349. * List of files ready to be loaded
  127350. */
  127351. static readonly FilesToLoad: {
  127352. [key: string]: File;
  127353. };
  127354. /**
  127355. * Callback called when a file is processed
  127356. */
  127357. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  127358. private _engine;
  127359. private _currentScene;
  127360. private _sceneLoadedCallback;
  127361. private _progressCallback;
  127362. private _additionalRenderLoopLogicCallback;
  127363. private _textureLoadingCallback;
  127364. private _startingProcessingFilesCallback;
  127365. private _onReloadCallback;
  127366. private _errorCallback;
  127367. private _elementToMonitor;
  127368. private _sceneFileToLoad;
  127369. private _filesToLoad;
  127370. /**
  127371. * Creates a new FilesInput
  127372. * @param engine defines the rendering engine
  127373. * @param scene defines the hosting scene
  127374. * @param sceneLoadedCallback callback called when scene is loaded
  127375. * @param progressCallback callback called to track progress
  127376. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  127377. * @param textureLoadingCallback callback called when a texture is loading
  127378. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  127379. * @param onReloadCallback callback called when a reload is requested
  127380. * @param errorCallback callback call if an error occurs
  127381. */
  127382. 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);
  127383. private _dragEnterHandler;
  127384. private _dragOverHandler;
  127385. private _dropHandler;
  127386. /**
  127387. * Calls this function to listen to drag'n'drop events on a specific DOM element
  127388. * @param elementToMonitor defines the DOM element to track
  127389. */
  127390. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  127391. /**
  127392. * Release all associated resources
  127393. */
  127394. dispose(): void;
  127395. private renderFunction;
  127396. private drag;
  127397. private drop;
  127398. private _traverseFolder;
  127399. private _processFiles;
  127400. /**
  127401. * Load files from a drop event
  127402. * @param event defines the drop event to use as source
  127403. */
  127404. loadFiles(event: any): void;
  127405. private _processReload;
  127406. /**
  127407. * Reload the current scene from the loaded files
  127408. */
  127409. reload(): void;
  127410. }
  127411. }
  127412. declare module BABYLON {
  127413. /**
  127414. * Defines the root class used to create scene optimization to use with SceneOptimizer
  127415. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127416. */
  127417. export class SceneOptimization {
  127418. /**
  127419. * Defines the priority of this optimization (0 by default which means first in the list)
  127420. */
  127421. priority: number;
  127422. /**
  127423. * Gets a string describing the action executed by the current optimization
  127424. * @returns description string
  127425. */
  127426. getDescription(): string;
  127427. /**
  127428. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127429. * @param scene defines the current scene where to apply this optimization
  127430. * @param optimizer defines the current optimizer
  127431. * @returns true if everything that can be done was applied
  127432. */
  127433. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127434. /**
  127435. * Creates the SceneOptimization object
  127436. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127437. * @param desc defines the description associated with the optimization
  127438. */
  127439. constructor(
  127440. /**
  127441. * Defines the priority of this optimization (0 by default which means first in the list)
  127442. */
  127443. priority?: number);
  127444. }
  127445. /**
  127446. * Defines an optimization used to reduce the size of render target textures
  127447. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127448. */
  127449. export class TextureOptimization extends SceneOptimization {
  127450. /**
  127451. * Defines the priority of this optimization (0 by default which means first in the list)
  127452. */
  127453. priority: number;
  127454. /**
  127455. * 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
  127456. */
  127457. maximumSize: number;
  127458. /**
  127459. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127460. */
  127461. step: number;
  127462. /**
  127463. * Gets a string describing the action executed by the current optimization
  127464. * @returns description string
  127465. */
  127466. getDescription(): string;
  127467. /**
  127468. * Creates the TextureOptimization object
  127469. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127470. * @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
  127471. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127472. */
  127473. constructor(
  127474. /**
  127475. * Defines the priority of this optimization (0 by default which means first in the list)
  127476. */
  127477. priority?: number,
  127478. /**
  127479. * 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
  127480. */
  127481. maximumSize?: number,
  127482. /**
  127483. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127484. */
  127485. step?: number);
  127486. /**
  127487. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127488. * @param scene defines the current scene where to apply this optimization
  127489. * @param optimizer defines the current optimizer
  127490. * @returns true if everything that can be done was applied
  127491. */
  127492. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127493. }
  127494. /**
  127495. * Defines an optimization used to increase or decrease the rendering resolution
  127496. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127497. */
  127498. export class HardwareScalingOptimization extends SceneOptimization {
  127499. /**
  127500. * Defines the priority of this optimization (0 by default which means first in the list)
  127501. */
  127502. priority: number;
  127503. /**
  127504. * Defines the maximum scale to use (2 by default)
  127505. */
  127506. maximumScale: number;
  127507. /**
  127508. * Defines the step to use between two passes (0.5 by default)
  127509. */
  127510. step: number;
  127511. private _currentScale;
  127512. private _directionOffset;
  127513. /**
  127514. * Gets a string describing the action executed by the current optimization
  127515. * @return description string
  127516. */
  127517. getDescription(): string;
  127518. /**
  127519. * Creates the HardwareScalingOptimization object
  127520. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127521. * @param maximumScale defines the maximum scale to use (2 by default)
  127522. * @param step defines the step to use between two passes (0.5 by default)
  127523. */
  127524. constructor(
  127525. /**
  127526. * Defines the priority of this optimization (0 by default which means first in the list)
  127527. */
  127528. priority?: number,
  127529. /**
  127530. * Defines the maximum scale to use (2 by default)
  127531. */
  127532. maximumScale?: number,
  127533. /**
  127534. * Defines the step to use between two passes (0.5 by default)
  127535. */
  127536. step?: number);
  127537. /**
  127538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127539. * @param scene defines the current scene where to apply this optimization
  127540. * @param optimizer defines the current optimizer
  127541. * @returns true if everything that can be done was applied
  127542. */
  127543. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127544. }
  127545. /**
  127546. * Defines an optimization used to remove shadows
  127547. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127548. */
  127549. export class ShadowsOptimization extends SceneOptimization {
  127550. /**
  127551. * Gets a string describing the action executed by the current optimization
  127552. * @return description string
  127553. */
  127554. getDescription(): string;
  127555. /**
  127556. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127557. * @param scene defines the current scene where to apply this optimization
  127558. * @param optimizer defines the current optimizer
  127559. * @returns true if everything that can be done was applied
  127560. */
  127561. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127562. }
  127563. /**
  127564. * Defines an optimization used to turn post-processes off
  127565. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127566. */
  127567. export class PostProcessesOptimization extends SceneOptimization {
  127568. /**
  127569. * Gets a string describing the action executed by the current optimization
  127570. * @return description string
  127571. */
  127572. getDescription(): string;
  127573. /**
  127574. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127575. * @param scene defines the current scene where to apply this optimization
  127576. * @param optimizer defines the current optimizer
  127577. * @returns true if everything that can be done was applied
  127578. */
  127579. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127580. }
  127581. /**
  127582. * Defines an optimization used to turn lens flares off
  127583. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127584. */
  127585. export class LensFlaresOptimization extends SceneOptimization {
  127586. /**
  127587. * Gets a string describing the action executed by the current optimization
  127588. * @return description string
  127589. */
  127590. getDescription(): string;
  127591. /**
  127592. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127593. * @param scene defines the current scene where to apply this optimization
  127594. * @param optimizer defines the current optimizer
  127595. * @returns true if everything that can be done was applied
  127596. */
  127597. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127598. }
  127599. /**
  127600. * Defines an optimization based on user defined callback.
  127601. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127602. */
  127603. export class CustomOptimization extends SceneOptimization {
  127604. /**
  127605. * Callback called to apply the custom optimization.
  127606. */
  127607. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  127608. /**
  127609. * Callback called to get custom description
  127610. */
  127611. onGetDescription: () => string;
  127612. /**
  127613. * Gets a string describing the action executed by the current optimization
  127614. * @returns description string
  127615. */
  127616. getDescription(): string;
  127617. /**
  127618. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127619. * @param scene defines the current scene where to apply this optimization
  127620. * @param optimizer defines the current optimizer
  127621. * @returns true if everything that can be done was applied
  127622. */
  127623. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127624. }
  127625. /**
  127626. * Defines an optimization used to turn particles off
  127627. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127628. */
  127629. export class ParticlesOptimization extends SceneOptimization {
  127630. /**
  127631. * Gets a string describing the action executed by the current optimization
  127632. * @return description string
  127633. */
  127634. getDescription(): string;
  127635. /**
  127636. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127637. * @param scene defines the current scene where to apply this optimization
  127638. * @param optimizer defines the current optimizer
  127639. * @returns true if everything that can be done was applied
  127640. */
  127641. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127642. }
  127643. /**
  127644. * Defines an optimization used to turn render targets off
  127645. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127646. */
  127647. export class RenderTargetsOptimization extends SceneOptimization {
  127648. /**
  127649. * Gets a string describing the action executed by the current optimization
  127650. * @return description string
  127651. */
  127652. getDescription(): string;
  127653. /**
  127654. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127655. * @param scene defines the current scene where to apply this optimization
  127656. * @param optimizer defines the current optimizer
  127657. * @returns true if everything that can be done was applied
  127658. */
  127659. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127660. }
  127661. /**
  127662. * Defines an optimization used to merge meshes with compatible materials
  127663. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127664. */
  127665. export class MergeMeshesOptimization extends SceneOptimization {
  127666. private static _UpdateSelectionTree;
  127667. /**
  127668. * Gets or sets a boolean which defines if optimization octree has to be updated
  127669. */
  127670. /**
  127671. * Gets or sets a boolean which defines if optimization octree has to be updated
  127672. */
  127673. static UpdateSelectionTree: boolean;
  127674. /**
  127675. * Gets a string describing the action executed by the current optimization
  127676. * @return description string
  127677. */
  127678. getDescription(): string;
  127679. private _canBeMerged;
  127680. /**
  127681. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127682. * @param scene defines the current scene where to apply this optimization
  127683. * @param optimizer defines the current optimizer
  127684. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  127685. * @returns true if everything that can be done was applied
  127686. */
  127687. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  127688. }
  127689. /**
  127690. * Defines a list of options used by SceneOptimizer
  127691. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127692. */
  127693. export class SceneOptimizerOptions {
  127694. /**
  127695. * Defines the target frame rate to reach (60 by default)
  127696. */
  127697. targetFrameRate: number;
  127698. /**
  127699. * Defines the interval between two checkes (2000ms by default)
  127700. */
  127701. trackerDuration: number;
  127702. /**
  127703. * Gets the list of optimizations to apply
  127704. */
  127705. optimizations: SceneOptimization[];
  127706. /**
  127707. * Creates a new list of options used by SceneOptimizer
  127708. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  127709. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  127710. */
  127711. constructor(
  127712. /**
  127713. * Defines the target frame rate to reach (60 by default)
  127714. */
  127715. targetFrameRate?: number,
  127716. /**
  127717. * Defines the interval between two checkes (2000ms by default)
  127718. */
  127719. trackerDuration?: number);
  127720. /**
  127721. * Add a new optimization
  127722. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  127723. * @returns the current SceneOptimizerOptions
  127724. */
  127725. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  127726. /**
  127727. * Add a new custom optimization
  127728. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  127729. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  127730. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127731. * @returns the current SceneOptimizerOptions
  127732. */
  127733. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  127734. /**
  127735. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  127736. * @param targetFrameRate defines the target frame rate (60 by default)
  127737. * @returns a SceneOptimizerOptions object
  127738. */
  127739. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127740. /**
  127741. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  127742. * @param targetFrameRate defines the target frame rate (60 by default)
  127743. * @returns a SceneOptimizerOptions object
  127744. */
  127745. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127746. /**
  127747. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  127748. * @param targetFrameRate defines the target frame rate (60 by default)
  127749. * @returns a SceneOptimizerOptions object
  127750. */
  127751. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127752. }
  127753. /**
  127754. * Class used to run optimizations in order to reach a target frame rate
  127755. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127756. */
  127757. export class SceneOptimizer implements IDisposable {
  127758. private _isRunning;
  127759. private _options;
  127760. private _scene;
  127761. private _currentPriorityLevel;
  127762. private _targetFrameRate;
  127763. private _trackerDuration;
  127764. private _currentFrameRate;
  127765. private _sceneDisposeObserver;
  127766. private _improvementMode;
  127767. /**
  127768. * Defines an observable called when the optimizer reaches the target frame rate
  127769. */
  127770. onSuccessObservable: Observable<SceneOptimizer>;
  127771. /**
  127772. * Defines an observable called when the optimizer enables an optimization
  127773. */
  127774. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  127775. /**
  127776. * Defines an observable called when the optimizer is not able to reach the target frame rate
  127777. */
  127778. onFailureObservable: Observable<SceneOptimizer>;
  127779. /**
  127780. * Gets a boolean indicating if the optimizer is in improvement mode
  127781. */
  127782. readonly isInImprovementMode: boolean;
  127783. /**
  127784. * Gets the current priority level (0 at start)
  127785. */
  127786. readonly currentPriorityLevel: number;
  127787. /**
  127788. * Gets the current frame rate checked by the SceneOptimizer
  127789. */
  127790. readonly currentFrameRate: number;
  127791. /**
  127792. * Gets or sets the current target frame rate (60 by default)
  127793. */
  127794. /**
  127795. * Gets or sets the current target frame rate (60 by default)
  127796. */
  127797. targetFrameRate: number;
  127798. /**
  127799. * Gets or sets the current interval between two checks (every 2000ms by default)
  127800. */
  127801. /**
  127802. * Gets or sets the current interval between two checks (every 2000ms by default)
  127803. */
  127804. trackerDuration: number;
  127805. /**
  127806. * Gets the list of active optimizations
  127807. */
  127808. readonly optimizations: SceneOptimization[];
  127809. /**
  127810. * Creates a new SceneOptimizer
  127811. * @param scene defines the scene to work on
  127812. * @param options defines the options to use with the SceneOptimizer
  127813. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  127814. * @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)
  127815. */
  127816. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  127817. /**
  127818. * Stops the current optimizer
  127819. */
  127820. stop(): void;
  127821. /**
  127822. * Reset the optimizer to initial step (current priority level = 0)
  127823. */
  127824. reset(): void;
  127825. /**
  127826. * Start the optimizer. By default it will try to reach a specific framerate
  127827. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  127828. */
  127829. start(): void;
  127830. private _checkCurrentState;
  127831. /**
  127832. * Release all resources
  127833. */
  127834. dispose(): void;
  127835. /**
  127836. * Helper function to create a SceneOptimizer with one single line of code
  127837. * @param scene defines the scene to work on
  127838. * @param options defines the options to use with the SceneOptimizer
  127839. * @param onSuccess defines a callback to call on success
  127840. * @param onFailure defines a callback to call on failure
  127841. * @returns the new SceneOptimizer object
  127842. */
  127843. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  127844. }
  127845. }
  127846. declare module BABYLON {
  127847. /**
  127848. * Class used to serialize a scene into a string
  127849. */
  127850. export class SceneSerializer {
  127851. /**
  127852. * Clear cache used by a previous serialization
  127853. */
  127854. static ClearCache(): void;
  127855. /**
  127856. * Serialize a scene into a JSON compatible object
  127857. * @param scene defines the scene to serialize
  127858. * @returns a JSON compatible object
  127859. */
  127860. static Serialize(scene: Scene): any;
  127861. /**
  127862. * Serialize a mesh into a JSON compatible object
  127863. * @param toSerialize defines the mesh to serialize
  127864. * @param withParents defines if parents must be serialized as well
  127865. * @param withChildren defines if children must be serialized as well
  127866. * @returns a JSON compatible object
  127867. */
  127868. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  127869. }
  127870. }
  127871. declare module BABYLON {
  127872. /**
  127873. * Class used to host texture specific utilities
  127874. */
  127875. export class TextureTools {
  127876. /**
  127877. * Uses the GPU to create a copy texture rescaled at a given size
  127878. * @param texture Texture to copy from
  127879. * @param width defines the desired width
  127880. * @param height defines the desired height
  127881. * @param useBilinearMode defines if bilinear mode has to be used
  127882. * @return the generated texture
  127883. */
  127884. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  127885. }
  127886. }
  127887. declare module BABYLON {
  127888. /**
  127889. * This represents the different options available for the video capture.
  127890. */
  127891. export interface VideoRecorderOptions {
  127892. /** Defines the mime type of the video. */
  127893. mimeType: string;
  127894. /** Defines the FPS the video should be recorded at. */
  127895. fps: number;
  127896. /** Defines the chunk size for the recording data. */
  127897. recordChunckSize: number;
  127898. /** The audio tracks to attach to the recording. */
  127899. audioTracks?: MediaStreamTrack[];
  127900. }
  127901. /**
  127902. * This can help with recording videos from BabylonJS.
  127903. * This is based on the available WebRTC functionalities of the browser.
  127904. *
  127905. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  127906. */
  127907. export class VideoRecorder {
  127908. private static readonly _defaultOptions;
  127909. /**
  127910. * Returns whether or not the VideoRecorder is available in your browser.
  127911. * @param engine Defines the Babylon Engine.
  127912. * @returns true if supported otherwise false.
  127913. */
  127914. static IsSupported(engine: Engine): boolean;
  127915. private readonly _options;
  127916. private _canvas;
  127917. private _mediaRecorder;
  127918. private _recordedChunks;
  127919. private _fileName;
  127920. private _resolve;
  127921. private _reject;
  127922. /**
  127923. * True when a recording is already in progress.
  127924. */
  127925. readonly isRecording: boolean;
  127926. /**
  127927. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  127928. * @param engine Defines the BabylonJS Engine you wish to record.
  127929. * @param options Defines options that can be used to customize the capture.
  127930. */
  127931. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  127932. /**
  127933. * Stops the current recording before the default capture timeout passed in the startRecording function.
  127934. */
  127935. stopRecording(): void;
  127936. /**
  127937. * Starts recording the canvas for a max duration specified in parameters.
  127938. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  127939. * If null no automatic download will start and you can rely on the promise to get the data back.
  127940. * @param maxDuration Defines the maximum recording time in seconds.
  127941. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  127942. * @return A promise callback at the end of the recording with the video data in Blob.
  127943. */
  127944. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  127945. /**
  127946. * Releases internal resources used during the recording.
  127947. */
  127948. dispose(): void;
  127949. private _handleDataAvailable;
  127950. private _handleError;
  127951. private _handleStop;
  127952. }
  127953. }
  127954. declare module BABYLON {
  127955. /**
  127956. * Class containing a set of static utilities functions for screenshots
  127957. */
  127958. export class ScreenshotTools {
  127959. /**
  127960. * Captures a screenshot of the current rendering
  127961. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127962. * @param engine defines the rendering engine
  127963. * @param camera defines the source camera
  127964. * @param size This parameter can be set to a single number or to an object with the
  127965. * following (optional) properties: precision, width, height. If a single number is passed,
  127966. * it will be used for both width and height. If an object is passed, the screenshot size
  127967. * will be derived from the parameters. The precision property is a multiplier allowing
  127968. * rendering at a higher or lower resolution
  127969. * @param successCallback defines the callback receives a single parameter which contains the
  127970. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127971. * src parameter of an <img> to display it
  127972. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127973. * Check your browser for supported MIME types
  127974. */
  127975. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  127976. /**
  127977. * Captures a screenshot of the current rendering
  127978. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127979. * @param engine defines the rendering engine
  127980. * @param camera defines the source camera
  127981. * @param size This parameter can be set to a single number or to an object with the
  127982. * following (optional) properties: precision, width, height. If a single number is passed,
  127983. * it will be used for both width and height. If an object is passed, the screenshot size
  127984. * will be derived from the parameters. The precision property is a multiplier allowing
  127985. * rendering at a higher or lower resolution
  127986. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127987. * Check your browser for supported MIME types
  127988. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  127989. * to the src parameter of an <img> to display it
  127990. */
  127991. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  127992. /**
  127993. * Generates an image screenshot from the specified camera.
  127994. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127995. * @param engine The engine to use for rendering
  127996. * @param camera The camera to use for rendering
  127997. * @param size This parameter can be set to a single number or to an object with the
  127998. * following (optional) properties: precision, width, height. If a single number is passed,
  127999. * it will be used for both width and height. If an object is passed, the screenshot size
  128000. * will be derived from the parameters. The precision property is a multiplier allowing
  128001. * rendering at a higher or lower resolution
  128002. * @param successCallback The callback receives a single parameter which contains the
  128003. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128004. * src parameter of an <img> to display it
  128005. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128006. * Check your browser for supported MIME types
  128007. * @param samples Texture samples (default: 1)
  128008. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128009. * @param fileName A name for for the downloaded file.
  128010. */
  128011. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  128012. /**
  128013. * Generates an image screenshot from the specified camera.
  128014. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128015. * @param engine The engine to use for rendering
  128016. * @param camera The camera to use for rendering
  128017. * @param size This parameter can be set to a single number or to an object with the
  128018. * following (optional) properties: precision, width, height. If a single number is passed,
  128019. * it will be used for both width and height. If an object is passed, the screenshot size
  128020. * will be derived from the parameters. The precision property is a multiplier allowing
  128021. * rendering at a higher or lower resolution
  128022. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128023. * Check your browser for supported MIME types
  128024. * @param samples Texture samples (default: 1)
  128025. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128026. * @param fileName A name for for the downloaded file.
  128027. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128028. * to the src parameter of an <img> to display it
  128029. */
  128030. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  128031. /**
  128032. * Gets height and width for screenshot size
  128033. * @private
  128034. */
  128035. private static _getScreenshotSize;
  128036. }
  128037. }
  128038. declare module BABYLON {
  128039. /**
  128040. * A cursor which tracks a point on a path
  128041. */
  128042. export class PathCursor {
  128043. private path;
  128044. /**
  128045. * Stores path cursor callbacks for when an onchange event is triggered
  128046. */
  128047. private _onchange;
  128048. /**
  128049. * The value of the path cursor
  128050. */
  128051. value: number;
  128052. /**
  128053. * The animation array of the path cursor
  128054. */
  128055. animations: Animation[];
  128056. /**
  128057. * Initializes the path cursor
  128058. * @param path The path to track
  128059. */
  128060. constructor(path: Path2);
  128061. /**
  128062. * Gets the cursor point on the path
  128063. * @returns A point on the path cursor at the cursor location
  128064. */
  128065. getPoint(): Vector3;
  128066. /**
  128067. * Moves the cursor ahead by the step amount
  128068. * @param step The amount to move the cursor forward
  128069. * @returns This path cursor
  128070. */
  128071. moveAhead(step?: number): PathCursor;
  128072. /**
  128073. * Moves the cursor behind by the step amount
  128074. * @param step The amount to move the cursor back
  128075. * @returns This path cursor
  128076. */
  128077. moveBack(step?: number): PathCursor;
  128078. /**
  128079. * Moves the cursor by the step amount
  128080. * If the step amount is greater than one, an exception is thrown
  128081. * @param step The amount to move the cursor
  128082. * @returns This path cursor
  128083. */
  128084. move(step: number): PathCursor;
  128085. /**
  128086. * Ensures that the value is limited between zero and one
  128087. * @returns This path cursor
  128088. */
  128089. private ensureLimits;
  128090. /**
  128091. * Runs onchange callbacks on change (used by the animation engine)
  128092. * @returns This path cursor
  128093. */
  128094. private raiseOnChange;
  128095. /**
  128096. * Executes a function on change
  128097. * @param f A path cursor onchange callback
  128098. * @returns This path cursor
  128099. */
  128100. onchange(f: (cursor: PathCursor) => void): PathCursor;
  128101. }
  128102. }
  128103. declare module BABYLON {
  128104. /** @hidden */
  128105. export var blurPixelShader: {
  128106. name: string;
  128107. shader: string;
  128108. };
  128109. }
  128110. declare module BABYLON {
  128111. /** @hidden */
  128112. export var pointCloudVertexDeclaration: {
  128113. name: string;
  128114. shader: string;
  128115. };
  128116. }
  128117. // Mixins
  128118. interface Window {
  128119. mozIndexedDB: IDBFactory;
  128120. webkitIndexedDB: IDBFactory;
  128121. msIndexedDB: IDBFactory;
  128122. webkitURL: typeof URL;
  128123. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  128124. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  128125. WebGLRenderingContext: WebGLRenderingContext;
  128126. MSGesture: MSGesture;
  128127. CANNON: any;
  128128. AudioContext: AudioContext;
  128129. webkitAudioContext: AudioContext;
  128130. PointerEvent: any;
  128131. Math: Math;
  128132. Uint8Array: Uint8ArrayConstructor;
  128133. Float32Array: Float32ArrayConstructor;
  128134. mozURL: typeof URL;
  128135. msURL: typeof URL;
  128136. VRFrameData: any; // WebVR, from specs 1.1
  128137. DracoDecoderModule: any;
  128138. setImmediate(handler: (...args: any[]) => void): number;
  128139. }
  128140. interface HTMLCanvasElement {
  128141. requestPointerLock(): void;
  128142. msRequestPointerLock?(): void;
  128143. mozRequestPointerLock?(): void;
  128144. webkitRequestPointerLock?(): void;
  128145. /** Track wether a record is in progress */
  128146. isRecording: boolean;
  128147. /** Capture Stream method defined by some browsers */
  128148. captureStream(fps?: number): MediaStream;
  128149. }
  128150. interface CanvasRenderingContext2D {
  128151. msImageSmoothingEnabled: boolean;
  128152. }
  128153. interface MouseEvent {
  128154. mozMovementX: number;
  128155. mozMovementY: number;
  128156. webkitMovementX: number;
  128157. webkitMovementY: number;
  128158. msMovementX: number;
  128159. msMovementY: number;
  128160. }
  128161. interface Navigator {
  128162. mozGetVRDevices: (any: any) => any;
  128163. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128164. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128165. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128166. webkitGetGamepads(): Gamepad[];
  128167. msGetGamepads(): Gamepad[];
  128168. webkitGamepads(): Gamepad[];
  128169. }
  128170. interface HTMLVideoElement {
  128171. mozSrcObject: any;
  128172. }
  128173. interface Math {
  128174. fround(x: number): number;
  128175. imul(a: number, b: number): number;
  128176. }
  128177. interface WebGLRenderingContext {
  128178. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  128179. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  128180. vertexAttribDivisor(index: number, divisor: number): void;
  128181. createVertexArray(): any;
  128182. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  128183. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  128184. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  128185. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  128186. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  128187. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  128188. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  128189. // Queries
  128190. createQuery(): WebGLQuery;
  128191. deleteQuery(query: WebGLQuery): void;
  128192. beginQuery(target: number, query: WebGLQuery): void;
  128193. endQuery(target: number): void;
  128194. getQueryParameter(query: WebGLQuery, pname: number): any;
  128195. getQuery(target: number, pname: number): any;
  128196. MAX_SAMPLES: number;
  128197. RGBA8: number;
  128198. READ_FRAMEBUFFER: number;
  128199. DRAW_FRAMEBUFFER: number;
  128200. UNIFORM_BUFFER: number;
  128201. HALF_FLOAT_OES: number;
  128202. RGBA16F: number;
  128203. RGBA32F: number;
  128204. R32F: number;
  128205. RG32F: number;
  128206. RGB32F: number;
  128207. R16F: number;
  128208. RG16F: number;
  128209. RGB16F: number;
  128210. RED: number;
  128211. RG: number;
  128212. R8: number;
  128213. RG8: number;
  128214. UNSIGNED_INT_24_8: number;
  128215. DEPTH24_STENCIL8: number;
  128216. /* Multiple Render Targets */
  128217. drawBuffers(buffers: number[]): void;
  128218. readBuffer(src: number): void;
  128219. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  128220. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  128221. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  128222. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  128223. // Occlusion Query
  128224. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  128225. ANY_SAMPLES_PASSED: number;
  128226. QUERY_RESULT_AVAILABLE: number;
  128227. QUERY_RESULT: number;
  128228. }
  128229. interface WebGLProgram {
  128230. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  128231. }
  128232. interface EXT_disjoint_timer_query {
  128233. QUERY_COUNTER_BITS_EXT: number;
  128234. TIME_ELAPSED_EXT: number;
  128235. TIMESTAMP_EXT: number;
  128236. GPU_DISJOINT_EXT: number;
  128237. QUERY_RESULT_EXT: number;
  128238. QUERY_RESULT_AVAILABLE_EXT: number;
  128239. queryCounterEXT(query: WebGLQuery, target: number): void;
  128240. createQueryEXT(): WebGLQuery;
  128241. beginQueryEXT(target: number, query: WebGLQuery): void;
  128242. endQueryEXT(target: number): void;
  128243. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  128244. deleteQueryEXT(query: WebGLQuery): void;
  128245. }
  128246. interface WebGLUniformLocation {
  128247. _currentState: any;
  128248. }
  128249. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  128250. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  128251. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  128252. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128253. interface WebGLRenderingContext {
  128254. readonly RASTERIZER_DISCARD: number;
  128255. readonly DEPTH_COMPONENT24: number;
  128256. readonly TEXTURE_3D: number;
  128257. readonly TEXTURE_2D_ARRAY: number;
  128258. readonly TEXTURE_COMPARE_FUNC: number;
  128259. readonly TEXTURE_COMPARE_MODE: number;
  128260. readonly COMPARE_REF_TO_TEXTURE: number;
  128261. readonly TEXTURE_WRAP_R: number;
  128262. readonly HALF_FLOAT: number;
  128263. readonly RGB8: number;
  128264. readonly RED_INTEGER: number;
  128265. readonly RG_INTEGER: number;
  128266. readonly RGB_INTEGER: number;
  128267. readonly RGBA_INTEGER: number;
  128268. readonly R8_SNORM: number;
  128269. readonly RG8_SNORM: number;
  128270. readonly RGB8_SNORM: number;
  128271. readonly RGBA8_SNORM: number;
  128272. readonly R8I: number;
  128273. readonly RG8I: number;
  128274. readonly RGB8I: number;
  128275. readonly RGBA8I: number;
  128276. readonly R8UI: number;
  128277. readonly RG8UI: number;
  128278. readonly RGB8UI: number;
  128279. readonly RGBA8UI: number;
  128280. readonly R16I: number;
  128281. readonly RG16I: number;
  128282. readonly RGB16I: number;
  128283. readonly RGBA16I: number;
  128284. readonly R16UI: number;
  128285. readonly RG16UI: number;
  128286. readonly RGB16UI: number;
  128287. readonly RGBA16UI: number;
  128288. readonly R32I: number;
  128289. readonly RG32I: number;
  128290. readonly RGB32I: number;
  128291. readonly RGBA32I: number;
  128292. readonly R32UI: number;
  128293. readonly RG32UI: number;
  128294. readonly RGB32UI: number;
  128295. readonly RGBA32UI: number;
  128296. readonly RGB10_A2UI: number;
  128297. readonly R11F_G11F_B10F: number;
  128298. readonly RGB9_E5: number;
  128299. readonly RGB10_A2: number;
  128300. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  128301. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  128302. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  128303. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  128304. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  128305. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  128306. 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;
  128307. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  128308. readonly TRANSFORM_FEEDBACK: number;
  128309. readonly INTERLEAVED_ATTRIBS: number;
  128310. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  128311. createTransformFeedback(): WebGLTransformFeedback;
  128312. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  128313. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  128314. beginTransformFeedback(primitiveMode: number): void;
  128315. endTransformFeedback(): void;
  128316. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  128317. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128318. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128319. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128320. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  128321. }
  128322. interface ImageBitmap {
  128323. readonly width: number;
  128324. readonly height: number;
  128325. close(): void;
  128326. }
  128327. interface WebGLQuery extends WebGLObject {
  128328. }
  128329. declare var WebGLQuery: {
  128330. prototype: WebGLQuery;
  128331. new(): WebGLQuery;
  128332. };
  128333. interface WebGLSampler extends WebGLObject {
  128334. }
  128335. declare var WebGLSampler: {
  128336. prototype: WebGLSampler;
  128337. new(): WebGLSampler;
  128338. };
  128339. interface WebGLSync extends WebGLObject {
  128340. }
  128341. declare var WebGLSync: {
  128342. prototype: WebGLSync;
  128343. new(): WebGLSync;
  128344. };
  128345. interface WebGLTransformFeedback extends WebGLObject {
  128346. }
  128347. declare var WebGLTransformFeedback: {
  128348. prototype: WebGLTransformFeedback;
  128349. new(): WebGLTransformFeedback;
  128350. };
  128351. interface WebGLVertexArrayObject extends WebGLObject {
  128352. }
  128353. declare var WebGLVertexArrayObject: {
  128354. prototype: WebGLVertexArrayObject;
  128355. new(): WebGLVertexArrayObject;
  128356. };
  128357. // Type definitions for WebVR API
  128358. // Project: https://w3c.github.io/webvr/
  128359. // Definitions by: six a <https://github.com/lostfictions>
  128360. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128361. interface VRDisplay extends EventTarget {
  128362. /**
  128363. * Dictionary of capabilities describing the VRDisplay.
  128364. */
  128365. readonly capabilities: VRDisplayCapabilities;
  128366. /**
  128367. * z-depth defining the far plane of the eye view frustum
  128368. * enables mapping of values in the render target depth
  128369. * attachment to scene coordinates. Initially set to 10000.0.
  128370. */
  128371. depthFar: number;
  128372. /**
  128373. * z-depth defining the near plane of the eye view frustum
  128374. * enables mapping of values in the render target depth
  128375. * attachment to scene coordinates. Initially set to 0.01.
  128376. */
  128377. depthNear: number;
  128378. /**
  128379. * An identifier for this distinct VRDisplay. Used as an
  128380. * association point in the Gamepad API.
  128381. */
  128382. readonly displayId: number;
  128383. /**
  128384. * A display name, a user-readable name identifying it.
  128385. */
  128386. readonly displayName: string;
  128387. readonly isConnected: boolean;
  128388. readonly isPresenting: boolean;
  128389. /**
  128390. * If this VRDisplay supports room-scale experiences, the optional
  128391. * stage attribute contains details on the room-scale parameters.
  128392. */
  128393. readonly stageParameters: VRStageParameters | null;
  128394. /**
  128395. * Passing the value returned by `requestAnimationFrame` to
  128396. * `cancelAnimationFrame` will unregister the callback.
  128397. * @param handle Define the hanle of the request to cancel
  128398. */
  128399. cancelAnimationFrame(handle: number): void;
  128400. /**
  128401. * Stops presenting to the VRDisplay.
  128402. * @returns a promise to know when it stopped
  128403. */
  128404. exitPresent(): Promise<void>;
  128405. /**
  128406. * Return the current VREyeParameters for the given eye.
  128407. * @param whichEye Define the eye we want the parameter for
  128408. * @returns the eye parameters
  128409. */
  128410. getEyeParameters(whichEye: string): VREyeParameters;
  128411. /**
  128412. * Populates the passed VRFrameData with the information required to render
  128413. * the current frame.
  128414. * @param frameData Define the data structure to populate
  128415. * @returns true if ok otherwise false
  128416. */
  128417. getFrameData(frameData: VRFrameData): boolean;
  128418. /**
  128419. * Get the layers currently being presented.
  128420. * @returns the list of VR layers
  128421. */
  128422. getLayers(): VRLayer[];
  128423. /**
  128424. * Return a VRPose containing the future predicted pose of the VRDisplay
  128425. * when the current frame will be presented. The value returned will not
  128426. * change until JavaScript has returned control to the browser.
  128427. *
  128428. * The VRPose will contain the position, orientation, velocity,
  128429. * and acceleration of each of these properties.
  128430. * @returns the pose object
  128431. */
  128432. getPose(): VRPose;
  128433. /**
  128434. * Return the current instantaneous pose of the VRDisplay, with no
  128435. * prediction applied.
  128436. * @returns the current instantaneous pose
  128437. */
  128438. getImmediatePose(): VRPose;
  128439. /**
  128440. * The callback passed to `requestAnimationFrame` will be called
  128441. * any time a new frame should be rendered. When the VRDisplay is
  128442. * presenting the callback will be called at the native refresh
  128443. * rate of the HMD. When not presenting this function acts
  128444. * identically to how window.requestAnimationFrame acts. Content should
  128445. * make no assumptions of frame rate or vsync behavior as the HMD runs
  128446. * asynchronously from other displays and at differing refresh rates.
  128447. * @param callback Define the eaction to run next frame
  128448. * @returns the request handle it
  128449. */
  128450. requestAnimationFrame(callback: FrameRequestCallback): number;
  128451. /**
  128452. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  128453. * Repeat calls while already presenting will update the VRLayers being displayed.
  128454. * @param layers Define the list of layer to present
  128455. * @returns a promise to know when the request has been fulfilled
  128456. */
  128457. requestPresent(layers: VRLayer[]): Promise<void>;
  128458. /**
  128459. * Reset the pose for this display, treating its current position and
  128460. * orientation as the "origin/zero" values. VRPose.position,
  128461. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  128462. * updated when calling resetPose(). This should be called in only
  128463. * sitting-space experiences.
  128464. */
  128465. resetPose(): void;
  128466. /**
  128467. * The VRLayer provided to the VRDisplay will be captured and presented
  128468. * in the HMD. Calling this function has the same effect on the source
  128469. * canvas as any other operation that uses its source image, and canvases
  128470. * created without preserveDrawingBuffer set to true will be cleared.
  128471. * @param pose Define the pose to submit
  128472. */
  128473. submitFrame(pose?: VRPose): void;
  128474. }
  128475. declare var VRDisplay: {
  128476. prototype: VRDisplay;
  128477. new(): VRDisplay;
  128478. };
  128479. interface VRLayer {
  128480. leftBounds?: number[] | Float32Array | null;
  128481. rightBounds?: number[] | Float32Array | null;
  128482. source?: HTMLCanvasElement | null;
  128483. }
  128484. interface VRDisplayCapabilities {
  128485. readonly canPresent: boolean;
  128486. readonly hasExternalDisplay: boolean;
  128487. readonly hasOrientation: boolean;
  128488. readonly hasPosition: boolean;
  128489. readonly maxLayers: number;
  128490. }
  128491. interface VREyeParameters {
  128492. /** @deprecated */
  128493. readonly fieldOfView: VRFieldOfView;
  128494. readonly offset: Float32Array;
  128495. readonly renderHeight: number;
  128496. readonly renderWidth: number;
  128497. }
  128498. interface VRFieldOfView {
  128499. readonly downDegrees: number;
  128500. readonly leftDegrees: number;
  128501. readonly rightDegrees: number;
  128502. readonly upDegrees: number;
  128503. }
  128504. interface VRFrameData {
  128505. readonly leftProjectionMatrix: Float32Array;
  128506. readonly leftViewMatrix: Float32Array;
  128507. readonly pose: VRPose;
  128508. readonly rightProjectionMatrix: Float32Array;
  128509. readonly rightViewMatrix: Float32Array;
  128510. readonly timestamp: number;
  128511. }
  128512. interface VRPose {
  128513. readonly angularAcceleration: Float32Array | null;
  128514. readonly angularVelocity: Float32Array | null;
  128515. readonly linearAcceleration: Float32Array | null;
  128516. readonly linearVelocity: Float32Array | null;
  128517. readonly orientation: Float32Array | null;
  128518. readonly position: Float32Array | null;
  128519. readonly timestamp: number;
  128520. }
  128521. interface VRStageParameters {
  128522. sittingToStandingTransform?: Float32Array;
  128523. sizeX?: number;
  128524. sizeY?: number;
  128525. }
  128526. interface Navigator {
  128527. getVRDisplays(): Promise<VRDisplay[]>;
  128528. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  128529. }
  128530. interface Window {
  128531. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  128532. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  128533. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  128534. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128535. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128536. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  128537. }
  128538. interface Gamepad {
  128539. readonly displayId: number;
  128540. }
  128541. type XRSessionMode =
  128542. | "inline"
  128543. | "immersive-vr"
  128544. | "immersive-ar";
  128545. type XRReferenceSpaceType =
  128546. | "viewer"
  128547. | "local"
  128548. | "local-floor"
  128549. | "bounded-floor"
  128550. | "unbounded";
  128551. type XREnvironmentBlendMode =
  128552. | "opaque"
  128553. | "additive"
  128554. | "alpha-blend";
  128555. type XRVisibilityState =
  128556. | "visible"
  128557. | "visible-blurred"
  128558. | "hidden";
  128559. type XRHandedness =
  128560. | "none"
  128561. | "left"
  128562. | "right";
  128563. type XRTargetRayMode =
  128564. | "gaze"
  128565. | "tracked-pointer"
  128566. | "screen";
  128567. type XREye =
  128568. | "none"
  128569. | "left"
  128570. | "right";
  128571. interface XRSpace extends EventTarget {
  128572. }
  128573. interface XRRenderState {
  128574. depthNear?: number;
  128575. depthFar?: number;
  128576. inlineVerticalFieldOfView?: number;
  128577. baseLayer?: XRWebGLLayer;
  128578. }
  128579. interface XRInputSource {
  128580. handedness: XRHandedness;
  128581. targetRayMode: XRTargetRayMode;
  128582. targetRaySpace: XRSpace;
  128583. gripSpace: XRSpace | undefined;
  128584. gamepad: Gamepad | undefined;
  128585. profiles: Array<string>;
  128586. }
  128587. interface XRSession {
  128588. addEventListener: Function;
  128589. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  128590. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  128591. requestAnimationFrame: Function;
  128592. end(): Promise<void>;
  128593. renderState: XRRenderState;
  128594. inputSources: Array<XRInputSource>;
  128595. }
  128596. interface XRReferenceSpace extends XRSpace {
  128597. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  128598. onreset: any;
  128599. }
  128600. interface XRFrame {
  128601. session: XRSession;
  128602. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  128603. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  128604. }
  128605. interface XRViewerPose extends XRPose {
  128606. views: Array<XRView>;
  128607. }
  128608. interface XRPose {
  128609. transform: XRRigidTransform;
  128610. emulatedPosition: boolean;
  128611. }
  128612. declare var XRWebGLLayer: {
  128613. prototype: XRWebGLLayer;
  128614. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  128615. };
  128616. interface XRWebGLLayer {
  128617. framebuffer: WebGLFramebuffer;
  128618. framebufferWidth: number;
  128619. framebufferHeight: number;
  128620. getViewport: Function;
  128621. }
  128622. interface XRRigidTransform {
  128623. position: DOMPointReadOnly;
  128624. orientation: DOMPointReadOnly;
  128625. matrix: Float32Array;
  128626. inverse: XRRigidTransform;
  128627. }
  128628. interface XRView {
  128629. eye: XREye;
  128630. projectionMatrix: Float32Array;
  128631. transform: XRRigidTransform;
  128632. }
  128633. interface XRInputSourceChangeEvent {
  128634. session: XRSession;
  128635. removed: Array<XRInputSource>;
  128636. added: Array<XRInputSource>;
  128637. }